File indexing completed on 2024-12-30 23:27:57
0001
0002
0003 function die { echo Failed $1: status $2 ; exit $2 ; }
0004
0005 TEST_DIR=${LOCALTOP}/src/HeterogeneousCore/AlpakaTest/test
0006
0007 if [ "$#" != "1" ]; then
0008 die "Need exactly 1 argument ('cpu', 'cuda', or 'rocm'), got $#" 1
0009 fi
0010 if [[ "$1" =~ ^(cpu|cuda|rocm)$ ]]; then
0011 TARGET=$1
0012 else
0013 die "Argument needs to be 'cpu', 'cuda', or 'rocm'; got '$1'" 1
0014 fi
0015
0016
0017 if [ "$TARGET" == "cpu" ]; then
0018 cudaIsEnabled
0019 if [ "$?" == "0" ]; then
0020 echo "Test target is 'cpu', but NVIDIA GPU is detected. Ignoring the CPU tests."
0021 exit 0
0022 fi
0023 rocmIsEnabled
0024 if [ "$?" == "0" ]; then
0025 echo "Test target is 'cpu', but AMD GPU is detected. Ignoring the CPU tests."
0026 exit 0
0027 fi
0028 fi
0029
0030 function runSuccess {
0031 echo "cmsRun testAlpakaModules_cfg.py $1"
0032 cmsRun ${TEST_DIR}/testAlpakaModules_cfg.py $1 || die "cmsRun testAlpakaModules_cfg.py $1" $?
0033 echo
0034 }
0035 function runSuccessHostAndDevice {
0036 echo "cmsRun testAlpakaModulesHostAndDevice_cfg.py $1"
0037 cmsRun ${TEST_DIR}/testAlpakaModulesHostAndDevice_cfg.py $1 || die "cmsRun testAlpakaModulesHostAndDevice_cfg.py $1" $?
0038 echo
0039 }
0040 function runFailure {
0041 echo "cmsRun testAlpakaModules_cfg.py $1 (job itself is expected to fail)"
0042 cmsRun -j testAlpakaModules_jobreport.xml ${TEST_DIR}/testAlpakaModules_cfg.py $1 && die "cmsRun testAlpakaModules_cfg.py $1 did not fail" 1
0043 EXIT_CODE=$(edmFjrDump --exitCode testAlpakaModules_jobreport.xml)
0044 if [ "x${EXIT_CODE}" != "x8035" ]; then
0045 echo "Alpaka module test for unavailable accelerator reported exit code ${EXIT_CODE} which is different from the expected 8035"
0046 exit 1
0047 fi
0048 echo
0049 }
0050
0051 function runForGPU {
0052 ACCELERATOR=$1
0053 BACKEND=$2
0054
0055 runSuccess "--expectBackend=$BACKEND"
0056 runSuccess "--accelerators=$ACCELERATOR --expectBackend=$BACKEND"
0057 runSuccess "--processAcceleratorBackend=$BACKEND --expectBackend=$BACKEND"
0058 runSuccess "--moduleBackend=$BACKEND --expectBackend=$BACKEND"
0059
0060 runSuccess "--processAcceleratorBackend=$BACKEND --moduleBackend=serial_sync --expectBackend=serial_sync"
0061 runSuccess "--processAcceleratorBackend=serial_sync --moduleBackend=$BACKEND --expectBackend=$BACKEND"
0062 runSuccess "--moduleSynchronize --expectBackend=$BACKEND"
0063 runSuccess "--processAcceleratorSynchronize --expectBackend=$BACKEND"
0064
0065 runFailure "--accelerators=$ACCELERATOR --processAcceleratorBackend=serial_sync --expectBackend=serial_sync"
0066 runFailure "--accelerators=$ACCELERATOR --moduleBackend=serial_sync --expectBackend=serial_sync"
0067 runFailure "--accelerators=$ACCELERATOR --processAcceleratorBackend=$BACKEND --moduleBackend=serial_sync --expectBackend=serial_sync"
0068 runFailure "--accelerators=$ACCELERATOR --processAcceleratorBackend=serial_sync --moduleBackend=$BACKEND --expectBackend=$BACKEND"
0069 runFailure "--accelerators=cpu --processAcceleratorBackend=$BACKEND --expectBackend=$BACKEND"
0070 runFailure "--accelerators=cpu --moduleBackend=$BACKEND --expectBackend=$BACKEND"
0071 runFailure "--accelerators=cpu --processAcceleratorBackend=serial_sync --moduleBackend=$BACKEND --expectBackend=$BACKEND"
0072 runFailure "--accelerators=cpu --processAcceleratorBackend=$BACKEND --moduleBackend=serial_sync --expectBackend=serial_sync"
0073
0074 runSuccessHostAndDevice "--expectBackend=$BACKEND"
0075 }
0076
0077 runSuccess "--accelerators=cpu --expectBackend=serial_sync"
0078 runSuccess "--processAcceleratorBackend=serial_sync --expectBackend=serial_sync"
0079 runSuccess "--moduleBackend=serial_sync --expectBackend=serial_sync"
0080
0081 if [ "${TARGET}" == "cpu" ]; then
0082 runSuccess "--expectBackend=serial_sync"
0083 runSuccess "--moduleSynchronize --expectBackend=serial_sync"
0084 runSuccess "--processAcceleratorSynchronize --expectBackend=serial_sync"
0085
0086 runFailure "--accelerators=gpu-nvidia --expectBackend=cuda_async"
0087 runFailure "--processAcceleratorBackend=cuda_async --expectBackend=cuda_async"
0088 runFailure "--moduleBackend=cuda_async --expectBackend=cuda_async"
0089
0090 runFailure "--processAcceleratorBackend=cuda_async --moduleBackend=serial_sync --expectBackend=serial_sync"
0091 runFailure "--processAcceleratorBackend=serial_sync --moduleBackend=cuda_async --expectBackend=cuda_async"
0092
0093 runSuccessHostAndDevice "--expectBackend=serial_sync"
0094
0095 elif [ "${TARGET}" == "cuda" ]; then
0096 runForGPU "gpu-nvidia" "cuda_async"
0097
0098 elif [ "${TARGET}" == "rocm" ]; then
0099 runForGPU "gpu-amd" "rocm_async"
0100
0101 fi