mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-11 08:20:18 -06:00
CUDA: Convert tests to use CUDA_ARCHITECTURES
This commit is contained in:
@@ -1,9 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(CXXStandardSetTwice CXX CUDA)
|
||||
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30)
|
||||
|
||||
add_executable(CXXStandardSetTwice main.cu)
|
||||
target_compile_features(CXXStandardSetTwice PUBLIC cxx_std_11)
|
||||
|
||||
@@ -15,7 +15,7 @@ project (Complex CXX CUDA)
|
||||
#and also building cpp targets that need cuda implicit libraries
|
||||
|
||||
#verify that we can pass explicit cuda arch flags
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30)
|
||||
set(CMAKE_CUDA_STANDARD 11)
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CUDA_STANDARD_REQUIRED TRUE)
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(MixedStandardLevels1 CXX CUDA)
|
||||
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14)
|
||||
set(CMAKE_CUDA_STANDARD 11)
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30)
|
||||
|
||||
add_executable(MixedStandardLevels1 main.cu lib.cpp)
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(MixedStandardLevels2 CXX CUDA)
|
||||
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17) #this can decay
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30)
|
||||
|
||||
add_executable(MixedStandardLevels2 main.cu lib.cpp)
|
||||
target_compile_features(MixedStandardLevels2 PUBLIC cuda_std_11)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(MixedStandardLevels3 CXX CUDA)
|
||||
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30)
|
||||
|
||||
add_executable(MixedStandardLevels3 main.cu lib.cpp)
|
||||
target_compile_features(MixedStandardLevels3 PUBLIC cuda_std_03 cxx_std_14)
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(MixedStandardLevels4 CXX CUDA)
|
||||
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
|
||||
|
||||
set(CMAKE_CUDA_STANDARD 03)
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30)
|
||||
|
||||
add_executable(MixedStandardLevels4 main.cu lib.cpp)
|
||||
target_compile_features(MixedStandardLevels4 PUBLIC cxx_std_14)
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(MixedStandardLevels5 CXX CUDA)
|
||||
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 98)
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30)
|
||||
|
||||
add_executable(MixedStandardLevels5 main.cu lib.cpp)
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
project(ProperDeviceLibraries CXX CUDA)
|
||||
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_35,code=compute_35 -gencode arch=compute_35,code=sm_35")
|
||||
set(CMAKE_CUDA_STANDARD 11)
|
||||
set(CMAKE_CUDA_ARCHITECTURES 35)
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(WithC CUDA C)
|
||||
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30)
|
||||
|
||||
add_executable(CudaWithC main.c cuda.cu)
|
||||
|
||||
|
||||
@@ -5,9 +5,9 @@ project (CircularLinkLine CUDA)
|
||||
# Verify that we de-duplicate the device link line
|
||||
# Verify that a de-duplicated link line still works with circular static libraries
|
||||
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30]")
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CUDA_STANDARD 11)
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30)
|
||||
|
||||
add_library(CUDACircularDeviceLinking1 STATIC file1.cu)
|
||||
add_library(CUDACircularDeviceLinking2 STATIC file2.cu)
|
||||
|
||||
@@ -24,9 +24,9 @@ endif()
|
||||
# Don't resolve the device symbols in the static library
|
||||
# Don't resolve the device symbols in the executable library
|
||||
# Verify that we can't use those device symbols from anything
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30] -gencode arch=compute_50,code=\\\"compute_50\\\"")
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
set(CMAKE_CUDA_STANDARD 11)
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30 50)
|
||||
set(CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS OFF)
|
||||
|
||||
add_library(CUDANoDeviceResolve SHARED file1.cu)
|
||||
|
||||
@@ -21,7 +21,7 @@ endif()
|
||||
# confirming that the first static library is on the device link line
|
||||
# 3. Verify that we can't use those device symbols from anything that links
|
||||
# to the static library
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[sm_30] -gencode arch=compute_50,code=\\\"compute_50\\\"")
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30 50)
|
||||
|
||||
add_library(CUDAResolveDeviceDepsA STATIC file1.cu)
|
||||
add_library(CUDAResolveDeviceDepsB STATIC file2.cu)
|
||||
|
||||
@@ -15,9 +15,8 @@ else()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30]")
|
||||
|
||||
set(CMAKE_CUDA_STANDARD 11)
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30)
|
||||
set(CMAKE_CUDA_RUNTIME_LIBRARY static)
|
||||
|
||||
if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC")
|
||||
|
||||
@@ -9,9 +9,7 @@ project (SeparateCompilation CUDA)
|
||||
#and executables.
|
||||
#We complicate the matter by also testing that multiple static libraries
|
||||
#all containing cuda separable compilation code links properly
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=\\\"compute_30,sm_30,sm_35\\\"")
|
||||
string(APPEND CMAKE_CUDA_FLAGS " --generate-code=arch=compute_50,code=[compute_50,sm_50,sm_52]")
|
||||
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30 35 50 52)
|
||||
set(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
|
||||
add_library(CUDASeparateLibA STATIC file1.cu file2.cu file3.cu)
|
||||
target_compile_features(CUDASeparateLibA PRIVATE cuda_std_11)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
project(CudaOnlyStandard98 CUDA)
|
||||
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30)
|
||||
|
||||
# Support setting CUDA Standard to 98 which internally gets transformed to
|
||||
# CUDA03
|
||||
|
||||
@@ -3,17 +3,7 @@ cmake_minimum_required(VERSION 3.7)
|
||||
project (WithDefs CUDA)
|
||||
|
||||
#verify that we can pass explicit cuda arch flags
|
||||
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
|
||||
if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 9)
|
||||
set(debug_compile_flags --generate-code arch=compute_32,code=sm_32)
|
||||
else()
|
||||
set(debug_compile_flags --generate-code arch=compute_20,code=sm_20)
|
||||
endif()
|
||||
if(CMAKE_CUDA_SIMULATE_ID STREQUAL "MSVC")
|
||||
list(APPEND debug_compile_flags -Xcompiler=-WX)
|
||||
else()
|
||||
list(APPEND debug_compile_flags -Xcompiler=-Werror)
|
||||
endif()
|
||||
set(CMAKE_CUDA_ARCHITECTURES 30)
|
||||
set(release_compile_defs DEFREL)
|
||||
|
||||
#Goal for this example:
|
||||
@@ -29,7 +19,6 @@ target_compile_options(CudaOnlyWithDefs
|
||||
-DFLAG_COMPILE_LANG_$<COMPILE_LANGUAGE>
|
||||
-DFLAG_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA>
|
||||
--compiler-options=-DHOST_DEFINE
|
||||
$<$<CONFIG:DEBUG>:$<BUILD_INTERFACE:${debug_compile_flags}>>
|
||||
)
|
||||
|
||||
target_compile_definitions(CudaOnlyWithDefs
|
||||
|
||||
Reference in New Issue
Block a user