granularity.r 3.5 KB

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