Przeglądaj źródła

Merge topic 'clang-cuda-default-arch' into release-4.0

47ddbc9ded CUDA/Clang: Prefer NVCC's default architecture for each CUDA Toolkit version

Acked-by: Kitware Robot <[email protected]>
Reviewed-by: Raul Tambre <[email protected]>
Merge-request: !10698
Brad King 7 miesięcy temu
rodzic
commit
8dee757664
1 zmienionych plików z 8 dodań i 3 usunięć
  1. 8 3
      Modules/CMakeDetermineCUDACompiler.cmake

+ 8 - 3
Modules/CMakeDetermineCUDACompiler.cmake

@@ -112,9 +112,14 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN)
   cmake_cuda_architectures_validate(CUDA)
 
   if(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang")
-    # Clang doesn't automatically select an architecture supported by the SDK.
-    # Try in reverse order of deprecation with the most recent at front (i.e. the most likely to work for new setups).
-    foreach(arch "52" "30" "20")
+    # Clang does not automatically select an architecture supported by the SDK.
+    # Prefer NVCC's default for each SDK version, and fall back to older archs.
+    set(archs "")
+    if(NOT CMAKE_CUDA_COMPILER_TOOLKIT_VERSION VERSION_LESS 11.0)
+      list(APPEND archs 52)
+    endif()
+    list(APPEND archs 30 20)
+    foreach(arch IN LISTS archs)
       list(APPEND CMAKE_CUDA_COMPILER_ID_TEST_FLAGS_FIRST "${clang_test_flags} --cuda-gpu-arch=sm_${arch}")
     endforeach()
   elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")