Commit c6ccb344 authored by Christopher Bruns's avatar Christopher Bruns
Browse files

Corrected to avoid CUDA tests when cuda-enabled GPU is not present on Windows

parent 83889f1e
......@@ -26,10 +26,12 @@ try_run(RUN_RESULT_VAR COMPILE_RESULT_VAR
COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT_VAR
RUN_OUTPUT_VARIABLE RUN_OUTPUT_VAR
)
message("COMPILE_OUTPUT_VAR = ${COMPILE_OUTPUT_VAR}")
message("RUN_OUTPUT_VAR = ${RUN_OUTPUT_VAR}")
message("${RUN_OUTPUT_VAR}") # Display number of GPUs found
# COMPILE_RESULT_VAR is TRUE when compile succeeds
# RUN_RESULT_VAR is equal to the number of GPUs found
if(COMPILE_RESULT_VAR AND RUN_RESULT_VAR)
# RUN_RESULT_VAR is zero when a GPU is found
if(COMPILE_RESULT_VAR AND NOT RUN_RESULT_VAR)
set(CUDA_HAVE_GPU TRUE CACHE BOOL "Whether CUDA-capable GPU is present")
else()
set(CUDA_HAVE_GPU FALSE CACHE BOOL "Whether CUDA-capable GPU is present")
......
......@@ -8,6 +8,7 @@ int main() {
cudaError_t cudaResultCode = cudaGetDeviceCount(&deviceCount);
if (cudaResultCode != cudaSuccess)
deviceCount = 0;
/* machines with no GPUs can still report one emulation device */
for (device = 0; device < deviceCount; ++device) {
cudaGetDeviceProperties(&properties, device);
if (properties.major != 9999) /* 9999 means emulation only */
......@@ -15,6 +16,11 @@ int main() {
}
printf("%d GPU CUDA device(s) found\n", gpuDeviceCount);
return gpuDeviceCount;
/* don't just return the number of gpus, because other weird
errors can yield non-zero return values */
if (gpuDeviceCount > 0)
return 0; /* success */
else
return 1; /* failure */
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment