From c5911a379a6eafc71c9b8b2df8ea22a0a2eff7ce Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 22 Feb 2024 15:54:15 +0200 Subject: [PATCH] Build only for a single compute capability if not specified --- cmake/cuda_architecture_macros.cmake | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/cmake/cuda_architecture_macros.cmake b/cmake/cuda_architecture_macros.cmake index b18f3d5f..e2f3ac8b 100644 --- a/cmake/cuda_architecture_macros.cmake +++ b/cmake/cuda_architecture_macros.cmake @@ -28,19 +28,12 @@ function(get_available_cuda_architectures CUDA_ARCHITECTURES) set(${CUDA_ARCHITECTURES} "${ARCHITECTURES}" PARENT_SCOPE) endfunction() -# Sets the default value of CMAKE_CUDA_ARCHITECTURES effectively to "all": -# compile for all supported real (minor) architecture versions, and the highest virtual architecture version. +# Set the default CUDA architecture to either "native" or the lowest common denominator supported by CUDA 12 function(init_cmake_cuda_architectures) - get_available_cuda_architectures(ALL_ARCHITECTURES) - set(CMAKE_CUDA_ARCHITECTURES "") - foreach(arch ${ALL_ARCHITECTURES}) - # Skip deprecated 3.x architectures - if (arch GREATER_EQUAL 50) - list(APPEND CMAKE_CUDA_ARCHITECTURES "${arch}-real") - endif() - endforeach() - list(GET ALL_ARCHITECTURES -1 latest) - list(APPEND CMAKE_CUDA_ARCHITECTURES "${latest}-virtual") - set(CMAKE_CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}") + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24") + set(CMAKE_CUDA_ARCHITECTURES "native") + else() + set(CMAKE_CUDA_ARCHITECTURES "52") + endif() set(CMAKE_CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}" PARENT_SCOPE) endfunction()