From 39c90e7b768c75f78391effeea292431384a08de Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Wed, 30 Nov 2016 08:30:53 -0700 Subject: [PATCH 1/5] Enable collective metadata operations for hdf5-1.10; not protected yet --- libsrc4/nc4file.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libsrc4/nc4file.c b/libsrc4/nc4file.c index 5ae72fdecb..e92c8da509 100644 --- a/libsrc4/nc4file.c +++ b/libsrc4/nc4file.c @@ -364,6 +364,9 @@ nc4_create_file(const char *path, int cmode, MPI_Comm comm, MPI_Info info, #endif /* EXTRA_TESTS */ #ifdef USE_PARALLEL4 + H5Pset_all_coll_metadata_ops(fapl_id, 1 ); + H5Pset_coll_metadata_write(fapl_id, 1); + /* If this is a parallel file create, set up the file creation property list. */ if ((cmode & NC_MPIIO) || (cmode & NC_MPIPOSIX)) @@ -2261,6 +2264,8 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc) #endif #ifdef USE_PARALLEL4 + H5Pset_all_coll_metadata_ops(fapl_id, 1 ); + /* If this is a parallel file create, set up the file creation property list. */ if (mode & NC_MPIIO || mode & NC_MPIPOSIX) From 7c808e849bef22b89768791bf738adaa7c8182d9 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Wed, 30 Nov 2016 09:22:44 -0700 Subject: [PATCH 2/5] Get parallel hdf5 detection working --- CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d3251aee1..f7047c05b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -635,6 +635,9 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4) ENDIF() ENDIF(MSVC) + IF(NOT HDF5_C_LIBRARY) + SET(HDF5_C_LIBRARY hdf5) + ENDIF() ENDIF(HDF5_C_LIBRARY AND HDF5_HL_LIBRARY AND HDF5_INCLUDE_DIR) ### @@ -644,8 +647,8 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4) # Find out if HDF5 was built with parallel support. # Do that by checking for the targets H5Pget_fapl_mpiposx and # H5Pget_fapl_mpio in ${HDF5_LIB}. - CHECK_LIBRARY_EXISTS(hdf5 H5Pget_fapl_mpiposix "" HDF5_IS_PARALLEL_MPIPOSIX) - CHECK_LIBRARY_EXISTS(hdf5 H5Pget_fapl_mpio "" HDF5_IS_PARALLEL_MPIO) + CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5Pget_fapl_mpiposix "" HDF5_IS_PARALLEL_MPIPOSIX) + CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5Pget_fapl_mpio "" HDF5_IS_PARALLEL_MPIO) IF(HDF5_IS_PARALLEL_MPIPOSIX OR HDF5_IS_PARALLEL_MPIO) SET(HDF5_PARALLEL ON) ELSE() @@ -664,7 +667,6 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4) IF(ENABLE_DYNAMIC_LOADING) SET(USE_LIBDL ON CACHE BOOL "") ENDIF() - SET(HDF5_C_LIBRARY hdf5) ENDIF(NOT MSVC) #Check to see if H5Z_SZIP exists in HDF5_Libraries. If so, we must use szip. From e0269d6cac3328395ab39219fe8280a2ff97e35f Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Wed, 30 Nov 2016 10:30:00 -0700 Subject: [PATCH 3/5] Add hdf5 collective metadata api detection to cmake build --- CMakeLists.txt | 3 +++ config.h.cmake.in | 1 + libsrc4/nc4file.c | 6 ++++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f7047c05b1..f81d1ecdbe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -663,6 +663,9 @@ IF(USE_HDF5 OR ENABLE_NETCDF_4) SET(USE_PARALLEL_POSIX ON) ENDIF() + #Check to see if HDF5 library has collective metadata APIs, (HDF5 >= 1.10.0) + CHECK_LIBRARY_EXISTS(${HDF5_C_LIBRARY} H5Pset_all_coll_metadata_ops "" HDF5_HAS_COLL_METADATA_OPS) + OPTION(ENABLE_DYNAMIC_LOADING "Enable Dynamic Loading" ON) IF(ENABLE_DYNAMIC_LOADING) SET(USE_LIBDL ON CACHE BOOL "") diff --git a/config.h.cmake.in b/config.h.cmake.in index 0fb66a38be..20fd9efc88 100644 --- a/config.h.cmake.in +++ b/config.h.cmake.in @@ -97,6 +97,7 @@ are set when opening a binary file on Windows. */ #cmakedefine USE_PARALLEL_MPIO 1 #cmakedefine HDF5_HAS_H5FREE 1 #cmakedefine HDF5_HAS_LIBVER_BOUNDS 1 +#cmakedefine HDF5_HAS_COLL_METADATA_OPS 1 #cmakedefine HDF5_PARALLEL 1 #cmakedefine USE_PARALLEL 1 #cmakedefine USE_PARALLEL4 1 diff --git a/libsrc4/nc4file.c b/libsrc4/nc4file.c index e92c8da509..b622455775 100644 --- a/libsrc4/nc4file.c +++ b/libsrc4/nc4file.c @@ -364,9 +364,10 @@ nc4_create_file(const char *path, int cmode, MPI_Comm comm, MPI_Info info, #endif /* EXTRA_TESTS */ #ifdef USE_PARALLEL4 +#ifdef HDF5_HAS_COLL_METADATA_OPS H5Pset_all_coll_metadata_ops(fapl_id, 1 ); H5Pset_coll_metadata_write(fapl_id, 1); - +#endif /* If this is a parallel file create, set up the file creation property list. */ if ((cmode & NC_MPIIO) || (cmode & NC_MPIPOSIX)) @@ -2264,8 +2265,9 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc) #endif #ifdef USE_PARALLEL4 +#ifdef HDF5_HAS_COLL_METADATA_OPS H5Pset_all_coll_metadata_ops(fapl_id, 1 ); - +#endif /* If this is a parallel file create, set up the file creation property list. */ if (mode & NC_MPIIO || mode & NC_MPIPOSIX) From 72c1948980335f794dbbf044d6c46f12ef876b05 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Wed, 30 Nov 2016 11:50:47 -0700 Subject: [PATCH 4/5] Move metadata ops calls --- libsrc4/nc4file.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libsrc4/nc4file.c b/libsrc4/nc4file.c index b622455775..f1ac3460d8 100644 --- a/libsrc4/nc4file.c +++ b/libsrc4/nc4file.c @@ -364,10 +364,6 @@ nc4_create_file(const char *path, int cmode, MPI_Comm comm, MPI_Info info, #endif /* EXTRA_TESTS */ #ifdef USE_PARALLEL4 -#ifdef HDF5_HAS_COLL_METADATA_OPS - H5Pset_all_coll_metadata_ops(fapl_id, 1 ); - H5Pset_coll_metadata_write(fapl_id, 1); -#endif /* If this is a parallel file create, set up the file creation property list. */ if ((cmode & NC_MPIIO) || (cmode & NC_MPIPOSIX)) @@ -450,6 +446,11 @@ nc4_create_file(const char *path, int cmode, MPI_Comm comm, MPI_Info info, BAIL(NC_EHDFERR); /* Create the file. */ +#ifdef HDF5_HAS_COLL_METADATA_OPS + H5Pset_all_coll_metadata_ops(fapl_id, 1 ); + H5Pset_coll_metadata_write(fapl_id, 1); +#endif + if ((nc4_info->hdfid = H5Fcreate(path, flags, fcpl_id, fapl_id)) < 0) /*Change the return error from NC_EFILEMETADATA to System error EACCES because that is the more likely problem */ @@ -2265,9 +2266,6 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc) #endif #ifdef USE_PARALLEL4 -#ifdef HDF5_HAS_COLL_METADATA_OPS - H5Pset_all_coll_metadata_ops(fapl_id, 1 ); -#endif /* If this is a parallel file create, set up the file creation property list. */ if (mode & NC_MPIIO || mode & NC_MPIPOSIX) @@ -2322,6 +2320,9 @@ nc4_open_file(const char *path, int mode, void* parameters, NC *nc) /* The NetCDF-3.x prototype contains an mode option NC_SHARE for multiple processes accessing the dataset concurrently. As there is no HDF5 equivalent, NC_SHARE is treated as NC_NOWRITE. */ +#ifdef HDF5_HAS_COLL_METADATA_OPS + H5Pset_all_coll_metadata_ops(fapl_id, 1 ); +#endif if(inmemory) { if((nc4_info->hdfid = H5LTopen_file_image(meminfo->memory,meminfo->size, H5LT_FILE_IMAGE_DONT_COPY|H5LT_FILE_IMAGE_DONT_RELEASE From 9491ea2c5be24ab896917f5a0893a0cfd038ad70 Mon Sep 17 00:00:00 2001 From: Greg Sjaardema Date: Thu, 1 Dec 2016 11:56:33 -0700 Subject: [PATCH 5/5] Add hdf5 collective metadata api detection to configure-based build --- configure.ac | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 4bd25b517e..adc0c07ebc 100644 --- a/configure.ac +++ b/configure.ac @@ -923,7 +923,7 @@ if test "x$enable_netcdf_4" = xyes; then [AC_MSG_ERROR([Can't find or link to the hdf5 high-level. Use --disable-netcdf-4, or see config.log for errors.])]) AC_CHECK_HEADERS([hdf5.h], [], [AC_MSG_ERROR([Compiling a test with HDF5 failed. Either hdf5.h cannot be found, or config.log should be checked for other reason.])]) - AC_CHECK_FUNCS([H5Pget_fapl_mpiposix H5Pget_fapl_mpio H5Pset_deflate H5Z_SZIP H5free_memory]) + AC_CHECK_FUNCS([H5Pget_fapl_mpiposix H5Pget_fapl_mpio H5Pset_deflate H5Z_SZIP H5free_memory H5Pset_all_coll_metadata_ops]) # The user may have parallel HDF5 based on MPI POSIX. if test "x$ac_cv_func_H5Pget_fapl_mpiposix" = xyes; then @@ -935,6 +935,11 @@ if test "x$enable_netcdf_4" = xyes; then AC_DEFINE([USE_PARALLEL_MPIO], [1], [if true, compile in parallel netCDF-4 based on MPI/IO]) fi + # Check to see if HDF5 library has collective metadata APIs, (HDF5 >= 1.10.0) + if test "x$ac_cv_func_H5Pset_all_coll_metadata_ops" = xyes; then + AC_DEFINE([HDF5_HAS_COLL_METADATA_OPS], [1], [if true, use collective metadata ops in parallel netCDF-4]) + fi + # If parallel is available in hdf5, enable it in the C code. Also add some stuff to netcdf.h. hdf5_parallel=no if test "x$ac_cv_func_H5Pget_fapl_mpio" = xyes -o "x$ac_cv_func_H5Pget_fapl_mpiposix" = xyes; then