granularity_model.r 5.2 KB

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