diff options
author | Robert Maynard <rmaynard@nvidia.com> | 2021-08-17 16:28:23 (GMT) |
---|---|---|
committer | Robert Maynard <rmaynard@nvidia.com> | 2021-11-01 18:57:58 (GMT) |
commit | 14d8a2768d8b8c2ba0f341b4bd59a875aaf6c2f4 (patch) | |
tree | 2074643d278024f89622b959a7795ee57438c222 /Modules/CMakeDetermineCUDACompiler.cmake | |
parent | e1acb03cd9b53fe81dd9e1696ac293ae5ba468cc (diff) | |
download | CMake-14d8a2768d8b8c2ba0f341b4bd59a875aaf6c2f4.zip CMake-14d8a2768d8b8c2ba0f341b4bd59a875aaf6c2f4.tar.gz CMake-14d8a2768d8b8c2ba0f341b4bd59a875aaf6c2f4.tar.bz2 |
CUDA: Support nvcc 11.5 new -arch=all|all-major flags
Diffstat (limited to 'Modules/CMakeDetermineCUDACompiler.cmake')
-rw-r--r-- | Modules/CMakeDetermineCUDACompiler.cmake | 38 |
1 files changed, 30 insertions, 8 deletions
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index d06315e..8479831 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -258,13 +258,22 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) # Append user-specified architectures. if(CMAKE_CUDA_ARCHITECTURES) - foreach(arch ${CMAKE_CUDA_ARCHITECTURES}) - # Strip specifiers as PTX vs binary doesn't matter. - string(REGEX MATCH "[0-9]+" arch_name "${arch}") - string(APPEND clang_test_flags " --cuda-gpu-arch=sm_${arch_name}") - string(APPEND nvcc_test_flags " -gencode=arch=compute_${arch_name},code=sm_${arch_name}") - list(APPEND tested_architectures "${arch_name}") - endforeach() + if("x${CMAKE_CUDA_ARCHITECTURES}" STREQUAL "xall") + string(APPEND nvcc_test_flags " -arch=all") + set(architectures_mode all) + elseif("x${CMAKE_CUDA_ARCHITECTURES}" STREQUAL "xall-major") + string(APPEND nvcc_test_flags " -arch=all-major") + set(architectures_mode all-major) + else() + set(architectures_mode explicit) + foreach(arch ${CMAKE_CUDA_ARCHITECTURES}) + # Strip specifiers as PTX vs binary doesn't matter. + string(REGEX MATCH "[0-9]+" arch_name "${arch}") + string(APPEND clang_test_flags " --cuda-gpu-arch=sm_${arch_name}") + string(APPEND nvcc_test_flags " -gencode=arch=compute_${arch_name},code=sm_${arch_name}") + list(APPEND tested_architectures "${arch_name}") + endforeach() + endif() # If the user has specified architectures we'll want to fail during compiler detection if they don't work. set(CMAKE_CUDA_COMPILER_ID_REQUIRE_SUCCESS ON) @@ -597,7 +606,18 @@ if(DEFINED detected_architecture AND "${CMAKE_CUDA_ARCHITECTURES}" STREQUAL "") if(NOT CMAKE_CUDA_ARCHITECTURES) message(FATAL_ERROR "Failed to find a working CUDA architecture.") endif() -elseif(architectures) +elseif(architectures AND (architectures_mode STREQUAL "xall" OR + architectures_mode STREQUAL "xall-major")) + if(NOT CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") + message(FATAL_ERROR + "The CMAKE_CUDA_ARCHITECTURES:\n" + " ${CMAKE_CUDA_ARCHITECTURES}\n" + "is not supported with the ${CMAKE_CUDA_COMPILER_ID} compiler. Try:\n" + " ${architectures}\n" + "instead.") + endif() + +elseif(architectures AND architectures_mode STREQUAL "xexplicit") # Sort since order mustn't matter. list(SORT architectures) list(SORT tested_architectures) @@ -630,5 +650,7 @@ unset(_CUDA_LIBRARY_DIR) unset(_CUDA_TARGET_DIR) unset(_CUDA_TARGET_NAME) +unset(architectures_mode) + set(CMAKE_CUDA_COMPILER_ENV_VAR "CUDACXX") set(CMAKE_CUDA_HOST_COMPILER_ENV_VAR "CUDAHOSTCXX") |