From 138436609fbc1d4dd9f0cac8c1a5ed3e53446091 Mon Sep 17 00:00:00 2001 From: Brad King Date: Tue, 16 Apr 2024 15:09:58 -0400 Subject: CUDA: Fix detection of default C++ standard level with MSVC host compiler --- Modules/CMakeCUDACompilerId.cu.in | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Modules/CMakeCUDACompilerId.cu.in b/Modules/CMakeCUDACompilerId.cu.in index be8f1b3..cecb948 100644 --- a/Modules/CMakeCUDACompilerId.cu.in +++ b/Modules/CMakeCUDACompilerId.cu.in @@ -22,7 +22,15 @@ char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; #define CXX_STD_20 202002L #define CXX_STD_23 202302L -#define CXX_STD __cplusplus +#if defined(_MSC_VER) && defined(_MSVC_LANG) +# if _MSVC_LANG > __cplusplus +# define CXX_STD _MSVC_LANG +# else +# define CXX_STD __cplusplus +# endif +#else +# define CXX_STD __cplusplus +#endif const char* info_language_standard_default = "INFO" ":" "standard_default[" #if CXX_STD > CXX_STD_23 -- cgit v0.12 From 1f4060442116511dddae5e322c824b92eb309e52 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 17 Apr 2024 12:08:02 -0400 Subject: Tests/CompileFeatures: Cover CUDA default standard level --- Tests/CMakeLists.txt | 2 ++ Tests/CompileFeatures/CMakeLists.txt | 16 ++++++++++++++++ Tests/CompileFeatures/default_dialect.cu | 1 + 3 files changed, 19 insertions(+) create mode 100644 Tests/CompileFeatures/default_dialect.cu diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index fa388e0..42d958c 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -398,8 +398,10 @@ if(BUILD_TESTING) set(CompileFeatures_BUILD_OPTIONS -DCMake_TEST_C_STANDARDS=${TEST_STDS_C} -DCMake_TEST_CXX_STANDARDS=${TEST_STDS_CXX} + -DCMake_TEST_CUDA=${CMake_TEST_CUDA} ) ADD_TEST_MACRO(CompileFeatures CompileFeatures) + set_property(TEST CompileFeatures APPEND PROPERTY LABELS "CUDA") ADD_TEST_MACRO(CMakeCommands.target_compile_features) diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index d6acd7b..8f118f3 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -298,6 +298,22 @@ if (CMAKE_CXX_COMPILE_FEATURES) endif() endif () +if (CMake_TEST_CUDA + AND CMAKE_CUDA_COMPILE_FEATURES + AND CMAKE_CUDA_STANDARD_DEFAULT + AND NOT CMAKE_CUDA_FLAGS MATCHES "-std=") + add_executable(default_dialect_cuda default_dialect.cu) + target_compile_definitions(default_dialect_cuda PRIVATE + DEFAULT_CXX26=$ + DEFAULT_CXX23=$ + DEFAULT_CXX20=$ + DEFAULT_CXX17=$ + DEFAULT_CXX14=$ + DEFAULT_CXX11=$ + DEFAULT_CXX98=$ + ) +endif () + # always add a target "CompileFeatures" if ((NOT CXX_expected_features) OR (NOT cxx_auto_type IN_LIST CXX_expected_features)) diff --git a/Tests/CompileFeatures/default_dialect.cu b/Tests/CompileFeatures/default_dialect.cu new file mode 100644 index 0000000..a549a5c --- /dev/null +++ b/Tests/CompileFeatures/default_dialect.cu @@ -0,0 +1 @@ +#include "default_dialect.cpp" -- cgit v0.12 From 011f3d1dd345500969f106093dbc6a046e3f6365 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 19 Apr 2024 08:35:32 -0400 Subject: Tests/CompileFeatures: Fix c_std_23 case with Clang < 14 Generalize the `__STDC_VERSION__` exception previously added for AppleClang < 14 to also cover LLVM/Clang < 14. Although the two vendors do not follow the same version scheme, the major versions happen to match in this case. --- Tests/CompileFeatures/c_std_23.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Tests/CompileFeatures/c_std_23.c b/Tests/CompileFeatures/c_std_23.c index 6073b552..a60a16e 100644 --- a/Tests/CompileFeatures/c_std_23.c +++ b/Tests/CompileFeatures/c_std_23.c @@ -1,6 +1,5 @@ #include "c_std.h" #if defined(C_STD) && C_STD <= C_STD_17 && \ - !(C_STD == C_STD_17 && defined(__apple_build_version__) && \ - defined(__clang_major__) && __clang_major__ < 14) + !(C_STD == C_STD_17 && defined(__clang_major__) && __clang_major__ < 14) # error "c_std_23 not honored" #endif -- cgit v0.12 From fb0990ef04ab3c3f56bb6399403fc563b9dc89f8 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 17 Apr 2024 12:05:29 -0400 Subject: Tests/CompileFeatures: Cover cuda_std_## meta-features --- .gitlab/ci/configure_cuda12.2_clang.cmake | 1 + .gitlab/ci/configure_cuda12.2_nvidia.cmake | 1 + Tests/CMakeLists.txt | 2 ++ Tests/CompileFeatures/CMakeLists.txt | 8 +++++++- Tests/CompileFeatures/cuda_std_03.cu | 0 Tests/CompileFeatures/cuda_std_11.cu | 4 ++++ Tests/CompileFeatures/cuda_std_14.cu | 4 ++++ Tests/CompileFeatures/cuda_std_17.cu | 4 ++++ Tests/CompileFeatures/cuda_std_20.cu | 4 ++++ Tests/CompileFeatures/cuda_std_23.cu | 4 ++++ Tests/CompileFeatures/cuda_std_26.cu | 4 ++++ 11 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 Tests/CompileFeatures/cuda_std_03.cu create mode 100644 Tests/CompileFeatures/cuda_std_11.cu create mode 100644 Tests/CompileFeatures/cuda_std_14.cu create mode 100644 Tests/CompileFeatures/cuda_std_17.cu create mode 100644 Tests/CompileFeatures/cuda_std_20.cu create mode 100644 Tests/CompileFeatures/cuda_std_23.cu create mode 100644 Tests/CompileFeatures/cuda_std_26.cu diff --git a/.gitlab/ci/configure_cuda12.2_clang.cmake b/.gitlab/ci/configure_cuda12.2_clang.cmake index e13ca88..8f10f86 100644 --- a/.gitlab/ci/configure_cuda12.2_clang.cmake +++ b/.gitlab/ci/configure_cuda12.2_clang.cmake @@ -1,3 +1,4 @@ set(CMake_TEST_CUDA "Clang" CACHE STRING "") +set(CMake_TEST_CUDA_STANDARDS "03;11;14;17;20;23" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/configure_cuda12.2_nvidia.cmake b/.gitlab/ci/configure_cuda12.2_nvidia.cmake index 2cb2950..51a2511 100644 --- a/.gitlab/ci/configure_cuda12.2_nvidia.cmake +++ b/.gitlab/ci/configure_cuda12.2_nvidia.cmake @@ -1,4 +1,5 @@ set(CMake_TEST_CUDA "NVIDIA" CACHE STRING "") set(CMake_TEST_CUDA_CUPTI "ON" CACHE STRING "") +set(CMake_TEST_CUDA_STANDARDS "03;11;14;17;20" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 42d958c..5d9d193 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -395,10 +395,12 @@ if(BUILD_TESTING) string(REPLACE ";" "$" TEST_STDS_C "${CMake_TEST_C_STANDARDS}") string(REPLACE ";" "$" TEST_STDS_CXX "${CMake_TEST_CXX_STANDARDS}") + string(REPLACE ";" "$" TEST_STDS_CUDA "${CMake_TEST_CUDA_STANDARDS}") set(CompileFeatures_BUILD_OPTIONS -DCMake_TEST_C_STANDARDS=${TEST_STDS_C} -DCMake_TEST_CXX_STANDARDS=${TEST_STDS_CXX} -DCMake_TEST_CUDA=${CMake_TEST_CUDA} + -DCMake_TEST_CUDA_STANDARDS=${TEST_STDS_CUDA} ) ADD_TEST_MACRO(CompileFeatures CompileFeatures) set_property(TEST CompileFeatures APPEND PROPERTY LABELS "CUDA") diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index 8f118f3..469a085 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -9,7 +9,13 @@ set(ext_CXX cpp) set(std_C 90 99 11 17 23) set(std_CXX 98 11 14 17 20 23 26) -foreach(lang C CXX) +if(CMake_TEST_CUDA) + enable_language(CUDA) + set(ext_CUDA cu) + set(std_CUDA 03 11 14 17 20 23 26) +endif() + +foreach(lang C CXX CUDA) foreach(std IN LISTS std_${lang}) string(TOLOWER "${lang}_std_${std}" feature) if("${std}" IN_LIST CMake_TEST_${lang}_STANDARDS diff --git a/Tests/CompileFeatures/cuda_std_03.cu b/Tests/CompileFeatures/cuda_std_03.cu new file mode 100644 index 0000000..e69de29 diff --git a/Tests/CompileFeatures/cuda_std_11.cu b/Tests/CompileFeatures/cuda_std_11.cu new file mode 100644 index 0000000..76813fd --- /dev/null +++ b/Tests/CompileFeatures/cuda_std_11.cu @@ -0,0 +1,4 @@ +#include "cxx_std.h" +#if defined(CXX_STD) && CXX_STD < CXX_STD_11 +# error "cuda_std_11 not honored" +#endif diff --git a/Tests/CompileFeatures/cuda_std_14.cu b/Tests/CompileFeatures/cuda_std_14.cu new file mode 100644 index 0000000..53e23c8 --- /dev/null +++ b/Tests/CompileFeatures/cuda_std_14.cu @@ -0,0 +1,4 @@ +#include "cxx_std.h" +#if defined(CXX_STD) && CXX_STD <= CXX_STD_11 +# error "cuda_std_14 not honored" +#endif diff --git a/Tests/CompileFeatures/cuda_std_17.cu b/Tests/CompileFeatures/cuda_std_17.cu new file mode 100644 index 0000000..502defb --- /dev/null +++ b/Tests/CompileFeatures/cuda_std_17.cu @@ -0,0 +1,4 @@ +#include "cxx_std.h" +#if defined(CXX_STD) && CXX_STD <= CXX_STD_14 +# error "cuda_std_17 not honored" +#endif diff --git a/Tests/CompileFeatures/cuda_std_20.cu b/Tests/CompileFeatures/cuda_std_20.cu new file mode 100644 index 0000000..afdd3ba --- /dev/null +++ b/Tests/CompileFeatures/cuda_std_20.cu @@ -0,0 +1,4 @@ +#include "cxx_std.h" +#if defined(CXX_STD) && CXX_STD <= CXX_STD_17 +# error "cuda_std_20 not honored" +#endif diff --git a/Tests/CompileFeatures/cuda_std_23.cu b/Tests/CompileFeatures/cuda_std_23.cu new file mode 100644 index 0000000..6bdaeb9 --- /dev/null +++ b/Tests/CompileFeatures/cuda_std_23.cu @@ -0,0 +1,4 @@ +#include "cxx_std.h" +#if defined(CXX_STD) && CXX_STD <= CXX_STD_20 +# error "cuda_std_23 not honored" +#endif diff --git a/Tests/CompileFeatures/cuda_std_26.cu b/Tests/CompileFeatures/cuda_std_26.cu new file mode 100644 index 0000000..efeca8d --- /dev/null +++ b/Tests/CompileFeatures/cuda_std_26.cu @@ -0,0 +1,4 @@ +#include "cxx_std.h" +#if defined(CXX_STD) && CXX_STD <= CXX_STD_23 +# error "cuda_std_26 not honored" +#endif -- cgit v0.12