Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-11-11 05:36:42

0001 #!/bin/bash
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 # Some of the CPU-only tests fail if run on machine with GPU
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 
0063     runFailure "--accelerators=$ACCELERATOR --processAcceleratorBackend=serial_sync --expectBackend=serial_sync"
0064     runFailure "--accelerators=$ACCELERATOR --moduleBackend=serial_sync --expectBackend=serial_sync"
0065     runFailure "--accelerators=$ACCELERATOR --processAcceleratorBackend=$BACKEND --moduleBackend=serial_sync --expectBackend=serial_sync"
0066     runFailure "--accelerators=$ACCELERATOR --processAcceleratorBackend=serial_sync --moduleBackend=$BACKEND --expectBackend=$BACKEND"
0067     runFailure "--accelerators=cpu --processAcceleratorBackend=$BACKEND --expectBackend=$BACKEND"
0068     runFailure "--accelerators=cpu --moduleBackend=$BACKEND --expectBackend=$BACKEND"
0069     runFailure "--accelerators=cpu --processAcceleratorBackend=serial_sync --moduleBackend=$BACKEND --expectBackend=$BACKEND"
0070     runFailure "--accelerators=cpu --processAcceleratorBackend=$BACKEND --moduleBackend=serial_sync --expectBackend=serial_sync"
0071 
0072     runSuccessHostAndDevice "--expectBackend=$BACKEND"
0073 }
0074 
0075 runSuccess "--accelerators=cpu --expectBackend=serial_sync"
0076 runSuccess "--processAcceleratorBackend=serial_sync --expectBackend=serial_sync"
0077 runSuccess "--moduleBackend=serial_sync --expectBackend=serial_sync"
0078 
0079 if [ "${TARGET}" == "cpu" ]; then
0080     runSuccess "--expectBackend=serial_sync"
0081 
0082     runFailure "--accelerators=gpu-nvidia --expectBackend=cuda_async"
0083     runFailure "--processAcceleratorBackend=cuda_async --expectBackend=cuda_async"
0084     runFailure "--moduleBackend=cuda_async --expectBackend=cuda_async"
0085 
0086     runFailure "--processAcceleratorBackend=cuda_async --moduleBackend=serial_sync --expectBackend=serial_sync"
0087     runFailure "--processAcceleratorBackend=serial_sync --moduleBackend=cuda_async --expectBackend=cuda_async"
0088 
0089     runSuccessHostAndDevice "--expectBackend=serial_sync"
0090 
0091 elif [ "${TARGET}" == "cuda" ]; then
0092     runForGPU "gpu-nvidia" "cuda_async"
0093 
0094 elif [ "${TARGET}" == "rocm" ]; then
0095     runForGPU "gpu-amd" "rocm_async"
0096 
0097 fi