starpu_workers_activity.in 5.2 KB

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