Pārlūkot izejas kodu

Merge topic 'cuda_tests_no_hardcoded_sm_values' into release-4.0

83a0c72a2d ci: Tell CudaOnly.CompileFlags test what specific architecture to use

Acked-by: Kitware Robot <[email protected]>
Merge-request: !10701
Brad King 7 mēneši atpakaļ
vecāks
revīzija
1e6356e67f

+ 1 - 0
Tests/CudaOnly/CMakeLists.txt

@@ -7,6 +7,7 @@ endmacro ()
 set(CudaOnly.Architecture_BUILD_OPTIONS -DCMake_TEST_CUDA_ARCH=${CMake_TEST_CUDA_ARCH})
 add_cuda_test_macro(CudaOnly.Architecture Architecture)
 add_cuda_test_macro(CudaOnly.ArchSpecial CudaOnlyArchSpecial)
+set(CudaOnly.CompileFlags_BUILD_OPTIONS -DCMake_TEST_CUDA_ARCH=${CMake_TEST_CUDA_ARCH})
 add_cuda_test_macro(CudaOnly.CompileFlags CudaOnlyCompileFlags)
 add_cuda_test_macro(CudaOnly.EnableStandard CudaOnlyEnableStandard)
 add_cuda_test_macro(CudaOnly.ExportPTX CudaOnlyExportPTX)

+ 9 - 2
Tests/CudaOnly/CompileFlags/CMakeLists.txt

@@ -1,16 +1,23 @@
 cmake_minimum_required(VERSION 3.17)
 project(CompileFlags CUDA)
 
+if(CMake_TEST_CUDA_ARCH)
+  set(arch ${CMake_TEST_CUDA_ARCH})
+else()
+  set(arch 52)
+endif()
+
 add_executable(CudaOnlyCompileFlags main.cu)
+target_compile_definitions(CudaOnlyCompileFlags PRIVATE EXPECT_CUDA_ARCH=${arch})
 
 # 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
+    -gencode arch=compute_${arch},code=compute_${arch}
   )
   set_property(TARGET CudaOnlyCompileFlags PROPERTY CUDA_ARCHITECTURES)
 else()
-  set_property(TARGET CudaOnlyCompileFlags PROPERTY CUDA_ARCHITECTURES 50-real)
+  set_property(TARGET CudaOnlyCompileFlags PROPERTY CUDA_ARCHITECTURES ${arch}-real)
 endif()
 
 target_compile_options(CudaOnlyCompileFlags PRIVATE -DALWAYS_DEFINE)

+ 5 - 2
Tests/CudaOnly/CompileFlags/main.cu

@@ -1,6 +1,9 @@
+#ifndef EXPECT_CUDA_ARCH
+#  error "EXPECT_CUDA_ARCH not defined!"
+#endif
 #ifdef __CUDA_ARCH__
-#  if __CUDA_ARCH__ != 500
-#    error "Passed architecture 50, but got something else."
+#  if __CUDA_ARCH__ != (EXPECT_CUDA_ARCH * 10)
+#    error "__CUDA_ARCH__ does not match CUDA_ARCHITECTURES"
 #  endif
 #endif