starpu_mlr_analysis.in 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2016 Inria
  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. SOURCE_DIR=@abs_srcdir@
  20. outputfile="mlr_analysis.html"
  21. analysis_script="$SOURCE_DIR/starpu_mlr_analysis.Rmd"
  22. # Command line arguments
  23. inputfile=""
  24. help_script()
  25. {
  26. cat << EOF
  27. Give an example of the trace analysis for computing multiple linear regression model
  28. Options:
  29. -h Show this message
  30. Examples:
  31. $0 .starpu/sampling/codelets/tmp/test_mlr.out
  32. $0
  33. Report bugs to <@PACKAGE_BUGREPORT@>
  34. EOF
  35. }
  36. if [ "$1" = "--version" ] ; then
  37. echo "$PROGNAME (@PACKAGE_NAME@) @PACKAGE_VERSION@"
  38. exit 0
  39. fi
  40. if [ "$1" = "-h" ] || [ "$1" = "--help" ] ; then
  41. help_script
  42. exit 0
  43. fi
  44. while getopts "h" opt; do
  45. case $opt in
  46. \?)
  47. echo "Invalid option: -$OPTARG"
  48. help_script
  49. exit 3
  50. ;;
  51. esac
  52. done
  53. # Reading files that need to be analyzed
  54. shift $((OPTIND - 1))
  55. inputfile=$1
  56. if [[ $# < 1 ]]; then
  57. inputfile="$SOURCE_DIR/perfmodels/sampling/codelets/tmp/mlr_init.out"
  58. else
  59. # Error if there is more than one input file
  60. if [[ $# > 1 ]]; then
  61. echo "Error!"
  62. help_script
  63. exit 2
  64. fi
  65. fi
  66. if [ ! -s $inputfile ]
  67. then
  68. echo "Error: file $inputfile does not exist!"
  69. exit 5
  70. fi
  71. #####################################
  72. # Running analysis file to get actual results
  73. in="$(cd "$(dirname "$inputfile")"; pwd)/$(basename "$inputfile")"
  74. Rscript -e "library(knitr); input_trace = '$in' ; outputhtml='$outputfile';\
  75. outputRmd = gsub('.html\$','.Rmd',outputhtml);\
  76. knit('$analysis_script',output=outputRmd); knitr::knit2html(outputRmd)"