starpu_paje_sort.in 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2014 Université Joseph Fourier
  5. # Copyright (C) 2014-2015 Université Bordeaux
  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. # Script for sorting paje traces
  18. set -e # fail fast
  19. # File names
  20. basename="$PWD"
  21. inputfiles=""
  22. help_script()
  23. {
  24. cat << EOF
  25. Give statistical analysis of the paje trace
  26. $0 [ options ] paje.trace [paje.trace2 ...]
  27. Options:
  28. -h Show this message
  29. Examples:
  30. $0 example.trace
  31. Report bugs to <@PACKAGE_BUGREPORT@>
  32. EOF
  33. }
  34. if [ "$1" = "--version" ] ; then
  35. echo "$PROGNAME (@PACKAGE_NAME@) @PACKAGE_VERSION@"
  36. exit 0
  37. fi
  38. if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "" ] ; then
  39. help_script
  40. exit 0
  41. fi
  42. while getopts "h" opt; do
  43. case $opt in
  44. h)
  45. help_script
  46. exit 4
  47. ;;
  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. inputfiles=$@
  58. if [[ $# < 1 ]]; then
  59. echo "Error!"
  60. help_script
  61. exit 2
  62. fi
  63. #####################################
  64. # Transforming input files into .csv
  65. for file in $inputfiles; do
  66. if [ ! -s $file ]
  67. then
  68. echo "Error: file $file does not exist!"
  69. exit 5
  70. fi
  71. # Sorting traces
  72. grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\)\>\)\)' $file > start.trace
  73. grep -e '^\(\(%\)\|\(\(0\|1\|2\|3\|4\|5\|6\|7\)\>\)\)' -v $file > end.trace
  74. sort -s -V --key=2,2 end.trace > endSorted.trace
  75. if grep -q start_profiling endSorted.trace
  76. then
  77. echo Using start_profiling/stop_profiling trace selection.
  78. sed -ne '/start_profiling/,/stop_profiling/p' < endSorted.trace > endSorted2.trace
  79. else
  80. cp endSorted.trace endSorted2.trace
  81. fi
  82. cat start.trace endSorted2.trace > $file
  83. done
  84. # Cleanup: delete temporary files
  85. rm -f start.trace
  86. rm -f end.trace
  87. rm -f endSorted.trace
  88. rm -f endSorted2.trace