File indexing completed on 2024-04-06 12:15:46
0001 #include <cstdlib>
0002 #include <iostream>
0003
0004 #include <cuda_runtime.h>
0005
0006 #include "HeterogeneousCore/CUDAUtilities/interface/requireDevices.h"
0007
0008 namespace cms::cudatest {
0009 bool testDevices() {
0010 int devices = 0;
0011 auto status = cudaGetDeviceCount(&devices);
0012 if (status != cudaSuccess) {
0013 std::cerr << "Failed to initialise the CUDA runtime, the test will be skipped."
0014 << "\n";
0015 return false;
0016 }
0017 if (devices == 0) {
0018 std::cerr << "No CUDA devices available, the test will be skipped."
0019 << "\n";
0020 return false;
0021 }
0022 return true;
0023 }
0024
0025 void requireDevices() {
0026 if (not testDevices()) {
0027 exit(EXIT_SUCCESS);
0028 }
0029 }
0030 }