summaryrefslogtreecommitdiffstats
path: root/Tests
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-05-18 16:28:41 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-05-18 16:29:44 (GMT)
commitb246dee7db2e7e6fcd2a00c5b2bd6db21045025f (patch)
tree7d6c9310a65d91c49e7223de20f8df274ca93e0d /Tests
parent4acf31d681ff25543a5d7615521a75ebe368fb24 (diff)
parenta653ca9504569eb45077ee598945b18a3c9e4ee8 (diff)
downloadCMake-b246dee7db2e7e6fcd2a00c5b2bd6db21045025f.zip
CMake-b246dee7db2e7e6fcd2a00c5b2bd6db21045025f.tar.gz
CMake-b246dee7db2e7e6fcd2a00c5b2bd6db21045025f.tar.bz2
Merge topic 'cuda-clang'
a653ca9504 Tests: Update CUDA tests to work with Clang 5df21adf46 CUDA: Add support for Clang compiler dc2eae1f91 FindCUDAToolkit: Factor out discovery code into a separate file 70be10cbf4 CUDA: Remove toolkit include dirs from implicit include dirs only with NVIDIA Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Artem Belevich <tra@google.com> Acked-by: Robert Maynard <robert.maynard@kitware.com> Acked-by: Axel Huebl <axel.huebl@plasma.ninja> Acked-by: friendnick <ikoval67@gmail.com> Acked-by: Patrik Huber <patrikhuber@gmail.com> Merge-request: !4442
Diffstat (limited to 'Tests')
-rw-r--r--Tests/Cuda/CMakeLists.txt11
-rw-r--r--Tests/Cuda/ProperLinkFlags/CMakeLists.txt8
-rw-r--r--Tests/CudaOnly/CMakeLists.txt37
-rw-r--r--Tests/CudaOnly/CompileFlags/CMakeLists.txt9
-rw-r--r--Tests/CudaOnly/CompileFlags/main.cu7
-rw-r--r--Tests/CudaOnly/ExportPTX/CMakeLists.txt7
-rw-r--r--Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt15
-rw-r--r--Tests/CudaOnly/WithDefs/CMakeLists.txt2
-rw-r--r--Tests/CudaOnly/WithDefs/main.notcu6
-rw-r--r--Tests/RunCMake/CMP0104/CMP0104-WARN.cmake1
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/target_link_options/RunCMakeTest.cmake12
12 files changed, 70 insertions, 48 deletions
diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt
index 58b9b03..83f2f2d 100644
--- a/Tests/Cuda/CMakeLists.txt
+++ b/Tests/Cuda/CMakeLists.txt
@@ -1,5 +1,4 @@
-ADD_TEST_MACRO(Cuda.Complex CudaComplex)
ADD_TEST_MACRO(Cuda.ConsumeCompileFeatures CudaConsumeCompileFeatures)
ADD_TEST_MACRO(Cuda.CXXStandardSetTwice CXXStandardSetTwice)
ADD_TEST_MACRO(Cuda.ObjectLibrary CudaObjectLibrary)
@@ -12,10 +11,16 @@ ADD_TEST_MACRO(Cuda.NotEnabled CudaNotEnabled)
ADD_TEST_MACRO(Cuda.SeparableCompCXXOnly SeparableCompCXXOnly)
ADD_TEST_MACRO(Cuda.Toolkit Toolkit)
ADD_TEST_MACRO(Cuda.IncludePathNoToolkit IncludePathNoToolkit)
-ADD_TEST_MACRO(Cuda.ProperDeviceLibraries ProperDeviceLibraries)
-ADD_TEST_MACRO(Cuda.ProperLinkFlags ProperLinkFlags)
ADD_TEST_MACRO(Cuda.SharedRuntimePlusToolkit SharedRuntimePlusToolkit)
+# Separable compilation is currently only supported on NVCC. Disable tests
+# using it for other compilers.
+if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
+ ADD_TEST_MACRO(Cuda.Complex CudaComplex)
+ ADD_TEST_MACRO(Cuda.ProperDeviceLibraries ProperDeviceLibraries)
+ ADD_TEST_MACRO(Cuda.ProperLinkFlags ProperLinkFlags)
+endif()
+
# The CUDA only ships the shared version of the toolkit libraries
# on windows
if(NOT WIN32)
diff --git a/Tests/Cuda/ProperLinkFlags/CMakeLists.txt b/Tests/Cuda/ProperLinkFlags/CMakeLists.txt
index b6e0e39..d38da6d 100644
--- a/Tests/Cuda/ProperLinkFlags/CMakeLists.txt
+++ b/Tests/Cuda/ProperLinkFlags/CMakeLists.txt
@@ -9,11 +9,17 @@ project (ProperLinkFlags CUDA CXX)
#Specify a set of valid CUDA flags and an invalid set of CXX flags ( for CUDA )
#to make sure we don't use the CXX flags when linking CUDA executables
-string(APPEND CMAKE_CUDA_FLAGS " -arch=sm_35 --use_fast_math")
+if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
+ string(APPEND CMAKE_CUDA_FLAGS "--use_fast_math")
+elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "Clang")
+ string(APPEND CMAKE_CUDA_FLAGS "-ffast-math")
+endif()
+
set(CMAKE_CXX_FLAGS "-Wall")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CUDA_STANDARD 11)
+set(CMAKE_CUDA_ARCHITECTURES 35)
add_executable(ProperLinkFlags file1.cu main.cxx)
set_target_properties( ProperLinkFlags
diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt
index d74e810..ee7374e 100644
--- a/Tests/CudaOnly/CMakeLists.txt
+++ b/Tests/CudaOnly/CMakeLists.txt
@@ -1,17 +1,35 @@
ADD_TEST_MACRO(CudaOnly.Architecture Architecture)
-ADD_TEST_MACRO(CudaOnly.CircularLinkLine CudaOnlyCircularLinkLine)
ADD_TEST_MACRO(CudaOnly.CompileFlags CudaOnlyCompileFlags)
ADD_TEST_MACRO(CudaOnly.EnableStandard CudaOnlyEnableStandard)
ADD_TEST_MACRO(CudaOnly.ExportPTX CudaOnlyExportPTX)
-ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag)
-ADD_TEST_MACRO(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols)
-ADD_TEST_MACRO(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation)
ADD_TEST_MACRO(CudaOnly.SharedRuntimePlusToolkit CudaOnlySharedRuntimePlusToolkit)
ADD_TEST_MACRO(CudaOnly.Standard98 CudaOnlyStandard98)
ADD_TEST_MACRO(CudaOnly.Toolkit CudaOnlyToolkit)
ADD_TEST_MACRO(CudaOnly.WithDefs CudaOnlyWithDefs)
+if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
+ # Separable compilation is currently only supported on NVCC. Disable tests
+ # using it for other compilers.
+ ADD_TEST_MACRO(CudaOnly.CircularLinkLine CudaOnlyCircularLinkLine)
+ ADD_TEST_MACRO(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols)
+ ADD_TEST_MACRO(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation)
+
+ add_test(NAME CudaOnly.DontResolveDeviceSymbols COMMAND
+ ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
+ --build-and-test
+ "${CMAKE_CURRENT_SOURCE_DIR}/DontResolveDeviceSymbols/"
+ "${CMAKE_CURRENT_BINARY_DIR}/DontResolveDeviceSymbols/"
+ ${build_generator_args}
+ --build-project DontResolveDeviceSymbols
+ --build-options ${build_options}
+ --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
+ )
+
+ # Only NVCC defines __CUDACC_DEBUG__ when compiling in debug mode.
+ ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag)
+endif()
+
# The CUDA only ships the shared version of the toolkit libraries
# on windows
if(NOT WIN32)
@@ -22,17 +40,6 @@ if(MSVC)
ADD_TEST_MACRO(CudaOnly.PDB CudaOnlyPDB)
endif()
-add_test(NAME CudaOnly.DontResolveDeviceSymbols COMMAND
- ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
- --build-and-test
- "${CMAKE_CURRENT_SOURCE_DIR}/DontResolveDeviceSymbols/"
- "${CMAKE_CURRENT_BINARY_DIR}/DontResolveDeviceSymbols/"
- ${build_generator_args}
- --build-project DontResolveDeviceSymbols
- --build-options ${build_options}
- --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>
- )
-
add_test(NAME CudaOnly.RuntimeControls COMMAND
${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION>
--build-and-test
diff --git a/Tests/CudaOnly/CompileFlags/CMakeLists.txt b/Tests/CudaOnly/CompileFlags/CMakeLists.txt
index cbce7d6..5e8a8e4 100644
--- a/Tests/CudaOnly/CompileFlags/CMakeLists.txt
+++ b/Tests/CudaOnly/CompileFlags/CMakeLists.txt
@@ -1,16 +1,15 @@
cmake_minimum_required(VERSION 3.17)
-cmake_policy(SET CMP0104 OLD)
project(CompileFlags CUDA)
-# Clear defaults.
-set(CMAKE_CUDA_ARCHITECTURES)
-
add_executable(CudaOnlyCompileFlags main.cu)
# Try passing CUDA architecture flags explicitly.
if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
target_compile_options(CudaOnlyCompileFlags PRIVATE
-gencode arch=compute_50,code=compute_50
- --compiler-options=-DHOST_DEFINE
)
+else()
+ set_property(TARGET CudaOnlyCompileFlags PROPERTY CUDA_ARCHITECTURES 50-real)
endif()
+
+target_compile_options(CudaOnlyCompileFlags PRIVATE -DALWAYS_DEFINE)
diff --git a/Tests/CudaOnly/CompileFlags/main.cu b/Tests/CudaOnly/CompileFlags/main.cu
index 573d230..999c056 100644
--- a/Tests/CudaOnly/CompileFlags/main.cu
+++ b/Tests/CudaOnly/CompileFlags/main.cu
@@ -4,11 +4,8 @@
# endif
#endif
-// Check HOST_DEFINE only for nvcc
-#ifndef __CUDA__
-# ifndef HOST_DEFINE
-# error "HOST_DEFINE not defined!"
-# endif
+#ifndef ALWAYS_DEFINE
+# error "ALWAYS_DEFINE not defined!"
#endif
int main()
diff --git a/Tests/CudaOnly/ExportPTX/CMakeLists.txt b/Tests/CudaOnly/ExportPTX/CMakeLists.txt
index ff6e77c..ee5f54d 100644
--- a/Tests/CudaOnly/ExportPTX/CMakeLists.txt
+++ b/Tests/CudaOnly/ExportPTX/CMakeLists.txt
@@ -34,16 +34,15 @@ static std::string ptx_paths = "$<TARGET_OBJECTS:CudaPTX>";
# need to also pass the --name option
set(output_file ${CMAKE_CURRENT_BINARY_DIR}/embedded_objs.h)
-get_filename_component(cuda_compiler_bin "${CMAKE_CUDA_COMPILER}" DIRECTORY)
+find_package(CUDAToolkit REQUIRED)
find_program(bin_to_c
NAMES bin2c
- PATHS ${cuda_compiler_bin}
+ PATHS ${CUDAToolkit_BIN_DIR}
)
if(NOT bin_to_c)
message(FATAL_ERROR
"bin2c not found:\n"
- " CMAKE_CUDA_COMPILER='${CMAKE_CUDA_COMPILER}'\n"
- " cuda_compiler_bin='${cuda_compiler_bin}'\n"
+ " CUDAToolkit_BIN_DIR='${CUDAToolkit_BIN_DIR}'\n"
)
endif()
diff --git a/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt b/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt
index fbef15f..325723a 100644
--- a/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt
+++ b/Tests/CudaOnly/GPUDebugFlag/CMakeLists.txt
@@ -2,18 +2,19 @@
cmake_minimum_required(VERSION 3.7)
project (GPUDebugFlag CUDA)
-#Goal for this example:
-#verify that -G enables gpu debug flags
-string(APPEND CMAKE_CUDA_FLAGS " -gencode=arch=compute_30,code=compute_30")
-string(APPEND CMAKE_CUDA_FLAGS " -G")
set(CMAKE_CUDA_STANDARD 11)
+set(CMAKE_CUDA_ARCHITECTURES 30)
+
+# Goal for this example:
+# Verify that enabling device debug works.
+string(APPEND CMAKE_CUDA_FLAGS "-G")
add_executable(CudaOnlyGPUDebugFlag main.cu)
+#CUDA's __CUDACC_DEBUG__ define was added in NVCC 9.0
+#so if we are below 9.0.0 we will manually add the define so that the test
+#passes
if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 9.0.0)
- #CUDA's __CUDACC_DEBUG__ define was added in 9.0
- #so if we are below 9.0.0 we will manually add the define so that the test
- #passes
target_compile_definitions(CudaOnlyGPUDebugFlag PRIVATE "__CUDACC_DEBUG__")
endif()
diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt
index add8131..0ed81d8 100644
--- a/Tests/CudaOnly/WithDefs/CMakeLists.txt
+++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt
@@ -18,7 +18,7 @@ target_compile_options(CudaOnlyWithDefs
PRIVATE
-DFLAG_COMPILE_LANG_$<COMPILE_LANGUAGE>
-DFLAG_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA>
- --compiler-options=-DHOST_DEFINE
+ $<$<CUDA_COMPILER_ID:NVIDIA>:--compiler-options=-DHOST_DEFINE> # Host-only defines are possible only on NVCC.
)
target_compile_definitions(CudaOnlyWithDefs
diff --git a/Tests/CudaOnly/WithDefs/main.notcu b/Tests/CudaOnly/WithDefs/main.notcu
index a5f4ed6..9119eba 100644
--- a/Tests/CudaOnly/WithDefs/main.notcu
+++ b/Tests/CudaOnly/WithDefs/main.notcu
@@ -7,8 +7,10 @@
# error "INC_CUDA not defined!"
#endif
-#ifndef HOST_DEFINE
-# error "HOST_DEFINE not defined!"
+#ifdef __NVCC__
+# ifndef HOST_DEFINE
+# error "HOST_DEFINE not defined!"
+# endif
#endif
#ifndef PACKED_DEFINE
diff --git a/Tests/RunCMake/CMP0104/CMP0104-WARN.cmake b/Tests/RunCMake/CMP0104/CMP0104-WARN.cmake
index 841d0a8..2b4a8f5 100644
--- a/Tests/RunCMake/CMP0104/CMP0104-WARN.cmake
+++ b/Tests/RunCMake/CMP0104/CMP0104-WARN.cmake
@@ -1 +1,2 @@
include(CMP0104-Common.cmake)
+set_property(TARGET cuda PROPERTY CUDA_ARCHITECTURES)
diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
index 6472f46..449db4a 100644
--- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
@@ -285,7 +285,8 @@ run_cmake_command(NoUnusedVariables ${CMAKE_COMMAND} ${CMAKE_CURRENT_LIST_DIR}
"-DCMAKE_DEFAULT_CONFIGS=all"
)
-if(CMake_TEST_CUDA)
+# CudaSimple uses separable compilation, which is currently only supported on NVCC.
+if(CMake_TEST_CUDA AND CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CudaSimple-build)
run_cmake_configure(CudaSimple)
include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake)
diff --git a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake
index b919f48..2035eb4 100644
--- a/Tests/RunCMake/target_link_options/RunCMakeTest.cmake
+++ b/Tests/RunCMake/target_link_options/RunCMakeTest.cmake
@@ -50,10 +50,14 @@ if (NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
run_cmake_target(genex_DEVICE_LINK interface LinkOptions_shared_interface --config Release)
run_cmake_target(genex_DEVICE_LINK private LinkOptions_private --config Release)
if (CMake_TEST_CUDA)
- run_cmake_target(genex_DEVICE_LINK CMP0105_UNSET LinkOptions_CMP0105_UNSET --config Release)
- run_cmake_target(genex_DEVICE_LINK CMP0105_OLD LinkOptions_CMP0105_OLD --config Release)
- run_cmake_target(genex_DEVICE_LINK CMP0105_NEW LinkOptions_CMP0105_NEW --config Release)
- run_cmake_target(genex_DEVICE_LINK device LinkOptions_device --config Release)
+ # Separable compilation is only supported on NVCC.
+ if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
+ run_cmake_target(genex_DEVICE_LINK CMP0105_UNSET LinkOptions_CMP0105_UNSET --config Release)
+ run_cmake_target(genex_DEVICE_LINK CMP0105_OLD LinkOptions_CMP0105_OLD --config Release)
+ run_cmake_target(genex_DEVICE_LINK CMP0105_NEW LinkOptions_CMP0105_NEW --config Release)
+ run_cmake_target(genex_DEVICE_LINK device LinkOptions_device --config Release)
+ endif()
+
run_cmake_target(genex_DEVICE_LINK no_device LinkOptions_no_device --config Release)
endif()