Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 09:15:04

0001 #!/bin/bash
0002 #
0003 # This script tests whether the output of a certain ACTS framework example is
0004 # reproducible between single-threaded and multi-threaded runs. For example,
0005 # "./testReproducibility.sh ActsExampleFatrasGeneric" will run the
0006 # ActsExampleFatrasGeneric in single-threaded and multi-threaded mode and
0007 # check whether the output is the same aside from threading-induced event reordering.
0008 #
0009 set -uo pipefail
0010 
0011 # Check whether the user did specify the name of the example to be run
0012 ARGC=$#
0013 if [[ $ARGC -lt 2 ]]; then
0014   echo ""
0015   echo " Usage: "$0" <example> <flags> <output1> [<output2> ...]"
0016   echo ""
0017   echo " <example> is the executable name (e.g. ActsExampleFatrasGeneric)"
0018   echo " <flags> is a string containing CLI flags (e.g. \"-n 5\")"
0019   echo " <outputN> is the output name (which is the output file name without the trailing '.root')"
0020   echo ""
0021   exit 42
0022 fi
0023 
0024 # Compute the name of the example executable
0025 executable="$1 $2 --output-root true"
0026 echo ${executable}
0027 
0028 # Compute the output file names
0029 for ((i = 3; i <= $ARGC; i++)); do
0030   eval output=\$${i}.root
0031   eval outputs[$i]=$output
0032 done
0033 
0034 # Drop any remaining output file from previous runs of the example
0035 for output in "${outputs[@]}"; do
0036   rm -f $output ST$output MT$output
0037 done
0038 
0039 # Run the example in multi-threaded mode
0040 eval "${executable}"
0041 result=$?
0042 if [[ result -ne 0 ]]; then
0043   echo "Multi-threaded run failed!"
0044   exit $result
0045 fi
0046 
0047 # Back up the multi-threaded results
0048 for output in "${outputs[@]}"; do
0049   mv $output MT$output
0050 done
0051 
0052 # Run the example in single-threaded mode
0053 eval "${executable} -j 1"
0054 result=$?
0055 if [[ result -ne 0 ]]; then
0056   echo "Single-threaded run failed!"
0057   exit $result
0058 fi
0059 
0060 # Back up the single-threaded results
0061 for output in "${outputs[@]}"; do
0062   mv $output ST$output
0063 done
0064 
0065 # Check whether the results were identical (up to thread-induced reordering)
0066 for output in "${outputs[@]}"; do
0067   # Compare the active results files
0068   cmd="root -b -q -l -x -e '.x compareRootFiles.C(\"ST$output\", \"MT$output\")'"
0069   eval $cmd
0070   result=$?
0071 
0072   # If the results were different, abort and return the output status code
0073   if [[ result -ne 0 ]]; then
0074     exit $result
0075   fi
0076 
0077   # Otherwise clean up and continue
0078   rm ST$output MT$output
0079 done