starpu_paje_draw_histogram.in 3.0 KB

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