ROOTPWA
src/pwafitTest/runValgrind.sh
Go to the documentation of this file.
1 #!/bin/bash
2 
3 #
4 # runs pwafit with various tools of valgrind using test data set
5 #
6 # assumes that valgirnd is installed and in path
7 #
8 
9 function usage {
10  cat << EOF
11 Usage: $(basename ${0}) [OPTIONS]...
12 
13 Runs pwafit with various tools of valgrind using test data set
14 
15 OPTIONS:
16  -${CALLGRIND_OPT} if set, callgrind is run instead of memcheck
17  -${HELP_OPT} display this help and exit
18 EOF
19  echo
20 }
21 
22 # option variables
23 CALLGRIND_OPT="C"
24 HELP_OPT="h"
25 
26 VALGRIND_TOOL="memcheck"
27 # parse command line options
28 while getopts "${CALLGRIND_OPT}${HELP_OPT}" OPTION
29 do
30  case ${OPTION} in
31  ${CALLGRIND_OPT}) VALGRIND_TOOL="callgrind";;
32  ${HELP_OPT}) usage && exit 0;;
33  esac
34 done
35 shift $((${OPTIND} - 1)) # remove used optins and leave remaining arguments in $*
36 
37 # pwafit parameters
38 PROGRAM="../../bin/pwafit"
39 AMP_DIR="./amplitudes"
40 WAVE_LIST="./keyfiles/wavelist"
41 OUT_FILE="./result.root"
42 LOG_FILE="./pwafit_${VALGRIND_TOOL}.log"
43 BIN_MASS_MIN=2100
44 BIN_MASS_MAX=2140
45 
46 # get absolute paths
47 AMP_DIR=$(readlink -f "${AMP_DIR}")
48 WAVE_LIST=$(readlink -f "${WAVE_LIST}")
49 OUT_FILE=$(readlink -f "${OUT_FILE}")
50 LOG_FILE=$(readlink -f "${LOG_FILE}")
51 CURRENT_DIR=$(pwd)
52 
53 # run fit
54 echo ">>> ${0} started on $(date)"
55 echo ">>> running valgrind tool ${VALGRIND_TOOL} on ${PROGRAM}"
56 echo
57 
58 # prepare command line
59 case ${VALGRIND_TOOL} in
60  "memcheck") # run memcheck tool
61  #VALGRIND_OPT="--leak-check=full --freelist-vol=500000000 --show-reachable=yes --verbose"
62  VALGRIND_OPT="--leak-check=full --suppressions=$ROOTSYS/etc/valgrind-root.supp --freelist-vol=500000000 --verbose"
63  ;;
64  "callgrind") # run callgrind tool
65  VALGRIND_OPT="--tool=callgrind --simulate-cache=yes --verbose"
66  ;;
67  *)
68  echo "Unknown valgrind tool ${VALGRIND_TOOL}. Exiting."
69  exit 1
70  ;;
71 esac
72 PROGRAM_OPT="-q -w ${WAVE_LIST} -o ${OUT_FILE} -r 2 -l ${BIN_MASS_MIN} -u ${BIN_MASS_MAX} -N"
73 
74 # do it
75 cd ${AMP_DIR}
76 COMMAND="valgrind ${VALGRIND_OPT} ${PROGRAM} ${PROGRAM_OPT} &> ${LOG_FILE}"
77 echo "${COMMAND}"
78 time eval ${COMMAND}
79 cd ${CURRENT_DIR}
80 echo
81 
82 echo ">>> ${0} finished on $(date)"
83 exit 0