MCPcopy Create free account
hub / github.com/QuEST-Kit/QuEST / gpu_getNumberOfLocalGpus

Function gpu_getNumberOfLocalGpus

quest/src/gpu/gpu_config.cpp:177–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

175
176
177int gpu_getNumberOfLocalGpus() {
178#if COMPILE_CUDA
179
180 // HIP throws an error when a CUDA API function
181 // is called but no devices exist, which we handle
182 int num;
183 auto status = cudaGetDeviceCount(&num);
184
185 // treat query failure as indication of no local GPUs
186 // so do not call clearPossibleCudaError(). This is
187 // necessary because cudaGetDeviceCount() can report
188 // driver version errors when QuEST is GPU-compiled
189 // on a platform without a GPU, which we tolerate
190 return (status == cudaSuccess)? num : 0;
191
192#else
193 error_gpuQueriedButGpuNotCompiled();
194 return -1;
195#endif
196}
197
198
199bool gpu_isGpuAvailable() {

Callers 3

gpu_isGpuAvailableFunction · 0.85
gpu_bindLocalGPUsToNodesFunction · 0.85
printGpuInfoFunction · 0.85

Calls 1

Tested by

no test coverage detected