From 7bf520069938dcb106f9c0c7cc71ac079055ceed Mon Sep 17 00:00:00 2001 From: Brad King Date: Thu, 28 Apr 2022 14:46:45 -0400 Subject: CUDA: Restore CMAKE_CUDA_ARCHITECTURES support for -real and -virtual suffixes Fix the validation regex added by commit c267ed205a (CUDA: Defer architecture testing to the compiler testing step, 2022-04-25) to allow these values. --- Modules/CMakeDetermineCUDACompiler.cmake | 7 ++++--- Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake | 5 +++++ Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt | 6 +++--- Tests/RunCMake/CUDA_architectures/architectures-suffix-stderr.txt | 4 ++++ Tests/RunCMake/CUDA_architectures/architectures-suffix-stdout.txt | 4 ++++ Tests/RunCMake/CUDA_architectures/architectures-suffix.cmake | 6 ++++++ 6 files changed, 26 insertions(+), 6 deletions(-) create mode 100644 Tests/RunCMake/CUDA_architectures/architectures-suffix-stderr.txt create mode 100644 Tests/RunCMake/CUDA_architectures/architectures-suffix-stdout.txt create mode 100644 Tests/RunCMake/CUDA_architectures/architectures-suffix.cmake diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 23da8ee..0ac06ac 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -275,13 +275,14 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) if(DEFINED CMAKE_CUDA_ARCHITECTURES) if(CMAKE_CUDA_ARCHITECTURES STREQUAL "") message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES must be non-empty if set.") - elseif(CMAKE_CUDA_ARCHITECTURES AND NOT CMAKE_CUDA_ARCHITECTURES MATCHES "^([0-9]+[;0-9]*|all|all-major|native)$") + elseif(CMAKE_CUDA_ARCHITECTURES AND NOT CMAKE_CUDA_ARCHITECTURES MATCHES "^([0-9]+(-real|-virtual)?(;[0-9]+(-real|-virtual)?|;)*|all|all-major|native)$") message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES:\n" " ${CMAKE_CUDA_ARCHITECTURES}\n" "is not one of the following:\n" - "* a semicolon-separated list of integers\n" - "* a special value: all, all-major, native\n" + " * a semicolon-separated list of integers, each optionally\n" + " followed by '-real' or '-virtual'\n" + " * a special value: all, all-major, native\n" ) endif() endif() diff --git a/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake b/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake index e37d025..3e6b3a5 100644 --- a/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake @@ -20,3 +20,8 @@ if(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang" AND CMAKE_CUDA_ARCHITECTURES) endif() run_cmake(architectures-off) unset(RunCMake_TEST_OPTIONS) + +if(CMAKE_CUDA_ARCHITECTURES MATCHES "([0-9]+)") + set(arch "${CMAKE_MATCH_1}") + run_cmake_with_options(architectures-suffix -Darch=${arch}) +endif() diff --git a/Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt b/Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt index 48f379c..14c76d2 100644 --- a/Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt +++ b/Tests/RunCMake/CUDA_architectures/architectures-invalid-stderr.txt @@ -5,9 +5,9 @@ is not one of the following: - \* a semicolon-separated list of integers - - \* a special value: all, all-major, native + \* a semicolon-separated list of integers, each optionally + followed by '-real' or '-virtual' + \* a special value: all, all-major, native Call Stack \(most recent call first\): architectures-invalid\.cmake:2 \(enable_language\) diff --git a/Tests/RunCMake/CUDA_architectures/architectures-suffix-stderr.txt b/Tests/RunCMake/CUDA_architectures/architectures-suffix-stderr.txt new file mode 100644 index 0000000..7b6eb53 --- /dev/null +++ b/Tests/RunCMake/CUDA_architectures/architectures-suffix-stderr.txt @@ -0,0 +1,4 @@ +^(CMake Warning in [^ +]*/Tests/RunCMake/CUDA_architectures/architectures-suffix-build/CMakeFiles/CMakeTmp/CMakeLists.txt: + Clang doesn't support disabling CUDA real code generation. +*)*$ diff --git a/Tests/RunCMake/CUDA_architectures/architectures-suffix-stdout.txt b/Tests/RunCMake/CUDA_architectures/architectures-suffix-stdout.txt new file mode 100644 index 0000000..22ed7f6 --- /dev/null +++ b/Tests/RunCMake/CUDA_architectures/architectures-suffix-stdout.txt @@ -0,0 +1,4 @@ +-- CMAKE_CUDA_ARCHITECTURES='[0-9]+-real;[0-9]+-virtual;' +-- CMAKE_CUDA_ARCHITECTURES_ALL='[0-9;]+' +-- CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='[0-9;]+' +-- CMAKE_CUDA_ARCHITECTURES_NATIVE='[0-9;]+' diff --git a/Tests/RunCMake/CUDA_architectures/architectures-suffix.cmake b/Tests/RunCMake/CUDA_architectures/architectures-suffix.cmake new file mode 100644 index 0000000..8d7ec03 --- /dev/null +++ b/Tests/RunCMake/CUDA_architectures/architectures-suffix.cmake @@ -0,0 +1,6 @@ +set(CMAKE_CUDA_ARCHITECTURES "${arch}-real;${arch}-virtual;") +enable_language(CUDA) +message(STATUS "CMAKE_CUDA_ARCHITECTURES='${CMAKE_CUDA_ARCHITECTURES}'") +message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL='${CMAKE_CUDA_ARCHITECTURES_ALL}'") +message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='${CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR}'") +message(STATUS "CMAKE_CUDA_ARCHITECTURES_NATIVE='${CMAKE_CUDA_ARCHITECTURES_NATIVE}'") -- cgit v0.12