granularity_model.r 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. # StarPU --- Runtime system for heterogeneous multicore architectures.
  2. #
  3. # Copyright (C) 2008-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  4. #
  5. # StarPU is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU Lesser General Public License as published by
  7. # the Free Software Foundation; either version 2.1 of the License, or (at
  8. # your option) any later version.
  9. #
  10. # StarPU is distributed in the hope that it will be useful, but
  11. # WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. #
  14. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  15. #
  16. max <- 30
  17. sizelist <- seq(64, max*1024, 64);
  18. #schedlist <- c("greedy", "prio", "dm", "random", "no-prio", "ws", "lws");
  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. {
  52. list <- handle_size(size, grain);
  53. if (!is.na(list))
  54. {
  55. gflopstab <- c(gflopstab, list);
  56. sizetab <- c(sizetab, array(size, c(length(list))));
  57. }
  58. }
  59. return(
  60. data.frame(gflops=gflopstab, size=sizetab, grain=array(grain, c(length(gflopstab)) ))
  61. );
  62. }
  63. handle_grain_mean <- function(grain)
  64. {
  65. meantab <- NULL;
  66. sizetab <- NULL;
  67. for (size in sizelist)
  68. {
  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. parse_nm <- function (size, grain)
  82. {
  83. filename = paste("timing/granularity.nomodel", grain, size, sep=".");
  84. if (file.exists(filename))
  85. {
  86. ret <- scan(filename);
  87. return(ret);
  88. }
  89. return (NA);
  90. }
  91. handle_size_nm <- function (size, grain)
  92. {
  93. parsed <- parse_nm(size, grain);
  94. if (is.na(parsed))
  95. {
  96. return (NA);
  97. }
  98. gflops <- gflops(parsed, size);
  99. return(gflops);
  100. }
  101. handle_grain_nm <- function(grain)
  102. {
  103. gflopstab <- NULL;
  104. sizetab <- NULL;
  105. for (size in sizelist)
  106. {
  107. list <- handle_size_nm(size, grain);
  108. if (!is.na(list))
  109. {
  110. gflopstab <- c(gflopstab, list);
  111. sizetab <- c(sizetab, array(size, c(length(list))));
  112. }
  113. }
  114. return(
  115. data.frame(gflops=gflopstab, size=sizetab, grain=array(grain, c(length(gflopstab)) ))
  116. );
  117. }
  118. handle_grain_mean_nm <- function(grain)
  119. {
  120. meantab <- NULL;
  121. sizetab <- NULL;
  122. for (size in sizelist)
  123. {
  124. list <- mean(handle_size_nm(size, grain));
  125. if (!is.na(list))
  126. {
  127. meantab <- c(meantab, list);
  128. sizetab <- c(sizetab, array(size, c(length(list))));
  129. }
  130. }
  131. return(
  132. data.frame(gflops=meantab, size=sizetab, grain=array(grain, c(length(meantab)) ))
  133. # meantab
  134. );
  135. }
  136. handle_grain_mean <- function(grain)
  137. {
  138. meantab <- NULL;
  139. sizetab <- NULL;
  140. for (size in sizelist)
  141. {
  142. list <- mean(handle_size(size, grain));
  143. if (!is.na(list))
  144. {
  145. meantab <- c(meantab, list);
  146. sizetab <- c(sizetab, array(size, c(length(list))));
  147. }
  148. }
  149. return(
  150. data.frame(gflops=meantab, size=sizetab, grain=array(grain, c(length(meantab)) ))
  151. # meantab
  152. );
  153. }
  154. trace_grain <- function(grain, color, style)
  155. {
  156. # points(handle_grain(grain)$size, handle_grain(grain)$gflops, col=color);
  157. pouet <- handle_grain_mean(grain);
  158. pouetgflops <- pouet$gflops;
  159. pouetsize <- pouet$size;
  160. lines(pouetsize, pouetgflops, col=color, legend.text=TRUE, type = "o", pch = style, lwd=2);
  161. pouet <- handle_grain_mean_nm(grain);
  162. pouetgflops <- pouet$gflops;
  163. pouetsize <- pouet$size;
  164. lines(pouetsize, pouetgflops, col=color, legend.text=TRUE, type = "o", pch = style, lwd=1);
  165. }
  166. display_grain <- function()
  167. {
  168. xlist <- range(sizelist);
  169. ylist <- range(c(0,100));
  170. plot.new();
  171. plot.window(xlist, ylist, log="");
  172. i <- 0;
  173. colarray <- c("magenta", "blue", "peru", "green3", "navy", "red", "green2", "black", "orange");
  174. for (grain in grainlist)
  175. {
  176. trace_grain(grain, colarray[i+1], -1);
  177. i <- i + 1;
  178. }
  179. #axis(1, at=seq(0, max*1024, 1024), log="x")
  180. axis(1)
  181. axis(2, at=seq(0, 100, 10), tck=1)
  182. # axis(4, at=seq(0, 100, 10))
  183. box(bty="u")
  184. labels <- c("256", "256 no model", "512", "512 no model", "1024", "1024 no model");
  185. 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")
  186. mtext("matrix size", side=1, line=2, cex=1.6)
  187. mtext("GFlops", side=2, line=2, las=0, cex=1.6)
  188. title("Effect of granularity on the impact of scheduling");
  189. }
  190. display_grain()
  191. # boxplot(result, col=c("yellow", "red", "green"), xlab=sizelist);
  192. # plot(c(sizelist,sizelist,sizelist), c(result_greedy, result_prio, result_dm));
  193. # plot(sizelist, result_dm);
  194. # plot.new()
  195. # plot.window(range(c(sizelist,0) ), c(0, 6))