Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 1 addition & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.18)
cmake_minimum_required(VERSION 3.24)

#
# Setting a cmake_policy to OLD is deprecated by definition and will raise a
Expand All @@ -24,16 +24,6 @@ if(POLICY CMP0127)
cmake_policy(SET CMP0127 NEW)
endif()

#
# CMake 3.18+: CMAKE_CUDA_ARCHITECTURES
# https://cmake.org/cmake/help/latest/policy/CMP0104.html
# We have to migrate there, but maybe the new "native" option (CMake 3.24+)
# is what we want to wait for:
# https://cmake.org/cmake/help/v3.24/prop_tgt/CUDA_ARCHITECTURES.html
if(POLICY CMP0104)
cmake_policy(SET CMP0104 OLD)
endif()

#
# Prevent in-source builds
#
Expand Down
11 changes: 1 addition & 10 deletions Tools/CMake/AMReXCUDAOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,7 @@ endmacro ()
#
message(STATUS "Enabled CUDA options:")

set(AMReX_CUDA_ARCH_DEFAULT "Auto")
if(DEFINED CMAKE_CUDA_ARCHITECTURES)
set(AMReX_CUDA_ARCH_DEFAULT "${CMAKE_CUDA_ARCHITECTURES}")
endif ()
if(DEFINED ENV{AMREX_CUDA_ARCH})
set(AMReX_CUDA_ARCH_DEFAULT "$ENV{AMREX_CUDA_ARCH}")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us keep that $ENV{AMREX_CUDA_ARCH} hint to avoid breakage for users.

If found, we simply set the default for CMAKE_CUDA_ARCHITECTURES to it.

endif()
set(AMReX_CUDA_ARCH ${AMReX_CUDA_ARCH_DEFAULT} CACHE STRING "CUDA architecture (Use 'Auto' for automatic detection)")

option(AMReX_CUDA_FASTMATH "Enable CUDA fastmath" ON) # Note: inconsistent with AMReX_FASTMATH defaults
option(AMReX_CUDA_FASTMATH "Enable CUDA fastmath" ON)
cuda_print_option( AMReX_CUDA_FASTMATH )

set(AMReX_CUDA_MAXREGCOUNT "255" CACHE STRING
Expand Down
10 changes: 8 additions & 2 deletions Tools/CMake/AMReXParallelBackends.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,14 @@ if ( AMReX_GPU_BACKEND STREQUAL "CUDA"
)
endforeach()

# Take care of cuda archs
set_cuda_architectures(AMReX_CUDA_ARCH)
# default to building for the architecture of the available GPU
set(AMREX_CUDA_ARCHS native)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great!


# but, if the user specifies architectures explicitly then use that instead
if (DEFINED CMAKE_CUDA_ARCHITECTURES)
set(AMREX_CUDA_ARCHS ${CMAKE_CUDA_ARCHITECTURES})
endif()

foreach(D IN LISTS AMReX_SPACEDIM)
set_target_properties(amrex_${D}d
PROPERTIES
Expand Down
Loading