Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HDF5 H5Z-ZFP support in CMake #2753

Merged
merged 4 commits into from
May 11, 2022
Merged
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
2 changes: 2 additions & 0 deletions Docs/sphinx_documentation/source/BuildingAMReX.rst
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ The list of available options is reported in the :ref:`table <tab:cmakevar>` 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 |
Expand Down
6 changes: 6 additions & 0 deletions Tools/CMake/AMReXConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -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@)
Expand Down Expand Up @@ -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@)
Expand Down Expand Up @@ -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 ()
Expand Down
4 changes: 4 additions & 0 deletions Tools/CMake/AMReXOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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 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 )
Expand Down
1 change: 1 addition & 0 deletions Tools/CMake/AMReXSetDefines.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)


#
Expand Down
28 changes: 25 additions & 3 deletions Tools/CMake/AMReXThirdPartyLibraries.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down
1 change: 1 addition & 0 deletions Tools/CMake/AMReX_Config.H.in
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down