starpu_mlr_analysis.in 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2017 CNRS
  5. # Copyright (C) 2016 Inria
  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="mlr_analysis.html"
  23. analysis_script="$SOURCE_DIR/starpu_mlr_analysis.Rmd"
  24. # Command line arguments
  25. inputfile=""
  26. help_script()
  27. {
  28. cat << EOF
  29. Give an example of the trace analysis for computing multiple linear regression model
  30. Options:
  31. -h Show this message
  32. Examples:
  33. $0 .starpu/sampling/codelets/tmp/test_mlr.out
  34. $0
  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" ] ; 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. inputfile=$1
  58. if [[ $# < 1 ]]; then
  59. inputfile="$SOURCE_DIR/perfmodels/sampling/codelets/tmp/mlr_init.out"
  60. else
  61. # Error if there is more than one input file
  62. if [[ $# > 1 ]]; then
  63. echo "Error!"
  64. help_script
  65. exit 2
  66. fi
  67. fi
  68. if [ ! -s $inputfile ]
  69. then
  70. echo "Error: file $inputfile does not exist!"
  71. exit 5
  72. fi
  73. #####################################
  74. # Running analysis file to get actual results
  75. in="$(cd "$(dirname "$inputfile")"; pwd)/$(basename "$inputfile")"
  76. Rscript -e "library(knitr); input_trace = '$in' ; outputhtml='$outputfile';\
  77. outputRmd = gsub('.html\$','.Rmd',outputhtml);\
  78. knit('$analysis_script',output=outputRmd); knitr::knit2html(outputRmd)"