perturbate.r 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. sizelist <- seq(2048, 24576, 2048);
  2. schedlist <- c("greedy", "prio", "dm", "random");
  3. print(schedlist);
  4. print(sizelist);
  5. gflops <- function (x, size)
  6. {
  7. 2*size*size*size/(3000000*x);
  8. }
  9. parse <- function (size, ampl)
  10. {
  11. filename = paste("timing-perturbate/pertubate", size, ampl, sep=".");
  12. if (file.exists(filename))
  13. {
  14. ret <- scan(filename);
  15. return(ret);
  16. };
  17. return(NULL);
  18. }
  19. parse_ref <- function (size)
  20. {
  21. filename = paste("timings-sched/sched.greedy", size, sep=".");
  22. if (file.exists(filename))
  23. {
  24. ret <- scan(filename);
  25. return(ret);
  26. };
  27. return(NULL);
  28. }
  29. handle_size <- function (size, ampl)
  30. {
  31. gflops <- gflops(parse(size, ampl), size);
  32. return(gflops);
  33. }
  34. handle_size_ref <- function (size)
  35. {
  36. gflops <- gflops(parse_ref(size), size);
  37. return(gflops);
  38. }
  39. handle_ampl <- function(ampl)
  40. {
  41. gflopstab <- NULL;
  42. sizetab <- NULL;
  43. for (size in sizelist) {
  44. list <- handle_size(size, ampl);
  45. gflopstab <- c(gflopstab, list);
  46. sizetab <- c(sizetab, array(size, c(length(list))));
  47. }
  48. return(
  49. data.frame(gflops=gflopstab, size=sizetab, ampl=array(ampl, c(length(gflopstab)) ))
  50. );
  51. }
  52. handle_ampl_mean <- function(ampl)
  53. {
  54. meantab <- NULL;
  55. sizetab <- NULL;
  56. for (size in sizelist) {
  57. list <- mean(handle_size(size, ampl));
  58. meantab <- c(meantab, list);
  59. sizetab <- c(sizetab, array(size, c(length(list))));
  60. }
  61. return(
  62. data.frame(gflops=meantab, size=sizetab, ampl=array(ampl, c(length(meantab)) ))
  63. # meantab
  64. );
  65. }
  66. handle_ref_mean <- function()
  67. {
  68. meantab <- NULL;
  69. sizetab <- NULL;
  70. for (size in sizelist) {
  71. list <- mean(handle_size_ref(size));
  72. meantab <- c(meantab, list);
  73. sizetab <- c(sizetab, array(size, c(length(list))));
  74. }
  75. return(
  76. data.frame(gflops=meantab, size=sizetab)
  77. # meantab
  78. );
  79. }
  80. trace_ampl <- function(ampl, color, style)
  81. {
  82. #points(handle_ampl(ampl)$size, handle_ampl(ampl)$gflops, col=color);
  83. lines(handle_ampl_mean(ampl)$size, handle_ampl_mean(ampl)$gflops, type = "o", col=color, lwd= 1, lty=1, pch = style);
  84. }
  85. trace_ref <- function(color)
  86. {
  87. lines(handle_ref_mean()$size, handle_ref_mean()$gflops, col=color, lwd=3, lty=2);
  88. }
  89. display_ampl <- function()
  90. {
  91. xlist <- range(sizelist);
  92. ylist <- range(c(0,100));
  93. plot.new();
  94. plot.window(xlist, ylist);
  95. trace_ref("black");
  96. trace_ampl("1.0", "black", 4);
  97. trace_ampl("0.50", "black", 5);
  98. trace_ampl("0.25", "black", 2);
  99. trace_ampl("0.1", "black", 1);
  100. trace_ampl("0.0", "black", 0);
  101. axis(1, at=sizelist, font=1.6)
  102. axis(2, at=seq(0, 100, 10), tck=1, font=1.6)
  103. # axis(4, at=seq(0, 100, 10))
  104. box(bty="u")
  105. labels <- c("greedy", "0 %", "10 %", "25 %", "50 %", "100 %")
  106. legend("topleft", inset=.05, title="Perturbation", labels, lwd=c(2, 1, 1, 1, 1, 1), pch=c(-1, 0, 1, 2, 5, 4), lty=c(2, 1, 1, 1, 1, 1), col=c("black", "black", "black", "black", "black", "black"), bty="y", bg="white")
  107. mtext("matrix size", side=1, line=2, cex=1.6)
  108. mtext("GFlops", side=2, line=2, las=0, cex=1.6)
  109. # title("Impact of performance prediction innacuracies on LU decomposition");
  110. }
  111. display_ampl()