mirror of
https://github.com/reactos/CMake.git
synced 2024-11-27 05:20:34 +00:00
Tests: Update CUDA tests to work with Clang
This commit is contained in:
parent
5df21adf46
commit
a653ca9504
@ -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)
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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()
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1 +1,2 @@
|
||||
include(CMP0104-Common.cmake)
|
||||
set_property(TARGET cuda PROPERTY CUDA_ARCHITECTURES)
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user