diff --git a/.github/workflows/catalyst.yml b/.github/workflows/catalyst.yml index fd312d913c8..a6a907880d7 100644 --- a/.github/workflows/catalyst.yml +++ b/.github/workflows/catalyst.yml @@ -10,6 +10,8 @@ jobs: check_changes: uses: ./.github/workflows/check_changes.yml + # Container build scripts: + # https://gitlab.kitware.com/christos.tsolakis/catalyst-amrex-docker-images catalyst: name: Catalyst runs-on: ubuntu-22.04 @@ -20,7 +22,7 @@ jobs: CC: gcc CMAKE_PREFIX_PATH: "/opt/conduit:/opt/catalyst" container: - image: kitware/paraview:ci-catalyst-amrex-warpx-20240701 + image: kitware/paraview:ci-catalyst-amrex-warpx-20240828 steps: - uses: actions/checkout@v5 - name: Configure diff --git a/.github/workflows/sensei.yml b/.github/workflows/sensei.yml index 144f95dc299..65adf6c6fb8 100644 --- a/.github/workflows/sensei.yml +++ b/.github/workflows/sensei.yml @@ -12,7 +12,9 @@ jobs: check_changes: uses: ./.github/workflows/check_changes.yml + # deprecated / unsupported test_sensei: + if: 0 name: SENSEI Adaptor [test] runs-on: ubuntu-24.04 needs: check_changes diff --git a/CMakeLists.txt b/CMakeLists.txt index d3d99f6e7c8..ef89c955acf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.25) # # Setting a cmake_policy to OLD is deprecated by definition and will raise a @@ -27,11 +27,13 @@ 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: +# We us the new "native" option (CMake 3.24+): # https://cmake.org/cmake/help/v3.24/prop_tgt/CUDA_ARCHITECTURES.html +if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES) + set(CMAKE_CUDA_ARCHITECTURES native) +endif() if(POLICY CMP0104) - cmake_policy(SET CMP0104 OLD) + cmake_policy(SET CMP0104 NEW) endif() # @@ -106,9 +108,6 @@ include( AMReXOptions ) # if (AMReX_CUDA) enable_language(CUDA) - if(CMAKE_VERSION VERSION_LESS 3.20) - include(AMReX_SetupCUDA) - endif() endif () # diff --git a/Docs/sphinx_documentation/source/BuildingAMReX_Chapter.rst b/Docs/sphinx_documentation/source/BuildingAMReX_Chapter.rst index d5bb2acdb7c..c07aca2e2c0 100644 --- a/Docs/sphinx_documentation/source/BuildingAMReX_Chapter.rst +++ b/Docs/sphinx_documentation/source/BuildingAMReX_Chapter.rst @@ -23,7 +23,7 @@ Fortran compiler that supports the Fortran 2003 standard, and a C compiler that supports the C99 standard. Prerequisites for building with GNU Make include Python (>= 2.7, including 3) and standard tools available in any Unix-like environments (e.g., Perl and sed). For -building with CMake, the minimal requirement is version 3.18. +building with CMake, the minimal requirement is version 3.25. Please note that we fully support AMReX for Linux systems in general and on the DOE supercomputers (e.g. Cori, Summit) in particular. Many of our users do build diff --git a/Docs/sphinx_documentation/source/GPU.rst b/Docs/sphinx_documentation/source/GPU.rst index 9e370b8ee20..cfb66a3c960 100644 --- a/Docs/sphinx_documentation/source/GPU.rst +++ b/Docs/sphinx_documentation/source/GPU.rst @@ -251,7 +251,7 @@ check the :ref:`table ` below. +------------------------------+-------------------------------------------------+-------------+-----------------+ | Variable Name | Description | Default | Possible values | +==============================+=================================================+=============+=================+ - | AMReX_CUDA_ARCH | CUDA target architecture | Auto | User-defined | + | AMReX_CUDA_ARCH | CUDA target architecture | native | User-defined | +------------------------------+-------------------------------------------------+-------------+-----------------+ | AMReX_CUDA_FASTMATH | Enable CUDA fastmath library | YES | YES, NO | +------------------------------+-------------------------------------------------+-------------+-----------------+ @@ -297,7 +297,7 @@ For example, on Cori GPUs you can specify the architecture as follows: :: - cmake [options] -DAMReX_GPU_BACKEND=CUDA -DAMReX_CUDA_ARCH=Volta /path/to/amrex/source + cmake [options] -DAMReX_GPU_BACKEND=CUDA -DAMReX_CUDA_ARCH="80;90" /path/to/amrex/source If no architecture is specified, CMake will default to the architecture defined in the @@ -305,7 +305,7 @@ If no architecture is specified, CMake will default to the architecture defined If the latter is not defined, CMake will try to determine which GPU architecture is supported by the system. If more than one is found, CMake will build for all of them. If autodetection fails, a list of "common" architectures is assumed. -`Multiple CUDA architectures `__ can also be set manually as semicolon-separated list, e.g. ``-DAMReX_CUDA_ARCH=7.0;8.0``. +`Multiple CUDA architectures `__ can also be set manually as semicolon-separated list, e.g. ``-DAMReX_CUDA_ARCH="80;90"``. Building for multiple CUDA architectures will generally result in a larger library and longer build times. **Note that AMReX supports NVIDIA GPU architectures with compute capability 6.0 or higher and @@ -323,8 +323,7 @@ the following code into the appropriate CMakeLists.txt file: If instead of using an external installation of AMReX you prefer to include AMReX as a subproject -in your CMake setup, we strongly encourage you to use the ``AMReX_SetupCUDA`` module as shown below -if the CMake version is less than 3.20: +in your CMake setup (i.e., build AMReX on the fly), do this: .. highlight:: console @@ -333,12 +332,7 @@ if the CMake version is less than 3.20: # Enable CUDA in your CMake project enable_language(CUDA) - # Include the AMReX-provided CUDA setup module -- OBSOLETE with CMake >= 3.20 - if(CMAKE_VERSION VERSION_LESS 3.20) - include(AMReX_SetupCUDA) - endif() - - # Include AMReX source directory ONLY AFTER the two steps above + # Include AMReX source directory ONLY AFTER enable_language add_subdirectory(/path/to/amrex/source/dir) diff --git a/Tests/CMakeTestInstall/CMakeLists.txt b/Tests/CMakeTestInstall/CMakeLists.txt index 32fa809e57d..3609a264d4f 100644 --- a/Tests/CMakeTestInstall/CMakeLists.txt +++ b/Tests/CMakeTestInstall/CMakeLists.txt @@ -3,7 +3,7 @@ # building and running the code # in Tests/Amr/Advection_AmrCore/ # -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.25) project(amrex-test-install) diff --git a/Tests/SpackSmokeTest/CMakeLists.txt b/Tests/SpackSmokeTest/CMakeLists.txt index 6dd4a24528f..84b525c7f96 100644 --- a/Tests/SpackSmokeTest/CMakeLists.txt +++ b/Tests/SpackSmokeTest/CMakeLists.txt @@ -6,7 +6,7 @@ # against a currently installed version of AMReX. The resulting # executable can then be ran to test functionality. -cmake_minimum_required(VERSION 3.18) +cmake_minimum_required(VERSION 3.25) project(amrex-test-install) @@ -26,9 +26,6 @@ if (AMReX_GPU_BACKEND STREQUAL "CUDA") find_package(AMReX REQUIRED CUDA) elseif(AMReX_GPU_BACKEND STREQUAL "HIP") - if(CMAKE_VERSION VERSION_LESS 3.20) - message(FATAL_ERROR "HIP requires CMake version 3.20 or newer") - endif() find_package(AMReX REQUIRED HIP) find_package(rocrand REQUIRED CONFIG) find_package(rocprim REQUIRED CONFIG) @@ -83,10 +80,13 @@ target_link_libraries(install_test PUBLIC AMReX::amrex) # Additional CUDA configuration commands if (AMReX_GPU_BACKEND STREQUAL "CUDA") + if (AMREX_CUDA_ARCHS) + set_target_properties(install_test PROPERTIES + CUDA_ARCHITECTURES "${AMREX_CUDA_ARCHS}") + endif() set_target_properties(install_test PROPERTIES - LANGUAGE CUDA - CUDA_ARCHITECTURES "${AMREX_CUDA_ARCHS}" - CUDA_SEPARABLE_COMPILATION ON) + LANGUAGE CUDA + CUDA_SEPARABLE_COMPILATION ON) get_target_property(Source_Files install_test SOURCES) list(FILTER Source_Files INCLUDE REGEX "\\.cpp$") diff --git a/Tools/CMake/AMReXCUDAOptions.cmake b/Tools/CMake/AMReXCUDAOptions.cmake index cce0306f4b9..ede174e9296 100644 --- a/Tools/CMake/AMReXCUDAOptions.cmake +++ b/Tools/CMake/AMReXCUDAOptions.cmake @@ -17,14 +17,15 @@ 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}") -endif() -set(AMReX_CUDA_ARCH ${AMReX_CUDA_ARCH_DEFAULT} CACHE STRING "CUDA architecture (Use 'Auto' for automatic detection)") +elseif(DEFINED CMAKE_CUDA_ARCHITECTURES) + set(AMReX_CUDA_ARCH_DEFAULT "${CMAKE_CUDA_ARCHITECTURES}") +else() + set(AMReX_CUDA_ARCH_DEFAULT "native") +endif () +set(AMReX_CUDA_ARCH ${AMReX_CUDA_ARCH_DEFAULT} CACHE STRING "CUDA architecture (Use 'native' for automatic detection)") +set(CMAKE_CUDA_ARCHITECTURES "${AMReX_CUDA_ARCH}" CACHE STRING "" FORCE) option(AMReX_CUDA_FASTMATH "Enable CUDA fastmath" ON) # Note: inconsistent with AMReX_FASTMATH defaults cuda_print_option( AMReX_CUDA_FASTMATH ) diff --git a/Tools/CMake/AMReXConfig.cmake.in b/Tools/CMake/AMReXConfig.cmake.in index e14aae279c6..3a2ecafbe20 100644 --- a/Tools/CMake/AMReXConfig.cmake.in +++ b/Tools/CMake/AMReXConfig.cmake.in @@ -256,11 +256,7 @@ endif () # # AMReX 21.06+ supports CUDA_ARCHITECTURES if (@AMReX_CUDA@) - if (CMAKE_VERSION VERSION_LESS 3.20) - include(AMReX_SetupCUDA) - else () - find_dependency(CUDAToolkit REQUIRED) - endif () + find_dependency(CUDAToolkit REQUIRED) endif () # CMake targets @@ -275,7 +271,7 @@ if (NOT TARGET AMReX::amrex) # protection in case of multiple inclusions endif() # More Modern CUDA CMake -if (@CMAKE_VERSION@ VERSION_GREATER_EQUAL 3.20 AND @AMReX_CUDA@) +if (@AMReX_CUDA@) foreach(D IN LISTS AMReX_SPACEDIM) # CUDA architectures amrex was built for -- should we make set(AMREX_CUDA_ARCHS @AMREX_CUDA_ARCHS@ CACHE INTERNAL "CUDA archs AMReX is built for") diff --git a/Tools/CMake/AMReXFlagsTargets.cmake b/Tools/CMake/AMReXFlagsTargets.cmake index f11bfa8df53..aaad50efa9f 100644 --- a/Tools/CMake/AMReXFlagsTargets.cmake +++ b/Tools/CMake/AMReXFlagsTargets.cmake @@ -25,42 +25,21 @@ include_guard(GLOBAL) # = cxx,fortran,cuda # = gnu,intel,pgi,cray,clang,appleclang,crayclang,ibmclang,intelllvm,msvc,nvidia,nvhpc,xlclang # -if (CMAKE_VERSION VERSION_LESS 3.20) - foreach (_language CXX Fortran CUDA ) - set(_comp_lang "$") - string(TOLOWER "${_language}" _lang) - - foreach (_comp GNU Intel PGI Cray Clang AppleClang CrayClang IBMClang IntelLLVM MSVC NVIDIA NVHPC XLClang ) - string(TOLOWER "${_comp}" _id) - # Define variables - set(_comp_id "$<${_language}_COMPILER_ID:${_comp}>") - set(_${_lang}_${_id} "$") - set(_${_lang}_${_id}_dbg "$>") - set(_${_lang}_${_id}_rel "$>") - set(_${_lang}_${_id}_rwdbg "$>") - unset(_comp_id) - endforeach () - - unset(_comp_lang) - unset(_lang) - endforeach () -else () - foreach (_language CXX Fortran CUDA ) - string(TOLOWER "${_language}" _lang) - - foreach (_comp GNU Intel PGI Cray Clang AppleClang CrayClang IBMClang IntelLLVM MSVC NVIDIA NVHPC XLClang ) - string(TOLOWER "${_comp}" _id) - # Define variables - set(_${_lang}_${_id} "$") - set(_${_lang}_${_id}_dbg "$>") - set(_${_lang}_${_id}_rel "$>") - set(_${_lang}_${_id}_rwdbg "$>") - unset(_id) - endforeach () - - unset(_lang) - endforeach () -endif () +foreach (_language CXX Fortran CUDA ) + string(TOLOWER "${_language}" _lang) + + foreach (_comp GNU Intel PGI Cray Clang AppleClang CrayClang IBMClang IntelLLVM MSVC NVIDIA NVHPC XLClang ) + string(TOLOWER "${_comp}" _id) + # Define variables + set(_${_lang}_${_id} "$") + set(_${_lang}_${_id}_dbg "$>") + set(_${_lang}_${_id}_rel "$>") + set(_${_lang}_${_id}_rwdbg "$>") + unset(_id) + endforeach () + + unset(_lang) +endforeach () # diff --git a/Tools/CMake/AMReXParallelBackends.cmake b/Tools/CMake/AMReXParallelBackends.cmake index 5206c479ba6..22298a5f7b1 100644 --- a/Tools/CMake/AMReXParallelBackends.cmake +++ b/Tools/CMake/AMReXParallelBackends.cmake @@ -70,9 +70,7 @@ endif () # # # -if ( AMReX_GPU_BACKEND STREQUAL "CUDA" - AND - CMAKE_VERSION VERSION_GREATER_EQUAL 3.20 ) +if (AMReX_GPU_BACKEND STREQUAL "CUDA") find_package(CUDAToolkit REQUIRED) foreach(D IN LISTS AMReX_SPACEDIM) @@ -82,11 +80,9 @@ if ( AMReX_GPU_BACKEND STREQUAL "CUDA" target_link_libraries(amrex_${D}d PUBLIC CUDA::cusparse) endif () - if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 11.2) - # nvToolsExt: if tiny profiler or base profiler are on. - if (AMReX_TINY_PROFILE OR AMReX_BASE_PROFILE) - target_link_libraries(amrex_${D}d PUBLIC CUDA::nvToolsExt) - endif () + # if tiny profiler or base profiler are on we add range annotations + if (AMReX_TINY_PROFILE OR AMReX_BASE_PROFILE) + target_link_libraries(amrex_${D}d PUBLIC CUDA::nvtx3) endif () endforeach() @@ -110,13 +106,14 @@ if ( AMReX_GPU_BACKEND STREQUAL "CUDA" endforeach() # Take care of cuda archs - set_cuda_architectures(AMReX_CUDA_ARCH) - foreach(D IN LISTS AMReX_SPACEDIM) - set_target_properties(amrex_${D}d - PROPERTIES - CUDA_ARCHITECTURES "${AMREX_CUDA_ARCHS}" - ) - endforeach() + if (AMREX_CUDA_ARCHS) + foreach(D IN LISTS AMReX_SPACEDIM) + set_target_properties(amrex_${D}d + PROPERTIES + CUDA_ARCHITECTURES "${AMREX_CUDA_ARCHS}" + ) + endforeach() + endif() # # CUDA specific warnings @@ -378,14 +375,9 @@ if (AMReX_HIP) foreach(D IN LISTS AMReX_SPACEDIM) target_compile_options(amrex_${D}d PUBLIC $<$:-fgpu-rdc> ) - if(CMAKE_VERSION VERSION_LESS 3.18) - target_link_options(amrex_${D}d PUBLIC - -fgpu-rdc) - else() - target_link_options(amrex_${D}d PUBLIC - "$<$:-fgpu-rdc>" - "$<$:-fgpu-rdc>") - endif() + target_link_options(amrex_${D}d PUBLIC + "$<$:-fgpu-rdc>" + "$<$:-fgpu-rdc>") endforeach() endif() endif () diff --git a/Tools/CMake/AMReXTargetHelpers.cmake b/Tools/CMake/AMReXTargetHelpers.cmake index 5c46322d812..18e48e1ff28 100644 --- a/Tools/CMake/AMReXTargetHelpers.cmake +++ b/Tools/CMake/AMReXTargetHelpers.cmake @@ -127,12 +127,11 @@ function (setup_target_for_cuda_compilation _target) PROPERTIES CUDA_SEPARABLE_COMPILATION ${AMReX_GPU_RDC} # This adds -dc ) - set_cpp_sources_to_cuda_language(${_target}) - - if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.20) + if (AMREX_CUDA_ARCHS) set_target_properties( ${_target} PROPERTIES CUDA_ARCHITECTURES "${AMREX_CUDA_ARCHS}" ) endif () + set_cpp_sources_to_cuda_language(${_target}) endfunction () diff --git a/Tools/CMake/AMReXThirdPartyLibraries.cmake b/Tools/CMake/AMReXThirdPartyLibraries.cmake index b8ad503e83f..0d377087c88 100644 --- a/Tools/CMake/AMReXThirdPartyLibraries.cmake +++ b/Tools/CMake/AMReXThirdPartyLibraries.cmake @@ -59,13 +59,7 @@ if (AMReX_HDF5) endif () foreach(D IN LISTS AMReX_SPACEDIM) - if (TARGET hdf5::hdf5) # CMake >= 3.19 - target_link_libraries(amrex_${D}d PUBLIC hdf5::hdf5) - else () # CMake < 3.19 -- Remove when minimum cmake version is bumped up - target_include_directories(amrex_${D}d PUBLIC ${HDF5_INCLUDE_DIRS}) - target_compile_definitions(amrex_${D}d PUBLIC ${HDF5_DEFINITIONS}) - target_link_libraries(amrex_${D}d PUBLIC ${HDF5_LIBRARIES}) - endif () + target_link_libraries(amrex_${D}d PUBLIC hdf5::hdf5) endforeach() endif () @@ -81,12 +75,7 @@ if (AMReX_HDF5_ZFP) endif () foreach(D IN LISTS AMReX_SPACEDIM) - if (TARGET h5z_zfp::h5z_zfp) # CMake >= 3.19 - target_link_libraries(amrex_${D}d PUBLIC h5z_zfp::h5z_zfp) - else () # CMake < 3.19 -- Remove when minimum cmake version is bumped up - target_include_directories(amrex_${D}d PUBLIC ${H5Z_ZFP_INCLUDE_DIR}) - target_link_libraries(amrex_${D}d PUBLIC ${H5Z_ZFP_LIBRARY}) - endif () + target_link_libraries(amrex_${D}d PUBLIC h5z_zfp::h5z_zfp) endforeach() endif () diff --git a/Tools/CMake/AMReXUtils.cmake b/Tools/CMake/AMReXUtils.cmake index c79895879a3..85f5dcd7276 100644 --- a/Tools/CMake/AMReXUtils.cmake +++ b/Tools/CMake/AMReXUtils.cmake @@ -201,161 +201,3 @@ function (check_cuda_host_compiler) endif () endif () endfunction () - - -# -# -# FUNCTION: convert_cuda_archs -# -# -# cuda_select_nvcc_arch_flags accepts CUDA architecture in the form of -# names (Turing, Volta, ...) or decimal numbers (10.0, 9.0, ...). -# However, CMAKE_CUDA_ARCHITECTURES only accepts integer numbers. -# We need to convert the latter to decimal format, else cuda_select_nvcc_arch_flags -# will complain -# -# Arguments: -# -# _cuda_archs = the target architecture(s) -# -# -function (convert_cuda_archs _cuda_archs) - - foreach (_item IN LISTS ${_cuda_archs}) - # remove -real suffixes - string(REGEX REPLACE "\\-real$" "" _item "${_item}") - - string(REGEX MATCH "\\." _has_decimal "${_item}") - string(REGEX MATCH "[0-9]+" _is_number "${_item}") - - if (NOT _has_decimal AND _is_number) - math(EXPR _int "${_item}/10" OUTPUT_FORMAT DECIMAL) - math(EXPR _mod "${_item}%10" OUTPUT_FORMAT DECIMAL) - if(_int LESS 10) # CMake 3.30 does not support SM 10.0+ in cuda_select_nvcc_arch_flags - list(APPEND _tmp "${_int}.${_mod}") - endif() - else () - if(_item LESS 10) # CMake 3.30 does not support SM 10.0+ in cuda_select_nvcc_arch_flags - list(APPEND _tmp ${_item}) - endif() - endif() - endforeach () - - set(${_cuda_archs} ${_tmp} PARENT_SCOPE) - -endfunction () - - -# -# -# FUNCTION: set_cuda_architectures -# -# -# Detects the cuda capabilities of the GPU and set the internal -# variable AMREX_CUDA_ARCHS. -# -# Arguments: -# -# _cuda_archs = the target architecture(s) (select "Auto" for autodetection) -# -# Note: if no target arch is specified, it will try to determine -# which GPU architecture is supported by the system. If more than one is found, -# it will build for all of them. -# If autodetection fails, a list of "common" architectures is assumed. -# -function (set_cuda_architectures _cuda_archs) - - set(_archs ${${_cuda_archs}}) - convert_cuda_archs(_archs) - - include(FindCUDA/select_compute_arch) - cuda_select_nvcc_arch_flags(_nvcc_arch_flags ${_archs}) - - # Extract architecture number: anything less than 6.0 must go - string(REPLACE "-gencode;" "-gencode=" _nvcc_arch_flags "${_nvcc_arch_flags}") - - foreach (_item IN LISTS _nvcc_arch_flags) - # Match one time the regex [0-9]+. - # [0-9]+ means any number between 0 and 9 will be matched one or more times (option +) - string(REGEX MATCH "[0-9]+" _cuda_compute_capability "${_item}") - - if (_cuda_compute_capability LESS 60) - message(STATUS "Ignoring unsupported CUDA architecture ${_cuda_compute_capability}") - else () - list(APPEND _tmp ${_cuda_compute_capability}) - endif () - endforeach () - - set(AMREX_CUDA_ARCHS ${_tmp} CACHE INTERNAL "CUDA archs AMReX is built for") - -endfunction() - - -# -# -# FUNCTION: set_nvcc_arch_flags -# -# -# Detects the cuda capabilities of the GPU and set the internal -# variable NVCC_ARCH_FLAGS. -# -# Arguments: -# -# _cuda_archs = the target architecture(s) (select "Auto" for autodetection) -# _lto = true if LTO flags are required -# -# Note: if no target arch is specified, it will try to determine -# which GPU architecture is supported by the system. If more than one is found, -# it will build for all of them. -# If autodetection fails, a list of “common” architectures is assumed. -# -function (set_nvcc_arch_flags _cuda_archs _lto) - - set(_archs ${${_cuda_archs}}) - convert_cuda_archs(_archs) - - include(FindCUDA/select_compute_arch) - cuda_select_nvcc_arch_flags(_nvcc_arch_flags ${_archs}) - - # - # Remove unsupported architecture: anything less than 3.5 must go - # - string(REPLACE "-gencode;" "-gencode=" _nvcc_arch_flags "${_nvcc_arch_flags}") - - foreach (_item IN LISTS _nvcc_arch_flags) - # Match one time the regex [0-9]+. - # [0-9]+ means any number between 0 and 9 will be matched one or more times (option +) - string(REGEX MATCH "[0-9]+" _cuda_compute_capability "${_item}") - - if (_cuda_compute_capability LESS 35) - message(STATUS "Ignoring unsupported CUDA architecture ${_cuda_compute_capability}") - list(REMOVE_ITEM _nvcc_arch_flags ${_item}) - endif () - - endforeach () - - if (${_lto}) - # we replace - # -gencode=arch=compute_NN,code=sm_NN - # with - # -gencode=arch=compute_NN,code=lto_NN - set(_nvcc_arch_flags_org ${_nvcc_arch_flags}) - foreach (_item IN LISTS _nvcc_arch_flags_org) - string(REGEX MATCH "[0-9]+" _cuda_compute_capability "${_item}") - string(REPLACE "code=sm_${_cuda_compute_capability}" - "code=lto_${_cuda_compute_capability}" - _nvcc_arch_flags "${_nvcc_arch_flags}") - endforeach () - endif () - - if (NOT _nvcc_arch_flags) - message(FATAL_ERROR "the given target CUDA architectures are not supported by AMReX") - endif () - - # - # Set architecture-dependent flags - # - string(REPLACE ";" " " _nvcc_arch_flags "${_nvcc_arch_flags}") - set(NVCC_ARCH_FLAGS ${_nvcc_arch_flags} CACHE INTERNAL "CUDA architecture-dependent flags") - -endfunction() diff --git a/Tools/CMake/AMReX_SetupCUDA.cmake b/Tools/CMake/AMReX_SetupCUDA.cmake deleted file mode 100644 index d921f817b46..00000000000 --- a/Tools/CMake/AMReX_SetupCUDA.cmake +++ /dev/null @@ -1,143 +0,0 @@ -include_guard(GLOBAL) - -include(CMakeDependentOption) - -if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.20) - message(WARNING "\nAMReX_SetupCUDA is deprecated for CMake >= 3.20: it will not be processed!\n") - return() -endif () - -get_property(_lang GLOBAL PROPERTY ENABLED_LANGUAGES) -if (NOT ("CUDA" IN_LIST _lang )) - message(WARNING "AMReX_SetupCUDA will not be processed because CUDA language has not been enabled.") - return() -endif () - -# -# Check CUDA compiler and host compiler -# -include(AMReXUtils) -set_mininum_compiler_version(CUDA NVIDIA 10.0) -check_cuda_host_compiler() - -# -# CUDA-related options -# -include(AMReXCUDAOptions) - -# -# Find cuda flags for target architecture. -# -set_nvcc_arch_flags(AMReX_CUDA_ARCH AMReX_CUDA_LTO) - - -# CUDA compiler is in the form CUDA_HOME/bin/compiler-name -# Remove bin/compiler-name to get CUDA HOME -get_filename_component(_cuda_home ${CMAKE_CUDA_COMPILER} DIRECTORY) # remove compiler from path -get_filename_component(_cuda_home ${_cuda_home} DIRECTORY) # remove bin/ from path -set( CUDA_HOME ${_cuda_home} CACHE INTERNAL "Path to CUDA library") -unset(_cuda_home) - - -# We gotta set CUDA flags globally since there is no other way at this time to pass CUDA flags to -# device linking stage -if (NOT (CMAKE_SYSTEM_NAME STREQUAL "Windows" ) ) - # CUDA only supports 64bit builds on windows ( 32bit builds are deprecated ). - # Thus the option "--machine 64" is being set by the msbuild configuration. - # For Linux and MAC, we need to enforce that manually - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -m64") -endif () -string(APPEND CMAKE_CUDA_FLAGS " --expt-relaxed-constexpr --expt-extended-lambda") -string(APPEND CMAKE_CUDA_FLAGS " -Wno-deprecated-gpu-targets ${NVCC_ARCH_FLAGS}") -string(APPEND CMAKE_CUDA_FLAGS " -maxrregcount=${AMReX_CUDA_MAXREGCOUNT}") - -# This is to work around a bug with nvcc, see: https://github.com/kokkos/kokkos/issues/1473 -string(APPEND CMAKE_CUDA_FLAGS " -Xcudafe --diag_suppress=esa_on_defaulted_function_ignored") - -# and another bug related to implicit returns with if constexpr, see: https://stackoverflow.com/questions/64523302/cuda-missing-return-statement-at-end-of-non-void-function-in-constexpr-if-fun -string(APPEND CMAKE_CUDA_FLAGS " -Xcudafe --diag_suppress=implicit_return_from_non_void_function") - -if (AMReX_CUDA_FASTMATH) - set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} --use_fast_math") -endif () - -# -# Print numbers for warnings and errors -# -set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcudafe --display_error_number") - - -# -# CUDA specific warnings -# -if (AMReX_CUDA_WARN_CAPTURE_THIS) - string(APPEND CMAKE_CUDA_FLAGS " --Wext-lambda-captures-this") -endif() -if (AMReX_CUDA_ERROR_CAPTURE_THIS) - # note: prefer double-dash --Werror! - # https://github.com/ccache/ccache/issues/598 - string(APPEND CMAKE_CUDA_FLAGS " --Werror ext-lambda-captures-this") -endif() - -if (AMReX_CUDA_ERROR_CROSS_EXECUTION_SPACE_CALL) - string(APPEND CMAKE_CUDA_FLAGS " --Werror cross-execution-space-call") -endif() - -# -# Forward unknown NVCC flags to the host compiler -# -if (CUDA_FORWARD_UNKNOWN_FLAGS_HOST) - string(APPEND CMAKE_CUDA_FLAGS " --forward-unknown-to-host-compiler") -endif() - -# -# Code generation -# -if (AMReX_CUDA_PTX_VERBOSE) - string(APPEND CMAKE_CUDA_FLAGS " --ptxas-options=-v") -endif() - -# keep intermediately generated files -if (AMReX_CUDA_KEEP_FILES) - make_directory("${PROJECT_BINARY_DIR}/nvcc_tmp") - string(APPEND CMAKE_CUDA_FLAGS " --keep --keep-dir ${PROJECT_BINARY_DIR}/nvcc_tmp") -endif () - -# place intermediate files in object file folder -if (AMReX_CUDA_OBJDIR_AS_TEMPDIR) - string(APPEND CMAKE_CUDA_FLAGS " --objdir-as-tempdir") -endif () - -# compilation timings -if (AMReX_CUDA_COMPILATION_TIMER) - file(REMOVE "${PROJECT_BINARY_DIR}/nvcc_timings.csv") - string(APPEND CMAKE_CUDA_FLAGS " --time ${PROJECT_BINARY_DIR}/nvcc_timings.csv") -endif () - -# -# Debugging -# -if (AMReX_CUDA_DEBUG) - # is this unsupported with MSVC? - string(APPEND CMAKE_CUDA_FLAGS " -G") -endif() - -if (AMReX_CUDA_SHOW_LINENUMBERS AND NOT AMReX_CUDA_DEBUG) - # nvcc warning : '--device-debug (-G)' overrides '--generate-line-info (-lineinfo)' - string(APPEND CMAKE_CUDA_FLAGS " --generate-line-info") -endif () -if (AMReX_CUDA_SHOW_CODELINES) - string(APPEND CMAKE_CUDA_FLAGS " --source-in-ptx") -endif () - -if (AMReX_CUDA_BACKTRACE) - if (CMAKE_SYSTEM_NAME STREQUAL "Windows") - string(APPEND CMAKE_CUDA_FLAGS " -Xcompiler /Zi") # comes with Debug & RelWithDebInfo - else () - string(APPEND CMAKE_CUDA_FLAGS " -Xcompiler -rdynamic") - endif () -endif () - -if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.2) - string(APPEND CMAKE_CUDA_FLAGS " --display-error-number --diag-error 20092") -endif () diff --git a/Tools/Plotfile/CMakeLists.txt b/Tools/Plotfile/CMakeLists.txt index cc1556ed178..c972aedeb50 100644 --- a/Tools/Plotfile/CMakeLists.txt +++ b/Tools/Plotfile/CMakeLists.txt @@ -26,8 +26,9 @@ foreach( _exe IN LISTS _exe_names) target_link_libraries(${_exe} PRIVATE amrex) if (AMReX_CUDA) set_source_files_properties(${_exe}.cpp PROPERTIES LANGUAGE CUDA) - set_cuda_architectures(AMReX_CUDA_ARCH) - set_target_properties(${_exe} PROPERTIES CUDA_ARCHITECTURES "${AMREX_CUDA_ARCHS}") + if (AMREX_CUDA_ARCHS) + set_target_properties(${_exe} PROPERTIES CUDA_ARCHITECTURES "${AMREX_CUDA_ARCHS}") + endif() endif() # Add prefix to each tool's name to make them unique when installed.