starpu_top.sh 4.1 KB

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