sched.r 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  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. schedlist <- c("greedy", "dm", "random");
  17. sizelist <- seq(2048, 16384, 1024);
  18. #sizelist <- seq(2048, 16384, 2048);
  19. print(schedlist);
  20. print(sizelist);
  21. gflops <- function (x, size)
  22. {
  23. (2*size*size*size)/(1000000*x);
  24. }
  25. parse <- function (size, sched)
  26. {
  27. filename = paste("timings-sched/sched", sched, size, sep=".");
  28. if (file.exists(filename))
  29. {
  30. ret <- scan(paste("timings-sched/sched", sched, size, sep="."));
  31. return(ret);
  32. };
  33. return(NULL);
  34. }
  35. handle_size <- function (size, sched)
  36. {
  37. gflops <- gflops(parse(size, sched), size);
  38. return(gflops);
  39. }
  40. handle_sched <- function(sched)
  41. {
  42. gflopstab <- NULL;
  43. sizetab <- NULL;
  44. for (size in sizelist)
  45. {
  46. list <- handle_size(size, sched);
  47. gflopstab <- c(gflopstab, list);
  48. sizetab <- c(sizetab, array(size, c(length(list))));
  49. }
  50. return(
  51. data.frame(gflops=gflopstab, size=sizetab, sched=array(sched, c(length(gflopstab)) ))
  52. );
  53. }
  54. handle_sched_mean <- function(sched)
  55. {
  56. meantab <- NULL;
  57. sizetab <- NULL;
  58. for (size in sizelist)
  59. {
  60. list <- mean(handle_size(size, sched));
  61. meantab <- c(meantab, list);
  62. sizetab <- c(sizetab, array(size, c(length(list))));
  63. }
  64. return(
  65. data.frame(gflops=meantab, size=sizetab, sched=array(sched, c(length(meantab)) ))
  66. # meantab
  67. );
  68. }
  69. handle_sched_max <- function(sched)
  70. {
  71. gflopstab <- NULL;
  72. sizetab <- NULL;
  73. for (size in sizelist)
  74. {
  75. prout <- handle_size(size, sched);
  76. list <- max(prout);
  77. print(list);
  78. gflopstab <- c(gflopstab, list);
  79. sizetab <- c(sizetab, size);
  80. }
  81. return(
  82. data.frame(gflops=gflopstab, size=sizetab, sched=array(sched, c(length(gflopstab)) ))
  83. );
  84. }
  85. handle_sched_min <- function(sched)
  86. {
  87. gflopstab <- NULL;
  88. sizetab <- NULL;
  89. for (size in sizelist)
  90. {
  91. list <- min((handle_size(size, sched)));
  92. print("MIN"); print( list);
  93. gflopstab <- c(gflopstab, list);
  94. sizetab <- c(sizetab, size);
  95. }
  96. return(
  97. data.frame(gflops=gflopstab, size=sizetab, sched=array(sched, c(length(gflopstab)) ))
  98. );
  99. }
  100. trace_sched <- function(sched, color, style, prout)
  101. {
  102. #lines(handle_sched_mean(sched)$size, handle_sched_mean(sched)$gflops, col=color, legend.text=TRUE);
  103. if (length(handle_sched_mean(sched)))
  104. {
  105. if (prout)
  106. {
  107. #for (size in sizelist)
  108. #{
  109. # #lines(array(size, c(length( handle_size(size, sched) )) ), handle_size(size, sched));
  110. #}
  111. convexx <- NULL;
  112. convexy <- NULL;
  113. for (point in (handle_sched_min(sched)$size))
  114. {
  115. convexx <- c(convexx, point);
  116. }
  117. for (point in (handle_sched_min(sched)$gflops))
  118. {
  119. convexy <- c(convexy, point);
  120. }
  121. for (point in (handle_sched_max(sched)$size))
  122. {
  123. convexx <- c(point, convexx);
  124. }
  125. for (point in (handle_sched_max(sched)$gflops))
  126. {
  127. convexy <- c(point, convexy);
  128. }
  129. #lines(handle_sched_min(sched)$size, handle_sched_min(sched)$gflops);
  130. #lines(handle_sched_max(sched)$size, handle_sched_max(sched)$gflops);
  131. polygon(convexx, convexy, col="light gray", border=-1);
  132. lines(handle_sched_mean(sched)$size, handle_sched_mean(sched)$gflops, col=color, type = "o", pch=style, lty=2);
  133. }
  134. else
  135. {
  136. lines(handle_sched_mean(sched)$size, handle_sched_mean(sched)$gflops, col=color, type = "o", pch=style);
  137. }
  138. };
  139. }
  140. display_sched <- function()
  141. {
  142. xlist <- range(sizelist);
  143. ylist <- range(c(0,110));
  144. plot.new();
  145. plot.window(xlist, ylist);
  146. trace_sched("random", "black",1, 1);
  147. trace_sched("dm", "black", 0, 0);
  148. trace_sched("greedy", "black", 2, 0);
  149. axis(1, at=sizelist)
  150. axis(2, at=seq(0, 120, 10), tck=1)
  151. # axis(4, at=seq(0, 120, 10))
  152. box(bty="u")
  153. labels <- c("model", "greedy", "weighted random (mean)")
  154. legend("bottomright", inset=.05, title="Scheduling policy", labels, lwd=1, pch=c(0, 2, 1),lty=c(1, 1, 2, 1), col="black", bty="y", bg="white")
  155. mtext("matrix size", side=1, line=2, cex=1.6)
  156. mtext("GFlops", side=2, line=2, las=0, cex=1.6)
  157. # title("Impact of the scheduling strategy on blocked Matrix Multiplication");
  158. }
  159. display_sched()