diff options
author | Brad King <brad.king@kitware.com> | 2021-01-21 14:19:10 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-01-21 14:19:23 (GMT) |
commit | 8cdb9de586745f4935b30f6687a131a91234d646 (patch) | |
tree | ca9f922d88408413249b5457f6401d57670b45f9 | |
parent | 82b597024643564f05d7a19347bdf341ccb7f764 (diff) | |
parent | 92854bf29eb4e8e0e3977358a3ab40bc2059f1b2 (diff) | |
download | CMake-8cdb9de586745f4935b30f6687a131a91234d646.zip CMake-8cdb9de586745f4935b30f6687a131a91234d646.tar.gz CMake-8cdb9de586745f4935b30f6687a131a91234d646.tar.bz2 |
Merge topic 'cuda-archs'
92854bf29e CUDA: Update arch selection, restructure for maintainability
a58a572459 CUDA: Add arch selection debug mode to print out CUDA versions
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Raul Tambre <raul@tambre.ee>
Merge-request: !5719
-rw-r--r-- | Modules/FindCUDA/select_compute_arch.cmake | 89 |
1 files changed, 43 insertions, 46 deletions
diff --git a/Modules/FindCUDA/select_compute_arch.cmake b/Modules/FindCUDA/select_compute_arch.cmake index 9351288..a35b3f8 100644 --- a/Modules/FindCUDA/select_compute_arch.cmake +++ b/Modules/FindCUDA/select_compute_arch.cmake @@ -25,44 +25,26 @@ if(CMAKE_CUDA_COMPILER_LOADED) # CUDA as a language endif() # See: https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#gpu-feature-list +# Additions, deprecations, and removals can be found in the release notes: +# https://developer.nvidia.com/cuda-toolkit-archive -# This list will be used for CUDA_ARCH_NAME = All option -set(CUDA_KNOWN_GPU_ARCHITECTURES "Fermi" "Kepler" "Maxwell") +# The initial status here is for CUDA 7.0 +set(CUDA_KNOWN_GPU_ARCHITECTURES "Fermi" "Kepler" "Maxwell" "Kepler+Tegra" "Kepler+Tesla" "Maxwell+Tegra") +set(CUDA_COMMON_GPU_ARCHITECTURES "2.0" "2.1" "3.0" "3.5" "5.0" "5.3") +set(CUDA_LIMIT_GPU_ARCHITECTURE "6.0") +set(CUDA_ALL_GPU_ARCHITECTURES "2.0" "2.1" "3.0" "3.2" "3.5" "3.7" "5.0" "5.2" "5.3") +set(_CUDA_MAX_COMMON_ARCHITECTURE "5.2+PTX") -# This list will be used for CUDA_ARCH_NAME = Common option (enabled by default) -set(CUDA_COMMON_GPU_ARCHITECTURES "3.5" "5.0") -# 3.0 is removed in CUDA 11, see: -# https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html#deprecated-features -if(CUDA_VERSION VERSION_LESS "11.0") - list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "3.0") -endif() - -if(CUDA_VERSION VERSION_LESS "7.0") - set(CUDA_LIMIT_GPU_ARCHITECTURE "5.2") -endif() - -# This list is used to filter CUDA archs when autodetecting -set(CUDA_ALL_GPU_ARCHITECTURES "3.0" "3.2" "3.5" "5.0") - -if(CUDA_VERSION VERSION_GREATER_EQUAL "7.0") - list(APPEND CUDA_KNOWN_GPU_ARCHITECTURES "Kepler+Tegra" "Kepler+Tesla" "Maxwell+Tegra") - list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "5.2") - - if(CUDA_VERSION VERSION_LESS "8.0") - list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "5.2+PTX") - set(CUDA_LIMIT_GPU_ARCHITECTURE "6.0") - endif() -endif() if(CUDA_VERSION VERSION_GREATER_EQUAL "8.0") list(APPEND CUDA_KNOWN_GPU_ARCHITECTURES "Pascal") list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "6.0" "6.1") list(APPEND CUDA_ALL_GPU_ARCHITECTURES "6.0" "6.1" "6.2") - if(CUDA_VERSION VERSION_LESS "9.0") - list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "6.2+PTX") - set(CUDA_LIMIT_GPU_ARCHITECTURE "7.0") - endif() + set(_CUDA_MAX_COMMON_ARCHITECTURE "6.2+PTX") + set(CUDA_LIMIT_GPU_ARCHITECTURE "7.0") + + list(REMOVE_ITEM CUDA_COMMON_GPU_ARCHITECTURES "2.0" "2.1") endif () if(CUDA_VERSION VERSION_GREATER_EQUAL "9.0") @@ -70,10 +52,11 @@ if(CUDA_VERSION VERSION_GREATER_EQUAL "9.0") list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "7.0") list(APPEND CUDA_ALL_GPU_ARCHITECTURES "7.0" "7.2") - if(CUDA_VERSION VERSION_LESS "10.0") - list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "7.2+PTX") - set(CUDA_LIMIT_GPU_ARCHITECTURE "8.0") - endif() + set(_CUDA_MAX_COMMON_ARCHITECTURE "7.2+PTX") + set(CUDA_LIMIT_GPU_ARCHITECTURE "8.0") + + list(REMOVE_ITEM CUDA_KNOWN_GPU_ARCHITECTURES "Fermi") + list(REMOVE_ITEM CUDA_ALL_GPU_ARCHITECTURES "2.0" "2.1") endif() if(CUDA_VERSION VERSION_GREATER_EQUAL "10.0") @@ -81,32 +64,46 @@ if(CUDA_VERSION VERSION_GREATER_EQUAL "10.0") list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "7.5") list(APPEND CUDA_ALL_GPU_ARCHITECTURES "7.5") - if(CUDA_VERSION VERSION_LESS "11.0") - list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "7.5+PTX") - set(CUDA_LIMIT_GPU_ARCHITECTURE "8.0") - endif() + set(_CUDA_MAX_COMMON_ARCHITECTURE "7.5+PTX") + set(CUDA_LIMIT_GPU_ARCHITECTURE "8.0") + + list(REMOVE_ITEM CUDA_COMMON_GPU_ARCHITECTURES "3.0") endif() +# https://docs.nvidia.com/cuda/archive/11.0/cuda-toolkit-release-notes/index.html#cuda-general-new-features +# https://docs.nvidia.com/cuda/archive/11.0/cuda-toolkit-release-notes/index.html#deprecated-features if(CUDA_VERSION VERSION_GREATER_EQUAL "11.0") list(APPEND CUDA_KNOWN_GPU_ARCHITECTURES "Ampere") list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "8.0") list(APPEND CUDA_ALL_GPU_ARCHITECTURES "8.0") - if(CUDA_VERSION VERSION_LESS "11.1") - list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "8.0+PTX") - set(CUDA_LIMIT_GPU_ARCHITECTURE "8.6") - endif() + set(_CUDA_MAX_COMMON_ARCHITECTURE "8.0+PTX") + set(CUDA_LIMIT_GPU_ARCHITECTURE "8.6") + + list(REMOVE_ITEM CUDA_COMMON_GPU_ARCHITECTURES "3.5" "5.0") + list(REMOVE_ITEM CUDA_ALL_GPU_ARCHITECTURES "3.0" "3.2") endif() if(CUDA_VERSION VERSION_GREATER_EQUAL "11.1") - list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "8.6" "8.6+PTX") + list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "8.6") list(APPEND CUDA_ALL_GPU_ARCHITECTURES "8.6") - if(CUDA_VERSION VERSION_LESS "12.0") - set(CUDA_LIMIT_GPU_ARCHITECTURE "9.0") - endif() + set(_CUDA_MAX_COMMON_ARCHITECTURE "8.6+PTX") + set(CUDA_LIMIT_GPU_ARCHITECTURE "9.0") endif() +list(APPEND CUDA_COMMON_GPU_ARCHITECTURES "${_CUDA_MAX_COMMON_ARCHITECTURE}") + +# Check with: cmake -DCUDA_VERSION=7.0 -P select_compute_arch.cmake +if(DEFINED CMAKE_SCRIPT_MODE_FILE) + include(CMakePrintHelpers) + cmake_print_variables(CUDA_KNOWN_GPU_ARCHITECTURES) + cmake_print_variables(CUDA_COMMON_GPU_ARCHITECTURES) + cmake_print_variables(CUDA_LIMIT_GPU_ARCHITECTURE) + cmake_print_variables(CUDA_ALL_GPU_ARCHITECTURES) +endif() + + ################################################################################################ # A function for automatic detection of GPUs installed (if autodetection is enabled) # Usage: |