starpu_paje_summary.in 2.8 KB

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