From 5fac9ae3b005663628d479df8f8ddbc558226b81 Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Thu, 5 May 2022 11:41:27 -0600 Subject: [PATCH 1/4] Add HDF5 H5Z-ZFP support in CMake. --- Tools/CMake/AMReXConfig.cmake.in | 6 +++++ Tools/CMake/AMReXOptions.cmake | 4 ++++ Tools/CMake/AMReXSetDefines.cmake | 1 + Tools/CMake/AMReXThirdPartyLibraries.cmake | 28 +++++++++++++++++++--- Tools/CMake/AMReX_Config.H.in | 1 + 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/Tools/CMake/AMReXConfig.cmake.in b/Tools/CMake/AMReXConfig.cmake.in index d4be691c6dd..6fa60344f17 100644 --- a/Tools/CMake/AMReXConfig.cmake.in +++ b/Tools/CMake/AMReXConfig.cmake.in @@ -85,6 +85,7 @@ set(AMReX_HYPRE_FOUND @AMReX_HYPRE@) set(AMReX_PETSC_FOUND @AMReX_PETSC@) set(AMReX_SUNDIALS_FOUND @AMReX_SUNDIALS@) set(AMReX_HDF5_FOUND @AMReX_HDF5@) +set(AMReX_HDF5_ZFP_FOUND @AMReX_HDF5_ZFP@) # Compilation options set(AMReX_FPE_FOUND @AMReX_FPE@) @@ -131,6 +132,7 @@ set(AMReX_ASCENT @AMReX_ASCENT@) set(AMReX_HYPRE @AMReX_HYPRE@) set(AMReX_PETSC @AMReX_PETSC@) set(AMReX_HDF5 @AMReX_HDF5@) +set(AMReX_HDF5_ZFP @AMReX_HDF5_ZFP@) # Compilation options set(AMReX_FPE @AMReX_FPE@) @@ -200,6 +202,10 @@ if (@AMReX_HDF5@) find_dependency(HDF5 REQUIRED) endif () +if (@AMReX_HDF5_ZFP@) + find_dependency(H5Z-ZFP REQUIRED) +endif () + if (@AMReX_HYPRE@) find_dependency(HYPRE 2.20.0 REQUIRED) endif () diff --git a/Tools/CMake/AMReXOptions.cmake b/Tools/CMake/AMReXOptions.cmake index 6b45fb62d0a..33a11c98d70 100644 --- a/Tools/CMake/AMReXOptions.cmake +++ b/Tools/CMake/AMReXOptions.cmake @@ -303,6 +303,10 @@ if (AMReX_HDF5_ASYNC) message(FATAL_ERROR "\nAMReX_HDF5_ASYNC not yet supported\n") endif () +cmake_dependent_option(AMReX_HDF5_ZFP "Enable ZFP lossy compression in HDF5-based IO" OFF + "AMReX_HDF5" OFF ) +print_option(AMReX_HDF5_ZFP) + # SUNDIALS option( AMReX_SUNDIALS "Enable SUNDIALS interfaces" OFF ) print_option( AMReX_SUNDIALS ) diff --git a/Tools/CMake/AMReXSetDefines.cmake b/Tools/CMake/AMReXSetDefines.cmake index cd4c12bf838..358f08db766 100644 --- a/Tools/CMake/AMReXSetDefines.cmake +++ b/Tools/CMake/AMReXSetDefines.cmake @@ -165,6 +165,7 @@ endif () # add_amrex_define(AMREX_USE_HDF5 NO_LEGACY IF AMReX_HDF5) add_amrex_define(AMREX_USE_HDF5_ASYNC NO_LEGACY IF AMReX_HDF5_ASYNC) +add_amrex_define(AMREX_USE_HDF5_ZFP NO_LEGACY IF AMReX_HDF5_ZFP) # diff --git a/Tools/CMake/AMReXThirdPartyLibraries.cmake b/Tools/CMake/AMReXThirdPartyLibraries.cmake index 9f1f771d9fb..3eeb9907845 100644 --- a/Tools/CMake/AMReXThirdPartyLibraries.cmake +++ b/Tools/CMake/AMReXThirdPartyLibraries.cmake @@ -2,11 +2,16 @@ # HDF5 -- here it would be best to create an imported target # if (AMReX_HDF5) - set(HDF5_PREFER_PARALLEL TRUE) + if (AMReX_MPI) + set(HDF5_PREFER_PARALLEL TRUE) + endif () find_package(HDF5 1.10.4 REQUIRED) if (AMReX_MPI AND (NOT HDF5_IS_PARALLEL)) - message(FATAL_ERROR "\nHDF5 library does not support parallel I/O") - endif () + message(FATAL_ERROR "\nHDF5 library does not support parallel I/O") + endif () + if (HDF5_IS_PARALLEL AND (NOT AMReX_MPI)) + message(FATAL_ERROR "\nMPI enabled in HDF5 but not in AMReX, which will likely fail to build") + endif () if (TARGET hdf5::hdf5) # CMake >= 3.19 target_link_libraries(amrex PUBLIC hdf5::hdf5) @@ -18,6 +23,23 @@ if (AMReX_HDF5) endif () +# +# H5Z-ZFP +# +if (AMReX_HDF5_ZFP) + set(H5Z_ZFP_USE_STATIC_LIBS ON) # Static ON means using as a library, or OFF as an HDF5 plugin + find_package(H5Z_ZFP 1.0.1 CONFIG) + if (NOT AMReX_HDF5) + message(FATAL_ERROR "\nHDF5 must be enabled for ZFP support in HDF5") + endif () + + if (TARGET h5z_zfp::h5z_zfp) # CMake >= 3.19 + target_link_libraries(amrex PUBLIC h5z_zfp::h5z_zfp) + else () # CMake < 3.19 -- Remove when minimum cmake version is bumped up + target_include_directories(amrex PUBLIC ${H5Z_ZFP_INCLUDE_DIR}) + target_link_libraries(amrex PUBLIC ${H5Z_ZFP_LIBRARY}) + endif () +endif () # # Sensei diff --git a/Tools/CMake/AMReX_Config.H.in b/Tools/CMake/AMReX_Config.H.in index c4cf03571f8..c38d6a4e9b2 100644 --- a/Tools/CMake/AMReX_Config.H.in +++ b/Tools/CMake/AMReX_Config.H.in @@ -50,6 +50,7 @@ #cmakedefine AMREX_PARTICLES #cmakedefine AMREX_USE_HDF5 #cmakedefine AMREX_USE_HDF5_ASYNC +#cmakedefine AMREX_USE_HDF5_ZFP #cmakedefine AMREX_USE_HYPRE #cmakedefine AMREX_USE_PETSC #cmakedefine AMREX_USE_SUNDIALS From 0aa86f2e409196a5b4b78d9779ddccfe71cdae49 Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Thu, 5 May 2022 11:52:30 -0600 Subject: [PATCH 2/4] Fix indentation. --- Tools/CMake/AMReXThirdPartyLibraries.cmake | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Tools/CMake/AMReXThirdPartyLibraries.cmake b/Tools/CMake/AMReXThirdPartyLibraries.cmake index 3eeb9907845..e8be52dc173 100644 --- a/Tools/CMake/AMReXThirdPartyLibraries.cmake +++ b/Tools/CMake/AMReXThirdPartyLibraries.cmake @@ -29,16 +29,16 @@ endif () if (AMReX_HDF5_ZFP) set(H5Z_ZFP_USE_STATIC_LIBS ON) # Static ON means using as a library, or OFF as an HDF5 plugin find_package(H5Z_ZFP 1.0.1 CONFIG) - if (NOT AMReX_HDF5) - message(FATAL_ERROR "\nHDF5 must be enabled for ZFP support in HDF5") - endif () + if (NOT AMReX_HDF5) + message(FATAL_ERROR "\nHDF5 must be enabled for ZFP support in HDF5") + endif () - if (TARGET h5z_zfp::h5z_zfp) # CMake >= 3.19 - target_link_libraries(amrex PUBLIC h5z_zfp::h5z_zfp) - else () # CMake < 3.19 -- Remove when minimum cmake version is bumped up - target_include_directories(amrex PUBLIC ${H5Z_ZFP_INCLUDE_DIR}) - target_link_libraries(amrex PUBLIC ${H5Z_ZFP_LIBRARY}) - endif () + if (TARGET h5z_zfp::h5z_zfp) # CMake >= 3.19 + target_link_libraries(amrex PUBLIC h5z_zfp::h5z_zfp) + else () # CMake < 3.19 -- Remove when minimum cmake version is bumped up + target_include_directories(amrex PUBLIC ${H5Z_ZFP_INCLUDE_DIR}) + target_link_libraries(amrex PUBLIC ${H5Z_ZFP_LIBRARY}) + endif () endif () # From 54b73b7c15c4b933b59ec976576c06a39c4abd6b Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Thu, 5 May 2022 13:24:17 -0600 Subject: [PATCH 3/4] ZFP doesn't have to be lossy. --- Tools/CMake/AMReXOptions.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/CMake/AMReXOptions.cmake b/Tools/CMake/AMReXOptions.cmake index 33a11c98d70..663fefa606b 100644 --- a/Tools/CMake/AMReXOptions.cmake +++ b/Tools/CMake/AMReXOptions.cmake @@ -303,7 +303,7 @@ if (AMReX_HDF5_ASYNC) message(FATAL_ERROR "\nAMReX_HDF5_ASYNC not yet supported\n") endif () -cmake_dependent_option(AMReX_HDF5_ZFP "Enable ZFP lossy compression in HDF5-based IO" OFF +cmake_dependent_option(AMReX_HDF5_ZFP "Enable ZFP compression in HDF5-based IO" OFF "AMReX_HDF5" OFF ) print_option(AMReX_HDF5_ZFP) From 7c1c44a24348fdee79962caccf8fe4e769d459a5 Mon Sep 17 00:00:00 2001 From: Jon Rood Date: Tue, 10 May 2022 08:54:43 -0600 Subject: [PATCH 4/4] Add AMReX_HDF5_ZFP option to documentation. --- Docs/sphinx_documentation/source/BuildingAMReX.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Docs/sphinx_documentation/source/BuildingAMReX.rst b/Docs/sphinx_documentation/source/BuildingAMReX.rst index 47684fe305c..f5b8b263a4e 100644 --- a/Docs/sphinx_documentation/source/BuildingAMReX.rst +++ b/Docs/sphinx_documentation/source/BuildingAMReX.rst @@ -515,6 +515,8 @@ The list of available options is reported in the :ref:`table ` bel +------------------------------+-------------------------------------------------+-------------------------+-----------------------+ | AMReX_HDF5 | Enable HDF5-based I/O | NO | YES, NO | +------------------------------+-------------------------------------------------+-------------------------+-----------------------+ + | AMReX_HDF5_ZFP | Enable compression with ZFP in HDF5-based I/O | NO | YES, NO | + +------------------------------+-------------------------------------------------+-------------------------+-----------------------+ | AMReX_PLOTFILE_TOOLS | Build and install plotfile postprocessing tools| NO | YES, NO | +------------------------------+-------------------------------------------------+-------------------------+-----------------------+ | AMReX_ENABLE_TESTS | Enable CTest suite | NO | YES, NO |