starpu_paje_summary.in 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2014-2021 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. dir=$(dirname $file)
  74. # Sorting traces
  75. grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\|9\)\>\)\)' $file > $dir/start.trace
  76. grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\|9\|18\|19\)\>\)\)' -v $file > $dir/end.trace
  77. sort -s -V --key=2,2 $dir/end.trace > $dir/endSorted.trace
  78. cat $dir/start.trace $dir/endSorted.trace > $dir/outputSorted.trace
  79. # Transferring to .csv
  80. pj_dump -n $dir/outputSorted.trace > $file.csv
  81. perl -i -ne 'print if /^State/' $file.csv
  82. # Cleanup: delete temporary files
  83. rm -f $dir/outputSorted.trace
  84. rm -f $dir/start.trace
  85. rm -f $dir/end.trace
  86. rm -f $dir/endSorted.trace
  87. done
  88. analysis_input=`echo \"$inputfiles".csv\"" | sed 's/ */.csv", "/g'`
  89. #####################################
  90. # Running analysis file to get actual results
  91. Rscript -e "library(knitr); input_traces = c($analysis_input) ; outputhtml='$outputfile';\
  92. outputRmd = gsub('.html\$','.Rmd',outputhtml);\
  93. knit('$analysis_script',output=outputRmd); knitr::knit2html(outputRmd)"