CUDA: Add CudaOnly.CompileFlags test

Covers passing compile flags explicitly for both NVCC and Clang.
This commit is contained in:
Raul Tambre 2020-03-27 21:32:38 +02:00
parent f0931b0790
commit 21131ca60c
3 changed files with 33 additions and 0 deletions

View File

@ -1,6 +1,7 @@
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)

View File

@ -0,0 +1,16 @@
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
)
endif()

View File

@ -0,0 +1,16 @@
#ifdef __CUDA_ARCH__
# if __CUDA_ARCH__ != 500
# error "Passed architecture 50, but got something else."
# endif
#endif
// Check HOST_DEFINE only for nvcc
#ifndef __CUDA__
# ifndef HOST_DEFINE
# error "HOST_DEFINE not defined!"
# endif
#endif
int main()
{
}