Skip to content

Commit

Permalink
Build only for a single compute capability if not specified
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Feb 22, 2024
1 parent 1f173b8 commit c5911a3
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions cmake/cuda_architecture_macros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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()

0 comments on commit c5911a3

Please sign in to comment.