diff options
author | Henry Schreiner <henryschreineriii@gmail.com> | 2021-01-19 18:35:29 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-01-20 17:28:28 (GMT) |
commit | 92854bf29eb4e8e0e3977358a3ab40bc2059f1b2 (patch) | |
tree | 2649fa28026ed2d94b1900cb43a21927f1ff264d /Modules | |
parent | a58a57245986656b4eb0ee0d66ec9da6c715d22b (diff) | |
download | CMake-92854bf29eb4e8e0e3977358a3ab40bc2059f1b2.zip CMake-92854bf29eb4e8e0e3977358a3ab40bc2059f1b2.tar.gz CMake-92854bf29eb4e8e0e3977358a3ab40bc2059f1b2.tar.bz2 |
CUDA: Update arch selection, restructure for maintainability
Fixes: #21712
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindCUDA/select_compute_arch.cmake | 78 |
1 files changed, 32 insertions, 46 deletions
diff --git a/Modules/FindCUDA/select_compute_arch.cmake b/Modules/FindCUDA/select_compute_arch.cmake index b583308..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,35 @@ 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) |