Skip to content

Commit

Permalink
Merge branch 'HDFGroup:develop' into ECP-344_develop
Browse files Browse the repository at this point in the history
  • Loading branch information
vchoi-hdfgroup authored Nov 8, 2023
2 parents 9059377 + e0d095e commit abdc0c0
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 39 deletions.
5 changes: 1 addition & 4 deletions config/linux-gnulibc1
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,7 @@ case $FC_BASENAME in
nagfor)

F9XSUFFIXFLAG=""
# NOTE: The default is -ieee=stop, which will cause problems
# when the H5T module performs floating-point type
# introspection
AM_FCFLAGS="$AM_FCFLAGS -ieee=full"
AM_FCFLAGS="$AM_FCFLAGS"
FSEARCH_DIRS=""

# Production
Expand Down
4 changes: 2 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -4236,10 +4236,10 @@ AC_CONFIG_FILES([Makefile
hl/fortran/examples/Makefile
hl/fortran/examples/run-hlfortran-ex.sh])

AC_CONFIG_FILES([utils/subfiling_vfd/h5fuse.sh], [chmod +x utils/subfiling_vfd/h5fuse.sh])
AC_CONFIG_FILES([utils/subfiling_vfd/h5fuse], [chmod +x utils/subfiling_vfd/h5fuse])
if test -n "$TESTPARALLEL"; then
if test "X$SUBFILING_VFD" = "Xyes"; then
AC_CONFIG_LINKS([testpar/h5fuse.sh:utils/subfiling_vfd/h5fuse.sh])
AC_CONFIG_LINKS([testpar/h5fuse:utils/subfiling_vfd/h5fuse])
fi
fi

Expand Down
28 changes: 22 additions & 6 deletions release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,22 @@ Bug Fixes since HDF5-1.14.0 release
===================================
Library
-------
- Suppressed floating-point exceptions in H5T init code

The floating-point datatype initialization code in H5Tinit_float.c
could raise FE_INVALID exceptions while munging bits and performing
comparisons that might involve NaN. This was not a problem when the
initialization code was executed in H5detect at compile time (prior
to 1.14.3), but now that the code is executed at library startup
(1.14.3+), these exceptions can be caught by user code, as is the
default in the NAG Fortran compiler.

Starting in 1.14.4, we now suppress floating-point exceptions while
initializing the floating-point types and clear FE_INVALID before
restoring the original environment.

Fixes GitHub #3831

- Fixed a file handle leak in the core VFD

When opening a file with the core VFD and a file image, if the file
Expand Down Expand Up @@ -920,6 +936,12 @@ Bug Fixes since HDF5-1.14.0 release

Tools
-----

- Renamed h5fuse.sh to h5fuse

Addresses Discussion #3791


- Fixed an issue with unmatched MPI messages in ph5diff

The "manager" MPI rank in ph5diff was unintentionally sending "program end"
Expand Down Expand Up @@ -1184,12 +1206,6 @@ Known Problems
-O1 for the time being:
https://forums.developer.nvidia.com/t/hdf5-no-longer-compiles-with-nv-23-9/269045.

IEEE standard arithmetic enables software to raise exceptions such as overflow,
division by zero, and other illegal operations without interrupting or halting
the program flow. The HDF5 C library intentionally performs these exceptions.
Therefore, the "-ieee=full" nagfor switch is necessary when compiling a program
to avoid stopping on an exception.

CMake files do not behave correctly with paths containing spaces.
Do not use spaces in paths because the required escaping for handling spaces
results in very complex and fragile build files.
Expand Down
54 changes: 36 additions & 18 deletions src/H5Tinit_float.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,19 +51,23 @@
* Function: DETECT_F
*
* Purpose: This macro takes a floating point type like `double' and
* a base name like `natd' and detects byte order, mantissa
* location, exponent location, sign bit location, presence or
* absence of implicit mantissa bit, and exponent bias and
* initializes a detected_t structure with those properties.
* and detects byte order, mantissa location, exponent location,
* sign bit location, presence or absence of implicit mantissa
* bit, and exponent bias and initializes a detected_t structure
* with those properties.
*
* Note that these operations can raise floating-point
* exceptions and building with some compiler options
* (especially Fortran) can cause problems.
*-------------------------------------------------------------------------
*/
#define DETECT_F(TYPE, VAR, INFO) \
#define DETECT_F(TYPE, INFO) \
do { \
TYPE _v1, _v2, _v3; \
unsigned char _buf1[sizeof(TYPE)], _buf3[sizeof(TYPE)]; \
unsigned char _pad_mask[sizeof(TYPE)]; \
unsigned char _byte_mask; \
int _i, _j, _last = (-1); \
TYPE _v1, _v2, _v3; \
uint8_t _buf1[sizeof(TYPE)], _buf3[sizeof(TYPE)]; \
uint8_t _pad_mask[sizeof(TYPE)]; \
uint8_t _byte_mask; \
int _i, _j, _last = -1; \
\
memset(&INFO, 0, sizeof(INFO)); \
INFO.size = sizeof(TYPE); \
Expand All @@ -81,7 +85,7 @@
_v1 = (TYPE)4.0L; \
H5MM_memcpy(_buf1, (const void *)&_v1, sizeof(TYPE)); \
for (_i = 0; _i < (int)sizeof(TYPE); _i++) \
for (_byte_mask = (unsigned char)1; _byte_mask; _byte_mask = (unsigned char)(_byte_mask << 1)) { \
for (_byte_mask = (uint8_t)1; _byte_mask; _byte_mask = (uint8_t)(_byte_mask << 1)) { \
_buf1[_i] ^= _byte_mask; \
H5MM_memcpy((void *)&_v2, (const void *)_buf1, sizeof(TYPE)); \
H5_GCC_CLANG_DIAG_OFF("float-equal") \
Expand Down Expand Up @@ -118,20 +122,19 @@
_v1 = (TYPE)1.0L; \
_v2 = (TYPE)-1.0L; \
if (H5T__bit_cmp(sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask, &(INFO.sign)) < 0) \
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "failed to detect byte order"); \
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "failed to determine sign bit"); \
\
/* Mantissa */ \
INFO.mpos = 0; \
\
_v1 = (TYPE)1.0L; \
_v2 = (TYPE)1.5L; \
if (H5T__bit_cmp(sizeof(TYPE), INFO.perm, &_v1, &_v2, _pad_mask, &(INFO.msize)) < 0) \
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "failed to detect byte order"); \
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "failed to determine mantissa"); \
INFO.msize += 1 + (unsigned)(INFO.imp ? 0 : 1) - INFO.mpos; \
\
/* Exponent */ \
INFO.epos = INFO.mpos + INFO.msize; \
\
INFO.epos = INFO.mpos + INFO.msize; \
INFO.esize = INFO.sign - INFO.epos; \
\
_v1 = (TYPE)1.0L; \
Expand Down Expand Up @@ -456,17 +459,24 @@ H5T__set_precision(H5T_fpoint_det_t *d)
herr_t H5_NO_UBSAN
H5T__init_native_float_types(void)
{
fenv_t saved_fenv;
H5T_fpoint_det_t det;
H5T_t *dt = NULL;
herr_t ret_value = SUCCEED;

FUNC_ENTER_PACKAGE

/* Turn off floating-point exceptions while initializing to avoid
* tripping over signaling NaNs while looking at "don't care" bits.
*/
if (feholdexcept(&saved_fenv) != 0)
HSYS_GOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't save floating-point environment");

/* H5T_NATIVE_FLOAT */

/* Get the type's characteristics */
memset(&det, 0, sizeof(H5T_fpoint_det_t));
DETECT_F(float, FLOAT, det);
DETECT_F(float, det);

/* Allocate and fill type structure */
if (NULL == (dt = H5T__alloc()))
Expand Down Expand Up @@ -497,7 +507,7 @@ H5T__init_native_float_types(void)

/* Get the type's characteristics */
memset(&det, 0, sizeof(H5T_fpoint_det_t));
DETECT_F(double, DOUBLE, det);
DETECT_F(double, det);

/* Allocate and fill type structure */
if (NULL == (dt = H5T__alloc()))
Expand Down Expand Up @@ -528,7 +538,7 @@ H5T__init_native_float_types(void)

/* Get the type's characteristics */
memset(&det, 0, sizeof(H5T_fpoint_det_t));
DETECT_F(long double, LDOUBLE, det);
DETECT_F(long double, det);

/* Allocate and fill type structure */
if (NULL == (dt = H5T__alloc()))
Expand Down Expand Up @@ -561,6 +571,14 @@ H5T__init_native_float_types(void)
H5T_native_order_g = det.order;

done:
/* Clear any FE_INVALID exceptions from NaN handling */
if (feclearexcept(FE_INVALID) != 0)
HSYS_GOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't clear floating-point exceptions");

/* Restore the original environment */
if (feupdateenv(&saved_fenv) != 0)
HSYS_GOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't restore floating-point environment");

if (ret_value < 0) {
if (dt != NULL) {
dt->shared = H5FL_FREE(H5T_shared_t, dt->shared);
Expand Down
1 change: 1 addition & 0 deletions src/H5private.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <fenv.h>
#include <float.h>
#include <math.h>
#include <setjmp.h>
Expand Down
4 changes: 2 additions & 2 deletions testpar/t_subfiling_vfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -1898,7 +1898,7 @@ test_subfiling_h5fuse(void)
if (MAINPROCESS) {
FILE *h5fuse_script;

h5fuse_script = fopen("h5fuse.sh", "r");
h5fuse_script = fopen("h5fuse", "r");
if (h5fuse_script)
fclose(h5fuse_script);
else
Expand Down Expand Up @@ -2014,7 +2014,7 @@ test_subfiling_h5fuse(void)
SUBF_FILENAME, file_inode);

args[0] = strdup("env");
args[1] = strdup("./h5fuse.sh");
args[1] = strdup("./h5fuse");
args[2] = strdup("-q");
args[3] = strdup("-f");
args[4] = tmp_filename;
Expand Down
2 changes: 1 addition & 1 deletion utils/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ endif
# All subdirectories
SUBDIRS=$(MIRROR_VFD_DIR) $(TESTUTIL_DIR) $(TOOLS_DIR)

bin_SCRIPTS = subfiling_vfd/h5fuse.sh
bin_SCRIPTS = subfiling_vfd/h5fuse

include $(top_srcdir)/config/conclude.am
8 changes: 4 additions & 4 deletions utils/subfiling_vfd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
cmake_minimum_required (VERSION 3.18)
project (HDF5_UTILS_SUBFILINGVFD C)

configure_file (${HDF5_UTILS_SUBFILINGVFD_SOURCE_DIR}/h5fuse.sh.in ${HDF5_UTILS_SUBFILINGVFD_BINARY_DIR}/h5fuse.sh @ONLY)
configure_file (${HDF5_UTILS_SUBFILINGVFD_SOURCE_DIR}/h5fuse.in ${HDF5_UTILS_SUBFILINGVFD_BINARY_DIR}/h5fuse @ONLY)

# Copy h5fuse.sh to testpar directory for subfiling tests
# Copy h5fuse to testpar directory for subfiling tests
if (HDF5_ENABLE_PARALLEL AND HDF5_TEST_PARALLEL)
file (
COPY
${HDF5_UTILS_SUBFILINGVFD_BINARY_DIR}/h5fuse.sh
${HDF5_UTILS_SUBFILINGVFD_BINARY_DIR}/h5fuse
DESTINATION
${HDF5_TEST_PAR_BINARY_DIR}
)
endif ()

install (
FILES ${HDF5_UTILS_SUBFILINGVFD_BINARY_DIR}/h5fuse.sh
FILES ${HDF5_UTILS_SUBFILINGVFD_BINARY_DIR}/h5fuse
DESTINATION ${HDF5_INSTALL_BIN_DIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
COMPONENT utilsapplications
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ function usage {
configuration file either as a command-line argument or the script will
search for the *.config file in the current directory."
echo ""
echo "usage: h5fuse.sh [-f filename] [-h] [-p] [-q] [-r] [-v] "
echo "usage: h5fuse [-f filename] [-h] [-p] [-q] [-r] [-v] "
echo "-f filename Subfile configuration file."
echo "-h Print this help."
echo "-q Quiet all output. [no]"
echo "-p h5fuse.sh is being run in parallel, with more than one rank. [no]"
echo "-p h5fuse is being run in parallel, with more than one rank. [no]"
echo "-r Remove subfiles after being processed. [no]"
echo "-v Verbose output. [no]"
echo ""
Expand Down

0 comments on commit abdc0c0

Please sign in to comment.