activity.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/bash
  2. #
  3. # StarPU
  4. # Copyright (C) INRIA 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. grep -v "^cnt" $inputfile_with_counters > $inputfile
  25. grep "^cnt_ready" $inputfile_with_counters > $inputfile_cnt_ready
  26. grep "^cnt_submitted" $inputfile_with_counters > $inputfile_cnt_submitted
  27. max_cnt_submitted=`cut -f2 $inputfile_cnt_submitted |sort -n|tail -1`
  28. # Count the number of workers in the trace
  29. workers=`cut -f1 $inputfile | sort -n | uniq`
  30. nworkers=`cut -f1 $inputfile | sort -n | uniq|wc -l`
  31. # size of the entire graph
  32. width=2.5
  33. heigth=$(echo "0.5 + (0.5 * $nworkers)"|bc -l)
  34. # In case 3 arguments are provided, the 2nd (resp. 3rd) indicates the start
  35. # (resp. the end) of the interval to be displayed.
  36. if [ $# -ge 3 ]; then
  37. starttime=$2
  38. endtime=$3
  39. else
  40. starttime=$(cut -f 2 $inputfile |sort -n|head -1)
  41. endtime=$(cut -f 2 $inputfile |sort -n|tail -1)
  42. fi
  43. # Gnuplot header
  44. cat > gnuplotcmd << EOF
  45. set term postscript eps enhanced color
  46. set output "activity.eps"
  47. set xrange [$starttime:$endtime]
  48. set size $width,$heigth
  49. set multiplot;
  50. set origin 0.0,0.0;
  51. set size $width,0.5;
  52. plot "$inputfile_cnt_submitted" using 2:3 with filledcurves lt rgb "#999999" title "submitted",\
  53. "$inputfile_cnt_ready" using 2:3 with filledcurves lt rgb "#000000" title "ready"
  54. EOF
  55. cnt=0
  56. for worker in $workers
  57. do
  58. grep "^$worker" $inputfile > .tmp.$worker
  59. starty=$(echo "0.5 + (0.5 * $cnt)"|bc -l)
  60. cat >> gnuplotcmd << EOF
  61. set origin 0.0,$starty;
  62. set size $width,0.5;
  63. set key off
  64. plot ".tmp.$worker" using 2:(100) with filledcurves y1=0.0 lt rgb "#000000" notitle,\
  65. ".tmp.$worker" using 2:((100*(\$4+\$5))/\$3) with filledcurves y1=0.0 lt rgb "#ff0000" notitle,\
  66. ".tmp.$worker" using 2:((100*\$4)/\$3) with filledcurves y1=0.0 lt rgb "#00ff00" notitle
  67. EOF
  68. cnt=$(($cnt+1))
  69. done
  70. cat >> gnuplotcmd << EOF
  71. unset multiplot
  72. EOF
  73. gnuplot < gnuplotcmd
  74. rm gnuplotcmd
  75. rm $inputfile
  76. rm $inputfile_cnt_ready
  77. rm $inputfile_cnt_submitted
  78. for worker in $workers
  79. do
  80. rm .tmp.$worker
  81. done