starpu_paje_state_stats.in 3.4 KB

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