starpu_paje_summary.in 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2014 Université Joseph Fourier
  5. # Copyright (C) 2014-2015 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="summary.html"
  22. analysis_script="$(dirname $(which $0))/starpu_paje_summary.Rmd"
  23. analysis_input=""
  24. # Command line arguments
  25. inputfiles=""
  26. help_script()
  27. {
  28. cat << EOF
  29. Give statistical analysis of the paje trace
  30. Options:
  31. -h Show this message
  32. Examples:
  33. $0 example.native.trace
  34. $0 example.native.trace example.simgrid.trace
  35. Report bugs to <@PACKAGE_BUGREPORT@>
  36. EOF
  37. }
  38. if [ "$1" = "--version" ] ; then
  39. echo "$PROGNAME (@PACKAGE_NAME@) @PACKAGE_VERSION@"
  40. exit 0
  41. fi
  42. if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "" ] ; then
  43. help_script
  44. exit 0
  45. fi
  46. while getopts "h" opt; do
  47. case $opt in
  48. \?)
  49. echo "Invalid option: -$OPTARG"
  50. help_script
  51. exit 3
  52. ;;
  53. esac
  54. done
  55. # Reading files that need to be analyzed
  56. shift $((OPTIND - 1))
  57. inputfiles=$@
  58. # Error if there is no input files specified
  59. if [[ $# < 1 ]]; then
  60. echo "Error!"
  61. help_script
  62. exit 2
  63. fi
  64. #####################################
  65. # Transforming input files into .csv
  66. for file in $inputfiles; do
  67. if [ ! -s $file ]
  68. then
  69. echo "Error: file $file does not exist!"
  70. exit 5
  71. fi
  72. # Sorting traces
  73. grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\|9\)\>\)\)' $file > start.trace
  74. grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\|9\|18\|19\)\>\)\)' -v $file > end.trace
  75. sort -s -V --key=2,2 end.trace > endSorted.trace
  76. cat start.trace endSorted.trace > outputSorted.trace
  77. # Transferring to .csv
  78. pj_dump -n outputSorted.trace > $file.csv
  79. perl -i -ne 'print if /^State/' $file.csv
  80. done
  81. analysis_input=`echo \"$inputfiles".csv\"" | sed 's/ */.csv", "/g'`
  82. #####################################
  83. # Running analysis file to get actual results
  84. Rscript -e "library(knitr); input_traces = c($analysis_input) ; outputhtml='$outputfile';\
  85. outputRmd = gsub('.html\$','.Rmd',outputhtml);\
  86. knit('$analysis_script',output=outputRmd); knitr::knit2html(outputRmd)"
  87. # Cleanup: delete temporary files
  88. rm -f outputSorted.trace
  89. rm -f start.trace
  90. rm -f end.trace
  91. rm -f endSorted.trace