starpu_workers_activity.in 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. #!/bin/sh
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2010 Université de Bordeaux 1
  5. # Copyright (C) 2010, 2011, 2012 Centre National de la Recherche Scientifique
  6. #
  7. # StarPU is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU Lesser General Public License as published by
  9. # the Free Software Foundation; either version 2.1 of the License, or (at
  10. # your option) any later version.
  11. #
  12. # StarPU is distributed in the hope that it will be useful, but
  13. # WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. #
  16. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. PROGNAME=$0
  18. usage()
  19. {
  20. echo "Offline tool to display the activity of the workers during the execution."
  21. echo ""
  22. echo " The starpu_fxt_tool utility now generates a file named 'activity.data' which"
  23. echo " can be processed by this script to generate a plot named activity.eps"
  24. echo ""
  25. echo " Typical usage:"
  26. echo " ./starpu_fxt_tool -i /tmp/prof_file_foo"
  27. echo " $PROGNAME activity.data"
  28. echo ""
  29. echo "Options:"
  30. echo " -h, --help display this help and exit"
  31. echo " -v, --version output version information and exit"
  32. echo ""
  33. echo "Report bugs to <@PACKAGE_BUGREPORT@>"
  34. exit 0
  35. }
  36. if [ "$1" == "-v" ] || [ "$1" == "--version" ] ; then
  37. echo "$PROGNAME @STARPU_MAJOR_VERSION@.@STARPU_MINOR_VERSION@"
  38. exit 0
  39. fi
  40. if [ "$1" == "-h" ] || [ "$1" == "--help" ] || [ "$1" == "" ] ; then
  41. usage
  42. fi
  43. if [ ! -f $1 ] ; then
  44. echo "Error. File <$1> not found"
  45. echo ""
  46. usage
  47. fi
  48. # The input file must be generated by the starpu_fxt_tool command
  49. inputfile_with_counters=$1
  50. # We extract the counters out of the input file
  51. inputfile=.$inputfile_with_counters.activity
  52. inputfile_cnt_ready=.$1.cnt_ready
  53. inputfile_cnt_submitted=.$1.cnt_submitted
  54. set_profiling_list=.$1.set_profiling_list
  55. names=.$1.names
  56. grep "^set_profiling" $inputfile_with_counters > $set_profiling_list
  57. grep "0$" $set_profiling_list | cut -f 2 | sort -n > $set_profiling_list.disable
  58. grep "1$" $set_profiling_list | cut -f 2 | sort -n > $set_profiling_list.enable
  59. grep "^name" $inputfile_with_counters > $names
  60. grep -v "^cnt" $inputfile_with_counters | grep -v "^set_profiling" | grep -v "^name" > $inputfile
  61. grep "^cnt_ready" $inputfile_with_counters > $inputfile_cnt_ready
  62. grep "^cnt_submitted" $inputfile_with_counters > $inputfile_cnt_submitted
  63. # Count the number of workers in the trace
  64. workers=`cut -f1 $inputfile | sort -n | uniq`
  65. nworkers=`cut -f1 $inputfile | sort -n | uniq|wc -l`
  66. # size of the entire graph
  67. width=1.5
  68. heigth=0.40
  69. total_heigth=$(echo "$heigth + ($heigth * $nworkers)"|bc -l)
  70. # In case 3 arguments are provided, the 2nd (resp. 3rd) indicates the start
  71. # (resp. the end) of the interval to be displayed.
  72. if [ $# -ge 3 ]; then
  73. starttime=$2
  74. endtime=$3
  75. else
  76. #if profiling is explicitely enabled (resp. disabled) at some point, we set the
  77. # default start (rest. end) point when we enable (resp. disable) profiling for
  78. # the first time.
  79. profiling_enable_cnt=`wc -l $set_profiling_list.enable|sed -e "s/\(.*\) .*/\1/"`
  80. if [ $profiling_enable_cnt -ge 1 ]; then
  81. starttime=`head -1 $set_profiling_list.enable`
  82. else
  83. starttime=$(cut -f 2 $inputfile |sort -n|head -1)
  84. fi
  85. # TODO test if last disable > first enable
  86. profiling_disable_cnt=$(wc -l $set_profiling_list.disable|sed -e "s/\(.*\) .*/\1/")
  87. if [ $profiling_disable_cnt -ge 1 ]; then
  88. endtime=`tail -1 $set_profiling_list.disable`
  89. else
  90. endtime=$(cut -f 2 $inputfile |sort -n|tail -1)
  91. fi
  92. # The values in the file are in ms, we display seconds
  93. starttime=$(echo "$starttime * 0.001 "| bc -l)
  94. endtime=$(echo "$endtime * 0.001 "| bc -l)
  95. fi
  96. echo "START $starttime END $endtime"
  97. # Gnuplot header
  98. cat > gnuplotcmd << EOF
  99. set term postscript eps enhanced color
  100. set output "activity.eps"
  101. set xrange [$starttime:$endtime]
  102. set size $width,$total_heigth
  103. set multiplot;
  104. set origin 0.0,0.0;
  105. set size $width,$heigth;
  106. set logscale y
  107. plot "$inputfile_cnt_submitted" using (\$2/1000):3 with filledcurves lt rgb "#999999" title "submitted",\
  108. "$inputfile_cnt_ready" using (\$2/1000):3 with filledcurves lt rgb "#000000" title "ready"
  109. set nologscale y
  110. EOF
  111. cnt=0
  112. for worker in $workers
  113. do
  114. grep "^$worker" $inputfile > .tmp.$worker
  115. starty=$(echo "$heigth + ($heigth * $cnt)"|bc -l)
  116. cat >> gnuplotcmd << EOF
  117. set origin 0.0,$starty;
  118. set size $width,$heigth;
  119. set key off
  120. set yrange [0:100]
  121. set ylabel "$(cut -f2- $names |grep "^$worker" | cut -f2)"
  122. plot ".tmp.$worker" using (\$2/1000):(100) with filledcurves y1=0.0 lt rgb "#000000" notitle,\
  123. ".tmp.$worker" using (\$2/1000):((100*(\$4+\$5))/\$3) with filledcurves y1=0.0 lt rgb "#ff0000" notitle,\
  124. ".tmp.$worker" using (\$2/1000):((100*\$4)/\$3) with filledcurves y1=0.0 lt rgb "#00ff00" notitle
  125. EOF
  126. cnt=$(($cnt+1))
  127. done
  128. cat >> gnuplotcmd << EOF
  129. unset multiplot
  130. EOF
  131. gnuplot < gnuplotcmd
  132. rm gnuplotcmd
  133. rm $inputfile
  134. rm $inputfile_cnt_ready
  135. rm $inputfile_cnt_submitted
  136. rm $set_profiling_list
  137. rm $set_profiling_list.enable
  138. rm $set_profiling_list.disable
  139. #rm $names
  140. for worker in $workers
  141. do
  142. rm .tmp.$worker
  143. done