CMS 3D CMS Logo

Classes | Functions
cms::cudatest Namespace Reference

Classes

class  Thing
 

Functions

void requireDevices ()
 Print message and exit if there are no CUDA devices. More...
 
bool testDevices ()
 In presence of CUDA devices, return true; otherwise print message and return false. More...
 

Function Documentation

◆ requireDevices()

void cms::cudatest::requireDevices ( )

Print message and exit if there are no CUDA devices.

Definition at line 25 of file requireDevices.cc.

References beamvalidation::exit(), and testDevices().

25  {
26  if (not testDevices()) {
27  exit(EXIT_SUCCESS);
28  }
29  }
bool testDevices()
In presence of CUDA devices, return true; otherwise print message and return false.
def exit(msg="")

◆ testDevices()

bool cms::cudatest::testDevices ( )

In presence of CUDA devices, return true; otherwise print message and return false.

Definition at line 9 of file requireDevices.cc.

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, cms::alpakatools::devices(), and mps_update::status.

Referenced by requireDevices().

9  {
10  int devices = 0;
11  auto status = cudaGetDeviceCount(&devices);
12  if (status != cudaSuccess) {
13  std::cerr << "Failed to initialise the CUDA runtime, the test will be skipped."
14  << "\n";
15  return false;
16  }
17  if (devices == 0) {
18  std::cerr << "No CUDA devices available, the test will be skipped."
19  << "\n";
20  return false;
21  }
22  return true;
23  }
std::vector< alpaka::Dev< TPlatform > > const & devices()
Definition: devices.h:36