random.r 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. sizelist <- seq(2048, 24576, 2048);
  18. #schedlist <- c("greedy", "prio", "dm", "random", "no-prio", "ws", "lws");
  19. schedlist <- c("prio","random");
  20. print(schedlist);
  21. print(sizelist);
  22. gflops <- function (x, size)
  23. {
  24. 2*size*size*size/(3000000*x);
  25. }
  26. parse <- function (size, sched)
  27. {
  28. ret <- scan(paste("timings-sched/sched", sched, size, sep="."));
  29. return(ret);
  30. }
  31. handle_size <- function (size, sched)
  32. {
  33. gflops <- gflops(parse(size, sched), size);
  34. # return(data.frame(gflops=gflops, size=array(size, c(length(gflops))), sched=array(sched, c(length(gflops)))));
  35. return(gflops);
  36. }
  37. handle_sched <- function(sched)
  38. {
  39. gflopstab <- NULL;
  40. sizetab <- NULL;
  41. for (size in sizelist)
  42. {
  43. list <- handle_size(size, sched);
  44. gflopstab <- c(gflopstab, list);
  45. sizetab <- c(sizetab, array(size, c(length(list))));
  46. }
  47. return(
  48. data.frame(gflops=gflopstab, size=sizetab, sched=array(sched, c(length(gflopstab)) ))
  49. );
  50. }
  51. handle_sched_mean <- function(sched)
  52. {
  53. meantab <- NULL;
  54. sizetab <- NULL;
  55. for (size in sizelist)
  56. {
  57. list <- mean(handle_size(size, sched));
  58. meantab <- c(meantab, list);
  59. sizetab <- c(sizetab, array(size, c(length(list))));
  60. }
  61. return(
  62. data.frame(gflops=meantab, size=sizetab, sched=array(sched, c(length(meantab)) ))
  63. # meantab
  64. );
  65. }
  66. trace_sched <- function(sched, color, style)
  67. {
  68. #points(handle_sched(sched)$size, handle_sched(sched)$gflops, col=color);
  69. lines(handle_sched_mean(sched)$size, handle_sched_mean(sched)$gflops, col=color, legend.text=TRUE, type = "o", pch = style, lwd=2);
  70. }
  71. display_sched <- function()
  72. {
  73. xlist <- range(sizelist);
  74. ylist <- range(c(0,100));
  75. plot.new();
  76. plot.window(xlist, ylist);
  77. #trace_sched("dm", "black", 0);
  78. trace_sched("random", "blue", 1);
  79. #trace_sched("greedy", "black", 2);
  80. trace_sched("prio", "red", 4);
  81. #trace_sched("no-prio", "black");
  82. #trace_sched("ws", "purple");
  83. #trace_sched("lws", "purple");
  84. axis(1, at=sizelist)
  85. axis(2, at=seq(0, 100, 10), tck=1)
  86. # axis(4, at=seq(0, 100, 10))
  87. box(bty="u")
  88. #labels <- c("greedy", "priority", "model", "random", "black", "ws", "lws")
  89. # labels <- c("greedy", "priority", "model", "random")
  90. #labels <- c("model", "weighted random", "greedy", "priority")
  91. labels <- c("weighted random", "priority")
  92. legend("topleft", inset=.05, title="Scheduling policy", labels, lwd=2, cex=1.6, lty=c(1, 1, 1, 1, 1, 1), pch=c(1, 4),col=c("blue","red"), bty="y", bg="white")
  93. mtext("matrix size", side=1, line=2, cex=1.6)
  94. mtext("GFlops", side=2, line=2, las=0, cex=1.6)
  95. title("LU decomposition");
  96. }
  97. display_sched()
  98. # boxplot(result, col=c("yellow", "red", "green"), xlab=sizelist);
  99. # plot(c(sizelist,sizelist,sizelist), c(result_greedy, result_prio, result_dm));
  100. # plot(sizelist, result_dm);
  101. # plot.new()
  102. # plot.window(range(c(sizelist,0) ), c(0, 6))