starpu_paje_draw_histogram.in 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2014-2021 Université de Bordeaux, CNRS (LaBRI UMR 5800), Inria
  5. # Copyright (C) 2014 Université Joseph Fourier
  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. #
  18. # Script for giving statistical analysis of the paje trace
  19. set -e # fail fast
  20. # File names
  21. r_script="$(dirname $(which $0))/starpu_paje_draw_histogram.R"
  22. r_input=""
  23. # Command line arguments
  24. range="0:-1"
  25. name="All"
  26. verbose=0
  27. inputfiles=""
  28. help_script()
  29. {
  30. cat << EOF
  31. Give statistical analysis of the paje trace
  32. $0 [ options ] paje.trace [paje.trace2 ...]
  33. Options:
  34. -r To fix range x1:x2 ("-1" for infinity)
  35. -n To choose a certain state
  36. -v Print output to command line
  37. -h Show this message
  38. Examples:
  39. $0 -n chol_model_22 example.native.trace
  40. $0 -r 100:300 -n FetchingInput,Overhead -v example.native.trace example.simgrid.trace
  41. Report bugs to <@PACKAGE_BUGREPORT@>
  42. EOF
  43. }
  44. if [ "$1" = "--version" ] ; then
  45. echo "$PROGNAME (@PACKAGE_NAME@) @PACKAGE_VERSION@"
  46. exit 0
  47. fi
  48. if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "" ] ; then
  49. help_script
  50. exit 0
  51. fi
  52. while getopts "r:n:vh" opt; do
  53. case $opt in
  54. r)
  55. range="$OPTARG"
  56. ;;
  57. n)
  58. name="$OPTARG"
  59. ;;
  60. v)
  61. verbose=1
  62. ;;
  63. h)
  64. help_script
  65. exit 4
  66. ;;
  67. \?)
  68. echo "Invalid option: -$OPTARG"
  69. help_script
  70. exit 3
  71. ;;
  72. esac
  73. done
  74. # Reading files that need to be analyzed
  75. shift $((OPTIND - 1))
  76. inputfiles=$@
  77. if [[ $# < 1 ]]; then
  78. echo "Error!"
  79. help_script
  80. exit 2
  81. fi
  82. # Getting range
  83. range1=$(eval echo $range | cut -d: -f1)
  84. range2=$(eval echo $range | cut -d: -f2)
  85. #####################################
  86. # Transforming input files into .csv
  87. for file in $inputfiles; do
  88. if [ ! -s $file ]
  89. then
  90. echo "Error: file $file does not exist!"
  91. exit 5
  92. fi
  93. dir=$(dirname $file)
  94. # Sorting traces
  95. grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\)\>\)\)' $file > $dir/start.trace
  96. grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\)\>\)\)' -v $file > $dir/end.trace
  97. sort -s -V --key=2,2 $dir/end.trace > $dir/endSorted.trace
  98. if grep -q start_profiling $dir/endSorted.trace
  99. then
  100. echo Using start_profiling/stop_profiling trace selection.
  101. sed -ne '/start_profiling/,/stop_profiling/p' < $dir/endSorted.trace > $dir/endSorted2.trace
  102. else
  103. cp $dir/endSorted.trace $dir/endSorted2.trace
  104. fi
  105. cat $dir/start.trace $dir/endSorted2.trace > $dir/outputSorted.trace
  106. # Transferring to .csv
  107. pj_dump -n $dir/outputSorted.trace > $file.csv
  108. perl -i -ne 'print if /^State/' $file.csv
  109. r_input=$(eval echo "$r_input $file.csv")
  110. # Cleanup: delete temporary files
  111. rm -f $dir/outputSorted.trace
  112. rm -f $dir/start.trace
  113. rm -f $dir/end.trace
  114. rm -f $dir/endSorted.trace
  115. rm -f $dir/endSorted2.trace
  116. done
  117. #####################################
  118. # Running R file to get actual results
  119. Rscript $r_script $range1 $range2 $name $r_input
  120. # Directly opening .pdf result
  121. if [[ $verbose == 1 ]]; then
  122. evince Rplots.pdf
  123. fi