starpu_workers_activity 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. #!/bin/bash
  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. usage()
  18. {
  19. echo "Offline tool to display the activity of the workers during the execution."
  20. echo ""
  21. echo " The fxt_tool utility now generates a file named 'activity.data' which can"
  22. echo " be processed by this script to generate a plot named activity.eps"
  23. echo ""
  24. echo " Typical usage:"
  25. echo " ./fxt_tool -i /tmp/prof_file_foo"
  26. echo " $0 activity.data"
  27. exit 1
  28. }
  29. if [ "$1" == "-h" ] || [ "$1" == "-help" ] || [ "$1" == "" ] ; then
  30. usage
  31. fi
  32. if [ ! -f $1 ] ; then
  33. echo "Error. File <$1> not found"
  34. echo ""
  35. usage
  36. fi
  37. # The input file must be generated by the starpu_fxt_tool command
  38. inputfile_with_counters=$1
  39. # We extract the counters out of the input file
  40. inputfile=.$inputfile_with_counters.activity
  41. inputfile_cnt_ready=.$1.cnt_ready
  42. inputfile_cnt_submitted=.$1.cnt_submitted
  43. set_profiling_list=.$1.set_profiling_list
  44. names=.$1.names
  45. grep "^set_profiling" $inputfile_with_counters > $set_profiling_list
  46. grep "0$" $set_profiling_list | cut -f 2 | sort -n > $set_profiling_list.disable
  47. grep "1$" $set_profiling_list | cut -f 2 | sort -n > $set_profiling_list.enable
  48. grep "^name" $inputfile_with_counters > $names
  49. grep -v "^cnt" $inputfile_with_counters | grep -v "^set_profiling" | grep -v "^name" > $inputfile
  50. grep "^cnt_ready" $inputfile_with_counters > $inputfile_cnt_ready
  51. grep "^cnt_submitted" $inputfile_with_counters > $inputfile_cnt_submitted
  52. # Count the number of workers in the trace
  53. workers=`cut -f1 $inputfile | sort -n | uniq`
  54. nworkers=`cut -f1 $inputfile | sort -n | uniq|wc -l`
  55. # size of the entire graph
  56. width=1.5
  57. heigth=0.40
  58. total_heigth=$(echo "$heigth + ($heigth * $nworkers)"|bc -l)
  59. # In case 3 arguments are provided, the 2nd (resp. 3rd) indicates the start
  60. # (resp. the end) of the interval to be displayed.
  61. if [ $# -ge 3 ]; then
  62. starttime=$2
  63. endtime=$3
  64. else
  65. #if profiling is explicitely enabled (resp. disabled) at some point, we set the
  66. # default start (rest. end) point when we enable (resp. disable) profiling for
  67. # the first time.
  68. profiling_enable_cnt=`wc -l $set_profiling_list.enable|sed -e "s/\(.*\) .*/\1/"`
  69. if [ $profiling_enable_cnt -ge 1 ]; then
  70. starttime=`head -1 $set_profiling_list.enable`
  71. else
  72. starttime=$(cut -f 2 $inputfile |sort -n|head -1)
  73. fi
  74. # TODO test if last disable > first enable
  75. profiling_disable_cnt=$(wc -l $set_profiling_list.disable|sed -e "s/\(.*\) .*/\1/")
  76. if [ $profiling_disable_cnt -ge 1 ]; then
  77. endtime=`tail -1 $set_profiling_list.disable`
  78. else
  79. endtime=$(cut -f 2 $inputfile |sort -n|tail -1)
  80. fi
  81. # The values in the file are in ms, we display seconds
  82. starttime=$(echo "$starttime * 0.001 "| bc -l)
  83. endtime=$(echo "$endtime * 0.001 "| bc -l)
  84. fi
  85. echo "START $starttime END $endtime"
  86. # Gnuplot header
  87. cat > gnuplotcmd << EOF
  88. set term postscript eps enhanced color
  89. set output "activity.eps"
  90. set xrange [$starttime:$endtime]
  91. set size $width,$total_heigth
  92. set multiplot;
  93. set origin 0.0,0.0;
  94. set size $width,$heigth;
  95. set logscale y
  96. plot "$inputfile_cnt_submitted" using (\$2/1000):3 with filledcurves lt rgb "#999999" title "submitted",\
  97. "$inputfile_cnt_ready" using (\$2/1000):3 with filledcurves lt rgb "#000000" title "ready"
  98. set nologscale y
  99. EOF
  100. cnt=0
  101. for worker in $workers
  102. do
  103. grep "^$worker" $inputfile > .tmp.$worker
  104. starty=$(echo "$heigth + ($heigth * $cnt)"|bc -l)
  105. cat >> gnuplotcmd << EOF
  106. set origin 0.0,$starty;
  107. set size $width,$heigth;
  108. set key off
  109. set yrange [0:100]
  110. set ylabel "$(cut -f2- $names |grep "^$worker" | cut -f2)"
  111. plot ".tmp.$worker" using (\$2/1000):(100) with filledcurves y1=0.0 lt rgb "#000000" notitle,\
  112. ".tmp.$worker" using (\$2/1000):((100*(\$4+\$5))/\$3) with filledcurves y1=0.0 lt rgb "#ff0000" notitle,\
  113. ".tmp.$worker" using (\$2/1000):((100*\$4)/\$3) with filledcurves y1=0.0 lt rgb "#00ff00" notitle
  114. EOF
  115. cnt=$(($cnt+1))
  116. done
  117. cat >> gnuplotcmd << EOF
  118. unset multiplot
  119. EOF
  120. gnuplot < gnuplotcmd
  121. rm gnuplotcmd
  122. rm $inputfile
  123. rm $inputfile_cnt_ready
  124. rm $inputfile_cnt_submitted
  125. rm $set_profiling_list
  126. rm $set_profiling_list.enable
  127. rm $set_profiling_list.disable
  128. #rm $names
  129. for worker in $workers
  130. do
  131. rm .tmp.$worker
  132. done