CMS 3D CMS Logo

requireDevices.cc
Go to the documentation of this file.
1 #include <cstdlib>
2 #include <iostream>
3 
4 #include <hip/hip_runtime.h>
5 
7 
8 namespace cms::rocmtest {
9 
10  bool testDevices() {
11  int devices = 0;
12  auto status = hipGetDeviceCount(&devices);
13  if (status != hipSuccess) {
14  std::cerr << "Failed to initialise the ROCm runtime, the test will be skipped.\n";
15  return false;
16  }
17  if (devices == 0) {
18  std::cerr << "No ROCm devices available, the test will be skipped.\n";
19  return false;
20  }
21  return true;
22  }
23 
24  void requireDevices() {
25  if (not testDevices()) {
26  exit(EXIT_SUCCESS);
27  }
28  }
29 
30 } // namespace cms::rocmtest
void requireDevices()
Print message and exit if there are no ROCm devices.
std::vector< alpaka::Dev< TPlatform > > const & devices()
Definition: devices.h:35
bool testDevices()
In presence of ROCm devices, return true; otherwise print message and return false.
def exit(msg="")