starpu_workers_activity.in 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #!/bin/sh
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2010-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  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. 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 " -d directory where to save output files, by default current directory"
  33. echo ""
  34. echo "Report bugs to <@PACKAGE_BUGREPORT@>"
  35. exit 0
  36. }
  37. if [ "$1" = "-v" ] || [ "$1" = "--version" ] ; then
  38. echo "$PROGNAME (@PACKAGE_NAME@) @PACKAGE_VERSION@"
  39. exit 0
  40. fi
  41. if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "" ] ; then
  42. usage
  43. fi
  44. odir="."
  45. if [ "$1" = "-d" ]
  46. then
  47. odir=$2
  48. shift ; shift
  49. fi
  50. if [ ! -f $1 ] ; then
  51. echo "Error. File <$1> not found"
  52. echo ""
  53. usage
  54. fi
  55. # The input file must be generated by the starpu_fxt_tool command
  56. inputfile_with_counters=$1
  57. # We extract the counters out of the input file
  58. dir=$(dirname $1)
  59. inputfile=$dir/.$(basename $1).activity
  60. inputfile_cnt_ready=$dir/.$(basename $1).cnt_ready
  61. inputfile_cnt_submitted=$dir/.$(basename $1).cnt_submitted
  62. set_profiling_list=$dir/.$(basename $1).set_profiling_list
  63. names=$dir/.$(basename $1).names
  64. grep "^set_profiling" $inputfile_with_counters > $set_profiling_list
  65. grep "0$" $set_profiling_list | cut -f 2 | sort -n > $set_profiling_list.disable
  66. grep "1$" $set_profiling_list | cut -f 2 | sort -n > $set_profiling_list.enable
  67. grep "^name" $inputfile_with_counters > $names
  68. grep -v "^cnt" $inputfile_with_counters | grep -v "^set_profiling" | grep -v "^name" > $inputfile
  69. grep "^cnt_ready" $inputfile_with_counters > $inputfile_cnt_ready
  70. grep "^cnt_submitted" $inputfile_with_counters > $inputfile_cnt_submitted
  71. # Count the number of workers in the trace
  72. workers=`cut -f1 $inputfile | sort -n | uniq`
  73. nworkers=`cut -f1 $inputfile | sort -n | uniq|wc -l`
  74. # size of the entire graph
  75. width=1.5
  76. heigth=0.40
  77. total_heigth=$(echo "$heigth + ($heigth * $nworkers)"|bc -l)
  78. # In case 3 arguments are provided, the 2nd (resp. 3rd) indicates the start
  79. # (resp. the end) of the interval to be displayed.
  80. if [ $# -ge 3 ]; then
  81. starttime=$2
  82. endtime=$3
  83. else
  84. #if profiling is explicitely enabled (resp. disabled) at some point, we set the
  85. # default start (rest. end) point when we enable (resp. disable) profiling for
  86. # the first time.
  87. profiling_enable_cnt=`wc -l $set_profiling_list.enable|sed -e "s/\(.*\) .*/\1/"`
  88. if [ $profiling_enable_cnt -ge 1 ]; then
  89. starttime=`head -1 $set_profiling_list.enable`
  90. else
  91. starttime=$(cut -f 2 $inputfile |sort -n|head -1)
  92. fi
  93. # TODO test if last disable > first enable
  94. profiling_disable_cnt=$(wc -l $set_profiling_list.disable|sed -e "s/\(.*\) .*/\1/")
  95. if [ $profiling_disable_cnt -ge 1 ]; then
  96. endtime=`tail -1 $set_profiling_list.disable`
  97. else
  98. endtime=$(cut -f 2 $inputfile |sort -n|tail -1)
  99. fi
  100. # The values in the file are in ms, we display seconds
  101. starttime=$(echo "$starttime * 0.001 "| bc -l)
  102. endtime=$(echo "$endtime * 0.001 "| bc -l)
  103. fi
  104. echo "START $starttime END $endtime"
  105. # Gnuplot header
  106. cat > gnuplotcmd << EOF
  107. set term postscript eps enhanced color
  108. set output "$odir/activity.eps"
  109. set xrange [$starttime:$endtime]
  110. set size $width,$total_heigth
  111. set multiplot;
  112. set origin 0.0,0.0;
  113. set size $width,$heigth;
  114. set logscale y
  115. plot "$inputfile_cnt_submitted" using (\$2/1000):3 with filledcurves lt rgb "#999999" title "submitted",\
  116. "$inputfile_cnt_ready" using (\$2/1000):3 with filledcurves lt rgb "#000000" title "ready"
  117. set nologscale y
  118. EOF
  119. cnt=0
  120. for worker in $workers
  121. do
  122. grep "^$worker\s" $inputfile > .tmp.$worker
  123. starty=$(echo "$heigth + ($heigth * $cnt)"|bc -l)
  124. cat >> gnuplotcmd << EOF
  125. set origin 0.0,$starty;
  126. set size $width,$heigth;
  127. set key off
  128. set yrange [0:100]
  129. set ylabel "$(cut -f2- $names |grep "^$worker$" | cut -f2)"
  130. plot ".tmp.$worker" using (\$2/1000):(100) with filledcurves y1=0.0 lt rgb "#000000" notitle,\
  131. ".tmp.$worker" using (\$2/1000):((100*(\$4+\$5))/\$3) with filledcurves y1=0.0 lt rgb "#ff0000" notitle,\
  132. ".tmp.$worker" using (\$2/1000):((100*\$4)/\$3) with filledcurves y1=0.0 lt rgb "#00ff00" notitle
  133. EOF
  134. cnt=$(($cnt+1))
  135. done
  136. cat >> gnuplotcmd << EOF
  137. unset multiplot
  138. EOF
  139. gnuplot < gnuplotcmd
  140. rm gnuplotcmd
  141. rm $inputfile
  142. rm $inputfile_cnt_ready
  143. rm $inputfile_cnt_submitted
  144. rm $set_profiling_list
  145. rm $set_profiling_list.enable
  146. rm $set_profiling_list.disable
  147. #rm $names
  148. for worker in $workers
  149. do
  150. rm .tmp.$worker
  151. done