summaryrefslogtreecommitdiffstats
path: root/Tests/CudaOnly
diff options
context:
space:
mode:
authorRaul Tambre <raul@tambre.ee>2020-03-27 19:31:52 (GMT)
committerRaul Tambre <raul@tambre.ee>2020-05-15 15:12:39 (GMT)
commita653ca9504569eb45077ee598945b18a3c9e4ee8 (patch)
tree9e2753a976a8b43a0cc06587dcc62bb0f3008c84 /Tests/CudaOnly
parent5df21adf46be14061fe0e8ea53213d905e834600 (diff)
downloadCMake-a653ca9504569eb45077ee598945b18a3c9e4ee8.zip
CMake-a653ca9504569eb45077ee598945b18a3c9e4ee8.tar.gz
CMake-a653ca9504569eb45077ee598945b18a3c9e4ee8.tar.bz2
Tests: Update CUDA tests to work with Clang
Diffstat (limited to 'Tests/CudaOnly')
-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
7 files changed, 44 insertions, 39 deletions
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