starpu_paje_summary.in 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2017 CNRS
  5. # Copyright (C) 2016 Inria
  6. # Copyright (C) 2014-2015 Université de Bordeaux
  7. # Copyright (C) 2014 Université Joseph Fourier
  8. #
  9. # StarPU is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU Lesser General Public License as published by
  11. # the Free Software Foundation; either version 2.1 of the License, or (at
  12. # your option) any later version.
  13. #
  14. # StarPU is distributed in the hope that it will be useful, but
  15. # WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. #
  18. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  19. #
  20. # Script for giving statistical analysis of the paje trace
  21. set -e # fail fast
  22. # File names
  23. SOURCE_DIR=@abs_srcdir@
  24. outputfile="summary.html"
  25. analysis_script="$SOURCE_DIR/starpu_paje_summary.Rmd"
  26. analysis_input=""
  27. # Command line arguments
  28. inputfiles=""
  29. help_script()
  30. {
  31. cat << EOF
  32. Give statistical analysis of the paje trace
  33. Options:
  34. -h Show this message
  35. Examples:
  36. $0 example.native.trace
  37. $0 example.native.trace example.simgrid.trace
  38. Report bugs to <@PACKAGE_BUGREPORT@>
  39. EOF
  40. }
  41. if [ "$1" = "--version" ] ; then
  42. echo "$PROGNAME (@PACKAGE_NAME@) @PACKAGE_VERSION@"
  43. exit 0
  44. fi
  45. if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "" ] ; then
  46. help_script
  47. exit 0
  48. fi
  49. while getopts "h" opt; do
  50. case $opt in
  51. \?)
  52. echo "Invalid option: -$OPTARG"
  53. help_script
  54. exit 3
  55. ;;
  56. esac
  57. done
  58. # Reading files that need to be analyzed
  59. shift $((OPTIND - 1))
  60. inputfiles=$@
  61. # Error if there is no input files specified
  62. if [[ $# < 1 ]]; then
  63. echo "Error!"
  64. help_script
  65. exit 2
  66. fi
  67. #####################################
  68. # Transforming input files into .csv
  69. for file in $inputfiles; do
  70. if [ ! -s $file ]
  71. then
  72. echo "Error: file $file does not exist!"
  73. exit 5
  74. fi
  75. # Sorting traces
  76. grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\|9\)\>\)\)' $file > start.trace
  77. grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\|9\|18\|19\)\>\)\)' -v $file > end.trace
  78. sort -s -V --key=2,2 end.trace > endSorted.trace
  79. cat start.trace endSorted.trace > outputSorted.trace
  80. # Transferring to .csv
  81. pj_dump -n outputSorted.trace > $file.csv
  82. perl -i -ne 'print if /^State/' $file.csv
  83. done
  84. analysis_input=`echo \"$inputfiles".csv\"" | sed 's/ */.csv", "/g'`
  85. #####################################
  86. # Running analysis file to get actual results
  87. Rscript -e "library(knitr); input_traces = c($analysis_input) ; outputhtml='$outputfile';\
  88. outputRmd = gsub('.html\$','.Rmd',outputhtml);\
  89. knit('$analysis_script',output=outputRmd); knitr::knit2html(outputRmd)"
  90. # Cleanup: delete temporary files
  91. rm -f outputSorted.trace
  92. rm -f start.trace
  93. rm -f end.trace
  94. rm -f endSorted.trace