Skip to content

Commit

Permalink
Subfiling VFD source cleanup (#3241) (#3290)
Browse files Browse the repository at this point in the history
* Subfiling VFD source cleanup (#3241)

* Subfiling VFD source cleanup

Modularize Subfiling CMake code into separate CMakeLists.txt file

Update Mercury util code to latest version and update Copyright

Generate mercury_util_config.h header file instead of using
pre-generated file

Remove unnecessary Mercury functionality

Fix minor warning in Subfiling VFD code

* Remove Mercury headers from Autotools publicly-distributed header list

* Fix CMake builds when Subfiling VFD isn't enabled (#3250)

* Fix CMake builds when Subfiling VFD isn't enabled

* Add Subfiling VFD entry to hdf5-config.cmake.in
  • Loading branch information
jhendersonHDF authored Jul 27, 2023
1 parent 144bec3 commit 17a5a1a
Show file tree
Hide file tree
Showing 37 changed files with 173 additions and 3,293 deletions.
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -760,8 +760,22 @@ if (HDF5_ENABLE_SUBFILING_VFD)
${HDF5_SRC_INCLUDE_DIRS}
${H5FD_SUBFILING_MERCURY_DIR}
)
set (H5_HAVE_MERCURY_H 1)
set (CMAKE_REQUIRED_INCLUDES "${H5FD_SUBFILING_MERCURY_DIR}")

# Run some configure checks for the Mercury util files
set (CMAKE_EXTRA_INCLUDE_FILES pthread.h)
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})

check_type_size(PTHREAD_MUTEX_ADAPTIVE_NP PTHREAD_MUTEX_ADAPTIVE_NP_SIZE)
if (HAVE_PTHREAD_MUTEX_ADAPTIVE_NP_SIZE)
set (${HDF_PREFIX}_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP 1)
endif ()

check_symbol_exists(pthread_condattr_setclock pthread.h
${HDF_PREFIX}_HAVE_PTHREAD_CONDATTR_SETCLOCK)

unset (CMAKE_EXTRA_INCLUDE_FILES)
unset (CMAKE_REQUIRED_LIBRARIES)
endif()

#option (DEFAULT_API_VERSION "Enable v1.14 API (v16, v18, v110, v112, v114)" "v114")
Expand Down
9 changes: 9 additions & 0 deletions config/cmake/ConfigureChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,15 @@ if (MINGW OR NOT WINDOWS)
list (APPEND LINK_LIBS posix4)
endif ()
endif ()

# Check for clock_gettime() CLOCK_MONOTONIC_COARSE
set (CMAKE_EXTRA_INCLUDE_FILES time.h)
check_type_size(CLOCK_MONOTONIC_COARSE CLOCK_MONOTONIC_COARSE_SIZE)
if (HAVE_CLOCK_MONOTONIC_COARSE_SIZE)
set (${HDF_PREFIX}_HAVE_CLOCK_MONOTONIC_COARSE 1)
endif ()
unset (CMAKE_EXTRA_INCLUDE_FILES)

#-----------------------------------------------------------------------------

#-----------------------------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions config/cmake/H5pubconf.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@
/* Define to 1 if you have the `clock_gettime' function. */
#cmakedefine H5_HAVE_CLOCK_GETTIME @H5_HAVE_CLOCK_GETTIME@

/* Define to 1 if CLOCK_MONOTONIC_COARSE is available */
#cmakedefine H5_HAVE_CLOCK_MONOTONIC_COARSE @H5_HAVE_CLOCK_MONOTONIC_COARSE@

/* Define if the function stack tracing code is to be compiled in */
#cmakedefine H5_HAVE_CODESTACK @H5_HAVE_CODESTACK@

Expand Down Expand Up @@ -255,6 +258,12 @@
/* Define to 1 if you have the <pthread.h> header file. */
#cmakedefine H5_HAVE_PTHREAD_H @H5_HAVE_PTHREAD_H@

/* Define to 1 if 'pthread_condattr_setclock()' is available */
#cmakedefine H5_HAVE_PTHREAD_CONDATTR_SETCLOCK @H5_HAVE_PTHREAD_CONDATTR_SETCLOCK@

/* Define to 1 if PTHREAD_MUTEX_ADAPTIVE_NP is available */
#cmakedefine H5_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP @H5_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP@

/* Define to 1 if you have the <pwd.h> header file. */
#cmakedefine H5_HAVE_PWD_H @H5_HAVE_PWD_H@

Expand Down
1 change: 1 addition & 0 deletions config/cmake/hdf5-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ set (${HDF5_PACKAGE_NAME}_ENABLE_PLUGIN_SUPPORT @HDF5_ENABLE_PLUGIN_SUPPORT@)
set (${HDF5_PACKAGE_NAME}_ENABLE_Z_LIB_SUPPORT @HDF5_ENABLE_Z_LIB_SUPPORT@)
set (${HDF5_PACKAGE_NAME}_ENABLE_SZIP_SUPPORT @HDF5_ENABLE_SZIP_SUPPORT@)
set (${HDF5_PACKAGE_NAME}_ENABLE_SZIP_ENCODING @HDF5_ENABLE_SZIP_ENCODING@)
set (${HDF5_PACKAGE_NAME}_ENABLE_SUBFILING_VFD @HDF5_ENABLE_SUBFILING_VFD@)
set (${HDF5_PACKAGE_NAME}_BUILD_SHARED_LIBS @H5_ENABLE_SHARED_LIB@)
set (${HDF5_PACKAGE_NAME}_BUILD_STATIC_LIBS @H5_ENABLE_STATIC_LIB@)
set (${HDF5_PACKAGE_NAME}_PACKAGE_EXTLIBS @HDF5_PACKAGE_EXTLIBS@)
Expand Down
17 changes: 17 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -3072,6 +3072,23 @@ if test "X$SUBFILING_VFD" = "Xyes"; then
AC_SEARCH_LIBS([shm_open], [rt])
AC_CHECK_LIB([pthread], [pthread_self],[], [echo "Error: Required library pthread not found." && exit 1])

# Perform various checks for Mercury util code
AC_CHECK_DECL([PTHREAD_MUTEX_ADAPTIVE_NP],
[AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], [1],
[Define if has PTHREAD_MUTEX_ADAPTIVE_NP])],
[],
[[#include <pthread.h>]])
AC_CHECK_DECL([pthread_condattr_setclock],
[AC_DEFINE([HAVE_PTHREAD_CONDATTR_SETCLOCK], [1],
[Define if has pthread_condattr_setclock()])],
[],
[[#include <pthread.h>]])
AC_CHECK_DECL([CLOCK_MONOTONIC_COARSE],
[AC_DEFINE([HAVE_CLOCK_MONOTONIC_COARSE], [1],
[Define if has CLOCK_MONOTONIC_COARSE])],
[],
[[#include <time.h>]])

else
AC_MSG_RESULT([no])
fi
Expand Down
7 changes: 6 additions & 1 deletion release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ Bug Fixes since HDF5-1.14.1 release

Configuration
-------------
-
- Fixed a configuration issue that prevented building of the Subfiling VFD on macOS

Checks were added to the CMake and Autotools code to verify that CLOCK_MONOTONIC_COARSE,
PTHREAD_MUTEX_ADAPTIVE_NP and pthread_condattr_setclock() are available before attempting
to use them in Subfiling VFD-related utility code. Without these checks, attempting
to build the Subfiling VFD on macOS would fail.


Tools
Expand Down
33 changes: 5 additions & 28 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,34 +274,12 @@ set (H5FD_HDRS
${HDF5_SRC_DIR}/H5FDsplitter.h
${HDF5_SRC_DIR}/H5FDstdio.h
${HDF5_SRC_DIR}/H5FDwindows.h
${H5FD_SUBFILING_DIR}/H5FDsubfiling.h
${H5FD_SUBFILING_DIR}/H5FDioc.h
)

# Append Subfiling VFD and Mercury sources to H5FD interface if Subfiling VFD is built
if (HDF5_ENABLE_SUBFILING_VFD)
set (MERCURY_UTIL_SOURCES
${H5FD_SUBFILING_DIR}/mercury/src/util/mercury_dlog.c
${H5FD_SUBFILING_DIR}/mercury/src/util/mercury_log.c
${H5FD_SUBFILING_DIR}/mercury/src/util/mercury_thread.c
${H5FD_SUBFILING_DIR}/mercury/src/util/mercury_thread_condition.c
${H5FD_SUBFILING_DIR}/mercury/src/util/mercury_thread_pool.c
${H5FD_SUBFILING_DIR}/mercury/src/util/mercury_thread_mutex.c
${H5FD_SUBFILING_DIR}/mercury/src/util/mercury_util.c
)

set (H5FD_SUBFILING_SOURCES
${H5FD_SUBFILING_DIR}/H5FDioc.c
${H5FD_SUBFILING_DIR}/H5FDioc_int.c
${H5FD_SUBFILING_DIR}/H5FDioc_threads.c
${H5FD_SUBFILING_DIR}/H5FDsubfiling.c
${H5FD_SUBFILING_DIR}/H5FDsubfile_int.c
${H5FD_SUBFILING_DIR}/H5subfiling_common.c
${MERCURY_UTIL_SOURCES}
)
)

list (APPEND H5FD_SOURCES ${H5FD_SUBFILING_SOURCES})
endif()
# Append Subfiling VFD and Mercury sources to H5FD
# interface if Subfiling VFD is built. Append Subfiling
# VFD public headers to H5FD_HDRS regardless.
add_subdirectory (${H5FD_SUBFILING_DIR})

IDE_GENERATED_PROPERTIES ("H5FD" "${H5FD_HDRS}" "${H5FD_SOURCES}" )

Expand Down Expand Up @@ -859,7 +837,6 @@ set (H5_PUBLIC_HEADERS
${H5TS_HDRS}
${H5VL_HDRS}
${H5Z_HDRS}
${subfile_HDRS}
)

set (H5_PRIVATE_HEADERS
Expand Down
60 changes: 60 additions & 0 deletions src/H5FDsubfiling/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
cmake_minimum_required (VERSION 3.18)
project (HDF5_H5FD_SUBFILING C)

# Sanity checking
if (NOT H5FD_HDRS)
message (FATAL_ERROR "internal configure error - H5FD_HDRS not set")
endif ()
if (NOT H5FD_SUBFILING_DIR)
message (FATAL_ERROR "internal configure error - H5FD_SUBFILING_DIR not set")
endif ()

if (HDF5_ENABLE_SUBFILING_VFD)
# Sanity checking
if (NOT H5FD_SOURCES)
message (FATAL_ERROR "internal configure error - H5FD_SOURCES not set")
endif ()
if (NOT H5FD_SUBFILING_MERCURY_DIR)
message (FATAL_ERROR "internal configure error - H5FD_SUBFILING_MERCURY_DIR not set")
endif ()

# Add mercury util sources to Subfiling VFD sources
set (MERCURY_UTIL_SOURCES
${H5FD_SUBFILING_MERCURY_DIR}/mercury_thread.c
${H5FD_SUBFILING_MERCURY_DIR}/mercury_thread_condition.c
${H5FD_SUBFILING_MERCURY_DIR}/mercury_thread_pool.c
${H5FD_SUBFILING_MERCURY_DIR}/mercury_thread_mutex.c
)

set (HDF5_H5FD_SUBFILING_SOURCES
${H5FD_SUBFILING_DIR}/H5FDioc.c
${H5FD_SUBFILING_DIR}/H5FDioc_int.c
${H5FD_SUBFILING_DIR}/H5FDioc_threads.c
${H5FD_SUBFILING_DIR}/H5FDsubfiling.c
${H5FD_SUBFILING_DIR}/H5FDsubfile_int.c
${H5FD_SUBFILING_DIR}/H5subfiling_common.c
${MERCURY_UTIL_SOURCES}
)

# Add Subfiling VFD sources to HDF5 library's H5FD sources
set (H5FD_SOURCES
${H5FD_SOURCES}
${HDF5_H5FD_SUBFILING_SOURCES}
PARENT_SCOPE
)
endif ()

# Add Subfiling VFD public headers to HDF5 library's
# public H5FD headers, even if the Subfiling VFD isn't
# enabled and built
set (HDF5_H5FD_SUBFILING_HEADERS
${H5FD_SUBFILING_DIR}/H5FDsubfiling.h
${H5FD_SUBFILING_DIR}/H5FDioc.h
)

# Add Subfiling VFD public headers to HDF5 library's public H5FD headers
set (H5FD_HDRS
${H5FD_HDRS}
${HDF5_H5FD_SUBFILING_HEADERS}
PARENT_SCOPE
)
2 changes: 2 additions & 0 deletions src/H5FDsubfiling/H5subfiling_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -1082,6 +1082,7 @@ init_app_topology(H5FD_subfiling_params_t *subfiling_config, MPI_Comm comm, MPI_
}

case SELECT_IOC_WITH_CONFIG:
case ioc_selection_options:
default:
H5_SUBFILING_GOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid IOC selection strategy");
break;
Expand Down Expand Up @@ -1711,6 +1712,7 @@ identify_ioc_ranks(sf_topology_t *app_topology, int rank_stride)
}

case SELECT_IOC_WITH_CONFIG:
case ioc_selection_options:
default:
H5_SUBFILING_GOTO_ERROR(H5E_VFL, H5E_BADVALUE, FAIL, "invalid IOC selection strategy");
break;
Expand Down
5 changes: 3 additions & 2 deletions src/H5FDsubfiling/mercury/LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Copyright (c) 2013-2021, UChicago Argonne, LLC and The HDF Group.
Copyright (c) 2013-2022, UChicago Argonne, LLC and The HDF Group.
Copyright (c) 2022-2023, Intel Corporation.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand All @@ -24,4 +25,4 @@ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Loading

0 comments on commit 17a5a1a

Please sign in to comment.