starpu_paje_state_stats.in 3.4 KB

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