granularity_model.r 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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 <- 30
  17. sizelist <- seq(64, max*1024, 64);
  18. #schedlist <- c("greedy", "prio", "dm", "random", "no-prio", "ws");
  19. #schedlist <- c("greedy", "prio", "dm", "random");
  20. #grainlist <- c(256, 512, 1024)
  21. grainlist <- c(512, 1024)
  22. gflops <- function (x, size)
  23. {
  24. 2*size*size*size/(3000000*x);
  25. }
  26. parse <- function (size, grain)
  27. {
  28. filename = paste("timing/granularity", grain, size, sep=".");
  29. if (file.exists(filename))
  30. {
  31. ret <- scan(filename);
  32. return(ret);
  33. }
  34. return (NA);
  35. }
  36. handle_size <- function (size, grain)
  37. {
  38. parsed <- parse(size, grain);
  39. if (is.na(parsed))
  40. {
  41. return (NA);
  42. }
  43. gflops <- gflops(parsed, size);
  44. return(gflops);
  45. }
  46. handle_grain <- function(grain)
  47. {
  48. gflopstab <- NULL;
  49. sizetab <- NULL;
  50. for (size in sizelist) {
  51. list <- handle_size(size, grain);
  52. if (!is.na(list))
  53. {
  54. gflopstab <- c(gflopstab, list);
  55. sizetab <- c(sizetab, array(size, c(length(list))));
  56. }
  57. }
  58. return(
  59. data.frame(gflops=gflopstab, size=sizetab, grain=array(grain, c(length(gflopstab)) ))
  60. );
  61. }
  62. handle_grain_mean <- function(grain)
  63. {
  64. meantab <- NULL;
  65. sizetab <- NULL;
  66. for (size in sizelist) {
  67. list <- mean(handle_size(size, grain));
  68. if (!is.na(list))
  69. {
  70. meantab <- c(meantab, list);
  71. sizetab <- c(sizetab, array(size, c(length(list))));
  72. }
  73. }
  74. return(
  75. data.frame(gflops=meantab, size=sizetab, grain=array(grain, c(length(meantab)) ))
  76. # meantab
  77. );
  78. }
  79. parse_nm <- function (size, grain)
  80. {
  81. filename = paste("timing/granularity.nomodel", grain, size, sep=".");
  82. if (file.exists(filename))
  83. {
  84. ret <- scan(filename);
  85. return(ret);
  86. }
  87. return (NA);
  88. }
  89. handle_size_nm <- function (size, grain)
  90. {
  91. parsed <- parse_nm(size, grain);
  92. if (is.na(parsed))
  93. {
  94. return (NA);
  95. }
  96. gflops <- gflops(parsed, size);
  97. return(gflops);
  98. }
  99. handle_grain_nm <- function(grain)
  100. {
  101. gflopstab <- NULL;
  102. sizetab <- NULL;
  103. for (size in sizelist) {
  104. list <- handle_size_nm(size, grain);
  105. if (!is.na(list))
  106. {
  107. gflopstab <- c(gflopstab, list);
  108. sizetab <- c(sizetab, array(size, c(length(list))));
  109. }
  110. }
  111. return(
  112. data.frame(gflops=gflopstab, size=sizetab, grain=array(grain, c(length(gflopstab)) ))
  113. );
  114. }
  115. handle_grain_mean_nm <- function(grain)
  116. {
  117. meantab <- NULL;
  118. sizetab <- NULL;
  119. for (size in sizelist) {
  120. list <- mean(handle_size_nm(size, grain));
  121. if (!is.na(list))
  122. {
  123. meantab <- c(meantab, list);
  124. sizetab <- c(sizetab, array(size, c(length(list))));
  125. }
  126. }
  127. return(
  128. data.frame(gflops=meantab, size=sizetab, grain=array(grain, c(length(meantab)) ))
  129. # meantab
  130. );
  131. }
  132. handle_grain_mean <- function(grain)
  133. {
  134. meantab <- NULL;
  135. sizetab <- NULL;
  136. for (size in sizelist) {
  137. list <- mean(handle_size(size, grain));
  138. if (!is.na(list))
  139. {
  140. meantab <- c(meantab, list);
  141. sizetab <- c(sizetab, array(size, c(length(list))));
  142. }
  143. }
  144. return(
  145. data.frame(gflops=meantab, size=sizetab, grain=array(grain, c(length(meantab)) ))
  146. # meantab
  147. );
  148. }
  149. trace_grain <- function(grain, color, style)
  150. {
  151. # points(handle_grain(grain)$size, handle_grain(grain)$gflops, col=color);
  152. pouet <- handle_grain_mean(grain);
  153. pouetgflops <- pouet$gflops;
  154. pouetsize <- pouet$size;
  155. lines(pouetsize, pouetgflops, col=color, legend.text=TRUE, type = "o", pch = style, lwd=2);
  156. pouet <- handle_grain_mean_nm(grain);
  157. pouetgflops <- pouet$gflops;
  158. pouetsize <- pouet$size;
  159. lines(pouetsize, pouetgflops, col=color, legend.text=TRUE, type = "o", pch = style, lwd=1);
  160. }
  161. display_grain <- function()
  162. {
  163. xlist <- range(sizelist);
  164. ylist <- range(c(0,100));
  165. plot.new();
  166. plot.window(xlist, ylist, log="");
  167. i <- 0;
  168. colarray <- c("magenta", "blue", "peru", "green3", "navy", "red", "green2", "black", "orange");
  169. for (grain in grainlist) {
  170. trace_grain(grain, colarray[i+1], -1);
  171. i <- i + 1;
  172. }
  173. #axis(1, at=seq(0, max*1024, 1024), log="x")
  174. axis(1)
  175. axis(2, at=seq(0, 100, 10), tck=1)
  176. # axis(4, at=seq(0, 100, 10))
  177. box(bty="u")
  178. labels <- c("256", "256 no model", "512", "512 no model", "1024", "1024 no model");
  179. legend("bottomright", inset=.05, title="Tile size", labels, lwd=2, lty=c(1, 1, 1, 1, 1, 1), pch=-1, col=c("magenta", "magenta", "blue", "blue", "peru", "peru"), bty="y", bg="white")
  180. mtext("matrix size", side=1, line=2, cex=1.6)
  181. mtext("GFlops", side=2, line=2, las=0, cex=1.6)
  182. title("Effect of granularity on the impact of scheduling");
  183. }
  184. display_grain()
  185. # boxplot(result, col=c("yellow", "red", "green"), xlab=sizelist);
  186. # plot(c(sizelist,sizelist,sizelist), c(result_greedy, result_prio, result_dm));
  187. # plot(sizelist, result_dm);
  188. # plot.new()
  189. # plot.window(range(c(sizelist,0) ), c(0, 6))