starpu_paje_sort.in 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2017 CNRS
  5. # Copyright (C) 2014,2015,2017 Université de Bordeaux
  6. # Copyright (C) 2014 Université Joseph Fourier
  7. #
  8. # StarPU is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU Lesser General Public License as published by
  10. # the Free Software Foundation; either version 2.1 of the License, or (at
  11. # your option) any later version.
  12. #
  13. # StarPU is distributed in the hope that it will be useful, but
  14. # WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  16. #
  17. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  18. #
  19. # Script for sorting paje traces
  20. set -e # fail fast
  21. # File names
  22. basename="$PWD"
  23. inputfiles=""
  24. help_script()
  25. {
  26. cat << EOF
  27. Give statistical analysis of the paje trace
  28. $0 [ options ] paje.trace [paje.trace2 ...]
  29. Options:
  30. -h Show this message
  31. Examples:
  32. $0 example.trace
  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" ] || [ "$1" = "" ] ; then
  41. help_script
  42. exit 0
  43. fi
  44. while getopts "h" opt; do
  45. case $opt in
  46. h)
  47. help_script
  48. exit 4
  49. ;;
  50. \?)
  51. echo "Invalid option: -$OPTARG"
  52. help_script
  53. exit 3
  54. ;;
  55. esac
  56. done
  57. # Reading files that need to be analyzed
  58. shift $((OPTIND - 1))
  59. inputfiles=$@
  60. if [[ $# < 1 ]]; then
  61. echo "Error!"
  62. help_script
  63. exit 2
  64. fi
  65. get_event_num() {
  66. grep "^%EventDef[ ]$2" $1 | sed -e "s/.*$2[ ]*//"
  67. }
  68. #####################################
  69. # Transforming input files into .csv
  70. for file in $inputfiles; do
  71. if [ ! -s $file ]
  72. then
  73. echo "Error: file $file does not exist!"
  74. exit 5
  75. fi
  76. DefCont="$(get_event_num $file PajeDefineContainerType) "
  77. DefEvent="$(get_event_num $file PajeDefineEventType) "
  78. DefState="$(get_event_num $file PajeDefineStateType) "
  79. DefVar="$(get_event_num $file PajeDefineVariableType) "
  80. DefLink="$(get_event_num $file PajeDefineLinkType) "
  81. DefEnt="$(get_event_num $file PajeDefineEntityValue) "
  82. CreateCont="$(get_event_num $file PajeCreateContainer) "
  83. AddVar="$(get_event_num $file PajeAddVariable) "
  84. grepstr="^\\(%\\|$DefCont\\|$DefEvent\\|$DefState\\|$DefVar\\|$DefLink\\|$DefEnt\\|$CreateCont\\|$AddVar\\)"
  85. grepstr=${grepstr//[ ]/[ ]}
  86. # Sorting traces
  87. grep -e "$grepstr" $file > start.trace
  88. grep -e "$grepstr" -v $file > end.trace
  89. sort -s -V --key=2,2 end.trace > endSorted.trace
  90. if grep -q start_profiling endSorted.trace
  91. then
  92. echo Using start_profiling/stop_profiling trace selection.
  93. sed -ne '/start_profiling/,/stop_profiling/p' < endSorted.trace > endSorted2.trace
  94. else
  95. cp endSorted.trace endSorted2.trace
  96. fi
  97. cat start.trace endSorted2.trace > $file
  98. done
  99. # Cleanup: delete temporary files
  100. rm -f start.trace
  101. rm -f end.trace
  102. rm -f endSorted.trace
  103. rm -f endSorted2.trace