granularity.r 2.8 KB

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