From f0931b07905a960c7dfbcc90e772219150c24951 Mon Sep 17 00:00:00 2001 From: Raul Tambre Date: Fri, 27 Mar 2020 20:52:39 +0200 Subject: CUDA: Convert tests to use CUDA_ARCHITECTURES --- Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt | 3 +-- Tests/Cuda/Complex/CMakeLists.txt | 2 +- Tests/Cuda/MixedStandardLevels1/CMakeLists.txt | 3 +-- Tests/Cuda/MixedStandardLevels2/CMakeLists.txt | 3 +-- Tests/Cuda/MixedStandardLevels3/CMakeLists.txt | 2 +- Tests/Cuda/MixedStandardLevels4/CMakeLists.txt | 3 +-- Tests/Cuda/MixedStandardLevels5/CMakeLists.txt | 3 +-- Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt | 2 +- Tests/Cuda/WithC/CMakeLists.txt | 2 +- Tests/CudaOnly/CircularLinkLine/CMakeLists.txt | 2 +- Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt | 2 +- Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt | 2 +- Tests/CudaOnly/RuntimeControls/CMakeLists.txt | 3 +-- Tests/CudaOnly/SeparateCompilation/CMakeLists.txt | 4 +--- Tests/CudaOnly/Standard98/CMakeLists.txt | 2 +- Tests/CudaOnly/WithDefs/CMakeLists.txt | 13 +------------ 16 files changed, 16 insertions(+), 35 deletions(-) diff --git a/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt b/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt index 1941c49..f4ad83a 100644 --- a/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt +++ b/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt @@ -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) diff --git a/Tests/Cuda/Complex/CMakeLists.txt b/Tests/Cuda/Complex/CMakeLists.txt index 08d1e16..265bd85 100644 --- a/Tests/Cuda/Complex/CMakeLists.txt +++ b/Tests/Cuda/Complex/CMakeLists.txt @@ -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) diff --git a/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt index b03e51e..e40ffa6 100644 --- a/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt +++ b/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt @@ -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) diff --git a/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt index 12dd328..7af8081 100644 --- a/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt +++ b/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt @@ -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) diff --git a/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt index 2b611be..2c42003 100644 --- a/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt +++ b/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt @@ -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) diff --git a/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt index faf6869..230230d 100644 --- a/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt +++ b/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt @@ -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) diff --git a/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt index 7209f60..5f5ee06 100644 --- a/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt +++ b/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt @@ -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) diff --git a/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt index cb47b09..fe28c3e 100644 --- a/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt +++ b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt @@ -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) diff --git a/Tests/Cuda/WithC/CMakeLists.txt b/Tests/Cuda/WithC/CMakeLists.txt index 69aa3f9..049cbce 100644 --- a/Tests/Cuda/WithC/CMakeLists.txt +++ b/Tests/Cuda/WithC/CMakeLists.txt @@ -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) diff --git a/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt b/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt index 5e6f7ab..e10a348 100644 --- a/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt +++ b/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt @@ -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) diff --git a/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt index 6e3697f..1265660 100644 --- a/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt +++ b/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt @@ -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) diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt index 57aa0b9..bd94ec8 100644 --- a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt +++ b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt @@ -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) diff --git a/Tests/CudaOnly/RuntimeControls/CMakeLists.txt b/Tests/CudaOnly/RuntimeControls/CMakeLists.txt index 8b58fec..0da5739 100644 --- a/Tests/CudaOnly/RuntimeControls/CMakeLists.txt +++ b/Tests/CudaOnly/RuntimeControls/CMakeLists.txt @@ -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") diff --git a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt index c1bd64a..586be81 100644 --- a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt +++ b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt @@ -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) diff --git a/Tests/CudaOnly/Standard98/CMakeLists.txt b/Tests/CudaOnly/Standard98/CMakeLists.txt index ef9a685..3ba0360 100644 --- a/Tests/CudaOnly/Standard98/CMakeLists.txt +++ b/Tests/CudaOnly/Standard98/CMakeLists.txt @@ -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 diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt index ba9bf04..add8131 100644 --- a/Tests/CudaOnly/WithDefs/CMakeLists.txt +++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt @@ -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_$ -DFLAG_LANG_IS_CUDA=$ --compiler-options=-DHOST_DEFINE - $<$:$> ) target_compile_definitions(CudaOnlyWithDefs -- cgit v0.12