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-2025 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 ITk 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 config files"
0026    echo "  -f <eventFilesDir>   Selects the input directory for event files"
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 "  -y <throughputType>  Type of throughput test to run (traccc/g200/g100, or with GBTS, g230/g130)"
0034    echo "  -h                   Print this help"
0035    echo ""
0036 }
0037 
0038 # Parse the command line arguments.
0039 TRACCC_EXECUTABLE=${TRACCC_EXECUTABLE:-"traccc_throughput_mt"}
0040 TRACCC_INPUT_DIR=${TRACCC_INPUT_DIR:-"ATLAS-P2-RUN4-03-00-01/"}
0041 TRACCC_EVENT_FILES=${TRACCC_EVENT_FILES:-"ATLAS-P2-RUN4-03-00-01/"}
0042 TRACCC_MIN_THREADS=${TRACCC_MIN_THREADS:-1}
0043 TRACCC_MAX_THREADS=${TRACCC_MAX_THREADS:-$(nproc)}
0044 TRACCC_THREAD_STEP=${TRACCC_THREAD_STEP:-1}
0045 TRACCC_REPETITIONS=${TRACCC_REPETITIONS:-5}
0046 TRACCC_N_EVENTS=${TRACCC_N_EVENTS:-100}
0047 TRACCC_CSV_FILE=${TRACCC_CSV_FILE:-"output.csv"}
0048 TRACCC_THROUGPUT_TYPE=${TRACCC_THROUGPUT_TYPE:-"traccc"}
0049 while getopts ":x:i:f:m:t:s:r:e:c:y:h" opt; do
0050    case $opt in
0051       x)
0052          TRACCC_EXECUTABLE=$OPTARG
0053          ;;
0054       i)
0055          TRACCC_INPUT_DIR=$OPTARG
0056          ;;
0057           f)
0058                 TRACCC_EVENT_FILES=$OPTARG
0059                 ;;
0060       m)
0061          TRACCC_MIN_THREADS=$OPTARG
0062          ;;
0063       t)
0064          TRACCC_MAX_THREADS=$OPTARG
0065          ;;
0066       s)
0067          TRACCC_THREAD_STEP=$OPTARG
0068          ;;
0069       r)
0070          TRACCC_REPETITIONS=$OPTARG
0071          ;;
0072           e)
0073                 TRACCC_N_EVENTS=$OPTARG
0074                 ;;
0075       c)
0076          TRACCC_CSV_FILE=$OPTARG
0077          ;;
0078       y)
0079          TRACCC_THROUGPUT_TYPE=$OPTARG
0080          ;;
0081       h)
0082          usage
0083          exit 0
0084          ;;
0085       :)
0086          echo "Argument -$OPTARG requires a parameter!"
0087          usage
0088          exit 1
0089          ;;
0090       ?)
0091          echo "Unknown argument: -$OPTARG"
0092          usage
0093          exit 1
0094          ;;
0095    esac
0096 done
0097 
0098 # Print the configuration received.
0099 echo "Using configuration:"
0100 echo "   EXECUTABLE      : ${TRACCC_EXECUTABLE}"
0101 echo "   INPUT_DIR       : ${TRACCC_INPUT_DIR}"
0102 echo "   EVENT_FILES     : ${TRACCC_EVENT_FILES}"
0103 echo "   MIN_THREADS     : ${TRACCC_MIN_THREADS}"
0104 echo "   MAX_THREADS     : ${TRACCC_MAX_THREADS}"
0105 echo "   THREAD_STEP     : ${TRACCC_THREAD_STEP}"
0106 echo "   REPETITIONS     : ${TRACCC_REPETITIONS}"
0107 echo "   CSV_FILE        : ${TRACCC_CSV_FILE}"
0108 echo "   THROUGHPUT_TYPE : ${TRACCC_THROUGPUT_TYPE}"
0109 
0110 # Check whether the output file already exists. Refuse to overwrite existing
0111 # files.
0112 if [[ -f "${TRACCC_CSV_FILE}" ]]; then
0113    echo "***"
0114    echo "*** Will not overwrite ${TRACCC_CSV_FILE}!"
0115    echo "***"
0116    exit 1
0117 fi
0118 
0119 # Additional flags tuning the cuts for the G100/G200 pipelines.
0120 G200_CUTS=(--seedfinder-z-range=-3000.:3000.
0121            --seedfinder-r-range=33.:320.
0122            --seedfinder-vertex-range=-200.:200.
0123            --seedfinder-minPt=0.9
0124            --seedfinder-cotThetaMax=27.2899
0125            --seedfinder-deltaR-range=20.:200.
0126            --seedfinder-impactMax=10.
0127            --seedfinder-sigmaScattering=3.
0128            --seedfinder-maxPtScattering=10.
0129            --seedfinder-maxSeedsPerSpM=1
0130            --max-num-branches-per-seed=3
0131            --max-num-branches-per-surface=5
0132            --track-candidates-range=7:20
0133            --min-step-length-for-next-surface=0.5
0134            --max-step-counts-for-next-surface=100
0135            --chi2-max=10.
0136            --max-num-skipping-per-cand=2
0137            --stepping-min-stepsize=0.0001
0138            --rk-tolerance-mm=0.0001
0139            --stepping-path-limit=5.
0140            --stepping-max-rk-updates=10000
0141            --stepping-use-mean-loss=1
0142            --stepping-use-eloss-gradient=0
0143            --stepping-use-field-gradient=0
0144            --stepping-do-covariance-transport=1
0145            --overstep-tolerance-um=-300.
0146            --min-mask-tolerance-mm=0.00001
0147            --max-mask-tolerance-mm=3.
0148            --search-window=0:0)
0149 
0150 G100_CUTS=${G200_CUTS[@]}
0151 G100_CUTS+=(--reco-stage=seeding)
0152 
0153 # Select which of these flags to use.
0154 TRACCC_CUTS=()
0155 if [[ "${TRACCC_THROUGPUT_TYPE}" == "g200" ]]; then
0156    TRACCC_CUTS=${G200_CUTS[@]}
0157 elif [[ "${TRACCC_THROUGPUT_TYPE}" == "g100" ]]; then
0158    TRACCC_CUTS=${G100_CUTS[@]}
0159 elif [[ "${TRACCC_THROUGPUT_TYPE}" == "g230" ]]; then
0160    TRACCC_CUTS=${G200_CUTS[@]}
0161    TRACCC_CUTS+=(--useGBTS --gbts_config_dir="${TRACCC_INPUT_DIR}")
0162 elif [[ "${TRACCC_THROUGPUT_TYPE}" == "g130" ]]; then
0163    TRACCC_CUTS=${G100_CUTS[@]}
0164    TRACCC_CUTS+=(--useGBTS --gbts_config_dir="${TRACCC_INPUT_DIR}")
0165 elif [[ "${TRACCC_THROUGPUT_TYPE}" != "traccc" ]]; then
0166    echo "***"
0167    echo "*** Unknown throughput type: '${TRACCC_THROUGPUT_TYPE}'"
0168    echo "***"
0169    exit 1
0170 fi
0171 
0172 # Put a header on the CSV file.
0173 echo "directory,threads,loaded_events,cold_run_events,processed_events,warm_up_time,processing_time" \
0174    > "${TRACCC_CSV_FILE}"
0175 
0176 # Counter for a nice printout.
0177 COUNTER=1
0178 COUNT=$((${#TRACCC_EVENT_FILES[@]}*${TRACCC_MAX_THREADS}*${TRACCC_REPETITIONS}))
0179 
0180 # Iterate over the number of threads.
0181 for NTHREAD in $(seq ${TRACCC_MIN_THREADS} ${TRACCC_THREAD_STEP} ${TRACCC_MAX_THREADS}); do
0182    # Iterate over the input datasets.
0183    echo "   EVENT_FILES     : ${TRACCC_EVENT_FILES}"
0184    for EVTDIR in ${TRACCC_EVENT_FILES[@]}; do
0185       # Perform the requested number of repetitions.
0186       for REPEAT in $(seq ${TRACCC_REPETITIONS}); do
0187 
0188          # Tell the user what's happening.
0189          echo ""
0190          echo "Running test ${COUNTER} / ${COUNT}"
0191          ((COUNTER++))
0192 
0193          # Run the throughput test.
0194          ${TRACCC_EXECUTABLE}                                                  \
0195             --detector-file="${TRACCC_INPUT_DIR}/detray_detector_geometry.json" \
0196             --material-file="${TRACCC_INPUT_DIR}/detray_detector_material_maps.json"   \
0197             --grid-file="${TRACCC_INPUT_DIR}/detray_detector_surface_grids.json" \
0198             --digitization-file="${TRACCC_INPUT_DIR}/ITk_digitization_config.json" \
0199             --conditions-file="${TRACCC_INPUT_DIR}/ITk_conditions_config.json" \
0200             --read-bfield-from-file                                            \
0201             --bfield-file="${TRACCC_INPUT_DIR}/ITk_bfield.cvf"                 \
0202             --input-directory="${EVTDIR}/"                                     \
0203             --use-acts-geom-source=0                                           \
0204             --input-events=${TRACCC_N_EVENTS}                                  \
0205             --cpu-threads=${NTHREAD}                                           \
0206             --cold-run-events=$((5*${NTHREAD}))                                \
0207             --processed-events=$((${TRACCC_N_EVENTS}*${NTHREAD}))              \
0208             --log-file="${TRACCC_CSV_FILE}"                                    \
0209             ${TRACCC_CUTS[@]}                                                  \
0210 
0211       done
0212    done
0213 done