Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-07-26 08:22:18

0001 #!/bin/bash
0002 #
0003 # TRACCC library, part of the ACTS project (R&D line)
0004 #
0005 # (c) 2023-2024 CERN for the benefit of the ACTS project
0006 #
0007 # Mozilla Public License Version 2.0
0008 #
0009 # Simple script running the selected instance of the multi-threaded throughput
0010 # executable on a whole set of ODD ttbar simulations, with different pileup
0011 # values.
0012 #
0013 
0014 # Stop on errors.
0015 set -e
0016 
0017 # Function printing the usage information for the script.
0018 usage() {
0019    echo "Script running a suite of multi-threaded throughput tests"
0020    echo ""
0021    echo "Usage: traccc_throughput_mt_profiling.sh [options]"
0022    echo ""
0023    echo "Basic options:"
0024    echo "  -x <executable>      Selects the executable to use"
0025    echo "  -i <inputDir>        Selects the input directory with the ttbar"
0026    echo "                       simulations"
0027    echo "  -m <minThreads>      Minimum number of threads to test"
0028    echo "  -t <maxThreads>      Maximum number of threads to test"
0029    echo "  -s <threadStep>      Steps to increase the thread count by"
0030    echo "  -r <repetitions>     The number of repetitions in the test"
0031    echo "  -e <eventMultiplier> Multiplier for the number of events per thread"
0032    echo "  -c <csvFile>         Name of the output CSV file"
0033    echo "  -h                   Print this help"
0034    echo ""
0035 }
0036 
0037 # Parse the command line arguments.
0038 TRACCC_EXECUTABLE=${TRACCC_EXECUTABLE:-"traccc_throughput_mt"}
0039 TRACCC_INPUT_DIR=${TRACCC_INPUT_DIR:-"odd/"}
0040 TRACCC_MIN_THREADS=${TRACCC_MIN_THREADS:-1}
0041 TRACCC_MAX_THREADS=${TRACCC_MAX_THREADS:-$(nproc)}
0042 TRACCC_THREAD_STEP=${TRACCC_THREAD_STEP:-1}
0043 TRACCC_REPETITIONS=${TRACCC_REPETITIONS:-5}
0044 TRACCC_EVT_MULTI=${TRACCC_EVT_MULTI:-"1"}
0045 TRACCC_CSV_FILE=${TRACCC_CSV_FILE:-"output.csv"}
0046 while getopts ":x:i:m:t:r:e:c:h" opt; do
0047    case $opt in
0048       x)
0049          TRACCC_EXECUTABLE=$OPTARG
0050          ;;
0051       i)
0052          TRACCC_INPUT_DIR=$OPTARG
0053          ;;
0054       m)
0055          TRACCC_MIN_THREADS=$OPTARG
0056          ;;
0057       t)
0058          TRACCC_MAX_THREADS=$OPTARG
0059          ;;
0060       s)
0061          TRACCC_THREAD_STEP=$OPTARG
0062          ;;
0063       r)
0064          TRACCC_REPETITIONS=$OPTARG
0065          ;;
0066       e)
0067          TRACCC_EVT_MULTI=$OPTARG
0068          ;;
0069       c)
0070          TRACCC_CSV_FILE=$OPTARG
0071          ;;
0072       h)
0073          usage
0074          exit 0
0075          ;;
0076       :)
0077          echo "Argument -$OPTARG requires a parameter!"
0078          usage
0079          exit 1
0080          ;;
0081       ?)
0082          echo "Unknown argument: -$OPTARG"
0083          usage
0084          exit 1
0085          ;;
0086    esac
0087 done
0088 
0089 # Print the configuration received.
0090 echo "Using configuration:"
0091 echo "   EXECUTABLE  : ${TRACCC_EXECUTABLE}"
0092 echo "   INPUT_DIR   : ${TRACCC_INPUT_DIR}"
0093 echo "   MIN_THREADS : ${TRACCC_MIN_THREADS}"
0094 echo "   MAX_THREADS : ${TRACCC_MAX_THREADS}"
0095 echo "   THREAD_STEP : ${TRACCC_THREAD_STEP}"
0096 echo "   REPETITIONS : ${TRACCC_REPETITIONS}"
0097 echo "   EVT_MULTI   : ${TRACCC_EVT_MULTI}"
0098 echo "   CSV_FILE    : ${TRACCC_CSV_FILE}"
0099 
0100 # Check whether the output file already exists. Refuse to overwrite existing
0101 # files.
0102 if [[ -f "${TRACCC_CSV_FILE}" ]]; then
0103    echo "***"
0104    echo "*** Will not overwrite ${TRACCC_CSV_FILE}!"
0105    echo "***"
0106    exit 1
0107 fi
0108 
0109 # The input directories to use.
0110 TRACCC_INPUT_DIRS=("ttbar_mu20"  "ttbar_mu40"  "ttbar_mu60"  "ttbar_mu80"
0111                    "ttbar_mu100" "ttbar_mu140" "ttbar_mu200" "ttbar_mu300")
0112 
0113 # The number of events to process for the different mu values. Chosen to take
0114 # roughly the same amount of time to process on a CPU.
0115 declare -A TRACCC_EVT_COUNT
0116 TRACCC_EVT_COUNT["ttbar_mu20"]=$((50*${TRACCC_EVT_MULTI}))
0117 TRACCC_EVT_COUNT["ttbar_mu40"]=$((50*${TRACCC_EVT_MULTI}))
0118 TRACCC_EVT_COUNT["ttbar_mu60"]=$((25*${TRACCC_EVT_MULTI}))
0119 TRACCC_EVT_COUNT["ttbar_mu80"]=$((25*${TRACCC_EVT_MULTI}))
0120 TRACCC_EVT_COUNT["ttbar_mu100"]=$((20*${TRACCC_EVT_MULTI}))
0121 TRACCC_EVT_COUNT["ttbar_mu140"]=$((15*${TRACCC_EVT_MULTI}))
0122 TRACCC_EVT_COUNT["ttbar_mu200"]=$((8*${TRACCC_EVT_MULTI}))
0123 TRACCC_EVT_COUNT["ttbar_mu300"]=$((5*${TRACCC_EVT_MULTI}))
0124 
0125 # Put a header on the CSV file.
0126 echo "directory,threads,loaded_events,cold_run_events,processed_events,warm_up_time,processing_time" \
0127    > "${TRACCC_CSV_FILE}"
0128 
0129 # Counter for a nice printout.
0130 COUNTER=1
0131 COUNT=$((${#TRACCC_INPUT_DIRS[@]}*${TRACCC_MAX_THREADS}*${TRACCC_REPETITIONS}))
0132 
0133 # Iterate over the number of threads.
0134 for NTHREAD in $(seq ${TRACCC_MIN_THREADS} ${TRACCC_THREAD_STEP} ${TRACCC_MAX_THREADS}); do
0135    # Iterate over the input datasets.
0136    for EVTDIR in ${TRACCC_INPUT_DIRS[@]}; do
0137       # Perform the requested number of repetitions.
0138       for REPEAT in $(seq ${TRACCC_REPETITIONS}); do
0139 
0140          # Tell the user what's happening.
0141          echo ""
0142          echo "Running test ${COUNTER} / ${COUNT}"
0143          ((COUNTER++))
0144 
0145          # Run the throughput test.
0146          ${TRACCC_EXECUTABLE}                                                   \
0147             --detector-file="geometries/odd/odd-detray_geometry_detray.json"    \
0148             --material-file="geometries/odd/odd-detray_material_detray.json"    \
0149             --grid-file="geometries/odd/odd-detray_surface_grids_detray.json"   \
0150             --digitization-file="geometries/odd/odd-digi-geometric-config.json" \
0151             --conditions-file="geometries/odd/odd-conditions.json"               \
0152             --input-directory="${TRACCC_INPUT_DIR}/geant4_${EVTDIR}/"           \
0153             --input-events=500                                                  \
0154             --cpu-threads=${NTHREAD}                                            \
0155             --cold-run-events=$((5*${NTHREAD}))                                 \
0156             --processed-events=$((${TRACCC_EVT_COUNT[${EVTDIR}]}*${NTHREAD}))   \
0157             --log-file="${TRACCC_CSV_FILE}"
0158       done
0159    done
0160 done