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

Subfiling VFD source cleanup (#3241) #3290

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
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
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 @@ -127,7 +127,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
25 changes: 1 addition & 24 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -274,33 +274,11 @@ 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})
add_subdirectory (${H5FD_SUBFILING_DIR})
endif()

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
53 changes: 53 additions & 0 deletions src/H5FDsubfiling/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
cmake_minimum_required (VERSION 3.18)
project (HDF5_H5FD_SUBFILING C)

# Sanity checking
if (NOT H5FD_SOURCES)
message (FATAL_ERROR "internal configure error - H5FD_SOURCES not set")
endif ()
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 (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}
)

set (HDF5_H5FD_SUBFILING_HEADERS
${H5FD_SUBFILING_DIR}/H5FDsubfiling.h
${H5FD_SUBFILING_DIR}/H5FDioc.h
)

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

# 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