Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 // C/C++ headers
0002 #include <cstdlib>
0003 
0004 // ROCm headers
0005 #include <hip/hip_runtime.h>
0006 
0007 // CMSSW headers
0008 #include "HeterogeneousCore/Common/interface/PlatformStatus.h"
0009 
0010 // local headers
0011 #include "isRocmDeviceSupported.h"
0012 
0013 // returns PlatformStatus::Success if at least one visible ROCm device can be used,
0014 // or different failure codes depending on the problem.
0015 int main() {
0016   int devices = 0;
0017   auto status = hipGetDeviceCount(&devices);
0018   if (status != hipSuccess) {
0019     // could not initialise the ROCm runtime
0020     return PlatformStatus::RuntimeNotAvailable;
0021   }
0022 
0023   // check that at least one visible ROCm device can be used
0024   for (int i = 0; i < devices; ++i) {
0025     if (isRocmDeviceSupported(i))
0026       return PlatformStatus::Success;
0027   }
0028 
0029   // no usable ROCm devices were found
0030   return PlatformStatus::DevicesNotAvailable;
0031 }