granularity.r 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. max <- 28
  2. maxy <- 400
  3. sizelist <- seq(2048, max*1024, 64);
  4. #schedlist <- c("greedy", "prio", "dm", "random", "no-prio", "ws");
  5. #schedlist <- c("greedy", "prio", "dm", "random");
  6. # grainlist <- c(64, 128, 256, 512, 768, 1024, 1280, 1536, 2048);
  7. grainlist <- c(256, 512, 1024, 2048);
  8. grainlistchar <- c("256", "512", "1024", "2048");
  9. gflops <- function (x, size)
  10. {
  11. 2*size*size*size/(3000000*x);
  12. }
  13. parse <- function (size, grain)
  14. {
  15. filename = paste("timing/granularity", grain, size, sep=".");
  16. if (file.exists(filename))
  17. {
  18. ret <- scan(filename);
  19. return(ret);
  20. }
  21. return (NA);
  22. }
  23. handle_size <- function (size, grain)
  24. {
  25. parsed <- parse(size, grain);
  26. if (is.na(parsed))
  27. {
  28. return (NA);
  29. }
  30. gflops <- gflops(parsed, size);
  31. return(gflops);
  32. }
  33. handle_grain <- function(grain)
  34. {
  35. gflopstab <- NULL;
  36. sizetab <- NULL;
  37. for (size in sizelist) {
  38. list <- handle_size(size, grain);
  39. if (!is.na(list))
  40. {
  41. gflopstab <- c(gflopstab, list);
  42. sizetab <- c(sizetab, array(size, c(length(list))));
  43. }
  44. }
  45. return(
  46. data.frame(gflops=gflopstab, size=sizetab, grain=array(grain, c(length(gflopstab)) ))
  47. );
  48. }
  49. handle_grain_mean <- function(grain)
  50. {
  51. meantab <- NULL;
  52. sizetab <- NULL;
  53. for (size in sizelist) {
  54. list <- mean(handle_size(size, grain));
  55. if (!is.na(list))
  56. {
  57. meantab <- c(meantab, list);
  58. sizetab <- c(sizetab, array(size, c(length(list))));
  59. }
  60. }
  61. return(
  62. data.frame(gflops=meantab, size=sizetab, grain=array(grain, c(length(meantab)) ))
  63. # meantab
  64. );
  65. }
  66. trace_grain <- function(grain, color, style)
  67. {
  68. #points(handle_grain(grain)$size, handle_grain(grain)$gflops, col=color);
  69. pouet <- handle_grain_mean(grain);
  70. pouetgflops <- pouet$gflops;
  71. pouetsize <- pouet$size;
  72. # print(pouetgflops);
  73. # print(pouetsize);
  74. lines(pouetsize, pouetgflops, col=color, legend.text=TRUE, type = "o", pch = style, lwd=2);
  75. }
  76. display_grain <- function()
  77. {
  78. xlist <- range(sizelist);
  79. ylist <- range(c(0,maxy));
  80. plot.new();
  81. #plot.window(xlist, ylist, log="x");
  82. plot.window(xlist, ylist);
  83. i <- 0;
  84. colarray <- c("magenta", "blue", "peru", "green3", "navy", "red", "green2", "black", "orange");
  85. for (grain in grainlist) {
  86. trace_grain(grain, colarray[i+1], -1);
  87. i <- i + 1;
  88. }
  89. axis(1, at=seq(0, max*1024, 2048))
  90. #axis(1)
  91. axis(2, at=seq(0, maxy, 25), tck=1)
  92. # axis(4, at=seq(0, 100, 10))
  93. box(bty="u")
  94. labels <- grainlistchar;
  95. 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")
  96. mtext("matrix size", side=1, line=2, cex=1.6)
  97. mtext("GFlops", side=2, line=2, las=0, cex=1.6)
  98. title("Impact of granularity on LU decomposition");
  99. }
  100. display_grain()
  101. # boxplot(result, col=c("yellow", "red", "green"), xlab=sizelist);
  102. # plot(c(sizelist,sizelist,sizelist), c(result_greedy, result_prio, result_dm));
  103. # plot(sizelist, result_dm);
  104. # plot.new()
  105. # plot.window(range(c(sizelist,0) ), c(0, 6))