granularity.r 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. # StarPU --- Runtime system for heterogeneous multicore architectures.
  2. #
  3. # Copyright (C) 2010 Université de Bordeaux 1
  4. # Copyright (C) 2010, 2011 Centre National de la Recherche Scientifique
  5. #
  6. # StarPU is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU Lesser General Public License as published by
  8. # the Free Software Foundation; either version 2.1 of the License, or (at
  9. # your option) any later version.
  10. #
  11. # StarPU is distributed in the hope that it will be useful, but
  12. # WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. #
  15. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. max <- 28
  17. maxy <- 400
  18. sizelist <- seq(2048, max*1024, 64);
  19. #schedlist <- c("greedy", "prio", "dm", "random", "no-prio", "ws");
  20. #schedlist <- c("greedy", "prio", "dm", "random");
  21. # grainlist <- c(64, 128, 256, 512, 768, 1024, 1280, 1536, 2048);
  22. grainlist <- c(256, 512, 1024, 2048);
  23. grainlistchar <- c("256", "512", "1024", "2048");
  24. gflops <- function (x, size)
  25. {
  26. 2*size*size*size/(3000000*x);
  27. }
  28. parse <- function (size, grain)
  29. {
  30. filename = paste("timing/granularity", grain, size, sep=".");
  31. if (file.exists(filename))
  32. {
  33. ret <- scan(filename);
  34. return(ret);
  35. }
  36. return (NA);
  37. }
  38. handle_size <- function (size, grain)
  39. {
  40. parsed <- parse(size, grain);
  41. if (is.na(parsed))
  42. {
  43. return (NA);
  44. }
  45. gflops <- gflops(parsed, size);
  46. return(gflops);
  47. }
  48. handle_grain <- function(grain)
  49. {
  50. gflopstab <- NULL;
  51. sizetab <- NULL;
  52. for (size in sizelist) {
  53. list <- handle_size(size, grain);
  54. if (!is.na(list))
  55. {
  56. gflopstab <- c(gflopstab, list);
  57. sizetab <- c(sizetab, array(size, c(length(list))));
  58. }
  59. }
  60. return(
  61. data.frame(gflops=gflopstab, size=sizetab, grain=array(grain, c(length(gflopstab)) ))
  62. );
  63. }
  64. handle_grain_mean <- function(grain)
  65. {
  66. meantab <- NULL;
  67. sizetab <- NULL;
  68. for (size in sizelist) {
  69. list <- mean(handle_size(size, grain));
  70. if (!is.na(list))
  71. {
  72. meantab <- c(meantab, list);
  73. sizetab <- c(sizetab, array(size, c(length(list))));
  74. }
  75. }
  76. return(
  77. data.frame(gflops=meantab, size=sizetab, grain=array(grain, c(length(meantab)) ))
  78. # meantab
  79. );
  80. }
  81. trace_grain <- function(grain, color, style)
  82. {
  83. #points(handle_grain(grain)$size, handle_grain(grain)$gflops, col=color);
  84. pouet <- handle_grain_mean(grain);
  85. pouetgflops <- pouet$gflops;
  86. pouetsize <- pouet$size;
  87. # print(pouetgflops);
  88. # print(pouetsize);
  89. lines(pouetsize, pouetgflops, col=color, legend.text=TRUE, type = "o", pch = style, lwd=2);
  90. }
  91. display_grain <- function()
  92. {
  93. xlist <- range(sizelist);
  94. ylist <- range(c(0,maxy));
  95. plot.new();
  96. #plot.window(xlist, ylist, log="x");
  97. plot.window(xlist, ylist);
  98. i <- 0;
  99. colarray <- c("magenta", "blue", "peru", "green3", "navy", "red", "green2", "black", "orange");
  100. for (grain in grainlist) {
  101. trace_grain(grain, colarray[i+1], -1);
  102. i <- i + 1;
  103. }
  104. axis(1, at=seq(0, max*1024, 2048))
  105. #axis(1)
  106. axis(2, at=seq(0, maxy, 25), tck=1)
  107. # axis(4, at=seq(0, 100, 10))
  108. box(bty="u")
  109. labels <- grainlistchar;
  110. legend("topleft", inset=.05, title="Tile size", labels, lwd=2, lty=c(1, 1, 1, 1, 1, 1), pch=-1, col=colarray, bty="y", bg="white")
  111. mtext("matrix size", side=1, line=2, cex=1.6)
  112. mtext("GFlops", side=2, line=2, las=0, cex=1.6)
  113. title("Impact of granularity on LU decomposition");
  114. }
  115. display_grain()
  116. # boxplot(result, col=c("yellow", "red", "green"), xlab=sizelist);
  117. # plot(c(sizelist,sizelist,sizelist), c(result_greedy, result_prio, result_dm));
  118. # plot(sizelist, result_dm);
  119. # plot.new()
  120. # plot.window(range(c(sizelist,0) ), c(0, 6))