| 175 | |
| 176 | |
| 177 | int 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 | |
| 199 | bool gpu_isGpuAvailable() { |
no test coverage detected