Skip to content

Fix threads and variables. #5523

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

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
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
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -791,14 +791,13 @@ endif ()

# Parallel IO usage requires MPI to be Linked and Included
if (H5_HAVE_PARALLEL)
set (LINK_LIBS ${LINK_LIBS} ${MPI_C_LIBRARIES})
list (APPEND LINK_PUB_LIBS MPI::MPI_C)
if (MPI_C_LINK_FLAGS)
set (CMAKE_EXE_LINKER_FLAGS "${MPI_C_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}")
endif ()
endif ()

# Determine if a threading package is available on this system
option (HDF5_ENABLE_THREADS "Enable thread support" ON)
set (THREADS_PREFER_PTHREAD_FLAG ON)
find_package (Threads)
if (Threads_FOUND)
Expand All @@ -821,12 +820,16 @@ if (Threads_FOUND)
else ()
message (FATAL_ERROR " **** thread support requires C11 threads, Win32 threads or Pthreads **** ")
endif ()
set (HDF5_THREADS_ENABLED ON) # Used to init hdf5-config.cmake
list (APPEND LINK_LIBS Threads::Threads)

# Check for compiler support for atomic variables
CHECK_INCLUDE_FILE("stdatomic.h" HAVE_STDATOMIC_H)
if (HAVE_STDATOMIC_H)
set (H5_HAVE_STDATOMIC_H 1)
endif()
else ()
set (HDF5_THREADS_ENABLED OFF) # Used to init hdf5-config.cmake
endif ()

# Determine whether to build the HDF5 Subfiling VFD
Expand Down Expand Up @@ -863,6 +866,8 @@ if (HDF5_ENABLE_SUBFILING_VFD)
endif()
endif()

message (VERBOSE "LINK_LIBS=${LINK_LIBS}")
message (VERBOSE "LINK_PUB_LIBS=${LINK_PUB_LIBS}")

set (HDF5_DEFAULT_API_VERSION "v200" CACHE STRING "Enable v2.0 API (v16, v18, v110, v112, v114, v200)")
set_property (CACHE HDF5_DEFAULT_API_VERSION PROPERTY STRINGS v16 v18 v110 v112 v114 v200)
Expand Down
1 change: 1 addition & 0 deletions config/cmake/HDF5PluginCache.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ if (NOT DEFINED H5PL_ALLOW_EXTERNAL_SUPPORT)
endif ()

if (H5PL_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT")
set (ENABLE_BITGROOM OFF CACHE BOOL "" FORCE)
set (ENABLE_JPEG OFF CACHE BOOL "" FORCE)
set (ENABLE_LZF OFF CACHE BOOL "" FORCE)
endif ()
Expand Down
4 changes: 2 additions & 2 deletions config/cmake/hdf5-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ set (${HDF5_PACKAGE_NAME}_INSTALL_MOD_FORTRAN "@HDF5_INSTALL_MOD_FORTRAN@")
set (${HDF5_PACKAGE_NAME}_BUILD_HL_LIB @HDF5_BUILD_HL_LIB@)
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}_ENABLE_THREADS @HDF5_ENABLE_THREADS@)
set (${HDF5_PACKAGE_NAME}_THREADS_ENABLED @HDF5_THREADS_ENABLED@)
set (${HDF5_PACKAGE_NAME}_ENABLE_THREADSAFE @HDF5_ENABLE_THREADSAFE@)
set (${HDF5_PACKAGE_NAME}_ENABLE_PARALLEL @HDF5_ENABLE_PARALLEL@)
set (${HDF5_PACKAGE_NAME}_DEFAULT_API_VERSION "@HDF5_DEFAULT_API_VERSION@")
Expand Down Expand Up @@ -92,7 +92,7 @@ if (${HDF5_PACKAGE_NAME}_ENABLE_PARALLEL)
find_package(MPI QUIET REQUIRED)
endif ()

if (${HDF5_PACKAGE_NAME}_ENABLE_THREADS)
if (${HDF5_PACKAGE_NAME}_THREADS_ENABLED)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads QUIET REQUIRED)
endif ()
Expand Down
4 changes: 2 additions & 2 deletions release_docs/AutotoolsToCMakeOptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ release_docs/INSTALL_CMake.txt file for more information on the CMake build syst
| mirror-vfd[Build the socket-based Mirror virtual file driver (VFD). [default=no]] | HDF5_ENABLE_MIRROR_VFD "Build the Mirror Virtual File Driver" [OFF] | if (HDF5_BUILD_UTILS) |
| ros3-vfd[Build the Read-Only S3 virtual file driver (VFD). [default=no]] | HDF5_ENABLE_ROS3_VFD "Build the ROS3 Virtual File Driver" [OFF] | |
| libhdfs[Provide libhdfs library to enable HDFS virtual file driver (VFD) [default=no]] | HDF5_ENABLE_HDFS "Enable HDFS" [OFF] | |
| threads[Enable threads capability. A prerequisite for enabling threadsafe API calls. [default=yes] | HDF5_ENABLE_THREADS "Enable thread support" [ON] | |
| threads[Enable threads capability. A prerequisite for enabling threadsafe API calls. [default=yes] | HDF5_THREADS_ENABLED "Enable thread support" [ON] | |
| threadsafe[Enable thread-safe capability. Not compatible with the high-level library, Fortran, or C++ wrappers. [default=no]] | HDF5_ENABLE_THREADSAFE "Enable Threadsafety" [OFF] | |
| file-locking[Sets the default for whether or not to use file locking when opening files. [default=best-effort]] | HDF5_USE_FILE_LOCKING "Use file locking by default (mainly for SWMR)" [ON] | HDF5_IGNORE_DISABLED_FILE_LOCKS "Ignore file locks when disabled on file system" [ON] |

Expand Down Expand Up @@ -78,5 +78,5 @@ release_docs/INSTALL_CMake.txt file for more information on the CMake build syst
| ------- | ------- | ------------ |
| examplesdir[--with-examplesdir=location], [Specify path for examples [default="DATAROOTDIR/hdf5_examples"]] | | |
| libmfu[--with-libmfu=DIR], [Use the libmfu library [default=no]] | | |
| pthread[--with-pthread=DIR][Specify alternative path to Pthreads library] | Handled by HDF5_ENABLE_THREADS | |
| pthread[--with-pthread=DIR][Specify alternative path to Pthreads library] | Handled by HDF5_THREADS_ENABLED | |

8 changes: 8 additions & 0 deletions release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ New Features

Configuration:
-------------
- Removed HDF5_ENABLE_THREADS option

The HDF5_ENABLE_THREADS option has been removed, as it no longer functions
as a proper build option. The library will always check for thread support
and set the internal status variable, HDF5_THREADS_ENABLED.
The HDF5_ENABLE_THREADSAFE option is still available to build with
thread-safe API calls.

- Added CMake configuration options to override compilers in h5cc:

HDF5_H5CC_C_COMPILER for the C compiler
Expand Down
11 changes: 2 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1110,13 +1110,8 @@ if (BUILD_STATIC_LIBS)
TARGET_C_PROPERTIES (${HDF5_LIB_TARGET} STATIC)
target_link_libraries (${HDF5_LIB_TARGET}
PRIVATE ${LINK_LIBS} ${LINK_COMP_LIBS}
PUBLIC "$<$<PLATFORM_ID:Windows>:${LINK_PUB_LIBS}>" "$<$<NOT:$<PLATFORM_ID:Windows>>:${CMAKE_DL_LIBS}>" "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:MPI::MPI_C>"
PUBLIC ${LINK_PUB_LIBS}
)
if (NOT WIN32)
target_link_libraries (${HDF5_LIB_TARGET}
PRIVATE "$<$<OR:$<BOOL:${HDF5_ENABLE_THREADS}>,$<BOOL:${HDF5_ENABLE_SUBFILING_VFD}>>:Threads::Threads>"
)
endif ()
set_global_variable (HDF5_LIBRARIES_TO_EXPORT ${HDF5_LIB_TARGET})
H5_SET_LIB_OPTIONS (${HDF5_LIB_TARGET} ${HDF5_LIB_NAME} STATIC 0)
set_target_properties (${HDF5_LIB_TARGET} PROPERTIES FOLDER libraries)
Expand All @@ -1137,16 +1132,14 @@ if (BUILD_SHARED_LIBS)
"H5_BUILT_AS_DYNAMIC_LIB"
${HDF_EXTRA_C_FLAGS}
PRIVATE
"$<$<BOOL:${HDF5_ENABLE_THREADS}>:H5_HAVE_THREADS>"
"$<$<BOOL:${HDF5_ENABLE_THREADSAFE}>:H5_HAVE_THREADSAFE>"
"$<$<BOOL:${HDF5_ENABLE_TRACE}>:H5_DEBUG_API>" # Enable tracing of the API
"$<$<BOOL:${HDF5_ENABLE_DEBUG_APIS}>:${HDF5_DEBUG_APIS}>"
"$<$<CONFIG:Developer>:${HDF5_DEVELOPER_DEFS}>"
)
TARGET_C_PROPERTIES (${HDF5_LIBSH_TARGET} SHARED)
target_link_libraries (${HDF5_LIBSH_TARGET}
PRIVATE ${LINK_LIBS} ${LINK_COMP_LIBS}
PUBLIC "$<$<PLATFORM_ID:Windows>:${LINK_PUB_LIBS}>" "$<$<NOT:$<PLATFORM_ID:Windows>>:${CMAKE_DL_LIBS}>" "$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:MPI::MPI_C>" "$<$<OR:$<BOOL:${HDF5_ENABLE_THREADS}>,$<BOOL:${HDF5_ENABLE_SUBFILING_VFD}>>:Threads::Threads>"
PUBLIC ${LINK_PUB_LIBS}
)
set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_LIBSH_TARGET}")
H5_SET_LIB_OPTIONS (${HDF5_LIBSH_TARGET} ${HDF5_LIB_NAME} SHARED "LIB")
Expand Down
2 changes: 1 addition & 1 deletion src/libhdf5.settings.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Features:
Dimension scales w/ new references: @DIMENSION_SCALES_WITH_NEW_REF@
Build HDF5 Tests: @BUILD_TESTING@
Build HDF5 Tools: @HDF5_BUILD_TOOLS@
Threads: @HDF5_ENABLE_THREADS@
Threads: @HDF5_THREADS_ENABLED@
Threadsafety: @HDF5_ENABLE_THREADSAFE@
Concurrency: @HDF5_ENABLE_CONCURRENCY@
Default API mapping: @HDF5_DEFAULT_API_VERSION@
Expand Down
Loading