From f9319308ec2be559a70ac076226e56a31d5bd579 Mon Sep 17 00:00:00 2001 From: "Jean M. Sexton" Date: Fri, 30 Aug 2024 10:34:45 -0500 Subject: [PATCH 1/2] add internal resuse of amrex library --- CMake/BuildERFExe.cmake | 2 +- CMakeLists.txt | 47 ++++++++++++++++++++++++++++--- Exec/DevTests/MultiBlock/prob.cpp | 2 +- 3 files changed, 45 insertions(+), 6 deletions(-) diff --git a/CMake/BuildERFExe.cmake b/CMake/BuildERFExe.cmake index d97720169..4fe502287 100644 --- a/CMake/BuildERFExe.cmake +++ b/CMake/BuildERFExe.cmake @@ -224,7 +224,7 @@ function(build_erf_lib erf_lib_name) endif() #Link to amrex library - target_link_libraries_system(${erf_lib_name} PUBLIC amrex) + target_link_libraries_system(${erf_lib_name} PUBLIC AMReX::amrex) if(ERF_ENABLE_CUDA) set(pctargets "${erf_lib_name}") foreach(tgt IN LISTS pctargets) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c97a8f2d..f3e5f0e9a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,7 @@ option(ERF_ENABLE_DOCUMENTATION "Build documentation" OFF) option(ERF_ENABLE_ALL_WARNINGS "Enable all compiler warnings" OFF) option(ERF_ENABLE_TESTS "Enable regression and unit tests" OFF) option(ERF_ENABLE_REGRESSION_TESTS_ONLY "Enable only regression tests" OFF) +option(ERF_USE_INTERNAL_AMREX "Add AMReX as subproject" ON) option(ERF_ENABLE_NETCDF "Enable NetCDF IO" OFF) option(ERF_ENABLE_HDF5 "Enable HDF5 IO" ${ERF_ENABLE_NETCDF}) option(ERF_ENABLE_PARTICLES "Enable Lagrangian particles" OFF) @@ -64,13 +65,51 @@ endif() ########################### AMReX ##################################### -set(AMREX_SUBMOD_LOCATION "${CMAKE_SOURCE_DIR}/Submodules/AMReX") -include(${CMAKE_SOURCE_DIR}/CMake/SetAmrexOptions.cmake) -list(APPEND CMAKE_MODULE_PATH "${AMREX_SUBMOD_LOCATION}/Tools/CMake") +if (${ERF_USE_INTERNAL_AMREX}) + set(AMREX_SUBMOD_LOCATION "${CMAKE_SOURCE_DIR}/Submodules/AMReX") + include(${CMAKE_SOURCE_DIR}/CMake/SetAmrexOptions.cmake) + list(APPEND CMAKE_MODULE_PATH "${AMREX_SUBMOD_LOCATION}/Tools/CMake") +# if (ERF_ENABLE_CUDA AND (CMAKE_VERSION VERSION_LESS 3.20)) +# include(AMReX_SetupCUDA) +# endif() ########################### AMReX ##################################### -add_subdirectory(${AMREX_SUBMOD_LOCATION}) + add_subdirectory(${AMREX_SUBMOD_LOCATION}) + set(FCOMPARE_EXE ${CMAKE_BINARY_DIR}/Submodules/AMReX/Tools/Plotfile/amrex_fcompare + CACHE INTERNAL "Path to fcompare executable for regression tests") +else() + set(CMAKE_PREFIX_PATH ${AMREX_DIR} ${CMAKE_PREFIX_PATH}) + list(APPEND AMREX_COMPONENTS + "3D" "PIC" "PARTICLES" "PDOUBLE" "DOUBLE" "LSOLVERS") + if (ERF_ENABLE_MPI) + list(APPEND AMREX_COMPONENTS "MPI") + endif() + if (ERF_ENABLE_OPENMP) + list(APPEND AMREX_COMPONENTS "OMP") + endif() + if (ERF_ENABLE_CUDA) + list(APPEND AMREX_COMPONENTS "CUDA") + endif() + if (ERF_ENABLE_SYCL) + list(APPEND AMREX_COMPONENTS "SYCL") + endif() + if (ERF_ENABLE_ROCM) + list(APPEND AMREX_COMPONENTS "HIP") + endif() + if (ERF_ENABLE_HYPRE) + list(APPEND AMREX_COMPONENTS "HYPRE") + endif() + if (ERF_ENABLE_TINY_PROFILE) + list(APPEND AMREX_COMPONENTS "TINY_PROFILE") + endif() + separate_arguments(AMREX_COMPONENTS) + find_package(AMReX CONFIG REQUIRED + COMPONENTS ${AMREX_COMPONENTS}) + message(STATUS "Found AMReX = ${AMReX_DIR}") + set(FCOMPARE_EXE ${AMReX_DIR}/../../../bin/amrex_fcompare + CACHE INTERNAL "Path to fcompare executable for regression tests") +endif() ########################## NETCDF ################################## diff --git a/Exec/DevTests/MultiBlock/prob.cpp b/Exec/DevTests/MultiBlock/prob.cpp index 5908aa55c..bd73b1672 100644 --- a/Exec/DevTests/MultiBlock/prob.cpp +++ b/Exec/DevTests/MultiBlock/prob.cpp @@ -44,7 +44,7 @@ Problem::init_custom_pert( Array4 const& /*mf_m*/, Array4 const& /*mf_u*/, Array4 const& /*mf_v*/, - const SolverChoice&) + const SolverChoice& sc) { const int khi = geomdata.Domain().bigEnd()[2]; From a6d630a1cf10890e2e521f89b227224c89ddbf30 Mon Sep 17 00:00:00 2001 From: "Jean M. Sexton" Date: Fri, 30 Aug 2024 15:05:53 -0500 Subject: [PATCH 2/2] Updates for multiblock --- CMake/ERFConfig.cmake.in | 17 +++++++++++++++++ CMakeLists.txt | 6 ++++++ Source/ERF.H | 2 +- 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 CMake/ERFConfig.cmake.in diff --git a/CMake/ERFConfig.cmake.in b/CMake/ERFConfig.cmake.in new file mode 100644 index 000000000..af6218e8e --- /dev/null +++ b/CMake/ERFConfig.cmake.in @@ -0,0 +1,17 @@ +@PACKAGE_INIT@ + +find_package(AMReX QUIET REQUIRED @AMREX_COMPONENTS@) + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") + +set(@PROJECT_NAME@_INCLUDE_DIRS "${PROJECT_PREFIX_DIR}/@CMAKE_INSTALL_INCLUDEDIR@") +set(@PROJECT_NAME@_LIBRARY_DIRS "${PROJECT_PREFIX_DIR}/@CMAKE_INSTALL_LIBDIR@") +set(@PROJECT_NAME@_LIBRARIES "@PROJECT_NAME@::erf_srclib") + +# CMake targets aliases: last dimension built will be our legacy target +if (NOT TARGET @PROJECT_NAME@::erf_srclib") # protection in case of multiple inclusions + add_library(@PROJECT_NAME@::erf_srclib ALIAS erf_srclib) +endif() + +set(@PROJECT_NAME@_FOUND TRUE) +check_required_components(@PROJECT_NAME@) diff --git a/CMakeLists.txt b/CMakeLists.txt index 854abe802..cd0e4077d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -184,6 +184,12 @@ configure_file( @ONLY ) +configure_package_config_file( + CMake/${PROJECT_NAME}Config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake + INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME} + ) + # General information about machine, compiler, and build type message(STATUS "ERF Information:") message(STATUS "CMAKE_SYSTEM_NAME = ${CMAKE_SYSTEM_NAME}") diff --git a/Source/ERF.H b/Source/ERF.H index f21ec6e82..2f8209012 100644 --- a/Source/ERF.H +++ b/Source/ERF.H @@ -375,7 +375,7 @@ public: // Velocity time averaged field amrex::Vector> vel_t_avg; - amrex::Vector t_avg_cnt; + amrex::Vector t_avg_cnt; #endif std::string pp_prefix {"erf"};