perfmodel_display_gnuplot.sh 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. #!/bin/bash
  2. #
  3. # StarPU
  4. # Copyright (C) Université Bordeaux 1, CNRS 2008-2010 (see AUTHORS file)
  5. #
  6. # This program 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. # This program 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. function compute_mean_and_stddev ()
  18. {
  19. filenamein=$1
  20. arch=$2
  21. filenameout=$3
  22. R --no-save > /dev/null << EOF
  23. table <- read.table("$filenamein")
  24. sizelist <- unique(table[,2])
  25. mins <- c()
  26. maxs <- c()
  27. means <- c()
  28. medians <- c()
  29. sds <- c()
  30. firstquarts <- c()
  31. thirdquarts <- c()
  32. for (size in sizelist)
  33. {
  34. sublist <- table[table[,2]==size,3]
  35. meanval <- mean(sublist)
  36. medianval <- median(sublist)
  37. sdval <- sd(sublist)
  38. firstquart <- quantile(sublist, 0.25)
  39. thirdquart <- quantile(sublist, 0.75)
  40. #minval <- min(sublist)
  41. minval <- quantile(sublist, 0.01)
  42. #maxval <- max(sublist)
  43. maxval <- quantile(sublist, 0.99)
  44. means <- c(means, meanval)
  45. medians <- c(medians, medianval)
  46. sds <- c(sds, sdval)
  47. firstquarts <- c(firstquarts, firstquart)
  48. thirdquarts <- c(thirdquarts, thirdquart)
  49. mins <- c(mins, minval)
  50. maxs <- c(maxs, maxval)
  51. }
  52. newtable <- data.frame(unique(sizelist), mins, firstquarts, medians, thirdquarts, maxs, means, sds);
  53. write.table(newtable, file="$filenameout");
  54. EOF
  55. }
  56. PERFMODELDISPLAY=./perfmodel_display
  57. function gnuplot_symbol()
  58. {
  59. symbol=$1
  60. echo "Display symbol $symbol"
  61. # TODO check return value $? of perfmodel_display to ensure we have valid data
  62. cuda_a=`$PERFMODELDISPLAY -s $symbol -a cuda -p a`
  63. cuda_b=`$PERFMODELDISPLAY -s $symbol -a cuda -p b`
  64. cuda_c=`$PERFMODELDISPLAY -s $symbol -a cuda -p c`
  65. cuda_alpha=`$PERFMODELDISPLAY -s $symbol -a cuda -p alpha`
  66. cuda_beta=`$PERFMODELDISPLAY -s $symbol -a cuda -p beta`
  67. cuda_debug=`$PERFMODELDISPLAY -s $symbol -p path-file-debug -a cuda`
  68. echo "CUDA : y = $cuda_a * size ^ $cuda_b + $cuda_c"
  69. echo "CUDA : y = $cuda_alpha * size ^ $cuda_beta"
  70. echo "CUDA : debug file $cuda_debug"
  71. cpu_a=`$PERFMODELDISPLAY -s $symbol -a cpu -p a`
  72. cpu_b=`$PERFMODELDISPLAY -s $symbol -a cpu -p b`
  73. cpu_c=`$PERFMODELDISPLAY -s $symbol -a cpu -p c`
  74. cpu_alpha=`$PERFMODELDISPLAY -s $symbol -a cpu -p alpha`
  75. cpu_beta=`$PERFMODELDISPLAY -s $symbol -a cpu -p beta`
  76. cpu_debug=`$PERFMODELDISPLAY -s $symbol -p path-file-debug -a cpu`
  77. echo "CPU : y = $cpu_a * size ^ $cpu_b + $cpu_c"
  78. echo "CPU : y = $cpu_alpha * size ^ $cpu_beta"
  79. echo "CPU : debug file $cpu_debug"
  80. # get the list of the different sizes of the tasks
  81. cuda_size_list=`cut -f2 $cuda_debug| sort -n |uniq|xargs`
  82. cpu_size_list=`cut -f2 $cpu_debug| sort -n |uniq|xargs`
  83. cpu_debug_data="model_$symbol.cpu.data"
  84. cuda_debug_data="model_$symbol.cuda.data"
  85. # In case we want stddev instead of a cloud of points ...
  86. compute_mean_and_stddev "$cpu_debug" "cpu" "$cpu_debug_data"
  87. compute_mean_and_stddev "$cuda_debug" "cuda" "$cuda_debug_data"
  88. # use ..
  89. #  "$cpu_debug_data" usi 2:3:4 with errorbars title "cpu measured"
  90. gnuplot > /dev/null << EOF
  91. set term postscript eps enhanced color
  92. set output "model_$symbol.eps"
  93. set xlabel "Size (bytes)"
  94. set ylabel "Execution time (us)"
  95. set size 0.60
  96. set multiplot
  97. set style line 1 lt 1 lw 3 linecolor -1
  98. set style line 2 lt 2 lw 3 linecolor -1
  99. set logscale x
  100. set logscale y
  101. #set grid y
  102. #set grid x
  103. set format x "10^{%L}"
  104. set format y "10^{%L}"
  105. set key top left
  106. set key title "Non-linear regression\n(y = {/Symbol a} x@^{{/Symbol b}} + {/Symbol g})"
  107. set bars 4.0
  108. plot $cpu_a * ( x ** $cpu_b ) + $cpu_c ls 1 title "CPU" ,\
  109. $cuda_a * ( x ** $cuda_b ) + $cuda_c ls 2 title "GPU" ,\
  110. "$cpu_debug_data" usi 2:4:3:7:6 with candlesticks ls 1 notitle whiskerbars ,\
  111. "$cpu_debug_data" usi 2:5:5:5:5 with candlesticks ls 1 notitle ,\
  112. "$cuda_debug_data" usi 2:4:3:7:6 with candlesticks ls 2 notitle whiskerbars ,\
  113. "$cuda_debug_data" usi 2:5:5:5:5 with candlesticks ls 2 notitle
  114. set noborder
  115. set origin 0.42,0.10
  116. set nologscale xy
  117. set size .15,.25
  118. set tics scale 0
  119. set xrange [-0.1:0.1]
  120. set noxtics
  121. set noytics
  122. set format y2 "%g %%"
  123. set y2tics (1,25,50,75,99)
  124. set y2tics nomirror
  125. set title "Percentiles"
  126. set xlabel ""
  127. set ylabel ""
  128. set key
  129. plot "$cuda_debug_data" usi (0):(25):(1):(99):(75) with candlesticks ls 1 notitle whiskerbars ,\
  130. "$cuda_debug_data" usi (0):(50):(50):(50):(50) with candlesticks ls 1 notitle
  131. unset multiplot
  132. EOF
  133. }
  134. for symbol in $@
  135. do
  136. gnuplot_symbol $symbol
  137. done