mirror of
https://gitlab.kitware.com/vtk/vtk-m
synced 2024-10-08 11:29:02 +00:00
CMAKE: add CMAKE_CUDA_ARCHITECTURE support
This commit is contained in:
parent
626c806772
commit
af129132cc
@ -98,8 +98,10 @@ foreach(option IN LISTS options)
|
||||
elseif(volta STREQUAL option)
|
||||
set(VTKm_CUDA_Architecture "volta" CACHE STRING "")
|
||||
|
||||
# From turing we set the architecture using the cannonical
|
||||
# CMAKE_CUDA_ARCHITECTURES
|
||||
elseif(turing STREQUAL option)
|
||||
set(VTKm_CUDA_Architecture "turing" CACHE STRING "")
|
||||
set(CMAKE_CUDA_ARCHITECTURES "75" CACHE STRING "")
|
||||
|
||||
elseif(hip STREQUAL option)
|
||||
if(CMAKE_VERSION VERSION_LESS_EQUAL 3.20)
|
||||
@ -165,7 +167,7 @@ if(SCCACHE_COMMAND)
|
||||
|
||||
# Use VTKm_CUDA_Architecture to determine if we need CUDA sccache setup
|
||||
# since this will also capture when kokkos is being used with CUDA backing
|
||||
if(DEFINED VTKm_CUDA_Architecture)
|
||||
if(DEFINED VTKm_CUDA_Architecture OR DEFINED CMAKE_CUDA_ARCHITECTURES)
|
||||
set(CMAKE_CUDA_COMPILER_LAUNCHER "${SCCACHE_COMMAND}" CACHE STRING "")
|
||||
endif()
|
||||
endif()
|
||||
|
@ -115,8 +115,15 @@ endif()
|
||||
# replace this with setting `cuda_architecture_flags` as part of the
|
||||
# EXPORT_PROPERTIES of the vtkm_cuda target
|
||||
if(VTKm_ENABLE_CUDA AND VTKM_FROM_INSTALL_DIR)
|
||||
set_target_properties(vtkm::cuda PROPERTIES cuda_architecture_flags "@VTKm_CUDA_Architecture_Flags@")
|
||||
set_target_properties(vtkm::cuda PROPERTIES requires_static_builds TRUE)
|
||||
|
||||
set_target_properties(vtkm::cuda PROPERTIES
|
||||
|
||||
# Canonical way of setting CUDA arch
|
||||
CUDA_ARCHITECTURES "@CMAKE_CUDA_ARCHITECTURES@"
|
||||
|
||||
# Legacy way of setting CUDA arch
|
||||
cuda_architecture_flags "@VTKm_CUDA_Architecture_Flags@"
|
||||
requires_static_builds TRUE)
|
||||
|
||||
# If VTK-m is built with 3.18+ and the consumer is < 3.18 we need to drop
|
||||
# these properties as they break the VTK-m cuda flag logic
|
||||
|
@ -108,10 +108,25 @@ if(VTKm_ENABLE_CUDA)
|
||||
target_compile_features(vtkm_cuda INTERFACE cxx_std_14)
|
||||
endif()
|
||||
|
||||
# If we have specified CMAKE_CUDA_ARCHITECTURES and CMake >= 3.18 we are
|
||||
# done setting up vtkm_cuda.
|
||||
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES OR CMAKE_VERSION VERSION_LESS 3.18)
|
||||
|
||||
# Recommend user to use CMAKE_CUDA_ARCHITECTURES instead
|
||||
if(DEFINED VTKm_CUDA_Architecture AND CMAKE_VERSION VERSION_GREATER_EQUAL 3.18)
|
||||
message(DEPRECATION "VTKm_CUDA_Architecture used, use CMAKE_CUDA_ARCHITECTURES instead in CMake >= 3.18")
|
||||
endif()
|
||||
|
||||
# We disable CMAKE_CUDA_ARCHITECTURES since we add the arch manually
|
||||
set(CMAKE_CUDA_ARCHITECTURES OFF)
|
||||
|
||||
# add the -gencode flags so that all cuda code
|
||||
# way compiled properly
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# When using CMAKE >= 3.18 use instead CMAKE_CUDA_ARCHITECTURES since it
|
||||
# is the canonical way to specify archs in modern CMAKE.
|
||||
#
|
||||
# Populates CMAKE_CUDA_FLAGS with the best set of flags to compile for a
|
||||
# given GPU architecture. The majority of developers should leave the
|
||||
# option at the default of 'native' which uses system introspection to
|
||||
@ -207,7 +222,8 @@ if(VTKm_ENABLE_CUDA)
|
||||
elseif(VTKm_CUDA_Architecture STREQUAL "maxwell")
|
||||
set(arch_flags --generate-code=arch=compute_50,code=sm_50)
|
||||
elseif(VTKm_CUDA_Architecture STREQUAL "pascal")
|
||||
set(arch_flags --generate-code=arch=compute_60,code=sm_60)
|
||||
set(arch_flags --generate-code=arch=compute_60,code=sm_60
|
||||
--generate-code=arch=compute_61,code=sm_61)
|
||||
elseif(VTKm_CUDA_Architecture STREQUAL "volta")
|
||||
set(arch_flags --generate-code=arch=compute_70,code=sm_70)
|
||||
elseif(VTKm_CUDA_Architecture STREQUAL "turing")
|
||||
@ -233,7 +249,6 @@ if(VTKm_ENABLE_CUDA)
|
||||
endif()
|
||||
|
||||
if(policy_105_enabled STREQUAL "NEW")
|
||||
set(CMAKE_CUDA_ARCHITECTURES OFF)
|
||||
target_compile_options(vtkm_cuda INTERFACE $<$<COMPILE_LANGUAGE:CUDA>:${arch_flags}>)
|
||||
target_link_options(vtkm_cuda INTERFACE $<DEVICE_LINK:${arch_flags}>)
|
||||
else()
|
||||
@ -250,6 +265,7 @@ if(VTKm_ENABLE_CUDA)
|
||||
unset(arch_flags)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Kokkos with its Cuda backend enabled, expects everything to be compiled using its
|
||||
|
@ -373,8 +373,6 @@ function(vtkm_add_target_information uses_vtkm_target)
|
||||
set_target_properties(${targets} PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
set_target_properties(${targets} PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
|
||||
endif()
|
||||
# CUDA_ARCHITECTURES added in CMake 3.18
|
||||
set_target_properties(${targets} PROPERTIES CUDA_ARCHITECTURES OFF)
|
||||
|
||||
if(VTKm_TI_DROP_UNUSED_SYMBOLS)
|
||||
foreach(target IN LISTS targets)
|
||||
|
10
docs/changelog/enable-cmake-cuda-architectures.md
Normal file
10
docs/changelog/enable-cmake-cuda-architectures.md
Normal file
@ -0,0 +1,10 @@
|
||||
## Enable CMAKE_CUDA_ARCHITECTURES
|
||||
|
||||
When using _CMake_ > 3.18, `CMAKE_CUDA_ARCHITECTURES` can now be used instead of
|
||||
`VTKm_CUDA_Architecture` to specify the list of architectures desired for the
|
||||
compilation of _CUDA_ sources.
|
||||
|
||||
Since `CMAKE_CUDA_ARCHITECTURES` is the canonical method of specifying _CUDA_
|
||||
architectures in _CMake_ and it is more flexible, for instance we can also
|
||||
specify _CUDA_ virtual architectures, from _CMake_ 3.18 explicitly setting
|
||||
`VTKm_CUDA_Architecture` will be deprecated whilst still supported.
|
Loading…
Reference in New Issue
Block a user