granularity.r 3.6 KB

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