diff options
author | Raul Tambre <raul@tambre.ee> | 2021-12-19 10:49:58 (GMT) |
---|---|---|
committer | Raul Tambre <raul@tambre.ee> | 2022-02-01 16:25:20 (GMT) |
commit | 8f64df0a7c2c9126017847f2bb8d37bc54ea0338 (patch) | |
tree | 589ad2a37c64cbde54e8e28006ad4393a7a5cd21 /Modules/CUDA | |
parent | 5305d5aa1a6900c64a5833176b43a21acb13fb30 (diff) | |
download | CMake-8f64df0a7c2c9126017847f2bb8d37bc54ea0338.zip CMake-8f64df0a7c2c9126017847f2bb8d37bc54ea0338.tar.gz CMake-8f64df0a7c2c9126017847f2bb8d37bc54ea0338.tar.bz2 |
CUDA: Generic all and all-major support
Commit 14d8a276 (CUDA: Support nvcc 11.5 new -arch=all|all-major flags,
2021-08-17) added all and all-major options to CUDA_ARCHITECTURES. These are
fairly generic and likely to see real-world use by distributors. Thus it's
desirable to support these also for Clang and older NVCC versions.
The supported architectures are dependent on the toolkit version. We determine
the toolkit version prior to compiler detection. For NVCC we get the version
from the vendor identification output, but for Clang we need to invoke NVCC
separately.
The architecture information is mostly based on the Wikipedia list with the
earliest supported version being CUDA 7.0. This could be documented and
expanded in the future to allow projects to query CUDA toolkit version and
architecture information.
For Clang we additionally constrain based on its support.
Additionally the architecture mismatch detection logic is fixed, improved and
updated for generic support:
* Commit 01428c55 (CUDA: Fail fast if CMAKE_CUDA_ARCHITECTURES doesn't work
during detection, 2020-08-29) enabled CMAKE_CUDA_COMPILER_ID_REQUIRE_SUCCESS
if CMAKE_CUDA_ARCHITECTURES is specified. This results in
CMakeDetermineCompilerID.cmake printing the compiler error and our code for
presenting the mismatch in a user-friendly way being useless. The custom
logic seems preferable so go back to not enabling it.
* Commit 14d8a276 (CUDA: Support nvcc 11.5 new -arch=all|all-major flags,
2021-08-17) tried to support CMP0054 but forgot to add x to the interpolated
result. Thus the conditions would always evaluate to false. This is fixed as
a byproduct of removing NVIDIA specific checks, improving the error message
and replacing architectures_mode with a simpler architectures_explicit.
Visual Studio support omits testing the flags during detection due to
complexities in determining the toolkit version when using it.
A long-term proper implementation would be #23161.
Implements #22860.
Diffstat (limited to 'Modules/CUDA')
-rw-r--r-- | Modules/CUDA/architectures.cmake | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/Modules/CUDA/architectures.cmake b/Modules/CUDA/architectures.cmake new file mode 100644 index 0000000..fa3a5a1 --- /dev/null +++ b/Modules/CUDA/architectures.cmake @@ -0,0 +1,46 @@ +# See supported GPUs on Wikipedia +# https://en.wikipedia.org/wiki/CUDA#GPUs_supported + +# Initial set based on CUDA 7.0. +set(CMAKE_CUDA_ARCHITECTURES_ALL 20 21 30 35 37 50 52 53) +set(CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR 20 30 35 50) + +if(CMAKE_CUDA_COMPILER_TOOLKIT_VERSION VERSION_GREATER_EQUAL 8.0) + list(APPEND CMAKE_CUDA_ARCHITECTURES_ALL 60 61 62) + list(APPEND CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR 60) +endif() + +if(CMAKE_CUDA_COMPILER_TOOLKIT_VERSION VERSION_GREATER_EQUAL 9.0) + if(NOT CMAKE_CUDA_COMPILER_ID STREQUAL "Clang" OR CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0) + list(APPEND CMAKE_CUDA_ARCHITECTURES_ALL 70 72) + list(APPEND CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR 70) + endif() + + list(REMOVE_ITEM CMAKE_CUDA_ARCHITECTURES_ALL 20 21) + list(REMOVE_ITEM CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR 20 21) +endif() + +if(CMAKE_CUDA_COMPILER_TOOLKIT_VERSION VERSION_GREATER_EQUAL 10.0 + AND (NOT CMAKE_CUDA_COMPILER_ID STREQUAL "Clang" OR CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)) + list(APPEND CMAKE_CUDA_ARCHITECTURES_ALL 75) +endif() + +if(CMAKE_CUDA_COMPILER_TOOLKIT_VERSION VERSION_GREATER_EQUAL 11.0) + if(NOT CMAKE_CUDA_COMPILER_ID STREQUAL "Clang" OR CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.0) + list(APPEND CMAKE_CUDA_ARCHITECTURES_ALL 80) + list(APPEND CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR 80) + endif() + + list(REMOVE_ITEM CMAKE_CUDA_ARCHITECTURES_ALL 30) + list(REMOVE_ITEM CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR 30) +endif() + +if(CMAKE_CUDA_COMPILER_TOOLKIT_VERSION VERSION_GREATER_EQUAL 11.1 + AND (NOT CMAKE_CUDA_COMPILER_ID STREQUAL "Clang" OR CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0)) + list(APPEND CMAKE_CUDA_ARCHITECTURES_ALL 86) +endif() + +if(CMAKE_CUDA_COMPILER_TOOLKIT_VERSION VERSION_GREATER_EQUAL 11.4 + AND (NOT CMAKE_CUDA_COMPILER_ID STREQUAL "Clang")) + list(APPEND CMAKE_CUDA_ARCHITECTURES_ALL 87) +endif() |