Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:15:47

0001 #include <cstdlib>
0002 #include <iostream>
0003 
0004 #include <hip/hip_runtime.h>
0005 
0006 #include "HeterogeneousCore/ROCmUtilities/interface/requireDevices.h"
0007 
0008 namespace cms::rocmtest {
0009 
0010   bool testDevices() {
0011     int devices = 0;
0012     auto status = hipGetDeviceCount(&devices);
0013     if (status != hipSuccess) {
0014       std::cerr << "Failed to initialise the ROCm runtime, the test will be skipped.\n";
0015       return false;
0016     }
0017     if (devices == 0) {
0018       std::cerr << "No ROCm devices available, the test will be skipped.\n";
0019       return false;
0020     }
0021     return true;
0022   }
0023 
0024   void requireDevices() {
0025     if (not testDevices()) {
0026       exit(EXIT_SUCCESS);
0027     }
0028   }
0029 
0030 }  // namespace cms::rocmtest