starpu_paje_sort.in 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2014-2020 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 sorting paje traces
  19. set -e # fail fast
  20. # File names
  21. basename="$PWD"
  22. inputfiles=""
  23. help_script()
  24. {
  25. cat << EOF
  26. Give statistical analysis of the paje trace
  27. $0 [ options ] paje.trace [paje.trace2 ...]
  28. Options:
  29. -h Show this message
  30. Examples:
  31. $0 example.trace
  32. Report bugs to <@PACKAGE_BUGREPORT@>
  33. EOF
  34. }
  35. if [ "$1" = "--version" ] ; then
  36. echo "$PROGNAME (@PACKAGE_NAME@) @PACKAGE_VERSION@"
  37. exit 0
  38. fi
  39. if [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "" ] ; then
  40. help_script
  41. exit 0
  42. fi
  43. while getopts "h" opt; do
  44. case $opt in
  45. h)
  46. help_script
  47. exit 4
  48. ;;
  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. if [[ $# < 1 ]]; then
  60. echo "Error!"
  61. help_script
  62. exit 2
  63. fi
  64. get_event_num() {
  65. grep "^%EventDef[ ]$2" $1 | sed -e "s/.*$2[ ]*//"
  66. }
  67. #####################################
  68. # Transforming input files into .csv
  69. for file in $inputfiles; do
  70. if [ ! -s $file ]
  71. then
  72. echo "Error: file $file does not exist!"
  73. exit 5
  74. fi
  75. DefCont="$(get_event_num $file PajeDefineContainerType) "
  76. DefEvent="$(get_event_num $file PajeDefineEventType) "
  77. DefState="$(get_event_num $file PajeDefineStateType) "
  78. DefVar="$(get_event_num $file PajeDefineVariableType) "
  79. DefLink="$(get_event_num $file PajeDefineLinkType) "
  80. DefEnt="$(get_event_num $file PajeDefineEntityValue) "
  81. CreateCont="$(get_event_num $file PajeCreateContainer) "
  82. AddVar="$(get_event_num $file PajeAddVariable) "
  83. grepstr="^\\(%\\|$DefCont\\|$DefEvent\\|$DefState\\|$DefVar\\|$DefLink\\|$DefEnt\\|$CreateCont\\|$AddVar\\)"
  84. grepstr=${grepstr//[ ]/[ ]}
  85. # Sorting traces
  86. grep -e "$grepstr" $file > start.trace
  87. grep -e "$grepstr" -v $file > end.trace
  88. sort -s -V --key=2,2 end.trace > endSorted.trace
  89. if grep -q start_profiling endSorted.trace
  90. then
  91. echo Using start_profiling/stop_profiling trace selection.
  92. sed -ne '/start_profiling/,/stop_profiling/p' < endSorted.trace > endSorted2.trace
  93. else
  94. cp endSorted.trace endSorted2.trace
  95. fi
  96. cat start.trace endSorted2.trace > $file
  97. done
  98. # Cleanup: delete temporary files
  99. rm -f start.trace
  100. rm -f end.trace
  101. rm -f endSorted.trace
  102. rm -f endSorted2.trace