From 8a441d3051351105da928c9a5ddce2ee6d6761b1 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 5 Aug 2016 15:41:55 -0400 Subject: [PATCH] Don't run nvcc native detection multiple times, as the results are cached. This fixes a issue where when CUDA is enabled and VTKm_CUDA_Architecture is set to native, we would run nvcc each time somebody explicitly enabled the CUDA component ( each example ). --- CMake/VTKmConfigureComponents.cmake | 44 +++++++++++++++-------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/CMake/VTKmConfigureComponents.cmake b/CMake/VTKmConfigureComponents.cmake index d1355b7a7..5a257e87c 100644 --- a/CMake/VTKmConfigureComponents.cmake +++ b/CMake/VTKmConfigureComponents.cmake @@ -247,27 +247,29 @@ macro(vtkm_configure_component_CUDA) #detect what the propery is set too if(VTKm_CUDA_Architecture STREQUAL "native") - #run execute_process to do auto_detection - set(command ${CUDA_NVCC_EXECUTABLE}) - set(args "-ccbin" "${CMAKE_CXX_COMPILER}" "--run" "${VTKm_CMAKE_MODULE_PATH}/VTKmDetectCUDAVersion.cxx") - execute_process( - COMMAND ${command} ${args} - RESULT_VARIABLE ran_properly - OUTPUT_VARIABLE run_output - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - - if(ran_properly EQUAL 0) - #find the position of the "--generate-code" output. With some compilers such as - #msvc we get compile output plus run output. So we need to strip out just the - #run output - string(FIND "${run_output}" "--generate-code" position) - string(SUBSTRING "${run_output}" ${position} -1 run_output) - set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} ${run_output}") - else() - set(VTKm_CUDA_Architecture "fermi") - if(NOT VTKm_CONFIGURE_QUIET) - message(STATUS "Unable to run \"${CUDA_NVCC_EXECUTABLE}\" to autodetect GPU architecture." - "Falling back to fermi, please manually specify if you want something else.") + if(NOT VTKM_CUDA_NATIVE_EXE_PROCESS_RAN) + #run execute_process to do auto_detection + set(command ${CUDA_NVCC_EXECUTABLE}) + set(args "-ccbin" "${CMAKE_CXX_COMPILER}" "--run" "${VTKm_CMAKE_MODULE_PATH}/VTKmDetectCUDAVersion.cxx") + execute_process( + COMMAND ${command} ${args} + RESULT_VARIABLE ran_properly + OUTPUT_VARIABLE run_output + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + if(ran_properly EQUAL 0) + #find the position of the "--generate-code" output. With some compilers such as + #msvc we get compile output plus run output. So we need to strip out just the + #run output + string(FIND "${run_output}" "--generate-code" position) + string(SUBSTRING "${run_output}" ${position} -1 run_output) + set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} ${run_output}") + set(VTKM_CUDA_NATIVE_EXE_PROCESS_RAN TRUE) + else() + set(VTKm_CUDA_Architecture "fermi") + if(NOT VTKm_CONFIGURE_QUIET) + message(STATUS "Unable to run \"${CUDA_NVCC_EXECUTABLE}\" to autodetect GPU architecture." + "Falling back to fermi, please manually specify if you want something else.") + endif() endif() endif() endif()