diff options
44 files changed, 3261 insertions, 759 deletions
diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index 37f306e..9ccb7a4 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -363,6 +363,16 @@ endif () HDF_CHECK_TYPE_SIZE (time_t ${HDF_PREFIX}_SIZEOF_TIME_T) #----------------------------------------------------------------------------- +# Check if _Float16 type is available +#----------------------------------------------------------------------------- +HDF_CHECK_TYPE_SIZE (_Float16 ${HDF_PREFIX}_SIZEOF__FLOAT16) +if (${HDF_PREFIX}_SIZEOF__FLOAT16) + set (${HDF_PREFIX}_HAVE__FLOAT16 1) +else () + set (${HDF_PREFIX}_HAVE__FLOAT16 0) +endif () + +#----------------------------------------------------------------------------- # Extra C99 types #----------------------------------------------------------------------------- diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index da53ade..b5dddba 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -140,6 +140,9 @@ /* Define if support for szip filter is enabled */ #cmakedefine H5_HAVE_FILTER_SZIP @H5_HAVE_FILTER_SZIP@ +/* Determine if _Float16 is available */ +#cmakedefine H5_HAVE__FLOAT16 @H5_HAVE__FLOAT16@ + /* Determine if __float128 is available */ #cmakedefine H5_HAVE_FLOAT128 @H5_HAVE_FLOAT128@ @@ -592,6 +595,9 @@ /* The size of `_Quad', as computed by sizeof. */ #define H5_SIZEOF__QUAD @H5_SIZEOF__QUAD@ +/* The size of `_Float16', as computed by sizeof. */ +#define H5_SIZEOF__FLOAT16 @H5_SIZEOF__FLOAT16@ + /* The size of `__float128', as computed by sizeof. */ #define H5_SIZEOF___FLOAT128 @H5_SIZEOF___FLOAT128@ diff --git a/configure.ac b/configure.ac index f945df5..1d26fb5 100644 --- a/configure.ac +++ b/configure.ac @@ -545,6 +545,17 @@ AC_CHECK_SIZEOF([long long]) AC_CHECK_SIZEOF([float]) AC_CHECK_SIZEOF([double]) AC_CHECK_SIZEOF([long double]) +AC_CHECK_SIZEOF([_Float16]) + +# Define HAVE__FLOAT16 macro for H5pubconf.h if _Float16 is available. +# Also define HAVE__FLOAT16 value to substitute into other files for +# conditional testing +HAVE__FLOAT16="no" +if test "$ac_cv_sizeof__Float16" != 0; then + HAVE__FLOAT16="yes" + AC_DEFINE([HAVE__FLOAT16], [1], [Determine if _Float16 is available]) +fi +AC_SUBST([HAVE__FLOAT16]) ## ---------------------------------------------------------------------- ## Check if the Fortran interface should be enabled diff --git a/doxygen/dox/LearnBasics2.dox b/doxygen/dox/LearnBasics2.dox index f436a02..ed2810c 100644 --- a/doxygen/dox/LearnBasics2.dox +++ b/doxygen/dox/LearnBasics2.dox @@ -626,6 +626,11 @@ into a long integer buffer.) <th span="3"><strong>Float</strong></th> </tr> <tr> +<td>_Float16</td> +<td>#H5T_NATIVE_FLOAT16</td> +<td>#H5T_IEEE_F16BE or #H5T_IEEE_F16LE</td> +</tr> +<tr> <td>float</td> <td>#H5T_NATIVE_FLOAT</td> <td>#H5T_IEEE_F32BE or #H5T_IEEE_F32LE</td> diff --git a/doxygen/examples/tables/predefinedDatatypes.dox b/doxygen/examples/tables/predefinedDatatypes.dox index 2427d0c..6cf044a 100644 --- a/doxygen/examples/tables/predefinedDatatypes.dox +++ b/doxygen/examples/tables/predefinedDatatypes.dox @@ -8,6 +8,14 @@ <th>Description</th> </tr> <tr> +<td>#H5T_IEEE_F16BE</td> +<td>16-bit big-endian IEEE floating point</td> +</tr> +<tr> +<td>#H5T_IEEE_F16LE</td> +<td>16-bit little-endian IEEE floating point</td> +</tr> +<tr> <td>#H5T_IEEE_F32BE</td> <td>32-bit big-endian IEEE floating point</td> </tr> @@ -465,6 +473,10 @@ <td>C-style unsigned long long</td> </tr> <tr> +<td>#H5T_NATIVE_FLOAT16</td> +<td>C-style _Float16 (May be H5I_INVALID_HID if platform doesn't support _Float16 type)</td> +</tr> +<tr> <td>#H5T_NATIVE_FLOAT</td> <td>C-style float</td> </tr> diff --git a/hl/src/H5LT.c b/hl/src/H5LT.c index 099356f..7d44792 100644 --- a/hl/src/H5LT.c +++ b/hl/src/H5LT.c @@ -2287,7 +2287,13 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, bo break; case H5T_FLOAT: - if (H5Tequal(dtype, H5T_IEEE_F32BE)) { + if (H5Tequal(dtype, H5T_IEEE_F16BE)) { + snprintf(dt_str, *slen, "H5T_IEEE_F16BE"); + } + else if (H5Tequal(dtype, H5T_IEEE_F16LE)) { + snprintf(dt_str, *slen, "H5T_IEEE_F16LE"); + } + else if (H5Tequal(dtype, H5T_IEEE_F32BE)) { snprintf(dt_str, *slen, "H5T_IEEE_F32BE"); } else if (H5Tequal(dtype, H5T_IEEE_F32LE)) { @@ -2299,6 +2305,11 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, bo else if (H5Tequal(dtype, H5T_IEEE_F64LE)) { snprintf(dt_str, *slen, "H5T_IEEE_F64LE"); } +#ifdef H5_HAVE__FLOAT16 + else if (H5Tequal(dtype, H5T_NATIVE_FLOAT16)) { + snprintf(dt_str, *slen, "H5T_NATIVE_FLOAT16"); + } +#endif else if (H5Tequal(dtype, H5T_NATIVE_FLOAT)) { snprintf(dt_str, *slen, "H5T_NATIVE_FLOAT"); } diff --git a/hl/src/H5LTanalyze.c b/hl/src/H5LTanalyze.c index 8890b8e..3e6b20d 100644 --- a/hl/src/H5LTanalyze.c +++ b/hl/src/H5LTanalyze.c @@ -29,14 +29,14 @@ #elif defined _MSC_VER #pragma warning(push, 1) #endif -#line 2 "hl/src//H5LTanalyze.c" +#line 1 "hl/src//H5LTanalyze.c" /* Quiet warnings about integer type macro redefinitions on Visual Studio * (MSVC doesn't define STDC_VERSION, but has inttypes.h). This is an * issue that is apparently fixed in flex 2.6.5. */ #include <stdint.h> -#line 9 "hl/src//H5LTanalyze.c" +#line 8 "hl/src//H5LTanalyze.c" #define YY_INT_ALIGNED short int @@ -647,8 +647,8 @@ static void yynoreturn yy_fatal_error ( const char* msg ); (yy_hold_char) = *yy_cp; \ *yy_cp = '\0'; \ (yy_c_buf_p) = yy_cp; -#define YY_NUM_RULES 64 -#define YY_END_OF_BUFFER 65 +#define YY_NUM_RULES 67 +#define YY_END_OF_BUFFER 68 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -656,38 +656,39 @@ struct yy_trans_info flex_int32_t yy_verify; flex_int32_t yy_nxt; }; -static const flex_int16_t yy_accept[275] = +static const flex_int16_t yy_accept[283] = { 0, - 63, 63, 65, 64, 63, 64, 55, 61, 62, 64, - 64, 64, 64, 59, 60, 57, 58, 63, 0, 55, - 0, 0, 0, 0, 0, 56, 0, 0, 0, 0, - 0, 38, 0, 0, 0, 0, 0, 39, 0, 0, + 66, 66, 68, 67, 66, 67, 58, 64, 65, 67, + 67, 67, 67, 62, 63, 60, 61, 66, 0, 58, + 0, 0, 0, 0, 0, 59, 0, 0, 0, 0, + 0, 41, 0, 0, 0, 0, 0, 42, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 37, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 54, 36, 0, 0, 0, 45, 49, 0, 0, - 0, 0, 0, 0, 0, 0, 51, 53, 50, 0, + 0, 57, 39, 0, 0, 0, 48, 52, 0, 0, + 0, 0, 0, 0, 0, 0, 54, 56, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 52, 0, 0, - 0, 0, 0, 0, 0, 0, 35, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 55, 0, 0, + 0, 0, 0, 0, 0, 0, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, - 2, 0, 0, 0, 0, 0, 0, 9, 10, 0, - 0, 47, 0, 44, 0, 0, 0, 0, 0, 0, + 0, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - - 0, 0, 3, 4, 5, 6, 7, 8, 11, 12, - 13, 14, 15, 16, 0, 0, 0, 43, 46, 28, - 29, 30, 31, 0, 0, 0, 22, 0, 0, 0, + 0, 1, 2, 0, 0, 0, 0, 0, 0, 9, + 10, 0, 0, 50, 0, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 17, 0, 0, 0, 0, 24, 0, 0, 0, 23, - 0, 0, 0, 41, 0, 0, 0, 32, 0, 26, - 18, 20, 19, 0, 25, 0, 40, 42, 33, 0, - 27, 21, 34, 0 + + 0, 0, 0, 0, 0, 0, 3, 4, 5, 6, + 7, 8, 11, 12, 13, 14, 15, 16, 0, 0, + 0, 46, 49, 28, 29, 30, 31, 32, 33, 0, + 0, 0, 22, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, + 0, 24, 0, 0, 0, 23, 0, 0, 0, 44, + 0, 0, 0, 35, 0, 26, 18, 20, 19, 0, + 25, 0, 43, 45, 36, 0, 0, 27, 21, 34, + 37, 0 } ; static const YY_CHAR yy_ec[256] = @@ -730,75 +731,77 @@ static const YY_CHAR yy_meta[41] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 } ; -static const flex_int16_t yy_base[277] = +static const flex_int16_t yy_base[285] = { 0, - 0, 0, 299, 300, 296, 0, 0, 300, 300, 11, - 288, 269, 264, 300, 300, 300, 300, 292, 290, 0, - 274, 257, 259, 261, 259, 300, 256, 259, 247, 246, - 16, 300, 265, 33, 14, 268, 259, 300, 251, 24, - 254, 252, 259, 262, 248, 243, 34, 251, 258, 254, - 235, 240, 244, 249, 236, 233, 235, 245, 231, 247, - 36, 231, 241, 223, 237, 300, 238, 241, 227, 222, - 247, 227, 219, 231, 226, 219, 208, 34, 223, 219, - 225, 300, 300, 208, 215, 202, 300, 300, 210, 200, - 204, 204, 38, 210, 39, 220, 300, 300, 300, 201, - - 47, 218, 212, 212, 211, 66, 73, 208, 195, 199, - 210, 199, 193, 191, 196, 75, 182, 300, 209, 212, - 209, 52, 206, 209, 206, 66, 300, 190, 198, 188, - 193, 193, 189, 169, 200, 197, 74, 71, 72, 77, - 186, 185, 84, 86, 87, 184, 183, 177, 183, 180, - 300, 175, 185, 165, 88, 90, 173, 167, 169, 166, - 91, 99, 96, 172, 171, 170, 169, 168, 167, 300, - 300, 166, 165, 164, 163, 162, 161, 300, 300, 94, - 160, 300, 155, 300, 171, 157, 156, 155, 154, 157, - 138, 143, 137, 141, 140, 140, 143, 137, 141, 136, - - 101, 139, 300, 300, 300, 300, 300, 300, 300, 300, - 300, 300, 300, 300, 145, 140, 130, 300, 300, 300, - 300, 300, 300, 127, 140, 140, 300, 121, 127, 131, - 136, 120, 134, 116, 120, 120, 118, 126, 113, 127, - 300, 117, 108, 123, 117, 300, 107, 104, 105, 300, - 108, 112, 102, 300, 105, 106, 104, 300, 93, 300, - 300, 300, 300, 78, 300, 57, 300, 300, 300, 56, - 300, 300, 300, 300, 127, 65 + 0, 0, 307, 308, 304, 0, 0, 308, 308, 11, + 296, 277, 272, 308, 308, 308, 308, 300, 298, 0, + 282, 265, 267, 269, 267, 308, 264, 267, 255, 254, + 16, 308, 273, 33, 14, 276, 267, 308, 259, 24, + 262, 260, 267, 270, 256, 251, 34, 259, 266, 262, + 243, 248, 252, 257, 244, 241, 243, 253, 239, 255, + 36, 239, 249, 231, 245, 308, 246, 249, 235, 230, + 255, 235, 227, 239, 234, 227, 216, 34, 231, 227, + 233, 308, 308, 216, 223, 210, 308, 308, 218, 208, + 212, 212, 38, 218, 39, 228, 308, 308, 308, 209, + + 47, 226, 220, 220, 219, 66, 73, 216, 203, 207, + 218, 207, 201, 199, 204, 80, 190, 308, 217, 220, + 217, 52, 214, 217, 214, 59, 308, 198, 206, 196, + 201, 201, 197, 177, 204, 207, 204, 75, 66, 73, + 78, 193, 192, 80, 85, 87, 191, 190, 184, 190, + 187, 308, 182, 192, 172, 89, 91, 94, 180, 174, + 176, 173, 96, 95, 102, 179, 178, 177, 176, 175, + 174, 308, 308, 173, 172, 171, 170, 169, 168, 308, + 308, 96, 167, 308, 162, 308, 178, 164, 163, 162, + 161, 160, 159, 162, 143, 148, 142, 146, 145, 145, + + 148, 142, 146, 141, 103, 144, 308, 308, 308, 308, + 308, 308, 308, 308, 308, 308, 308, 308, 150, 145, + 135, 308, 308, 308, 308, 308, 308, 308, 308, 132, + 145, 145, 308, 126, 132, 136, 141, 125, 139, 121, + 125, 125, 123, 131, 118, 132, 308, 122, 113, 128, + 122, 308, 112, 109, 110, 308, 113, 117, 107, 308, + 110, 114, 112, 123, 98, 308, 308, 308, 308, 100, + 308, 84, 308, 308, 308, 89, 68, 308, 308, 308, + 308, 308, 132, 65 } ; -static const flex_int16_t yy_def[277] = +static const flex_int16_t yy_def[285] = { 0, - 274, 1, 274, 274, 274, 275, 276, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 275, 276, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 0, 274, 274 + 282, 1, 282, 282, 282, 283, 284, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 283, 284, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 0, 282, 282 } ; -static const flex_int16_t yy_nxt[341] = +static const flex_int16_t yy_nxt[349] = { 0, 4, 5, 6, 7, 7, 7, 7, 7, 7, 7, 7, 8, 9, 4, 4, 10, 4, 4, 4, 4, @@ -806,40 +809,41 @@ static const flex_int16_t yy_nxt[341] = 4, 4, 4, 4, 4, 14, 15, 4, 16, 17, 21, 22, 36, 48, 49, 37, 39, 62, 40, 53, 41, 42, 77, 54, 43, 94, 63, 44, 45, 106, - 113, 55, 46, 109, 78, 47, 141, 20, 110, 107, - 119, 95, 120, 273, 142, 121, 122, 123, 114, 124, - 146, 135, 125, 126, 136, 164, 166, 272, 147, 157, - 158, 168, 159, 165, 167, 160, 161, 271, 172, 169, - - 174, 176, 186, 162, 188, 163, 173, 194, 175, 177, - 187, 199, 189, 195, 197, 270, 196, 200, 201, 198, - 215, 269, 268, 235, 216, 202, 236, 19, 267, 19, - 266, 265, 264, 263, 262, 261, 260, 259, 258, 257, - 256, 255, 254, 253, 252, 251, 250, 249, 248, 247, - 246, 245, 244, 243, 242, 241, 240, 239, 238, 237, - 234, 233, 232, 231, 230, 229, 228, 227, 226, 225, - 224, 223, 222, 221, 220, 219, 218, 217, 214, 213, - 212, 211, 210, 209, 208, 207, 206, 205, 204, 203, - 193, 192, 191, 190, 185, 184, 183, 182, 181, 180, - - 179, 178, 171, 170, 156, 155, 154, 153, 152, 151, - 150, 149, 148, 145, 144, 143, 140, 139, 138, 137, - 134, 133, 132, 131, 130, 129, 128, 127, 118, 117, - 116, 115, 112, 111, 108, 105, 104, 103, 102, 101, - 100, 99, 98, 97, 96, 93, 92, 91, 90, 89, - 88, 87, 86, 85, 84, 83, 82, 81, 80, 79, - 76, 75, 74, 73, 72, 71, 70, 69, 68, 67, - 66, 65, 64, 61, 60, 59, 58, 57, 56, 52, - 51, 50, 38, 35, 34, 33, 32, 31, 30, 29, - 28, 27, 26, 18, 25, 24, 23, 18, 274, 3, - - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274 + 113, 55, 46, 109, 78, 47, 142, 20, 110, 107, + 119, 95, 120, 147, 143, 121, 122, 123, 114, 124, + 166, 148, 125, 126, 135, 281, 136, 168, 167, 137, + 159, 160, 170, 161, 174, 169, 162, 163, 280, 176, + + 171, 178, 175, 188, 164, 190, 165, 177, 192, 179, + 201, 189, 198, 191, 279, 202, 193, 203, 199, 278, + 277, 200, 219, 204, 205, 241, 220, 276, 242, 275, + 274, 206, 19, 273, 19, 272, 271, 270, 269, 268, + 267, 266, 265, 264, 263, 262, 261, 260, 259, 258, + 257, 256, 255, 254, 253, 252, 251, 250, 249, 248, + 247, 246, 245, 244, 243, 240, 239, 238, 237, 236, + 235, 234, 233, 232, 231, 230, 229, 228, 227, 226, + 225, 224, 223, 222, 221, 218, 217, 216, 215, 214, + 213, 212, 211, 210, 209, 208, 207, 197, 196, 195, + + 194, 187, 186, 185, 184, 183, 182, 181, 180, 173, + 172, 158, 157, 156, 155, 154, 153, 152, 151, 150, + 149, 146, 145, 144, 141, 140, 139, 138, 134, 133, + 132, 131, 130, 129, 128, 127, 118, 117, 116, 115, + 112, 111, 108, 105, 104, 103, 102, 101, 100, 99, + 98, 97, 96, 93, 92, 91, 90, 89, 88, 87, + 86, 85, 84, 83, 82, 81, 80, 79, 76, 75, + 74, 73, 72, 71, 70, 69, 68, 67, 66, 65, + 64, 61, 60, 59, 58, 57, 56, 52, 51, 50, + 38, 35, 34, 33, 32, 31, 30, 29, 28, 27, + + 26, 18, 25, 24, 23, 18, 282, 3, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282 } ; -static const flex_int16_t yy_chk[341] = +static const flex_int16_t yy_chk[349] = { 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, @@ -847,37 +851,38 @@ static const flex_int16_t yy_chk[341] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 10, 10, 31, 35, 35, 31, 34, 47, 34, 40, 34, 34, 61, 40, 34, 78, 47, 34, 34, 93, - 101, 40, 34, 95, 61, 34, 122, 276, 95, 93, - 106, 78, 106, 270, 122, 106, 106, 107, 101, 107, - 126, 116, 107, 107, 116, 138, 139, 266, 126, 137, - 137, 140, 137, 138, 139, 137, 137, 264, 143, 140, - - 144, 145, 155, 137, 156, 137, 143, 161, 144, 145, - 155, 163, 156, 161, 162, 259, 161, 163, 163, 162, - 180, 257, 256, 201, 180, 163, 201, 275, 255, 275, - 253, 252, 251, 249, 248, 247, 245, 244, 243, 242, - 240, 239, 238, 237, 236, 235, 234, 233, 232, 231, - 230, 229, 228, 226, 225, 224, 217, 216, 215, 202, - 200, 199, 198, 197, 196, 195, 194, 193, 192, 191, - 190, 189, 188, 187, 186, 185, 183, 181, 177, 176, - 175, 174, 173, 172, 169, 168, 167, 166, 165, 164, - 160, 159, 158, 157, 154, 153, 152, 150, 149, 148, - - 147, 146, 142, 141, 136, 135, 134, 133, 132, 131, - 130, 129, 128, 125, 124, 123, 121, 120, 119, 117, - 115, 114, 113, 112, 111, 110, 109, 108, 105, 104, - 103, 102, 100, 96, 94, 92, 91, 90, 89, 86, - 85, 84, 81, 80, 79, 77, 76, 75, 74, 73, - 72, 71, 70, 69, 68, 67, 65, 64, 63, 62, - 60, 59, 58, 57, 56, 55, 54, 53, 52, 51, - 50, 49, 48, 46, 45, 44, 43, 42, 41, 39, - 37, 36, 33, 30, 29, 28, 27, 25, 24, 23, - 22, 21, 19, 18, 13, 12, 11, 5, 3, 274, - - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274, - 274, 274, 274, 274, 274, 274, 274, 274, 274, 274 + 101, 40, 34, 95, 61, 34, 122, 284, 95, 93, + 106, 78, 106, 126, 122, 106, 106, 107, 101, 107, + 139, 126, 107, 107, 116, 277, 116, 140, 139, 116, + 138, 138, 141, 138, 144, 140, 138, 138, 276, 145, + + 141, 146, 144, 156, 138, 157, 138, 145, 158, 146, + 164, 156, 163, 157, 272, 164, 158, 165, 163, 270, + 265, 163, 182, 165, 165, 205, 182, 264, 205, 263, + 262, 165, 283, 261, 283, 259, 258, 257, 255, 254, + 253, 251, 250, 249, 248, 246, 245, 244, 243, 242, + 241, 240, 239, 238, 237, 236, 235, 234, 232, 231, + 230, 221, 220, 219, 206, 204, 203, 202, 201, 200, + 199, 198, 197, 196, 195, 194, 193, 192, 191, 190, + 189, 188, 187, 185, 183, 179, 178, 177, 176, 175, + 174, 171, 170, 169, 168, 167, 166, 162, 161, 160, + + 159, 155, 154, 153, 151, 150, 149, 148, 147, 143, + 142, 137, 136, 135, 134, 133, 132, 131, 130, 129, + 128, 125, 124, 123, 121, 120, 119, 117, 115, 114, + 113, 112, 111, 110, 109, 108, 105, 104, 103, 102, + 100, 96, 94, 92, 91, 90, 89, 86, 85, 84, + 81, 80, 79, 77, 76, 75, 74, 73, 72, 71, + 70, 69, 68, 67, 65, 64, 63, 62, 60, 59, + 58, 57, 56, 55, 54, 53, 52, 51, 50, 49, + 48, 46, 45, 44, 43, 42, 41, 39, 37, 36, + 33, 30, 29, 28, 27, 25, 24, 23, 22, 21, + + 19, 18, 13, 12, 11, 5, 3, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282, 282, 282, + 282, 282, 282, 282, 282, 282, 282, 282 } ; static yy_state_type yy_last_accepting_state; @@ -936,8 +941,8 @@ static int my_yyinput(char *, int); extern char *myinput; extern size_t input_len; -#line 909 "hl/src//H5LTanalyze.c" -#line 910 "hl/src//H5LTanalyze.c" +#line 913 "hl/src//H5LTanalyze.c" +#line 914 "hl/src//H5LTanalyze.c" #define INITIAL 0 @@ -1149,7 +1154,7 @@ YY_DECL #line 53 "hl/src//H5LTanalyze.l" -#line 1122 "hl/src//H5LTanalyze.c" +#line 1126 "hl/src//H5LTanalyze.c" while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */ { @@ -1176,13 +1181,13 @@ yy_match: while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 275 ) + if ( yy_current_state >= 283 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; ++yy_cp; } - while ( yy_base[yy_current_state] != 300 ); + while ( yy_base[yy_current_state] != 308 ); yy_find_action: yy_act = yy_accept[yy_current_state]; @@ -1344,197 +1349,212 @@ YY_RULE_SETUP case 28: YY_RULE_SETUP #line 85 "hl/src//H5LTanalyze.l" -{return hid(H5T_IEEE_F32BE_TOKEN);} +{return hid(H5T_IEEE_F16BE_TOKEN);} YY_BREAK case 29: YY_RULE_SETUP #line 86 "hl/src//H5LTanalyze.l" -{return hid(H5T_IEEE_F32LE_TOKEN);} +{return hid(H5T_IEEE_F16LE_TOKEN);} YY_BREAK case 30: YY_RULE_SETUP #line 87 "hl/src//H5LTanalyze.l" -{return hid(H5T_IEEE_F64BE_TOKEN);} +{return hid(H5T_IEEE_F32BE_TOKEN);} YY_BREAK case 31: YY_RULE_SETUP #line 88 "hl/src//H5LTanalyze.l" -{return hid(H5T_IEEE_F64LE_TOKEN);} +{return hid(H5T_IEEE_F32LE_TOKEN);} YY_BREAK case 32: YY_RULE_SETUP #line 89 "hl/src//H5LTanalyze.l" -{return hid(H5T_NATIVE_FLOAT_TOKEN);} +{return hid(H5T_IEEE_F64BE_TOKEN);} YY_BREAK case 33: YY_RULE_SETUP #line 90 "hl/src//H5LTanalyze.l" -{return hid(H5T_NATIVE_DOUBLE_TOKEN);} +{return hid(H5T_IEEE_F64LE_TOKEN);} YY_BREAK case 34: YY_RULE_SETUP #line 91 "hl/src//H5LTanalyze.l" -{return hid(H5T_NATIVE_LDOUBLE_TOKEN);} +{return hid(H5T_NATIVE_FLOAT16_TOKEN);} YY_BREAK case 35: YY_RULE_SETUP -#line 93 "hl/src//H5LTanalyze.l" -{return token(H5T_STRING_TOKEN);} +#line 92 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_FLOAT_TOKEN);} YY_BREAK case 36: YY_RULE_SETUP -#line 94 "hl/src//H5LTanalyze.l" -{return token(STRSIZE_TOKEN);} +#line 93 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_DOUBLE_TOKEN);} YY_BREAK case 37: YY_RULE_SETUP -#line 95 "hl/src//H5LTanalyze.l" -{return token(STRPAD_TOKEN);} +#line 94 "hl/src//H5LTanalyze.l" +{return hid(H5T_NATIVE_LDOUBLE_TOKEN);} YY_BREAK case 38: YY_RULE_SETUP #line 96 "hl/src//H5LTanalyze.l" -{return token(CSET_TOKEN);} +{return token(H5T_STRING_TOKEN);} YY_BREAK case 39: YY_RULE_SETUP #line 97 "hl/src//H5LTanalyze.l" -{return token(CTYPE_TOKEN);} +{return token(STRSIZE_TOKEN);} YY_BREAK case 40: YY_RULE_SETUP #line 98 "hl/src//H5LTanalyze.l" -{return token(H5T_STR_NULLTERM_TOKEN);} +{return token(STRPAD_TOKEN);} YY_BREAK case 41: YY_RULE_SETUP #line 99 "hl/src//H5LTanalyze.l" -{return token(H5T_STR_NULLPAD_TOKEN);} +{return token(CSET_TOKEN);} YY_BREAK case 42: YY_RULE_SETUP #line 100 "hl/src//H5LTanalyze.l" -{return token(H5T_STR_SPACEPAD_TOKEN);} +{return token(CTYPE_TOKEN);} YY_BREAK case 43: YY_RULE_SETUP #line 101 "hl/src//H5LTanalyze.l" -{return token(H5T_CSET_ASCII_TOKEN);} +{return token(H5T_STR_NULLTERM_TOKEN);} YY_BREAK case 44: YY_RULE_SETUP #line 102 "hl/src//H5LTanalyze.l" -{return token(H5T_CSET_UTF8_TOKEN);} +{return token(H5T_STR_NULLPAD_TOKEN);} YY_BREAK case 45: YY_RULE_SETUP #line 103 "hl/src//H5LTanalyze.l" -{return token(H5T_C_S1_TOKEN);} +{return token(H5T_STR_SPACEPAD_TOKEN);} YY_BREAK case 46: YY_RULE_SETUP #line 104 "hl/src//H5LTanalyze.l" -{return token(H5T_FORTRAN_S1_TOKEN);} +{return token(H5T_CSET_ASCII_TOKEN);} YY_BREAK case 47: YY_RULE_SETUP #line 105 "hl/src//H5LTanalyze.l" -{return token(H5T_VARIABLE_TOKEN);} +{return token(H5T_CSET_UTF8_TOKEN);} YY_BREAK case 48: YY_RULE_SETUP -#line 107 "hl/src//H5LTanalyze.l" -{return token(H5T_COMPOUND_TOKEN);} +#line 106 "hl/src//H5LTanalyze.l" +{return token(H5T_C_S1_TOKEN);} YY_BREAK case 49: YY_RULE_SETUP -#line 108 "hl/src//H5LTanalyze.l" -{return token(H5T_ENUM_TOKEN);} +#line 107 "hl/src//H5LTanalyze.l" +{return token(H5T_FORTRAN_S1_TOKEN);} YY_BREAK case 50: YY_RULE_SETUP -#line 109 "hl/src//H5LTanalyze.l" -{return token(H5T_ARRAY_TOKEN);} +#line 108 "hl/src//H5LTanalyze.l" +{return token(H5T_VARIABLE_TOKEN);} YY_BREAK case 51: YY_RULE_SETUP #line 110 "hl/src//H5LTanalyze.l" -{return token(H5T_VLEN_TOKEN);} +{return token(H5T_COMPOUND_TOKEN);} YY_BREAK case 52: YY_RULE_SETUP -#line 112 "hl/src//H5LTanalyze.l" -{return token(H5T_OPAQUE_TOKEN);} +#line 111 "hl/src//H5LTanalyze.l" +{return token(H5T_ENUM_TOKEN);} YY_BREAK case 53: YY_RULE_SETUP -#line 113 "hl/src//H5LTanalyze.l" -{return token(OPQ_SIZE_TOKEN);} +#line 112 "hl/src//H5LTanalyze.l" +{return token(H5T_ARRAY_TOKEN);} YY_BREAK case 54: YY_RULE_SETUP -#line 114 "hl/src//H5LTanalyze.l" -{return token(OPQ_TAG_TOKEN);} +#line 113 "hl/src//H5LTanalyze.l" +{return token(H5T_VLEN_TOKEN);} YY_BREAK case 55: YY_RULE_SETUP +#line 115 "hl/src//H5LTanalyze.l" +{return token(H5T_OPAQUE_TOKEN);} + YY_BREAK +case 56: +YY_RULE_SETUP #line 116 "hl/src//H5LTanalyze.l" +{return token(OPQ_SIZE_TOKEN);} + YY_BREAK +case 57: +YY_RULE_SETUP +#line 117 "hl/src//H5LTanalyze.l" +{return token(OPQ_TAG_TOKEN);} + YY_BREAK +case 58: +YY_RULE_SETUP +#line 119 "hl/src//H5LTanalyze.l" { H5LTyylval.ival = atoi(yytext); return NUMBER; } YY_BREAK -case 56: -/* rule 56 can match eol */ +case 59: +/* rule 59 can match eol */ YY_RULE_SETUP -#line 121 "hl/src//H5LTanalyze.l" +#line 124 "hl/src//H5LTanalyze.l" { H5LTyylval.sval = trim_quotes(yytext); return STRING; } YY_BREAK -case 57: +case 60: YY_RULE_SETUP -#line 126 "hl/src//H5LTanalyze.l" +#line 129 "hl/src//H5LTanalyze.l" {return token('{');} YY_BREAK -case 58: +case 61: YY_RULE_SETUP -#line 127 "hl/src//H5LTanalyze.l" +#line 130 "hl/src//H5LTanalyze.l" {return token('}');} YY_BREAK -case 59: +case 62: YY_RULE_SETUP -#line 128 "hl/src//H5LTanalyze.l" +#line 131 "hl/src//H5LTanalyze.l" {return token('[');} YY_BREAK -case 60: +case 63: YY_RULE_SETUP -#line 129 "hl/src//H5LTanalyze.l" +#line 132 "hl/src//H5LTanalyze.l" {return token(']');} YY_BREAK -case 61: +case 64: YY_RULE_SETUP -#line 130 "hl/src//H5LTanalyze.l" +#line 133 "hl/src//H5LTanalyze.l" {return token(':');} YY_BREAK -case 62: +case 65: YY_RULE_SETUP -#line 131 "hl/src//H5LTanalyze.l" +#line 134 "hl/src//H5LTanalyze.l" {return token(';');} YY_BREAK -case 63: -/* rule 63 can match eol */ +case 66: +/* rule 66 can match eol */ YY_RULE_SETUP -#line 132 "hl/src//H5LTanalyze.l" +#line 135 "hl/src//H5LTanalyze.l" ; YY_BREAK -case 64: +case 67: YY_RULE_SETUP -#line 134 "hl/src//H5LTanalyze.l" +#line 137 "hl/src//H5LTanalyze.l" ECHO; YY_BREAK -#line 1507 "hl/src//H5LTanalyze.c" +#line 1526 "hl/src//H5LTanalyze.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1831,7 +1851,7 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 275 ) + if ( yy_current_state >= 283 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; @@ -1859,11 +1879,11 @@ static int yy_get_next_buffer (void) while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) { yy_current_state = (int) yy_def[yy_current_state]; - if ( yy_current_state >= 275 ) + if ( yy_current_state >= 283 ) yy_c = yy_meta[yy_c]; } yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c]; - yy_is_jam = (yy_current_state == 274); + yy_is_jam = (yy_current_state == 282); return yy_is_jam ? 0 : yy_current_state; } @@ -2539,7 +2559,7 @@ void yyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 134 "hl/src//H5LTanalyze.l" +#line 137 "hl/src//H5LTanalyze.l" /* Allocate a copy of `quoted` with the double quote character at diff --git a/hl/src/H5LTanalyze.l b/hl/src/H5LTanalyze.l index 58a6636..a573f81 100644 --- a/hl/src/H5LTanalyze.l +++ b/hl/src/H5LTanalyze.l @@ -82,10 +82,13 @@ H5T_NATIVE_ULONG {return hid(H5T_NATIVE_ULONG_TOKEN);} H5T_NATIVE_LLONG {return hid(H5T_NATIVE_LLONG_TOKEN);} H5T_NATIVE_ULLONG {return hid(H5T_NATIVE_ULLONG_TOKEN);} +H5T_IEEE_F16BE {return hid(H5T_IEEE_F16BE_TOKEN);} +H5T_IEEE_F16LE {return hid(H5T_IEEE_F16LE_TOKEN);} H5T_IEEE_F32BE {return hid(H5T_IEEE_F32BE_TOKEN);} H5T_IEEE_F32LE {return hid(H5T_IEEE_F32LE_TOKEN);} H5T_IEEE_F64BE {return hid(H5T_IEEE_F64BE_TOKEN);} H5T_IEEE_F64LE {return hid(H5T_IEEE_F64LE_TOKEN);} +H5T_NATIVE_FLOAT16 {return hid(H5T_NATIVE_FLOAT16_TOKEN);} H5T_NATIVE_FLOAT {return hid(H5T_NATIVE_FLOAT_TOKEN);} H5T_NATIVE_DOUBLE {return hid(H5T_NATIVE_DOUBLE_TOKEN);} H5T_NATIVE_LDOUBLE {return hid(H5T_NATIVE_LDOUBLE_TOKEN);} diff --git a/hl/src/H5LTparse.c b/hl/src/H5LTparse.c index 592b863..bb71376 100644 --- a/hl/src/H5LTparse.c +++ b/hl/src/H5LTparse.c @@ -213,84 +213,87 @@ enum yysymbol_kind_t YYSYMBOL_H5T_NATIVE_ULONG_TOKEN = 27, /* H5T_NATIVE_ULONG_TOKEN */ YYSYMBOL_H5T_NATIVE_LLONG_TOKEN = 28, /* H5T_NATIVE_LLONG_TOKEN */ YYSYMBOL_H5T_NATIVE_ULLONG_TOKEN = 29, /* H5T_NATIVE_ULLONG_TOKEN */ - YYSYMBOL_H5T_IEEE_F32BE_TOKEN = 30, /* H5T_IEEE_F32BE_TOKEN */ - YYSYMBOL_H5T_IEEE_F32LE_TOKEN = 31, /* H5T_IEEE_F32LE_TOKEN */ - YYSYMBOL_H5T_IEEE_F64BE_TOKEN = 32, /* H5T_IEEE_F64BE_TOKEN */ - YYSYMBOL_H5T_IEEE_F64LE_TOKEN = 33, /* H5T_IEEE_F64LE_TOKEN */ - YYSYMBOL_H5T_NATIVE_FLOAT_TOKEN = 34, /* H5T_NATIVE_FLOAT_TOKEN */ - YYSYMBOL_H5T_NATIVE_DOUBLE_TOKEN = 35, /* H5T_NATIVE_DOUBLE_TOKEN */ - YYSYMBOL_H5T_NATIVE_LDOUBLE_TOKEN = 36, /* H5T_NATIVE_LDOUBLE_TOKEN */ - YYSYMBOL_H5T_STRING_TOKEN = 37, /* H5T_STRING_TOKEN */ - YYSYMBOL_STRSIZE_TOKEN = 38, /* STRSIZE_TOKEN */ - YYSYMBOL_STRPAD_TOKEN = 39, /* STRPAD_TOKEN */ - YYSYMBOL_CSET_TOKEN = 40, /* CSET_TOKEN */ - YYSYMBOL_CTYPE_TOKEN = 41, /* CTYPE_TOKEN */ - YYSYMBOL_H5T_VARIABLE_TOKEN = 42, /* H5T_VARIABLE_TOKEN */ - YYSYMBOL_H5T_STR_NULLTERM_TOKEN = 43, /* H5T_STR_NULLTERM_TOKEN */ - YYSYMBOL_H5T_STR_NULLPAD_TOKEN = 44, /* H5T_STR_NULLPAD_TOKEN */ - YYSYMBOL_H5T_STR_SPACEPAD_TOKEN = 45, /* H5T_STR_SPACEPAD_TOKEN */ - YYSYMBOL_H5T_CSET_ASCII_TOKEN = 46, /* H5T_CSET_ASCII_TOKEN */ - YYSYMBOL_H5T_CSET_UTF8_TOKEN = 47, /* H5T_CSET_UTF8_TOKEN */ - YYSYMBOL_H5T_C_S1_TOKEN = 48, /* H5T_C_S1_TOKEN */ - YYSYMBOL_H5T_FORTRAN_S1_TOKEN = 49, /* H5T_FORTRAN_S1_TOKEN */ - YYSYMBOL_H5T_OPAQUE_TOKEN = 50, /* H5T_OPAQUE_TOKEN */ - YYSYMBOL_OPQ_SIZE_TOKEN = 51, /* OPQ_SIZE_TOKEN */ - YYSYMBOL_OPQ_TAG_TOKEN = 52, /* OPQ_TAG_TOKEN */ - YYSYMBOL_H5T_COMPOUND_TOKEN = 53, /* H5T_COMPOUND_TOKEN */ - YYSYMBOL_H5T_ENUM_TOKEN = 54, /* H5T_ENUM_TOKEN */ - YYSYMBOL_H5T_ARRAY_TOKEN = 55, /* H5T_ARRAY_TOKEN */ - YYSYMBOL_H5T_VLEN_TOKEN = 56, /* H5T_VLEN_TOKEN */ - YYSYMBOL_STRING = 57, /* STRING */ - YYSYMBOL_NUMBER = 58, /* NUMBER */ - YYSYMBOL_59_ = 59, /* '{' */ - YYSYMBOL_60_ = 60, /* '}' */ - YYSYMBOL_61_ = 61, /* '[' */ - YYSYMBOL_62_ = 62, /* ']' */ - YYSYMBOL_63_ = 63, /* ':' */ - YYSYMBOL_64_ = 64, /* ';' */ - YYSYMBOL_YYACCEPT = 65, /* $accept */ - YYSYMBOL_start = 66, /* start */ - YYSYMBOL_ddl_type = 67, /* ddl_type */ - YYSYMBOL_atomic_type = 68, /* atomic_type */ - YYSYMBOL_integer_type = 69, /* integer_type */ - YYSYMBOL_fp_type = 70, /* fp_type */ - YYSYMBOL_compound_type = 71, /* compound_type */ - YYSYMBOL_72_1 = 72, /* $@1 */ - YYSYMBOL_memb_list = 73, /* memb_list */ - YYSYMBOL_memb_def = 74, /* memb_def */ - YYSYMBOL_75_2 = 75, /* $@2 */ - YYSYMBOL_field_name = 76, /* field_name */ - YYSYMBOL_field_offset = 77, /* field_offset */ - YYSYMBOL_offset = 78, /* offset */ - YYSYMBOL_array_type = 79, /* array_type */ - YYSYMBOL_80_3 = 80, /* $@3 */ - YYSYMBOL_dim_list = 81, /* dim_list */ - YYSYMBOL_dim = 82, /* dim */ - YYSYMBOL_83_4 = 83, /* $@4 */ - YYSYMBOL_84_5 = 84, /* $@5 */ - YYSYMBOL_dimsize = 85, /* dimsize */ - YYSYMBOL_vlen_type = 86, /* vlen_type */ - YYSYMBOL_opaque_type = 87, /* opaque_type */ - YYSYMBOL_88_6 = 88, /* @6 */ - YYSYMBOL_89_7 = 89, /* $@7 */ - YYSYMBOL_opaque_size = 90, /* opaque_size */ - YYSYMBOL_opaque_tag = 91, /* opaque_tag */ - YYSYMBOL_string_type = 92, /* string_type */ - YYSYMBOL_93_8 = 93, /* $@8 */ - YYSYMBOL_94_9 = 94, /* $@9 */ - YYSYMBOL_95_10 = 95, /* $@10 */ - YYSYMBOL_96_11 = 96, /* @11 */ - YYSYMBOL_strsize = 97, /* strsize */ - YYSYMBOL_strpad = 98, /* strpad */ - YYSYMBOL_cset = 99, /* cset */ - YYSYMBOL_ctype = 100, /* ctype */ - YYSYMBOL_enum_type = 101, /* enum_type */ - YYSYMBOL_102_12 = 102, /* $@12 */ - YYSYMBOL_enum_list = 103, /* enum_list */ - YYSYMBOL_enum_def = 104, /* enum_def */ - YYSYMBOL_105_13 = 105, /* $@13 */ - YYSYMBOL_enum_symbol = 106, /* enum_symbol */ - YYSYMBOL_enum_val = 107 /* enum_val */ + YYSYMBOL_H5T_IEEE_F16BE_TOKEN = 30, /* H5T_IEEE_F16BE_TOKEN */ + YYSYMBOL_H5T_IEEE_F16LE_TOKEN = 31, /* H5T_IEEE_F16LE_TOKEN */ + YYSYMBOL_H5T_IEEE_F32BE_TOKEN = 32, /* H5T_IEEE_F32BE_TOKEN */ + YYSYMBOL_H5T_IEEE_F32LE_TOKEN = 33, /* H5T_IEEE_F32LE_TOKEN */ + YYSYMBOL_H5T_IEEE_F64BE_TOKEN = 34, /* H5T_IEEE_F64BE_TOKEN */ + YYSYMBOL_H5T_IEEE_F64LE_TOKEN = 35, /* H5T_IEEE_F64LE_TOKEN */ + YYSYMBOL_H5T_NATIVE_FLOAT16_TOKEN = 36, /* H5T_NATIVE_FLOAT16_TOKEN */ + YYSYMBOL_H5T_NATIVE_FLOAT_TOKEN = 37, /* H5T_NATIVE_FLOAT_TOKEN */ + YYSYMBOL_H5T_NATIVE_DOUBLE_TOKEN = 38, /* H5T_NATIVE_DOUBLE_TOKEN */ + YYSYMBOL_H5T_NATIVE_LDOUBLE_TOKEN = 39, /* H5T_NATIVE_LDOUBLE_TOKEN */ + YYSYMBOL_H5T_STRING_TOKEN = 40, /* H5T_STRING_TOKEN */ + YYSYMBOL_STRSIZE_TOKEN = 41, /* STRSIZE_TOKEN */ + YYSYMBOL_STRPAD_TOKEN = 42, /* STRPAD_TOKEN */ + YYSYMBOL_CSET_TOKEN = 43, /* CSET_TOKEN */ + YYSYMBOL_CTYPE_TOKEN = 44, /* CTYPE_TOKEN */ + YYSYMBOL_H5T_VARIABLE_TOKEN = 45, /* H5T_VARIABLE_TOKEN */ + YYSYMBOL_H5T_STR_NULLTERM_TOKEN = 46, /* H5T_STR_NULLTERM_TOKEN */ + YYSYMBOL_H5T_STR_NULLPAD_TOKEN = 47, /* H5T_STR_NULLPAD_TOKEN */ + YYSYMBOL_H5T_STR_SPACEPAD_TOKEN = 48, /* H5T_STR_SPACEPAD_TOKEN */ + YYSYMBOL_H5T_CSET_ASCII_TOKEN = 49, /* H5T_CSET_ASCII_TOKEN */ + YYSYMBOL_H5T_CSET_UTF8_TOKEN = 50, /* H5T_CSET_UTF8_TOKEN */ + YYSYMBOL_H5T_C_S1_TOKEN = 51, /* H5T_C_S1_TOKEN */ + YYSYMBOL_H5T_FORTRAN_S1_TOKEN = 52, /* H5T_FORTRAN_S1_TOKEN */ + YYSYMBOL_H5T_OPAQUE_TOKEN = 53, /* H5T_OPAQUE_TOKEN */ + YYSYMBOL_OPQ_SIZE_TOKEN = 54, /* OPQ_SIZE_TOKEN */ + YYSYMBOL_OPQ_TAG_TOKEN = 55, /* OPQ_TAG_TOKEN */ + YYSYMBOL_H5T_COMPOUND_TOKEN = 56, /* H5T_COMPOUND_TOKEN */ + YYSYMBOL_H5T_ENUM_TOKEN = 57, /* H5T_ENUM_TOKEN */ + YYSYMBOL_H5T_ARRAY_TOKEN = 58, /* H5T_ARRAY_TOKEN */ + YYSYMBOL_H5T_VLEN_TOKEN = 59, /* H5T_VLEN_TOKEN */ + YYSYMBOL_STRING = 60, /* STRING */ + YYSYMBOL_NUMBER = 61, /* NUMBER */ + YYSYMBOL_62_ = 62, /* '{' */ + YYSYMBOL_63_ = 63, /* '}' */ + YYSYMBOL_64_ = 64, /* '[' */ + YYSYMBOL_65_ = 65, /* ']' */ + YYSYMBOL_66_ = 66, /* ':' */ + YYSYMBOL_67_ = 67, /* ';' */ + YYSYMBOL_YYACCEPT = 68, /* $accept */ + YYSYMBOL_start = 69, /* start */ + YYSYMBOL_ddl_type = 70, /* ddl_type */ + YYSYMBOL_atomic_type = 71, /* atomic_type */ + YYSYMBOL_integer_type = 72, /* integer_type */ + YYSYMBOL_fp_type = 73, /* fp_type */ + YYSYMBOL_compound_type = 74, /* compound_type */ + YYSYMBOL_75_1 = 75, /* $@1 */ + YYSYMBOL_memb_list = 76, /* memb_list */ + YYSYMBOL_memb_def = 77, /* memb_def */ + YYSYMBOL_78_2 = 78, /* $@2 */ + YYSYMBOL_field_name = 79, /* field_name */ + YYSYMBOL_field_offset = 80, /* field_offset */ + YYSYMBOL_offset = 81, /* offset */ + YYSYMBOL_array_type = 82, /* array_type */ + YYSYMBOL_83_3 = 83, /* $@3 */ + YYSYMBOL_dim_list = 84, /* dim_list */ + YYSYMBOL_dim = 85, /* dim */ + YYSYMBOL_86_4 = 86, /* $@4 */ + YYSYMBOL_87_5 = 87, /* $@5 */ + YYSYMBOL_dimsize = 88, /* dimsize */ + YYSYMBOL_vlen_type = 89, /* vlen_type */ + YYSYMBOL_opaque_type = 90, /* opaque_type */ + YYSYMBOL_91_6 = 91, /* @6 */ + YYSYMBOL_92_7 = 92, /* $@7 */ + YYSYMBOL_opaque_size = 93, /* opaque_size */ + YYSYMBOL_opaque_tag = 94, /* opaque_tag */ + YYSYMBOL_string_type = 95, /* string_type */ + YYSYMBOL_96_8 = 96, /* $@8 */ + YYSYMBOL_97_9 = 97, /* $@9 */ + YYSYMBOL_98_10 = 98, /* $@10 */ + YYSYMBOL_99_11 = 99, /* @11 */ + YYSYMBOL_strsize = 100, /* strsize */ + YYSYMBOL_strpad = 101, /* strpad */ + YYSYMBOL_cset = 102, /* cset */ + YYSYMBOL_ctype = 103, /* ctype */ + YYSYMBOL_enum_type = 104, /* enum_type */ + YYSYMBOL_105_12 = 105, /* $@12 */ + YYSYMBOL_enum_list = 106, /* enum_list */ + YYSYMBOL_enum_def = 107, /* enum_def */ + YYSYMBOL_108_13 = 108, /* $@13 */ + YYSYMBOL_enum_symbol = 109, /* enum_symbol */ + YYSYMBOL_enum_val = 110 /* enum_val */ }; typedef enum yysymbol_kind_t yysymbol_kind_t; @@ -616,21 +619,21 @@ union yyalloc #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 58 +#define YYFINAL 61 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 197 +#define YYLAST 206 /* YYNTOKENS -- Number of terminals. */ -#define YYNTOKENS 65 +#define YYNTOKENS 68 /* YYNNTS -- Number of nonterminals. */ #define YYNNTS 43 /* YYNRULES -- Number of rules. */ -#define YYNRULES 92 +#define YYNRULES 95 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 134 +#define YYNSTATES 137 /* YYMAXUTOK -- Last valid token kind. */ -#define YYMAXUTOK 313 +#define YYMAXUTOK 316 /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM @@ -649,14 +652,14 @@ static const yytype_int8 yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 63, 64, + 2, 2, 2, 2, 2, 2, 2, 2, 66, 67, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 61, 2, 62, 2, 2, 2, 2, 2, 2, + 2, 64, 2, 65, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 59, 2, 60, 2, 2, 2, 2, + 2, 2, 2, 62, 2, 63, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -675,23 +678,23 @@ static const yytype_int8 yytranslate[] = 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, - 55, 56, 57, 58 + 55, 56, 57, 58, 59, 60, 61 }; #if YYDEBUG /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_int16 yyrline[] = { - 0, 101, 101, 102, 104, 105, 106, 107, 109, 110, - 111, 112, 113, 116, 117, 118, 119, 120, 121, 122, - 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, - 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, - 145, 146, 147, 148, 149, 150, 151, 155, 154, 163, - 164, 166, 166, 203, 211, 212, 215, 217, 217, 226, - 227, 229, 230, 229, 237, 240, 247, 252, 244, 259, - 261, 266, 273, 282, 289, 263, 313, 314, 316, 317, - 318, 320, 321, 323, 324, 328, 327, 332, 333, 335, - 335, 385, 387 + 0, 102, 102, 103, 105, 106, 107, 108, 110, 111, + 112, 113, 114, 117, 118, 119, 120, 121, 122, 123, + 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, + 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, + 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, + 159, 158, 167, 168, 170, 170, 207, 215, 216, 219, + 221, 221, 230, 231, 233, 234, 233, 241, 244, 251, + 256, 248, 263, 265, 270, 277, 286, 293, 267, 317, + 318, 320, 321, 322, 324, 325, 327, 328, 332, 331, + 336, 337, 339, 339, 389, 391 }; #endif @@ -718,24 +721,26 @@ static const char *const yytname[] = "H5T_NATIVE_USHORT_TOKEN", "H5T_NATIVE_INT_TOKEN", "H5T_NATIVE_UINT_TOKEN", "H5T_NATIVE_LONG_TOKEN", "H5T_NATIVE_ULONG_TOKEN", "H5T_NATIVE_LLONG_TOKEN", - "H5T_NATIVE_ULLONG_TOKEN", "H5T_IEEE_F32BE_TOKEN", - "H5T_IEEE_F32LE_TOKEN", "H5T_IEEE_F64BE_TOKEN", "H5T_IEEE_F64LE_TOKEN", - "H5T_NATIVE_FLOAT_TOKEN", "H5T_NATIVE_DOUBLE_TOKEN", - "H5T_NATIVE_LDOUBLE_TOKEN", "H5T_STRING_TOKEN", "STRSIZE_TOKEN", - "STRPAD_TOKEN", "CSET_TOKEN", "CTYPE_TOKEN", "H5T_VARIABLE_TOKEN", - "H5T_STR_NULLTERM_TOKEN", "H5T_STR_NULLPAD_TOKEN", - "H5T_STR_SPACEPAD_TOKEN", "H5T_CSET_ASCII_TOKEN", "H5T_CSET_UTF8_TOKEN", - "H5T_C_S1_TOKEN", "H5T_FORTRAN_S1_TOKEN", "H5T_OPAQUE_TOKEN", - "OPQ_SIZE_TOKEN", "OPQ_TAG_TOKEN", "H5T_COMPOUND_TOKEN", - "H5T_ENUM_TOKEN", "H5T_ARRAY_TOKEN", "H5T_VLEN_TOKEN", "STRING", - "NUMBER", "'{'", "'}'", "'['", "']'", "':'", "';'", "$accept", "start", - "ddl_type", "atomic_type", "integer_type", "fp_type", "compound_type", - "$@1", "memb_list", "memb_def", "$@2", "field_name", "field_offset", - "offset", "array_type", "$@3", "dim_list", "dim", "$@4", "$@5", - "dimsize", "vlen_type", "opaque_type", "@6", "$@7", "opaque_size", - "opaque_tag", "string_type", "$@8", "$@9", "$@10", "@11", "strsize", - "strpad", "cset", "ctype", "enum_type", "$@12", "enum_list", "enum_def", - "$@13", "enum_symbol", "enum_val", YY_NULLPTR + "H5T_NATIVE_ULLONG_TOKEN", "H5T_IEEE_F16BE_TOKEN", + "H5T_IEEE_F16LE_TOKEN", "H5T_IEEE_F32BE_TOKEN", "H5T_IEEE_F32LE_TOKEN", + "H5T_IEEE_F64BE_TOKEN", "H5T_IEEE_F64LE_TOKEN", + "H5T_NATIVE_FLOAT16_TOKEN", "H5T_NATIVE_FLOAT_TOKEN", + "H5T_NATIVE_DOUBLE_TOKEN", "H5T_NATIVE_LDOUBLE_TOKEN", + "H5T_STRING_TOKEN", "STRSIZE_TOKEN", "STRPAD_TOKEN", "CSET_TOKEN", + "CTYPE_TOKEN", "H5T_VARIABLE_TOKEN", "H5T_STR_NULLTERM_TOKEN", + "H5T_STR_NULLPAD_TOKEN", "H5T_STR_SPACEPAD_TOKEN", + "H5T_CSET_ASCII_TOKEN", "H5T_CSET_UTF8_TOKEN", "H5T_C_S1_TOKEN", + "H5T_FORTRAN_S1_TOKEN", "H5T_OPAQUE_TOKEN", "OPQ_SIZE_TOKEN", + "OPQ_TAG_TOKEN", "H5T_COMPOUND_TOKEN", "H5T_ENUM_TOKEN", + "H5T_ARRAY_TOKEN", "H5T_VLEN_TOKEN", "STRING", "NUMBER", "'{'", "'}'", + "'['", "']'", "':'", "';'", "$accept", "start", "ddl_type", + "atomic_type", "integer_type", "fp_type", "compound_type", "$@1", + "memb_list", "memb_def", "$@2", "field_name", "field_offset", "offset", + "array_type", "$@3", "dim_list", "dim", "$@4", "$@5", "dimsize", + "vlen_type", "opaque_type", "@6", "$@7", "opaque_size", "opaque_tag", + "string_type", "$@8", "$@9", "$@10", "@11", "strsize", "strpad", "cset", + "ctype", "enum_type", "$@12", "enum_list", "enum_def", "$@13", + "enum_symbol", "enum_val", YY_NULLPTR }; static const char * @@ -759,20 +764,20 @@ yysymbol_name (yysymbol_kind_t yysymbol) STATE-NUM. */ static const yytype_int16 yypact[] = { - 114, -25, -25, -25, -25, -25, -25, -25, -25, -25, + 120, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, -25, -25, -25, -24, -22, -25, -13, -25, - -11, 49, -25, -25, -25, -25, -25, -25, -25, -25, - -25, -25, 18, 45, 38, 168, 39, 114, -25, -4, - 41, -25, 36, -25, 42, -25, -25, 37, -25, 40, - 56, -25, -3, -25, -25, -25, -25, -25, -25, -25, - -25, 43, -25, 66, 55, 51, -21, 57, -25, 0, - 95, -25, 50, -25, -25, -25, -25, -25, -25, -25, - -25, -25, 89, -25, 90, 97, 92, 99, 52, -25, - -25, -25, -25, -25, -25, 94, -25, 119, 100, -25, - -6, -25, -25, -25, 98, -25, 120, 46, -25, -25, - 101, -25, 103, -25 + -25, -25, -25, -25, -25, -25, -25, -25, -24, -22, + -25, -13, -25, -11, 52, -25, -25, -25, -25, -25, + -25, -25, -25, -25, -25, 18, 48, 41, 177, 42, + 120, -25, -4, 44, -25, 39, -25, 45, -25, -25, + 40, -25, 43, 59, -25, -3, -25, -25, -25, -25, + -25, -25, -25, -25, 46, -25, 69, 58, 54, -21, + 60, -25, 0, 101, -25, 53, -25, -25, -25, -25, + -25, -25, -25, -25, -25, 95, -25, 96, 103, 98, + 105, 55, -25, -25, -25, -25, -25, -25, 100, -25, + 125, 106, -25, -6, -25, -25, -25, 104, -25, 126, + 49, -25, -25, 107, -25, 109, -25 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -783,23 +788,23 @@ static const yytype_int8 yydefact[] = 2, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, 0, 0, 47, 0, 57, - 0, 0, 3, 4, 8, 9, 5, 6, 7, 12, - 10, 11, 0, 0, 0, 0, 0, 0, 1, 0, - 0, 49, 0, 59, 0, 76, 77, 0, 69, 0, - 0, 85, 0, 65, 71, 66, 48, 51, 50, 87, - 61, 0, 60, 0, 0, 0, 0, 0, 58, 0, - 0, 53, 54, 91, 86, 88, 89, 64, 62, 78, - 79, 80, 0, 70, 0, 0, 0, 0, 0, 72, - 67, 56, 55, 52, 92, 0, 63, 0, 0, 90, - 0, 68, 81, 82, 0, 73, 0, 0, 83, 84, - 0, 74, 0, 75 + 42, 43, 44, 45, 46, 47, 48, 49, 0, 0, + 50, 0, 60, 0, 0, 3, 4, 8, 9, 5, + 6, 7, 12, 10, 11, 0, 0, 0, 0, 0, + 0, 1, 0, 0, 52, 0, 62, 0, 79, 80, + 0, 72, 0, 0, 88, 0, 68, 74, 69, 51, + 54, 53, 90, 64, 0, 63, 0, 0, 0, 0, + 0, 61, 0, 0, 56, 57, 94, 89, 91, 92, + 67, 65, 81, 82, 83, 0, 73, 0, 0, 0, + 0, 0, 75, 70, 59, 58, 55, 95, 0, 66, + 0, 0, 93, 0, 71, 84, 85, 0, 76, 0, + 0, 86, 87, 0, 77, 0, 78 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int8 yypgoto[] = { - -25, -25, -15, -25, 111, -25, -25, -25, -25, -25, + -25, -25, -15, -25, 117, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, -25, @@ -809,11 +814,11 @@ static const yytype_int8 yypgoto[] = /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_uint8 yydefgoto[] = { - 0, 41, 42, 43, 44, 45, 46, 54, 70, 78, - 85, 92, 106, 112, 47, 56, 72, 82, 87, 108, - 98, 48, 49, 84, 118, 69, 104, 50, 83, 117, - 126, 132, 67, 102, 124, 130, 51, 79, 86, 95, - 107, 96, 115 + 0, 44, 45, 46, 47, 48, 49, 57, 73, 81, + 88, 95, 109, 115, 50, 59, 75, 85, 90, 111, + 101, 51, 52, 87, 121, 72, 107, 53, 86, 120, + 129, 135, 70, 105, 127, 133, 54, 82, 89, 98, + 110, 99, 118 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If @@ -824,23 +829,24 @@ static const yytype_uint8 yytable[] = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 52, 93, 53, 65, 94, - 122, 123, 64, 99, 100, 101, 55, 36, 57, 58, - 37, 38, 39, 40, 66, 77, 59, 81, 80, 1, - 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 128, 129, 60, 61, 63, 68, - 71, 74, 73, 88, 75, 89, 36, 90, 91, 37, - 38, 39, 40, 105, 116, 97, 76, 1, 2, 3, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 103, 109, 110, 111, 113, 114, 119, 120, - 121, 127, 125, 133, 36, 131, 62, 37, 38, 39, - 40, 1, 2, 3, 4, 5, 6, 7, 8, 9, - 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27 + 31, 32, 33, 34, 35, 36, 37, 38, 55, 96, + 56, 68, 97, 125, 126, 67, 102, 103, 104, 58, + 39, 60, 61, 40, 41, 42, 43, 69, 80, 62, + 84, 83, 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 131, 132, 63, 64, 66, 71, 74, 77, 76, 91, + 78, 92, 39, 93, 94, 40, 41, 42, 43, 108, + 119, 100, 79, 1, 2, 3, 4, 5, 6, 7, + 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 106, 112, 113, 114, 116, 117, 122, 123, 124, + 130, 128, 136, 39, 134, 65, 40, 41, 42, 43, + 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27 }; static const yytype_int8 yycheck[] = @@ -848,23 +854,24 @@ static const yytype_int8 yycheck[] = 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, 59, 57, 59, 42, 60, - 46, 47, 57, 43, 44, 45, 59, 50, 59, 0, - 53, 54, 55, 56, 58, 70, 38, 72, 61, 3, - 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 48, 49, 51, 59, 59, 58, - 64, 64, 60, 60, 64, 39, 50, 52, 57, 53, - 54, 55, 56, 63, 62, 58, 60, 3, 4, 5, - 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 57, 64, 64, 58, 64, 58, 64, 40, - 60, 41, 64, 60, 50, 64, 55, 53, 54, 55, - 56, 3, 4, 5, 6, 7, 8, 9, 10, 11, - 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, - 22, 23, 24, 25, 26, 27, 28, 29 + 33, 34, 35, 36, 37, 38, 39, 40, 62, 60, + 62, 45, 63, 49, 50, 60, 46, 47, 48, 62, + 53, 62, 0, 56, 57, 58, 59, 61, 73, 41, + 75, 64, 3, 4, 5, 6, 7, 8, 9, 10, + 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 51, 52, 54, 62, 62, 61, 67, 67, 63, 63, + 67, 42, 53, 55, 60, 56, 57, 58, 59, 66, + 65, 61, 63, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 40, 60, 67, 67, 61, 67, 61, 67, 43, 63, + 44, 67, 63, 53, 67, 58, 56, 57, 58, 59, + 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29 }; /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of @@ -874,32 +881,32 @@ static const yytype_int8 yystos[] = 0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 50, 53, 54, 55, - 56, 66, 67, 68, 69, 70, 71, 79, 86, 87, - 92, 101, 59, 59, 72, 59, 80, 59, 0, 38, - 51, 59, 69, 59, 67, 42, 58, 97, 58, 90, - 73, 64, 81, 60, 64, 64, 60, 67, 74, 102, - 61, 67, 82, 93, 88, 75, 103, 83, 60, 39, - 52, 57, 76, 57, 60, 104, 106, 58, 85, 43, - 44, 45, 98, 57, 91, 63, 77, 105, 84, 64, - 64, 58, 78, 64, 58, 107, 62, 94, 89, 64, - 40, 60, 46, 47, 99, 64, 95, 41, 48, 49, - 100, 64, 96, 60 + 32, 33, 34, 35, 36, 37, 38, 39, 40, 53, + 56, 57, 58, 59, 69, 70, 71, 72, 73, 74, + 82, 89, 90, 95, 104, 62, 62, 75, 62, 83, + 62, 0, 41, 54, 62, 72, 62, 70, 45, 61, + 100, 61, 93, 76, 67, 84, 63, 67, 67, 63, + 70, 77, 105, 64, 70, 85, 96, 91, 78, 106, + 86, 63, 42, 55, 60, 79, 60, 63, 107, 109, + 61, 88, 46, 47, 48, 101, 60, 94, 66, 80, + 108, 87, 67, 67, 61, 81, 67, 61, 110, 65, + 97, 92, 67, 43, 63, 49, 50, 102, 67, 98, + 44, 51, 52, 103, 67, 99, 63 }; /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ static const yytype_int8 yyr1[] = { - 0, 65, 66, 66, 67, 67, 67, 67, 68, 68, - 68, 68, 68, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, - 69, 69, 69, 69, 69, 69, 69, 69, 69, 69, - 70, 70, 70, 70, 70, 70, 70, 72, 71, 73, - 73, 75, 74, 76, 77, 77, 78, 80, 79, 81, - 81, 83, 84, 82, 85, 86, 88, 89, 87, 90, - 91, 93, 94, 95, 96, 92, 97, 97, 98, 98, - 98, 99, 99, 100, 100, 102, 101, 103, 103, 105, - 104, 106, 107 + 0, 68, 69, 69, 70, 70, 70, 70, 71, 71, + 71, 71, 71, 72, 72, 72, 72, 72, 72, 72, + 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, + 72, 72, 72, 72, 72, 72, 72, 72, 72, 72, + 73, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 75, 74, 76, 76, 78, 77, 79, 80, 80, 81, + 83, 82, 84, 84, 86, 87, 85, 88, 89, 91, + 92, 90, 93, 94, 96, 97, 98, 99, 95, 100, + 100, 101, 101, 101, 102, 102, 103, 103, 105, 104, + 106, 106, 108, 107, 109, 110 }; /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ @@ -909,12 +916,12 @@ static const yytype_int8 yyr2[] = 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 0, 5, 0, - 2, 0, 5, 1, 0, 2, 1, 0, 6, 0, - 2, 0, 0, 5, 1, 4, 0, 0, 11, 1, - 1, 0, 0, 0, 0, 19, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 0, 7, 0, 2, 0, - 4, 1, 1 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 0, 5, 0, 2, 0, 5, 1, 0, 2, 1, + 0, 6, 0, 2, 0, 0, 5, 1, 4, 0, + 0, 11, 1, 1, 0, 0, 0, 0, 19, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 0, 7, + 0, 2, 0, 4, 1, 1 }; @@ -1378,245 +1385,263 @@ yyreduce: switch (yyn) { case 2: /* start: %empty */ -#line 101 "hl/src//H5LTparse.y" +#line 102 "hl/src//H5LTparse.y" { memset(arr_stack, 0, STACK_SIZE*sizeof(struct arr_info)); /*initialize here?*/ } -#line 1353 "hl/src//H5LTparse.c" +#line 1360 "hl/src//H5LTparse.c" break; case 3: /* start: ddl_type */ -#line 102 "hl/src//H5LTparse.y" +#line 103 "hl/src//H5LTparse.y" { return (yyval.hid);} -#line 1359 "hl/src//H5LTparse.c" +#line 1366 "hl/src//H5LTparse.c" break; case 13: /* integer_type: H5T_STD_I8BE_TOKEN */ -#line 116 "hl/src//H5LTparse.y" +#line 117 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_STD_I8BE); } -#line 1365 "hl/src//H5LTparse.c" +#line 1372 "hl/src//H5LTparse.c" break; case 14: /* integer_type: H5T_STD_I8LE_TOKEN */ -#line 117 "hl/src//H5LTparse.y" +#line 118 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_STD_I8LE); } -#line 1371 "hl/src//H5LTparse.c" +#line 1378 "hl/src//H5LTparse.c" break; case 15: /* integer_type: H5T_STD_I16BE_TOKEN */ -#line 118 "hl/src//H5LTparse.y" +#line 119 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_STD_I16BE); } -#line 1377 "hl/src//H5LTparse.c" +#line 1384 "hl/src//H5LTparse.c" break; case 16: /* integer_type: H5T_STD_I16LE_TOKEN */ -#line 119 "hl/src//H5LTparse.y" +#line 120 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_STD_I16LE); } -#line 1383 "hl/src//H5LTparse.c" +#line 1390 "hl/src//H5LTparse.c" break; case 17: /* integer_type: H5T_STD_I32BE_TOKEN */ -#line 120 "hl/src//H5LTparse.y" +#line 121 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_STD_I32BE); } -#line 1389 "hl/src//H5LTparse.c" +#line 1396 "hl/src//H5LTparse.c" break; case 18: /* integer_type: H5T_STD_I32LE_TOKEN */ -#line 121 "hl/src//H5LTparse.y" +#line 122 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_STD_I32LE); } -#line 1395 "hl/src//H5LTparse.c" +#line 1402 "hl/src//H5LTparse.c" break; case 19: /* integer_type: H5T_STD_I64BE_TOKEN */ -#line 122 "hl/src//H5LTparse.y" +#line 123 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_STD_I64BE); } -#line 1401 "hl/src//H5LTparse.c" +#line 1408 "hl/src//H5LTparse.c" break; case 20: /* integer_type: H5T_STD_I64LE_TOKEN */ -#line 123 "hl/src//H5LTparse.y" +#line 124 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_STD_I64LE); } -#line 1407 "hl/src//H5LTparse.c" +#line 1414 "hl/src//H5LTparse.c" break; case 21: /* integer_type: H5T_STD_U8BE_TOKEN */ -#line 124 "hl/src//H5LTparse.y" +#line 125 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_STD_U8BE); } -#line 1413 "hl/src//H5LTparse.c" +#line 1420 "hl/src//H5LTparse.c" break; case 22: /* integer_type: H5T_STD_U8LE_TOKEN */ -#line 125 "hl/src//H5LTparse.y" +#line 126 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_STD_U8LE); } -#line 1419 "hl/src//H5LTparse.c" +#line 1426 "hl/src//H5LTparse.c" break; case 23: /* integer_type: H5T_STD_U16BE_TOKEN */ -#line 126 "hl/src//H5LTparse.y" +#line 127 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_STD_U16BE); } -#line 1425 "hl/src//H5LTparse.c" +#line 1432 "hl/src//H5LTparse.c" break; case 24: /* integer_type: H5T_STD_U16LE_TOKEN */ -#line 127 "hl/src//H5LTparse.y" +#line 128 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_STD_U16LE); } -#line 1431 "hl/src//H5LTparse.c" +#line 1438 "hl/src//H5LTparse.c" break; case 25: /* integer_type: H5T_STD_U32BE_TOKEN */ -#line 128 "hl/src//H5LTparse.y" +#line 129 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_STD_U32BE); } -#line 1437 "hl/src//H5LTparse.c" +#line 1444 "hl/src//H5LTparse.c" break; case 26: /* integer_type: H5T_STD_U32LE_TOKEN */ -#line 129 "hl/src//H5LTparse.y" +#line 130 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_STD_U32LE); } -#line 1443 "hl/src//H5LTparse.c" +#line 1450 "hl/src//H5LTparse.c" break; case 27: /* integer_type: H5T_STD_U64BE_TOKEN */ -#line 130 "hl/src//H5LTparse.y" +#line 131 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_STD_U64BE); } -#line 1449 "hl/src//H5LTparse.c" +#line 1456 "hl/src//H5LTparse.c" break; case 28: /* integer_type: H5T_STD_U64LE_TOKEN */ -#line 131 "hl/src//H5LTparse.y" +#line 132 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_STD_U64LE); } -#line 1455 "hl/src//H5LTparse.c" +#line 1462 "hl/src//H5LTparse.c" break; case 29: /* integer_type: H5T_NATIVE_CHAR_TOKEN */ -#line 132 "hl/src//H5LTparse.y" +#line 133 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_NATIVE_CHAR); } -#line 1461 "hl/src//H5LTparse.c" +#line 1468 "hl/src//H5LTparse.c" break; case 30: /* integer_type: H5T_NATIVE_SCHAR_TOKEN */ -#line 133 "hl/src//H5LTparse.y" +#line 134 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_NATIVE_SCHAR); } -#line 1467 "hl/src//H5LTparse.c" +#line 1474 "hl/src//H5LTparse.c" break; case 31: /* integer_type: H5T_NATIVE_UCHAR_TOKEN */ -#line 134 "hl/src//H5LTparse.y" +#line 135 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_NATIVE_UCHAR); } -#line 1473 "hl/src//H5LTparse.c" +#line 1480 "hl/src//H5LTparse.c" break; case 32: /* integer_type: H5T_NATIVE_SHORT_TOKEN */ -#line 135 "hl/src//H5LTparse.y" +#line 136 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_NATIVE_SHORT); } -#line 1479 "hl/src//H5LTparse.c" +#line 1486 "hl/src//H5LTparse.c" break; case 33: /* integer_type: H5T_NATIVE_USHORT_TOKEN */ -#line 136 "hl/src//H5LTparse.y" +#line 137 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_NATIVE_USHORT); } -#line 1485 "hl/src//H5LTparse.c" +#line 1492 "hl/src//H5LTparse.c" break; case 34: /* integer_type: H5T_NATIVE_INT_TOKEN */ -#line 137 "hl/src//H5LTparse.y" +#line 138 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_NATIVE_INT); } -#line 1491 "hl/src//H5LTparse.c" +#line 1498 "hl/src//H5LTparse.c" break; case 35: /* integer_type: H5T_NATIVE_UINT_TOKEN */ -#line 138 "hl/src//H5LTparse.y" +#line 139 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_NATIVE_UINT); } -#line 1497 "hl/src//H5LTparse.c" +#line 1504 "hl/src//H5LTparse.c" break; case 36: /* integer_type: H5T_NATIVE_LONG_TOKEN */ -#line 139 "hl/src//H5LTparse.y" +#line 140 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_NATIVE_LONG); } -#line 1503 "hl/src//H5LTparse.c" +#line 1510 "hl/src//H5LTparse.c" break; case 37: /* integer_type: H5T_NATIVE_ULONG_TOKEN */ -#line 140 "hl/src//H5LTparse.y" +#line 141 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_NATIVE_ULONG); } -#line 1509 "hl/src//H5LTparse.c" +#line 1516 "hl/src//H5LTparse.c" break; case 38: /* integer_type: H5T_NATIVE_LLONG_TOKEN */ -#line 141 "hl/src//H5LTparse.y" +#line 142 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_NATIVE_LLONG); } -#line 1515 "hl/src//H5LTparse.c" +#line 1522 "hl/src//H5LTparse.c" break; case 39: /* integer_type: H5T_NATIVE_ULLONG_TOKEN */ -#line 142 "hl/src//H5LTparse.y" +#line 143 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_NATIVE_ULLONG); } -#line 1521 "hl/src//H5LTparse.c" +#line 1528 "hl/src//H5LTparse.c" + break; + + case 40: /* fp_type: H5T_IEEE_F16BE_TOKEN */ +#line 146 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_IEEE_F16BE); } +#line 1534 "hl/src//H5LTparse.c" + break; + + case 41: /* fp_type: H5T_IEEE_F16LE_TOKEN */ +#line 147 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_IEEE_F16LE); } +#line 1540 "hl/src//H5LTparse.c" break; - case 40: /* fp_type: H5T_IEEE_F32BE_TOKEN */ -#line 145 "hl/src//H5LTparse.y" + case 42: /* fp_type: H5T_IEEE_F32BE_TOKEN */ +#line 148 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_IEEE_F32BE); } -#line 1527 "hl/src//H5LTparse.c" +#line 1546 "hl/src//H5LTparse.c" break; - case 41: /* fp_type: H5T_IEEE_F32LE_TOKEN */ -#line 146 "hl/src//H5LTparse.y" + case 43: /* fp_type: H5T_IEEE_F32LE_TOKEN */ +#line 149 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_IEEE_F32LE); } -#line 1533 "hl/src//H5LTparse.c" +#line 1552 "hl/src//H5LTparse.c" break; - case 42: /* fp_type: H5T_IEEE_F64BE_TOKEN */ -#line 147 "hl/src//H5LTparse.y" + case 44: /* fp_type: H5T_IEEE_F64BE_TOKEN */ +#line 150 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_IEEE_F64BE); } -#line 1539 "hl/src//H5LTparse.c" +#line 1558 "hl/src//H5LTparse.c" break; - case 43: /* fp_type: H5T_IEEE_F64LE_TOKEN */ -#line 148 "hl/src//H5LTparse.y" + case 45: /* fp_type: H5T_IEEE_F64LE_TOKEN */ +#line 151 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_IEEE_F64LE); } -#line 1545 "hl/src//H5LTparse.c" +#line 1564 "hl/src//H5LTparse.c" break; - case 44: /* fp_type: H5T_NATIVE_FLOAT_TOKEN */ -#line 149 "hl/src//H5LTparse.y" + case 46: /* fp_type: H5T_NATIVE_FLOAT16_TOKEN */ +#line 152 "hl/src//H5LTparse.y" + { (yyval.hid) = H5Tcopy(H5T_NATIVE_FLOAT16); } +#line 1570 "hl/src//H5LTparse.c" + break; + + case 47: /* fp_type: H5T_NATIVE_FLOAT_TOKEN */ +#line 153 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_NATIVE_FLOAT); } -#line 1551 "hl/src//H5LTparse.c" +#line 1576 "hl/src//H5LTparse.c" break; - case 45: /* fp_type: H5T_NATIVE_DOUBLE_TOKEN */ -#line 150 "hl/src//H5LTparse.y" + case 48: /* fp_type: H5T_NATIVE_DOUBLE_TOKEN */ +#line 154 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_NATIVE_DOUBLE); } -#line 1557 "hl/src//H5LTparse.c" +#line 1582 "hl/src//H5LTparse.c" break; - case 46: /* fp_type: H5T_NATIVE_LDOUBLE_TOKEN */ -#line 151 "hl/src//H5LTparse.y" + case 49: /* fp_type: H5T_NATIVE_LDOUBLE_TOKEN */ +#line 155 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tcopy(H5T_NATIVE_LDOUBLE); } -#line 1563 "hl/src//H5LTparse.c" +#line 1588 "hl/src//H5LTparse.c" break; - case 47: /* $@1: %empty */ -#line 155 "hl/src//H5LTparse.y" + case 50: /* $@1: %empty */ +#line 159 "hl/src//H5LTparse.y" { csindex++; cmpd_stack[csindex].id = H5Tcreate(H5T_COMPOUND, 1); /*temporarily set size to 1*/ } -#line 1569 "hl/src//H5LTparse.c" +#line 1594 "hl/src//H5LTparse.c" break; - case 48: /* compound_type: H5T_COMPOUND_TOKEN $@1 '{' memb_list '}' */ -#line 157 "hl/src//H5LTparse.y" + case 51: /* compound_type: H5T_COMPOUND_TOKEN $@1 '{' memb_list '}' */ +#line 161 "hl/src//H5LTparse.y" { (yyval.hid) = cmpd_stack[csindex].id; cmpd_stack[csindex].id = 0; cmpd_stack[csindex].first_memb = 1; csindex--; } -#line 1579 "hl/src//H5LTparse.c" +#line 1604 "hl/src//H5LTparse.c" break; - case 51: /* $@2: %empty */ -#line 166 "hl/src//H5LTparse.y" + case 54: /* $@2: %empty */ +#line 170 "hl/src//H5LTparse.y" { cmpd_stack[csindex].is_field = 1; /*notify lexer a compound member is parsed*/ } -#line 1585 "hl/src//H5LTparse.c" +#line 1610 "hl/src//H5LTparse.c" break; - case 52: /* memb_def: ddl_type $@2 field_name field_offset ';' */ -#line 168 "hl/src//H5LTparse.y" + case 55: /* memb_def: ddl_type $@2 field_name field_offset ';' */ +#line 172 "hl/src//H5LTparse.y" { size_t origin_size, new_size; hid_t dtype_id = cmpd_stack[csindex].id; @@ -1651,108 +1676,108 @@ yyreduce: new_size = H5Tget_size(dtype_id); } -#line 1624 "hl/src//H5LTparse.c" +#line 1649 "hl/src//H5LTparse.c" break; - case 53: /* field_name: STRING */ -#line 204 "hl/src//H5LTparse.y" + case 56: /* field_name: STRING */ +#line 208 "hl/src//H5LTparse.y" { (yyval.sval) = strdup(yylval.sval); free(yylval.sval); yylval.sval = NULL; } -#line 1634 "hl/src//H5LTparse.c" +#line 1659 "hl/src//H5LTparse.c" break; - case 54: /* field_offset: %empty */ -#line 211 "hl/src//H5LTparse.y" + case 57: /* field_offset: %empty */ +#line 215 "hl/src//H5LTparse.y" { (yyval.ival) = 0; } -#line 1640 "hl/src//H5LTparse.c" +#line 1665 "hl/src//H5LTparse.c" break; - case 55: /* field_offset: ':' offset */ -#line 213 "hl/src//H5LTparse.y" + case 58: /* field_offset: ':' offset */ +#line 217 "hl/src//H5LTparse.y" { (yyval.ival) = yylval.ival; } -#line 1646 "hl/src//H5LTparse.c" +#line 1671 "hl/src//H5LTparse.c" break; - case 57: /* $@3: %empty */ -#line 217 "hl/src//H5LTparse.y" + case 60: /* $@3: %empty */ +#line 221 "hl/src//H5LTparse.y" { asindex++; /*pushd onto the stack*/ } -#line 1652 "hl/src//H5LTparse.c" +#line 1677 "hl/src//H5LTparse.c" break; - case 58: /* array_type: H5T_ARRAY_TOKEN $@3 '{' dim_list ddl_type '}' */ -#line 219 "hl/src//H5LTparse.y" + case 61: /* array_type: H5T_ARRAY_TOKEN $@3 '{' dim_list ddl_type '}' */ +#line 223 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tarray_create2((yyvsp[-1].hid), arr_stack[asindex].ndims, arr_stack[asindex].dims); arr_stack[asindex].ndims = 0; asindex--; H5Tclose((yyvsp[-1].hid)); } -#line 1663 "hl/src//H5LTparse.c" +#line 1688 "hl/src//H5LTparse.c" break; - case 61: /* $@4: %empty */ -#line 229 "hl/src//H5LTparse.y" + case 64: /* $@4: %empty */ +#line 233 "hl/src//H5LTparse.y" { arr_stack[asindex].is_dim = 1; /*notice lexer of dimension size*/ } -#line 1669 "hl/src//H5LTparse.c" +#line 1694 "hl/src//H5LTparse.c" break; - case 62: /* $@5: %empty */ -#line 230 "hl/src//H5LTparse.y" + case 65: /* $@5: %empty */ +#line 234 "hl/src//H5LTparse.y" { unsigned ndims = arr_stack[asindex].ndims; arr_stack[asindex].dims[ndims] = (hsize_t)yylval.ival; arr_stack[asindex].ndims++; arr_stack[asindex].is_dim = 0; } -#line 1679 "hl/src//H5LTparse.c" +#line 1704 "hl/src//H5LTparse.c" break; - case 65: /* vlen_type: H5T_VLEN_TOKEN '{' ddl_type '}' */ -#line 241 "hl/src//H5LTparse.y" + case 68: /* vlen_type: H5T_VLEN_TOKEN '{' ddl_type '}' */ +#line 245 "hl/src//H5LTparse.y" { (yyval.hid) = H5Tvlen_create((yyvsp[-1].hid)); H5Tclose((yyvsp[-1].hid)); } -#line 1685 "hl/src//H5LTparse.c" +#line 1710 "hl/src//H5LTparse.c" break; - case 66: /* @6: %empty */ -#line 247 "hl/src//H5LTparse.y" + case 69: /* @6: %empty */ +#line 251 "hl/src//H5LTparse.y" { size_t size = (size_t)yylval.ival; (yyval.hid) = H5Tcreate(H5T_OPAQUE, size); } -#line 1694 "hl/src//H5LTparse.c" +#line 1719 "hl/src//H5LTparse.c" break; - case 67: /* $@7: %empty */ -#line 252 "hl/src//H5LTparse.y" + case 70: /* $@7: %empty */ +#line 256 "hl/src//H5LTparse.y" { H5Tset_tag((yyvsp[-3].hid), yylval.sval); free(yylval.sval); yylval.sval = NULL; } -#line 1704 "hl/src//H5LTparse.c" +#line 1729 "hl/src//H5LTparse.c" break; - case 68: /* opaque_type: H5T_OPAQUE_TOKEN '{' OPQ_SIZE_TOKEN opaque_size ';' @6 OPQ_TAG_TOKEN opaque_tag ';' $@7 '}' */ -#line 257 "hl/src//H5LTparse.y" + case 71: /* opaque_type: H5T_OPAQUE_TOKEN '{' OPQ_SIZE_TOKEN opaque_size ';' @6 OPQ_TAG_TOKEN opaque_tag ';' $@7 '}' */ +#line 261 "hl/src//H5LTparse.y" { (yyval.hid) = (yyvsp[-5].hid); } -#line 1710 "hl/src//H5LTparse.c" +#line 1735 "hl/src//H5LTparse.c" break; - case 71: /* $@8: %empty */ -#line 266 "hl/src//H5LTparse.y" + case 74: /* $@8: %empty */ +#line 270 "hl/src//H5LTparse.y" { if((yyvsp[-1].ival) == H5T_VARIABLE_TOKEN) is_variable = 1; else str_size = yylval.ival; } -#line 1721 "hl/src//H5LTparse.c" +#line 1746 "hl/src//H5LTparse.c" break; - case 72: /* $@9: %empty */ -#line 273 "hl/src//H5LTparse.y" + case 75: /* $@9: %empty */ +#line 277 "hl/src//H5LTparse.y" { if((yyvsp[-1].ival) == H5T_STR_NULLTERM_TOKEN) str_pad = H5T_STR_NULLTERM; @@ -1761,33 +1786,33 @@ yyreduce: else if((yyvsp[-1].ival) == H5T_STR_SPACEPAD_TOKEN) str_pad = H5T_STR_SPACEPAD; } -#line 1734 "hl/src//H5LTparse.c" +#line 1759 "hl/src//H5LTparse.c" break; - case 73: /* $@10: %empty */ -#line 282 "hl/src//H5LTparse.y" + case 76: /* $@10: %empty */ +#line 286 "hl/src//H5LTparse.y" { if((yyvsp[-1].ival) == H5T_CSET_ASCII_TOKEN) str_cset = H5T_CSET_ASCII; else if((yyvsp[-1].ival) == H5T_CSET_UTF8_TOKEN) str_cset = H5T_CSET_UTF8; } -#line 1745 "hl/src//H5LTparse.c" +#line 1770 "hl/src//H5LTparse.c" break; - case 74: /* @11: %empty */ -#line 289 "hl/src//H5LTparse.y" + case 77: /* @11: %empty */ +#line 293 "hl/src//H5LTparse.y" { if((yyvsp[-1].hid) == H5T_C_S1_TOKEN) (yyval.hid) = H5Tcopy(H5T_C_S1); else if((yyvsp[-1].hid) == H5T_FORTRAN_S1_TOKEN) (yyval.hid) = H5Tcopy(H5T_FORTRAN_S1); } -#line 1756 "hl/src//H5LTparse.c" +#line 1781 "hl/src//H5LTparse.c" break; - case 75: /* string_type: H5T_STRING_TOKEN '{' STRSIZE_TOKEN strsize ';' $@8 STRPAD_TOKEN strpad ';' $@9 CSET_TOKEN cset ';' $@10 CTYPE_TOKEN ctype ';' @11 '}' */ -#line 296 "hl/src//H5LTparse.y" + case 78: /* string_type: H5T_STRING_TOKEN '{' STRSIZE_TOKEN strsize ';' $@8 STRPAD_TOKEN strpad ';' $@9 CSET_TOKEN cset ';' $@10 CTYPE_TOKEN ctype ';' @11 '}' */ +#line 300 "hl/src//H5LTparse.y" { hid_t str_id = (yyvsp[-1].hid); @@ -1804,82 +1829,82 @@ yyreduce: (yyval.hid) = str_id; } -#line 1777 "hl/src//H5LTparse.c" +#line 1802 "hl/src//H5LTparse.c" break; - case 76: /* strsize: H5T_VARIABLE_TOKEN */ -#line 313 "hl/src//H5LTparse.y" + case 79: /* strsize: H5T_VARIABLE_TOKEN */ +#line 317 "hl/src//H5LTparse.y" {(yyval.ival) = H5T_VARIABLE_TOKEN;} -#line 1783 "hl/src//H5LTparse.c" +#line 1808 "hl/src//H5LTparse.c" break; - case 78: /* strpad: H5T_STR_NULLTERM_TOKEN */ -#line 316 "hl/src//H5LTparse.y" + case 81: /* strpad: H5T_STR_NULLTERM_TOKEN */ +#line 320 "hl/src//H5LTparse.y" {(yyval.ival) = H5T_STR_NULLTERM_TOKEN;} -#line 1789 "hl/src//H5LTparse.c" +#line 1814 "hl/src//H5LTparse.c" break; - case 79: /* strpad: H5T_STR_NULLPAD_TOKEN */ -#line 317 "hl/src//H5LTparse.y" + case 82: /* strpad: H5T_STR_NULLPAD_TOKEN */ +#line 321 "hl/src//H5LTparse.y" {(yyval.ival) = H5T_STR_NULLPAD_TOKEN;} -#line 1795 "hl/src//H5LTparse.c" +#line 1820 "hl/src//H5LTparse.c" break; - case 80: /* strpad: H5T_STR_SPACEPAD_TOKEN */ -#line 318 "hl/src//H5LTparse.y" + case 83: /* strpad: H5T_STR_SPACEPAD_TOKEN */ +#line 322 "hl/src//H5LTparse.y" {(yyval.ival) = H5T_STR_SPACEPAD_TOKEN;} -#line 1801 "hl/src//H5LTparse.c" +#line 1826 "hl/src//H5LTparse.c" break; - case 81: /* cset: H5T_CSET_ASCII_TOKEN */ -#line 320 "hl/src//H5LTparse.y" + case 84: /* cset: H5T_CSET_ASCII_TOKEN */ +#line 324 "hl/src//H5LTparse.y" {(yyval.ival) = H5T_CSET_ASCII_TOKEN;} -#line 1807 "hl/src//H5LTparse.c" +#line 1832 "hl/src//H5LTparse.c" break; - case 82: /* cset: H5T_CSET_UTF8_TOKEN */ -#line 321 "hl/src//H5LTparse.y" + case 85: /* cset: H5T_CSET_UTF8_TOKEN */ +#line 325 "hl/src//H5LTparse.y" {(yyval.ival) = H5T_CSET_UTF8_TOKEN;} -#line 1813 "hl/src//H5LTparse.c" +#line 1838 "hl/src//H5LTparse.c" break; - case 83: /* ctype: H5T_C_S1_TOKEN */ -#line 323 "hl/src//H5LTparse.y" + case 86: /* ctype: H5T_C_S1_TOKEN */ +#line 327 "hl/src//H5LTparse.y" {(yyval.hid) = H5T_C_S1_TOKEN;} -#line 1819 "hl/src//H5LTparse.c" +#line 1844 "hl/src//H5LTparse.c" break; - case 84: /* ctype: H5T_FORTRAN_S1_TOKEN */ -#line 324 "hl/src//H5LTparse.y" + case 87: /* ctype: H5T_FORTRAN_S1_TOKEN */ +#line 328 "hl/src//H5LTparse.y" {(yyval.hid) = H5T_FORTRAN_S1_TOKEN;} -#line 1825 "hl/src//H5LTparse.c" +#line 1850 "hl/src//H5LTparse.c" break; - case 85: /* $@12: %empty */ -#line 328 "hl/src//H5LTparse.y" + case 88: /* $@12: %empty */ +#line 332 "hl/src//H5LTparse.y" { is_enum = 1; enum_id = H5Tenum_create((yyvsp[-1].hid)); H5Tclose((yyvsp[-1].hid)); } -#line 1831 "hl/src//H5LTparse.c" +#line 1856 "hl/src//H5LTparse.c" break; - case 86: /* enum_type: H5T_ENUM_TOKEN '{' integer_type ';' $@12 enum_list '}' */ -#line 330 "hl/src//H5LTparse.y" + case 89: /* enum_type: H5T_ENUM_TOKEN '{' integer_type ';' $@12 enum_list '}' */ +#line 334 "hl/src//H5LTparse.y" { is_enum = 0; /*reset*/ (yyval.hid) = enum_id; } -#line 1837 "hl/src//H5LTparse.c" +#line 1862 "hl/src//H5LTparse.c" break; - case 89: /* $@13: %empty */ -#line 335 "hl/src//H5LTparse.y" + case 92: /* $@13: %empty */ +#line 339 "hl/src//H5LTparse.y" { is_enum_memb = 1; /*indicate member of enum*/ enum_memb_symbol = strdup(yylval.sval); free(yylval.sval); yylval.sval = NULL; } -#line 1848 "hl/src//H5LTparse.c" +#line 1873 "hl/src//H5LTparse.c" break; - case 90: /* enum_def: enum_symbol $@13 enum_val ';' */ -#line 342 "hl/src//H5LTparse.y" + case 93: /* enum_def: enum_symbol $@13 enum_val ';' */ +#line 346 "hl/src//H5LTparse.y" { char char_val=(char)yylval.ival; short short_val=(short)yylval.ival; @@ -1922,11 +1947,11 @@ yyreduce: H5Tclose(super); H5Tclose(native); } -#line 1895 "hl/src//H5LTparse.c" +#line 1920 "hl/src//H5LTparse.c" break; -#line 1899 "hl/src//H5LTparse.c" +#line 1924 "hl/src//H5LTparse.c" default: break; } diff --git a/hl/src/H5LTparse.h b/hl/src/H5LTparse.h index 84c5fd0..be3c91f 100644 --- a/hl/src/H5LTparse.h +++ b/hl/src/H5LTparse.h @@ -81,35 +81,38 @@ extern int H5LTyydebug; H5T_NATIVE_ULONG_TOKEN = 282, /* H5T_NATIVE_ULONG_TOKEN */ H5T_NATIVE_LLONG_TOKEN = 283, /* H5T_NATIVE_LLONG_TOKEN */ H5T_NATIVE_ULLONG_TOKEN = 284, /* H5T_NATIVE_ULLONG_TOKEN */ - H5T_IEEE_F32BE_TOKEN = 285, /* H5T_IEEE_F32BE_TOKEN */ - H5T_IEEE_F32LE_TOKEN = 286, /* H5T_IEEE_F32LE_TOKEN */ - H5T_IEEE_F64BE_TOKEN = 287, /* H5T_IEEE_F64BE_TOKEN */ - H5T_IEEE_F64LE_TOKEN = 288, /* H5T_IEEE_F64LE_TOKEN */ - H5T_NATIVE_FLOAT_TOKEN = 289, /* H5T_NATIVE_FLOAT_TOKEN */ - H5T_NATIVE_DOUBLE_TOKEN = 290, /* H5T_NATIVE_DOUBLE_TOKEN */ - H5T_NATIVE_LDOUBLE_TOKEN = 291, /* H5T_NATIVE_LDOUBLE_TOKEN */ - H5T_STRING_TOKEN = 292, /* H5T_STRING_TOKEN */ - STRSIZE_TOKEN = 293, /* STRSIZE_TOKEN */ - STRPAD_TOKEN = 294, /* STRPAD_TOKEN */ - CSET_TOKEN = 295, /* CSET_TOKEN */ - CTYPE_TOKEN = 296, /* CTYPE_TOKEN */ - H5T_VARIABLE_TOKEN = 297, /* H5T_VARIABLE_TOKEN */ - H5T_STR_NULLTERM_TOKEN = 298, /* H5T_STR_NULLTERM_TOKEN */ - H5T_STR_NULLPAD_TOKEN = 299, /* H5T_STR_NULLPAD_TOKEN */ - H5T_STR_SPACEPAD_TOKEN = 300, /* H5T_STR_SPACEPAD_TOKEN */ - H5T_CSET_ASCII_TOKEN = 301, /* H5T_CSET_ASCII_TOKEN */ - H5T_CSET_UTF8_TOKEN = 302, /* H5T_CSET_UTF8_TOKEN */ - H5T_C_S1_TOKEN = 303, /* H5T_C_S1_TOKEN */ - H5T_FORTRAN_S1_TOKEN = 304, /* H5T_FORTRAN_S1_TOKEN */ - H5T_OPAQUE_TOKEN = 305, /* H5T_OPAQUE_TOKEN */ - OPQ_SIZE_TOKEN = 306, /* OPQ_SIZE_TOKEN */ - OPQ_TAG_TOKEN = 307, /* OPQ_TAG_TOKEN */ - H5T_COMPOUND_TOKEN = 308, /* H5T_COMPOUND_TOKEN */ - H5T_ENUM_TOKEN = 309, /* H5T_ENUM_TOKEN */ - H5T_ARRAY_TOKEN = 310, /* H5T_ARRAY_TOKEN */ - H5T_VLEN_TOKEN = 311, /* H5T_VLEN_TOKEN */ - STRING = 312, /* STRING */ - NUMBER = 313 /* NUMBER */ + H5T_IEEE_F16BE_TOKEN = 285, /* H5T_IEEE_F16BE_TOKEN */ + H5T_IEEE_F16LE_TOKEN = 286, /* H5T_IEEE_F16LE_TOKEN */ + H5T_IEEE_F32BE_TOKEN = 287, /* H5T_IEEE_F32BE_TOKEN */ + H5T_IEEE_F32LE_TOKEN = 288, /* H5T_IEEE_F32LE_TOKEN */ + H5T_IEEE_F64BE_TOKEN = 289, /* H5T_IEEE_F64BE_TOKEN */ + H5T_IEEE_F64LE_TOKEN = 290, /* H5T_IEEE_F64LE_TOKEN */ + H5T_NATIVE_FLOAT16_TOKEN = 291, /* H5T_NATIVE_FLOAT16_TOKEN */ + H5T_NATIVE_FLOAT_TOKEN = 292, /* H5T_NATIVE_FLOAT_TOKEN */ + H5T_NATIVE_DOUBLE_TOKEN = 293, /* H5T_NATIVE_DOUBLE_TOKEN */ + H5T_NATIVE_LDOUBLE_TOKEN = 294, /* H5T_NATIVE_LDOUBLE_TOKEN */ + H5T_STRING_TOKEN = 295, /* H5T_STRING_TOKEN */ + STRSIZE_TOKEN = 296, /* STRSIZE_TOKEN */ + STRPAD_TOKEN = 297, /* STRPAD_TOKEN */ + CSET_TOKEN = 298, /* CSET_TOKEN */ + CTYPE_TOKEN = 299, /* CTYPE_TOKEN */ + H5T_VARIABLE_TOKEN = 300, /* H5T_VARIABLE_TOKEN */ + H5T_STR_NULLTERM_TOKEN = 301, /* H5T_STR_NULLTERM_TOKEN */ + H5T_STR_NULLPAD_TOKEN = 302, /* H5T_STR_NULLPAD_TOKEN */ + H5T_STR_SPACEPAD_TOKEN = 303, /* H5T_STR_SPACEPAD_TOKEN */ + H5T_CSET_ASCII_TOKEN = 304, /* H5T_CSET_ASCII_TOKEN */ + H5T_CSET_UTF8_TOKEN = 305, /* H5T_CSET_UTF8_TOKEN */ + H5T_C_S1_TOKEN = 306, /* H5T_C_S1_TOKEN */ + H5T_FORTRAN_S1_TOKEN = 307, /* H5T_FORTRAN_S1_TOKEN */ + H5T_OPAQUE_TOKEN = 308, /* H5T_OPAQUE_TOKEN */ + OPQ_SIZE_TOKEN = 309, /* OPQ_SIZE_TOKEN */ + OPQ_TAG_TOKEN = 310, /* OPQ_TAG_TOKEN */ + H5T_COMPOUND_TOKEN = 311, /* H5T_COMPOUND_TOKEN */ + H5T_ENUM_TOKEN = 312, /* H5T_ENUM_TOKEN */ + H5T_ARRAY_TOKEN = 313, /* H5T_ARRAY_TOKEN */ + H5T_VLEN_TOKEN = 314, /* H5T_VLEN_TOKEN */ + STRING = 315, /* STRING */ + NUMBER = 316 /* NUMBER */ }; typedef enum yytokentype yytoken_kind_t; #endif @@ -124,7 +127,7 @@ union YYSTYPE char *sval; /*for name string*/ hid_t hid; /*for hid_t token*/ -#line 128 "hl/src//H5LTparse.h" +#line 131 "hl/src//H5LTparse.h" }; typedef union YYSTYPE YYSTYPE; diff --git a/hl/src/H5LTparse.y b/hl/src/H5LTparse.y index 8621836..3a14e76 100644 --- a/hl/src/H5LTparse.y +++ b/hl/src/H5LTparse.y @@ -79,8 +79,9 @@ static char* enum_memb_symbol; /*enum member symbol string*/ %token <hid> H5T_NATIVE_SHORT_TOKEN H5T_NATIVE_USHORT_TOKEN H5T_NATIVE_INT_TOKEN H5T_NATIVE_UINT_TOKEN %token <hid> H5T_NATIVE_LONG_TOKEN H5T_NATIVE_ULONG_TOKEN H5T_NATIVE_LLONG_TOKEN H5T_NATIVE_ULLONG_TOKEN +%token <hid> H5T_IEEE_F16BE_TOKEN H5T_IEEE_F16LE_TOKEN %token <hid> H5T_IEEE_F32BE_TOKEN H5T_IEEE_F32LE_TOKEN H5T_IEEE_F64BE_TOKEN H5T_IEEE_F64LE_TOKEN -%token <hid> H5T_NATIVE_FLOAT_TOKEN H5T_NATIVE_DOUBLE_TOKEN H5T_NATIVE_LDOUBLE_TOKEN +%token <hid> H5T_NATIVE_FLOAT16_TOKEN H5T_NATIVE_FLOAT_TOKEN H5T_NATIVE_DOUBLE_TOKEN H5T_NATIVE_LDOUBLE_TOKEN %token <ival> H5T_STRING_TOKEN STRSIZE_TOKEN STRPAD_TOKEN CSET_TOKEN CTYPE_TOKEN H5T_VARIABLE_TOKEN %token <ival> H5T_STR_NULLTERM_TOKEN H5T_STR_NULLPAD_TOKEN H5T_STR_SPACEPAD_TOKEN @@ -142,10 +143,13 @@ integer_type : H5T_STD_I8BE_TOKEN { $<hid>$ = H5Tcopy(H5T_STD_I8BE); } | H5T_NATIVE_ULLONG_TOKEN { $<hid>$ = H5Tcopy(H5T_NATIVE_ULLONG); } ; -fp_type : H5T_IEEE_F32BE_TOKEN { $<hid>$ = H5Tcopy(H5T_IEEE_F32BE); } +fp_type : H5T_IEEE_F16BE_TOKEN { $<hid>$ = H5Tcopy(H5T_IEEE_F16BE); } + | H5T_IEEE_F16LE_TOKEN { $<hid>$ = H5Tcopy(H5T_IEEE_F16LE); } + | H5T_IEEE_F32BE_TOKEN { $<hid>$ = H5Tcopy(H5T_IEEE_F32BE); } | H5T_IEEE_F32LE_TOKEN { $<hid>$ = H5Tcopy(H5T_IEEE_F32LE); } | H5T_IEEE_F64BE_TOKEN { $<hid>$ = H5Tcopy(H5T_IEEE_F64BE); } | H5T_IEEE_F64LE_TOKEN { $<hid>$ = H5Tcopy(H5T_IEEE_F64LE); } + | H5T_NATIVE_FLOAT16_TOKEN { $<hid>$ = H5Tcopy(H5T_NATIVE_FLOAT16); } | H5T_NATIVE_FLOAT_TOKEN { $<hid>$ = H5Tcopy(H5T_NATIVE_FLOAT); } | H5T_NATIVE_DOUBLE_TOKEN { $<hid>$ = H5Tcopy(H5T_NATIVE_DOUBLE); } | H5T_NATIVE_LDOUBLE_TOKEN { $<hid>$ = H5Tcopy(H5T_NATIVE_LDOUBLE); } diff --git a/java/src/hdf/hdf5lib/HDF5Constants.java b/java/src/hdf/hdf5lib/HDF5Constants.java index 25b65fa..55b6f4b 100644 --- a/java/src/hdf/hdf5lib/HDF5Constants.java +++ b/java/src/hdf/hdf5lib/HDF5Constants.java @@ -1095,6 +1095,10 @@ public class HDF5Constants { /** */ public static final long H5T_FORTRAN_S1 = H5T_FORTRAN_S1(); /** */ + public static final long H5T_IEEE_F16BE = H5T_IEEE_F16BE(); + /** */ + public static final long H5T_IEEE_F16LE = H5T_IEEE_F16LE(); + /** */ public static final long H5T_IEEE_F32BE = H5T_IEEE_F32BE(); /** */ public static final long H5T_IEEE_F32LE = H5T_IEEE_F32LE(); @@ -1175,6 +1179,8 @@ public class HDF5Constants { /** */ public static final long H5T_NATIVE_FLOAT = H5T_NATIVE_FLOAT(); /** */ + public static final long H5T_NATIVE_FLOAT16 = H5T_NATIVE_FLOAT16(); + /** */ public static final long H5T_NATIVE_HADDR = H5T_NATIVE_HADDR(); /** */ public static final long H5T_NATIVE_HBOOL = H5T_NATIVE_HBOOL(); @@ -2580,6 +2586,10 @@ public class HDF5Constants { private static native final long H5T_FORTRAN_S1(); + private static native final long H5T_IEEE_F16BE(); + + private static native final long H5T_IEEE_F16LE(); + private static native final long H5T_IEEE_F32BE(); private static native final long H5T_IEEE_F32LE(); @@ -2660,6 +2670,8 @@ public class HDF5Constants { private static native final long H5T_NATIVE_FLOAT(); + private static native final long H5T_NATIVE_FLOAT16(); + private static native final long H5T_NATIVE_HADDR(); private static native final long H5T_NATIVE_HBOOL(); diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c index d83b462..ee1bd5a 100644 --- a/java/src/jni/h5Constants.c +++ b/java/src/jni/h5Constants.c @@ -2678,6 +2678,16 @@ Java_hdf_hdf5lib_HDF5Constants_H5T_1FORTRAN_1S1(JNIEnv *env, jclass cls) return H5T_FORTRAN_S1; } JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5T_1IEEE_1F16BE(JNIEnv *env, jclass cls) +{ + return H5T_IEEE_F16BE; +} +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5T_1IEEE_1F16LE(JNIEnv *env, jclass cls) +{ + return H5T_IEEE_F16LE; +} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1IEEE_1F32BE(JNIEnv *env, jclass cls) { return H5T_IEEE_F32BE; @@ -2878,6 +2888,11 @@ Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1FLOAT(JNIEnv *env, jclass cls) return H5T_NATIVE_FLOAT; } JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1FLOAT16(JNIEnv *env, jclass cls) +{ + return H5T_NATIVE_FLOAT16; +} +JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1NATIVE_1HADDR(JNIEnv *env, jclass cls) { return H5T_NATIVE_HADDR; diff --git a/java/src/jni/h5util.c b/java/src/jni/h5util.c index bf798b8..d10ab83 100644 --- a/java/src/jni/h5util.c +++ b/java/src/jni/h5util.c @@ -2082,7 +2082,9 @@ h5str_get_little_endian_type(hid_t tid) } case H5T_FLOAT: { - if (size == 4) + if (size == 2) + p_type = H5Tcopy(H5T_IEEE_F16LE); + else if (size == 4) p_type = H5Tcopy(H5T_IEEE_F32LE); else if (size == 8) p_type = H5Tcopy(H5T_IEEE_F64LE); @@ -2176,7 +2178,9 @@ h5str_get_big_endian_type(hid_t tid) } case H5T_FLOAT: { - if (size == 4) + if (size == 2) + p_type = H5Tcopy(H5T_IEEE_F16BE); + else if (size == 4) p_type = H5Tcopy(H5T_IEEE_F32BE); else if (size == 8) p_type = H5Tcopy(H5T_IEEE_F64BE); @@ -100,6 +100,30 @@ dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; \ } +/* Define the code templates for standard 16-bit floats for the "GUTS" in the H5T_INIT_TYPE macro */ +#define H5T_INIT_TYPE_FLOAT16_COMMON(ENDIANNESS) \ + { \ + H5T_INIT_TYPE_NUM_COMMON(ENDIANNESS) \ + dt->shared->u.atomic.u.f.sign = 15; \ + dt->shared->u.atomic.u.f.epos = 10; \ + dt->shared->u.atomic.u.f.esize = 5; \ + dt->shared->u.atomic.u.f.ebias = 0xf; \ + dt->shared->u.atomic.u.f.mpos = 0; \ + dt->shared->u.atomic.u.f.msize = 10; \ + dt->shared->u.atomic.u.f.norm = H5T_NORM_IMPLIED; \ + dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; \ + } + +#define H5T_INIT_TYPE_FLOAT16LE_CORE \ + { \ + H5T_INIT_TYPE_FLOAT16_COMMON(H5T_ORDER_LE) \ + } + +#define H5T_INIT_TYPE_FLOAT16BE_CORE \ + { \ + H5T_INIT_TYPE_FLOAT16_COMMON(H5T_ORDER_BE) \ + } + /* Define the code templates for standard floats for the "GUTS" in the H5T_INIT_TYPE macro */ #define H5T_INIT_TYPE_FLOAT_COMMON(ENDIANNESS) \ { \ @@ -374,6 +398,8 @@ H5T_order_t H5T_native_order_g = H5T_ORDER_ERROR; * If more of these are added, the new ones must be added to the list of * types to reset in H5T_term_package(). */ +hid_t H5T_IEEE_F16BE_g = FAIL; +hid_t H5T_IEEE_F16LE_g = FAIL; hid_t H5T_IEEE_F32BE_g = FAIL; hid_t H5T_IEEE_F32LE_g = FAIL; hid_t H5T_IEEE_F64BE_g = FAIL; @@ -429,6 +455,7 @@ hid_t H5T_NATIVE_LONG_g = FAIL; hid_t H5T_NATIVE_ULONG_g = FAIL; hid_t H5T_NATIVE_LLONG_g = FAIL; hid_t H5T_NATIVE_ULLONG_g = FAIL; +hid_t H5T_NATIVE_FLOAT16_g = FAIL; hid_t H5T_NATIVE_FLOAT_g = FAIL; hid_t H5T_NATIVE_DOUBLE_g = FAIL; hid_t H5T_NATIVE_LDOUBLE_g = FAIL; @@ -497,6 +524,7 @@ size_t H5T_NATIVE_LONG_ALIGN_g = 0; size_t H5T_NATIVE_ULONG_ALIGN_g = 0; size_t H5T_NATIVE_LLONG_ALIGN_g = 0; size_t H5T_NATIVE_ULLONG_ALIGN_g = 0; +size_t H5T_NATIVE_FLOAT16_ALIGN_g = 0; size_t H5T_NATIVE_FLOAT_ALIGN_g = 0; size_t H5T_NATIVE_DOUBLE_ALIGN_g = 0; size_t H5T_NATIVE_LDOUBLE_ALIGN_g = 0; @@ -532,6 +560,15 @@ size_t H5T_NATIVE_UINT_FAST64_ALIGN_g = 0; /* Useful floating-point values for conversion routines */ /* (+/- Inf for all floating-point types) */ +#ifdef H5_HAVE__FLOAT16 +/* Initialize these with a float literal since the f16 suffix + * is non-standard C and gives warnings when compiling the + * library with the -pedantic flag. These values will be + * overwritten anyway. + */ +H5__Float16 H5T_NATIVE_FLOAT16_POS_INF_g = 0.0f; +H5__Float16 H5T_NATIVE_FLOAT16_NEG_INF_g = 0.0f; +#endif float H5T_NATIVE_FLOAT_POS_INF_g = 0.0F; float H5T_NATIVE_FLOAT_NEG_INF_g = 0.0F; double H5T_NATIVE_DOUBLE_POS_INF_g = 0.0; @@ -684,6 +721,49 @@ H5T__init_inf(void) } /* end for */ } /* end if */ +#ifdef H5_HAVE__FLOAT16 + /* Get the _Float16 datatype */ + if (NULL == (dst_p = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT16_g))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype"); + dst = &dst_p->shared->u.atomic; + + /* Check that we can re-order the bytes correctly */ + if (H5T_ORDER_LE != H5T_native_order_g && H5T_ORDER_BE != H5T_native_order_g) + HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order"); + + /* +Inf */ + d = (uint8_t *)&H5T_NATIVE_FLOAT16_POS_INF_g; + H5T__bit_set(d, dst->u.f.sign, (size_t)1, false); + H5T__bit_set(d, dst->u.f.epos, dst->u.f.esize, true); + H5T__bit_set(d, dst->u.f.mpos, dst->u.f.msize, false); + + /* Swap the bytes if the machine architecture is big-endian */ + if (H5T_ORDER_BE == H5T_native_order_g) { + half_size = dst_p->shared->size / 2; + for (u = 0; u < half_size; u++) { + uint8_t tmp = d[dst_p->shared->size - (u + 1)]; + d[dst_p->shared->size - (u + 1)] = d[u]; + d[u] = tmp; + } /* end for */ + } /* end if */ + + /* -Inf */ + d = (uint8_t *)&H5T_NATIVE_FLOAT16_NEG_INF_g; + H5T__bit_set(d, dst->u.f.sign, (size_t)1, true); + H5T__bit_set(d, dst->u.f.epos, dst->u.f.esize, true); + H5T__bit_set(d, dst->u.f.mpos, dst->u.f.msize, false); + + /* Swap the bytes if the machine architecture is big-endian */ + if (H5T_ORDER_BE == H5T_native_order_g) { + half_size = dst_p->shared->size / 2; + for (u = 0; u < half_size; u++) { + uint8_t tmp = d[dst_p->shared->size - (u + 1)]; + d[dst_p->shared->size - (u + 1)] = d[u]; + d[u] = tmp; + } /* end for */ + } /* end if */ +#endif + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__init_inf() */ @@ -737,6 +817,9 @@ H5T_init(void) herr_t status; bool copied_dtype = true; /* Flag to indicate whether datatype was copied or allocated (for error cleanup) */ +#ifdef H5_HAVE__FLOAT16 + H5T_t *native_float16 = NULL; /* Datatype structure for native _Float16 type */ +#endif herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -778,6 +861,10 @@ H5T_init(void) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if (NULL == (native_ullong = (H5T_t *)H5I_object(H5T_NATIVE_ULLONG_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); +#ifdef H5_HAVE__FLOAT16 + if (NULL == (native_float16 = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT16_g))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); +#endif if (NULL == (native_float = (H5T_t *)H5I_object(H5T_NATIVE_FLOAT_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype object"); if (NULL == (native_double = (H5T_t *)H5I_object(H5T_NATIVE_DOUBLE_g))) @@ -822,6 +909,12 @@ H5T_init(void) *------------------------------------------------------------ */ + /* IEEE 2-byte little-endian float */ + H5T_INIT_TYPE(FLOAT16LE, H5T_IEEE_F16LE_g, COPY, native_double, SET, 2) + + /* IEEE 2-byte big-endian float */ + H5T_INIT_TYPE(FLOAT16BE, H5T_IEEE_F16BE_g, COPY, native_double, SET, 2) + /* IEEE 4-byte little-endian float */ H5T_INIT_TYPE(FLOATLE, H5T_IEEE_F32LE_g, COPY, native_double, SET, 4) @@ -1061,6 +1154,20 @@ H5T_init(void) H5T__register_int(H5T_PERS_HARD, "ldbl_flt", native_ldouble, native_float, H5T__conv_ldouble_float); status |= H5T__register_int(H5T_PERS_HARD, "ldbl_dbl", native_ldouble, native_double, H5T__conv_ldouble_double); +#ifdef H5_HAVE__FLOAT16 + status |= + H5T__register_int(H5T_PERS_HARD, "flt16_flt", native_float16, native_float, H5T__conv__Float16_float); + status |= H5T__register_int(H5T_PERS_HARD, "flt16_dbl", native_float16, native_double, + H5T__conv__Float16_double); + status |= H5T__register_int(H5T_PERS_HARD, "flt16_ldbl", native_float16, native_ldouble, + H5T__conv__Float16_ldouble); + status |= + H5T__register_int(H5T_PERS_HARD, "flt_flt16", native_float, native_float16, H5T__conv_float__Float16); + status |= H5T__register_int(H5T_PERS_HARD, "dbl_flt16", native_double, native_float16, + H5T__conv_double__Float16); + status |= H5T__register_int(H5T_PERS_HARD, "ldbl_flt16", native_ldouble, native_float16, + H5T__conv_ldouble__Float16); +#endif /* from long long */ status |= @@ -1219,6 +1326,10 @@ H5T_init(void) H5T__register_int(H5T_PERS_HARD, "schar_dbl", native_schar, native_double, H5T__conv_schar_double); status |= H5T__register_int(H5T_PERS_HARD, "schar_ldbl", native_schar, native_ldouble, H5T__conv_schar_ldouble); +#ifdef H5_HAVE__FLOAT16 + status |= H5T__register_int(H5T_PERS_HARD, "schar_flt16", native_schar, native_float16, + H5T__conv_schar__Float16); +#endif /* From unsigned char to floats */ status |= @@ -1227,6 +1338,10 @@ H5T_init(void) H5T__register_int(H5T_PERS_HARD, "uchar_dbl", native_uchar, native_double, H5T__conv_uchar_double); status |= H5T__register_int(H5T_PERS_HARD, "uchar_ldbl", native_uchar, native_ldouble, H5T__conv_uchar_ldouble); +#ifdef H5_HAVE__FLOAT16 + status |= H5T__register_int(H5T_PERS_HARD, "uchar_flt16", native_uchar, native_float16, + H5T__conv_uchar__Float16); +#endif /* From short to floats */ status |= @@ -1235,6 +1350,10 @@ H5T_init(void) H5T__register_int(H5T_PERS_HARD, "short_dbl", native_short, native_double, H5T__conv_short_double); status |= H5T__register_int(H5T_PERS_HARD, "short_ldbl", native_short, native_ldouble, H5T__conv_short_ldouble); +#ifdef H5_HAVE__FLOAT16 + status |= H5T__register_int(H5T_PERS_HARD, "short_flt16", native_short, native_float16, + H5T__conv_short__Float16); +#endif /* From unsigned short to floats */ status |= @@ -1243,23 +1362,39 @@ H5T_init(void) H5T__register_int(H5T_PERS_HARD, "ushort_dbl", native_ushort, native_double, H5T__conv_ushort_double); status |= H5T__register_int(H5T_PERS_HARD, "ushort_ldbl", native_ushort, native_ldouble, H5T__conv_ushort_ldouble); +#ifdef H5_HAVE__FLOAT16 + status |= H5T__register_int(H5T_PERS_HARD, "ushort_flt16", native_ushort, native_float16, + H5T__conv_ushort__Float16); +#endif /* From int to floats */ status |= H5T__register_int(H5T_PERS_HARD, "int_flt", native_int, native_float, H5T__conv_int_float); status |= H5T__register_int(H5T_PERS_HARD, "int_dbl", native_int, native_double, H5T__conv_int_double); status |= H5T__register_int(H5T_PERS_HARD, "int_ldbl", native_int, native_ldouble, H5T__conv_int_ldouble); +#ifdef H5_HAVE__FLOAT16 + status |= + H5T__register_int(H5T_PERS_HARD, "int_flt16", native_int, native_float16, H5T__conv_int__Float16); +#endif /* From unsigned int to floats */ status |= H5T__register_int(H5T_PERS_HARD, "uint_flt", native_uint, native_float, H5T__conv_uint_float); status |= H5T__register_int(H5T_PERS_HARD, "uint_dbl", native_uint, native_double, H5T__conv_uint_double); status |= H5T__register_int(H5T_PERS_HARD, "uint_ldbl", native_uint, native_ldouble, H5T__conv_uint_ldouble); +#ifdef H5_HAVE__FLOAT16 + status |= + H5T__register_int(H5T_PERS_HARD, "uint_flt16", native_uint, native_float16, H5T__conv_uint__Float16); +#endif /* From long to floats */ status |= H5T__register_int(H5T_PERS_HARD, "long_flt", native_long, native_float, H5T__conv_long_float); status |= H5T__register_int(H5T_PERS_HARD, "long_dbl", native_long, native_double, H5T__conv_long_double); status |= H5T__register_int(H5T_PERS_HARD, "long_ldbl", native_long, native_ldouble, H5T__conv_long_ldouble); +#ifdef H5_HAVE__FLOAT16 + status |= + H5T__register_int(H5T_PERS_HARD, "long_flt16", native_long, native_float16, H5T__conv_long__Float16); +#endif /* From unsigned long to floats */ status |= @@ -1268,6 +1403,10 @@ H5T_init(void) H5T__register_int(H5T_PERS_HARD, "ulong_dbl", native_ulong, native_double, H5T__conv_ulong_double); status |= H5T__register_int(H5T_PERS_HARD, "ulong_ldbl", native_ulong, native_ldouble, H5T__conv_ulong_ldouble); +#ifdef H5_HAVE__FLOAT16 + status |= H5T__register_int(H5T_PERS_HARD, "ulong_flt16", native_ulong, native_float16, + H5T__conv_ulong__Float16); +#endif /* From long long to floats */ status |= @@ -1278,6 +1417,10 @@ H5T_init(void) status |= H5T__register_int(H5T_PERS_HARD, "llong_ldbl", native_llong, native_ldouble, H5T__conv_llong_ldouble); #endif /* H5T_CONV_INTERNAL_LLONG_LDOUBLE */ +#ifdef H5_HAVE__FLOAT16 + status |= H5T__register_int(H5T_PERS_HARD, "llong_flt16", native_llong, native_float16, + H5T__conv_llong__Float16); +#endif /* From unsigned long long to floats */ status |= @@ -1288,6 +1431,10 @@ H5T_init(void) status |= H5T__register_int(H5T_PERS_HARD, "ullong_ldbl", native_ullong, native_ldouble, H5T__conv_ullong_ldouble); #endif /* H5T_CONV_INTERNAL_ULLONG_LDOUBLE */ +#ifdef H5_HAVE__FLOAT16 + status |= H5T__register_int(H5T_PERS_HARD, "ullong_flt16", native_ullong, native_float16, + H5T__conv_ullong__Float16); +#endif /* From floats to char */ status |= @@ -1296,6 +1443,10 @@ H5T_init(void) H5T__register_int(H5T_PERS_HARD, "dbl_schar", native_double, native_schar, H5T__conv_double_schar); status |= H5T__register_int(H5T_PERS_HARD, "ldbl_schar", native_ldouble, native_schar, H5T__conv_ldouble_schar); +#ifdef H5_HAVE__FLOAT16 + status |= H5T__register_int(H5T_PERS_HARD, "flt16_schar", native_float16, native_schar, + H5T__conv__Float16_schar); +#endif /* From floats to unsigned char */ status |= @@ -1304,6 +1455,10 @@ H5T_init(void) H5T__register_int(H5T_PERS_HARD, "dbl_uchar", native_double, native_uchar, H5T__conv_double_uchar); status |= H5T__register_int(H5T_PERS_HARD, "ldbl_uchar", native_ldouble, native_uchar, H5T__conv_ldouble_uchar); +#ifdef H5_HAVE__FLOAT16 + status |= H5T__register_int(H5T_PERS_HARD, "flt16_uchar", native_float16, native_uchar, + H5T__conv__Float16_uchar); +#endif /* From floats to short */ status |= @@ -1312,6 +1467,10 @@ H5T_init(void) H5T__register_int(H5T_PERS_HARD, "dbl_short", native_double, native_short, H5T__conv_double_short); status |= H5T__register_int(H5T_PERS_HARD, "ldbl_short", native_ldouble, native_short, H5T__conv_ldouble_short); +#ifdef H5_HAVE__FLOAT16 + status |= H5T__register_int(H5T_PERS_HARD, "flt16_short", native_float16, native_short, + H5T__conv__Float16_short); +#endif /* From floats to unsigned short */ status |= @@ -1320,23 +1479,39 @@ H5T_init(void) H5T__register_int(H5T_PERS_HARD, "dbl_ushort", native_double, native_ushort, H5T__conv_double_ushort); status |= H5T__register_int(H5T_PERS_HARD, "ldbl_ushort", native_ldouble, native_ushort, H5T__conv_ldouble_ushort); +#ifdef H5_HAVE__FLOAT16 + status |= H5T__register_int(H5T_PERS_HARD, "flt16_ushort", native_float16, native_ushort, + H5T__conv__Float16_ushort); +#endif /* From floats to int */ status |= H5T__register_int(H5T_PERS_HARD, "flt_int", native_float, native_int, H5T__conv_float_int); status |= H5T__register_int(H5T_PERS_HARD, "dbl_int", native_double, native_int, H5T__conv_double_int); status |= H5T__register_int(H5T_PERS_HARD, "ldbl_int", native_ldouble, native_int, H5T__conv_ldouble_int); +#ifdef H5_HAVE__FLOAT16 + status |= + H5T__register_int(H5T_PERS_HARD, "flt16_int", native_float16, native_int, H5T__conv__Float16_int); +#endif /* From floats to unsigned int */ status |= H5T__register_int(H5T_PERS_HARD, "flt_uint", native_float, native_uint, H5T__conv_float_uint); status |= H5T__register_int(H5T_PERS_HARD, "dbl_uint", native_double, native_uint, H5T__conv_double_uint); status |= H5T__register_int(H5T_PERS_HARD, "ldbl_uint", native_ldouble, native_uint, H5T__conv_ldouble_uint); +#ifdef H5_HAVE__FLOAT16 + status |= + H5T__register_int(H5T_PERS_HARD, "flt16_uint", native_float16, native_uint, H5T__conv__Float16_uint); +#endif /* From floats to long */ status |= H5T__register_int(H5T_PERS_HARD, "flt_long", native_float, native_long, H5T__conv_float_long); status |= H5T__register_int(H5T_PERS_HARD, "dbl_long", native_double, native_long, H5T__conv_double_long); status |= H5T__register_int(H5T_PERS_HARD, "ldbl_long", native_ldouble, native_long, H5T__conv_ldouble_long); +#ifdef H5_HAVE__FLOAT16 + status |= + H5T__register_int(H5T_PERS_HARD, "flt16_long", native_float16, native_long, H5T__conv__Float16_long); +#endif /* From floats to unsigned long */ status |= @@ -1345,6 +1520,10 @@ H5T_init(void) H5T__register_int(H5T_PERS_HARD, "dbl_ulong", native_double, native_ulong, H5T__conv_double_ulong); status |= H5T__register_int(H5T_PERS_HARD, "ldbl_ulong", native_ldouble, native_ulong, H5T__conv_ldouble_ulong); +#ifdef H5_HAVE__FLOAT16 + status |= H5T__register_int(H5T_PERS_HARD, "flt16_ulong", native_float16, native_ulong, + H5T__conv__Float16_ulong); +#endif /* From floats to long long */ status |= @@ -1355,6 +1534,10 @@ H5T_init(void) status |= H5T__register_int(H5T_PERS_HARD, "ldbl_llong", native_ldouble, native_llong, H5T__conv_ldouble_llong); #endif /* H5T_CONV_INTERNAL_LDOUBLE_LLONG */ +#ifdef H5_HAVE__FLOAT16 + status |= H5T__register_int(H5T_PERS_HARD, "flt16_llong", native_float16, native_llong, + H5T__conv__Float16_llong); +#endif /* From floats to unsigned long long */ status |= @@ -1365,6 +1548,10 @@ H5T_init(void) status |= H5T__register_int(H5T_PERS_HARD, "ldbl_ullong", native_ldouble, native_ullong, H5T__conv_ldouble_ullong); #endif /* H5T_CONV_INTERNAL_LDOUBLE_ULLONG */ +#ifdef H5_HAVE__FLOAT16 + status |= H5T__register_int(H5T_PERS_HARD, "flt16_ullong", native_float16, native_ullong, + H5T__conv__Float16_ullong); +#endif /* * The special no-op conversion is the fastest, so we list it last. The @@ -1546,6 +1733,8 @@ H5T_top_term_package(void) /* Reset all the datatype IDs */ if (H5T_IEEE_F32BE_g > 0) { + H5T_IEEE_F16BE_g = FAIL; + H5T_IEEE_F16LE_g = FAIL; H5T_IEEE_F32BE_g = FAIL; H5T_IEEE_F32LE_g = FAIL; H5T_IEEE_F64BE_g = FAIL; @@ -1598,6 +1787,7 @@ H5T_top_term_package(void) H5T_NATIVE_ULONG_g = FAIL; H5T_NATIVE_LLONG_g = FAIL; H5T_NATIVE_ULLONG_g = FAIL; + H5T_NATIVE_FLOAT16_g = FAIL; H5T_NATIVE_FLOAT_g = FAIL; H5T_NATIVE_DOUBLE_g = FAIL; H5T_NATIVE_LDOUBLE_g = FAIL; diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 72debe8..33852a9 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -113,6 +113,14 @@ * at least as wide as the destination. Overflow can occur * when the source magnitude is too large for the destination. * + * fX: Floating-point values to integers where the destination is at least + * as wide as the source. This case cannot generate overflows. + * + * Xf: Integers to floating-point values where the source is at least as + * wide as the destination. Overflows can occur when the destination is + * narrower than the source. + * + * * The macros take a subset of these arguments in the order listed here: * * CDATA: A pointer to the H5T_cdata_t structure that was passed to the @@ -690,6 +698,72 @@ H5T_CONV(H5T_CONV_Fx, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, Y) \ } while (0) +#define H5T_CONV_fX(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + do { \ + HDcompile_assert(sizeof(ST) <= sizeof(DT)); \ + H5T_CONV(H5T_CONV_xX, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, N) \ + } while (0) + +#define H5T_CONV_Xf_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX) || (sprec < dprec && *(S) == (ST)(D_MAX))) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_HI, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = H5_GLUE3(H5T_NATIVE_, DTYPE, _POS_INF_g); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception"); \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else if (*(S) < (ST)(D_MIN)) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_RANGE_LOW, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = H5_GLUE3(H5T_NATIVE_, DTYPE, _NEG_INF_g); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception"); \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else if (sprec > dprec) { \ + unsigned low_bit_pos, high_bit_pos; \ + \ + /* Detect high & low bits set in source */ \ + H5T_HI_LO_BIT_SET(ST, *(S), low_bit_pos, high_bit_pos) \ + \ + /* Check for more bits of precision in src than available in dst */ \ + if ((high_bit_pos - low_bit_pos) >= dprec) { \ + H5T_conv_ret_t except_ret = \ + (cb_struct.func)(H5T_CONV_EXCEPT_PRECISION, src_id, dst_id, S, D, cb_struct.user_data); \ + if (except_ret == H5T_CONV_UNHANDLED) \ + /* Let compiler convert if case is ignored by user handler*/ \ + *(D) = (DT)(*(S)); \ + else if (except_ret == H5T_CONV_ABORT) \ + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception"); \ + /* if(except_ret==H5T_CONV_HANDLED): Fall through, user handled it */ \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } \ + else \ + *(D) = (DT)(*(S)); \ + } +#define H5T_CONV_Xf_NOEX_CORE(STYPE, DTYPE, S, D, ST, DT, D_MIN, D_MAX) \ + { \ + if (*(S) > (ST)(D_MAX)) \ + *(D) = H5_GLUE3(H5T_NATIVE_, DTYPE, _POS_INF_g); \ + else if (*(S) < (ST)(D_MIN)) \ + *(D) = H5_GLUE3(H5T_NATIVE_, DTYPE, _NEG_INF_g); \ + else \ + *(D) = (DT)(*(S)); \ + } + +#define H5T_CONV_Xf(STYPE, DTYPE, ST, DT, D_MIN, D_MAX) \ + do { \ + H5T_CONV(H5T_CONV_Xf, STYPE, DTYPE, ST, DT, D_MIN, D_MAX, Y) \ + } while (0) + /* Since all "no exception" cores do the same thing (assign the value in the * source location to the destination location, using casting), use one "core" * to do them all. @@ -7874,6 +7948,227 @@ H5T__conv_ldouble_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t } #endif /*H5T_CONV_INTERNAL_LDOUBLE_ULLONG*/ +/* Conversions for _Float16 type */ +#ifdef H5_HAVE__FLOAT16 +herr_t +H5T__conv_schar__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + H5T_CONV_xF(SCHAR, FLOAT16, signed char, H5__Float16, -, -); +} + +herr_t +H5T__conv_uchar__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + H5T_CONV_xF(UCHAR, FLOAT16, unsigned char, H5__Float16, -, -); +} + +herr_t +H5T__conv_short__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + H5T_CONV_xF(SHORT, FLOAT16, short, H5__Float16, -, -); +} + +herr_t +H5T__conv_ushort__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + /* Suppress warning about non-standard floating-point literal suffix */ + H5_GCC_CLANG_DIAG_OFF("pedantic") + H5T_CONV_Xf(USHORT, FLOAT16, unsigned short, H5__Float16, -FLT16_MAX, FLT16_MAX); + H5_GCC_CLANG_DIAG_ON("pedantic") +} + +herr_t +H5T__conv_int__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + /* Suppress warning about non-standard floating-point literal suffix */ + H5_GCC_CLANG_DIAG_OFF("pedantic") + H5T_CONV_Xf(INT, FLOAT16, int, H5__Float16, -FLT16_MAX, FLT16_MAX); + H5_GCC_CLANG_DIAG_ON("pedantic") +} + +herr_t +H5T__conv_uint__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + /* Suppress warning about non-standard floating-point literal suffix */ + H5_GCC_CLANG_DIAG_OFF("pedantic") + H5T_CONV_Xf(UINT, FLOAT16, unsigned int, H5__Float16, -FLT16_MAX, FLT16_MAX); + H5_GCC_CLANG_DIAG_ON("pedantic") +} + +herr_t +H5T__conv_long__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + /* Suppress warning about non-standard floating-point literal suffix */ + H5_GCC_CLANG_DIAG_OFF("pedantic") + H5T_CONV_Xf(LONG, FLOAT16, long, H5__Float16, -FLT16_MAX, FLT16_MAX); + H5_GCC_CLANG_DIAG_ON("pedantic") +} + +herr_t +H5T__conv_ulong__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + /* Suppress warning about non-standard floating-point literal suffix */ + H5_GCC_CLANG_DIAG_OFF("pedantic") + H5T_CONV_Xf(ULONG, FLOAT16, unsigned long, H5__Float16, -FLT16_MAX, FLT16_MAX); + H5_GCC_CLANG_DIAG_ON("pedantic") +} + +herr_t +H5T__conv_llong__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + /* Suppress warning about non-standard floating-point literal suffix */ + H5_GCC_CLANG_DIAG_OFF("pedantic") + H5T_CONV_Xf(LLONG, FLOAT16, long long, H5__Float16, -FLT16_MAX, FLT16_MAX); + H5_GCC_CLANG_DIAG_ON("pedantic") +} + +herr_t +H5T__conv_ullong__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + /* Suppress warning about non-standard floating-point literal suffix */ + H5_GCC_CLANG_DIAG_OFF("pedantic") + H5T_CONV_Xf(ULLONG, FLOAT16, unsigned long long, H5__Float16, -FLT16_MAX, FLT16_MAX); + H5_GCC_CLANG_DIAG_ON("pedantic") +} + +herr_t +H5T__conv_float__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + /* Suppress warning about non-standard floating-point literal suffix */ + H5_GCC_CLANG_DIAG_OFF("pedantic") + H5T_CONV_Ff(FLOAT, FLOAT16, float, H5__Float16, -FLT16_MAX, FLT16_MAX); + H5_GCC_CLANG_DIAG_ON("pedantic") +} + +herr_t +H5T__conv_double__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + /* Suppress warning about non-standard floating-point literal suffix */ + H5_GCC_CLANG_DIAG_OFF("pedantic") + H5T_CONV_Ff(DOUBLE, FLOAT16, double, H5__Float16, -FLT16_MAX, FLT16_MAX); + H5_GCC_CLANG_DIAG_ON("pedantic") +} + +herr_t +H5T__conv_ldouble__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + /* Suppress warning about non-standard floating-point literal suffix */ + H5_GCC_CLANG_DIAG_OFF("pedantic") + H5T_CONV_Ff(LDOUBLE, FLOAT16, long double, H5__Float16, -FLT16_MAX, FLT16_MAX); + H5_GCC_CLANG_DIAG_ON("pedantic") +} + +herr_t +H5T__conv__Float16_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + H5_GCC_CLANG_DIAG_OFF("float-equal") + H5T_CONV_Fx(FLOAT16, SCHAR, H5__Float16, signed char, SCHAR_MIN, SCHAR_MAX); + H5_GCC_CLANG_DIAG_ON("float-equal") +} + +herr_t +H5T__conv__Float16_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + H5_GCC_CLANG_DIAG_OFF("float-equal") + H5T_CONV_Fx(FLOAT16, UCHAR, H5__Float16, unsigned char, 0, UCHAR_MAX); + H5_GCC_CLANG_DIAG_ON("float-equal") +} + +herr_t +H5T__conv__Float16_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + H5_GCC_CLANG_DIAG_OFF("float-equal") + H5T_CONV_Fx(FLOAT16, SHORT, H5__Float16, short, SHRT_MIN, SHRT_MAX); + H5_GCC_CLANG_DIAG_ON("float-equal") +} + +herr_t +H5T__conv__Float16_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + H5T_CONV_fX(FLOAT16, USHORT, H5__Float16, unsigned short, 0, USHRT_MAX); +} + +herr_t +H5T__conv__Float16_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + H5T_CONV_fX(FLOAT16, INT, H5__Float16, int, INT_MIN, INT_MAX); +} + +herr_t +H5T__conv__Float16_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + H5T_CONV_fX(FLOAT16, UINT, H5__Float16, unsigned int, 0, UINT_MAX); +} + +herr_t +H5T__conv__Float16_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + H5T_CONV_fX(FLOAT16, LONG, H5__Float16, long, LONG_MIN, LONG_MAX); +} + +herr_t +H5T__conv__Float16_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + H5T_CONV_fX(FLOAT16, ULONG, H5__Float16, unsigned long, 0, ULONG_MAX); +} + +herr_t +H5T__conv__Float16_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + H5T_CONV_fX(FLOAT16, LLONG, H5__Float16, long long, LLONG_MIN, LLONG_MAX); +} + +herr_t +H5T__conv__Float16_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + H5T_CONV_fX(FLOAT16, ULLONG, H5__Float16, unsigned long long, 0, ULLONG_MAX); +} + +herr_t +H5T__conv__Float16_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + H5T_CONV_fF(FLOAT16, FLOAT, H5__Float16, float, -, -); +} + +herr_t +H5T__conv__Float16_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + H5T_CONV_fF(FLOAT16, DOUBLE, H5__Float16, double, -, -); +} + +herr_t +H5T__conv__Float16_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, + size_t H5_ATTR_UNUSED bkg_stride, void *buf, void H5_ATTR_UNUSED *bkg) +{ + H5T_CONV_fF(FLOAT16, LDOUBLE, H5__Float16, long double, -, -); +} +#endif + /*------------------------------------------------------------------------- * Function: H5T__conv_f_i * @@ -7910,8 +8205,9 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz uint8_t *int_buf = NULL; /*buffer for temporary value */ size_t buf_size; /*buffer size for temporary value */ size_t i; /*miscellaneous counters */ - size_t first; /*first bit(MSB) in an integer */ - ssize_t sfirst; /*a signed version of `first' */ + ssize_t msb_pos_s; /*first bit(MSB) in an integer */ + ssize_t new_msb_pos; /*MSB position after shifting mantissa by exponent */ + hssize_t shift_val; /*shift value when shifting mantissa by exponent */ H5T_conv_cb_t cb_struct = {NULL, NULL}; /*conversion callback structure */ bool truncated; /*if fraction value is dropped */ bool reverse; /*if reverse order of destination at the end */ @@ -7976,8 +8272,11 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz /* Allocate enough space for the buffer holding temporary * converted value */ - buf_size = (size_t)(pow(2.0, (double)src.u.f.esize) / 8 + 1); - int_buf = (uint8_t *)H5MM_calloc(buf_size); + if (dst.prec / 8 > src_p->shared->size) + buf_size = (dst.prec + 7) / 8; + else + buf_size = src_p->shared->size; + int_buf = (uint8_t *)H5MM_calloc(buf_size); /* Get conversion exception callback property */ if (H5CX_get_dt_conv_cb(&cb_struct) < 0) @@ -8234,35 +8533,46 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz H5T__bit_inc(int_buf, src.u.f.msize, 8 * buf_size - src.u.f.msize); /* + * What is the bit position for the most significant bit(MSB) of S + * which is set? This is checked before shifting and before possibly + * converting to a negative integer. Note that later use of this value + * assumes that H5T__bit_shift will always shift in 0 during a right + * shift. + */ + msb_pos_s = H5T__bit_find(int_buf, (size_t)0, src.prec, H5T_BIT_MSB, true); + + /* + * The temporary buffer has no bits set and must therefore be + * zero; nothing to do. + */ + if (msb_pos_s < 0) + goto padding; + + /* * Shift mantissa part by exponent minus mantissa size(right shift), * or by mantissa size minus exponent(left shift). Example: Sequence * 10...010111, expo=20, expo-msize=-3. Right-shift the sequence, we get * 00010...10. The last three bits were dropped. */ - H5T__bit_shift(int_buf, expo - (ssize_t)src.u.f.msize, (size_t)0, buf_size * 8); + shift_val = expo - (ssize_t)src.u.f.msize; + H5T__bit_shift(int_buf, shift_val, (size_t)0, buf_size * 8); + + /* Calculate the new position of the MSB after shifting and + * skip to the padding section if we shifted exactly to 0 + * (MSB position is -1) + */ + new_msb_pos = msb_pos_s + shift_val; + if (new_msb_pos == -1) + goto padding; /* - * If expo is less than mantissa size, the frantional value is dropped off + * If expo is less than mantissa size, the fractional value is dropped off * during conversion. Set exception type to be "truncate" */ if ((size_t)expo < src.u.f.msize && cb_struct.func) truncated = true; - /* - * What is the bit position for the most significant bit(MSB) of S - * which is set? This is checked before converted to negative - * integer. - */ - sfirst = H5T__bit_find(int_buf, (size_t)0, 8 * buf_size, H5T_BIT_MSB, true); - first = (size_t)sfirst; - - if (sfirst < 0) { - /* - * The source has no bits set and must therefore be zero. - * Set the destination to zero - nothing to do. - */ - } - else if (H5T_SGN_NONE == dst.u.i.sign) { /*destination is unsigned*/ + if (H5T_SGN_NONE == dst.u.i.sign) { /*destination is unsigned*/ /* * Destination is unsigned. Library's default way: If the source value * is greater than the maximal destination value then it overflows, the @@ -8289,7 +8599,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz } } else { /*source is positive*/ - if (first >= dst.prec) { + if (new_msb_pos >= (ssize_t)dst.prec) { /*overflow*/ if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ @@ -8310,7 +8620,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, "can't handle conversion exception"); } - else if (first < dst.prec) { + else { if (truncated && cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ @@ -8320,9 +8630,11 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz src_rev, d, cb_struct.user_data); } - if (except_ret == H5T_CONV_UNHANDLED) + if (except_ret == H5T_CONV_UNHANDLED) { /*copy source value into it if case is ignored by user handler*/ - H5T__bit_copy(d, dst.offset, int_buf, (size_t)0, first + 1); + if (new_msb_pos >= 0) + H5T__bit_copy(d, dst.offset, int_buf, (size_t)0, (size_t)new_msb_pos + 1); + } else if (except_ret == H5T_CONV_HANDLED) { /*No need to reverse the order of destination because user handles it*/ reverse = false; @@ -8336,7 +8648,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz } else if (H5T_SGN_2 == dst.u.i.sign) { /*Destination is signed*/ if (sign) { /*source is negative*/ - if (first < dst.prec - 1) { + if ((new_msb_pos >= 0) && ((size_t)new_msb_pos < dst.prec - 1)) { if (truncated && cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ @@ -8348,8 +8660,8 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz if (except_ret == H5T_CONV_UNHANDLED) { /*If this case ignored by user handler*/ /*Convert to integer representation. Equivalent to ~(value - 1).*/ - H5T__bit_dec(int_buf, (size_t)0, 8 * buf_size); - H5T__bit_neg(int_buf, (size_t)0, 8 * buf_size); + H5T__bit_dec(int_buf, (size_t)0, dst.prec); + H5T__bit_neg(int_buf, (size_t)0, dst.prec); /*copy source value into destination*/ H5T__bit_copy(d, dst.offset, int_buf, (size_t)0, dst.prec - 1); @@ -8389,7 +8701,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz } } else { /*source is positive*/ - if (first >= dst.prec - 1) { + if (new_msb_pos >= (ssize_t)dst.prec - 1) { /*overflow*/ if (cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ @@ -8410,7 +8722,7 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz goto next; } } - else if (first < dst.prec - 1) { + else if (new_msb_pos < (ssize_t)dst.prec - 1) { if (truncated && cb_struct.func) { /*If user's exception handler is present, use it*/ /*reverse order first*/ @@ -8422,7 +8734,8 @@ H5T__conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz if (except_ret == H5T_CONV_UNHANDLED) { /*copy source value into it if case is ignored by user handler*/ - H5T__bit_copy(d, dst.offset, int_buf, (size_t)0, first + 1); + if (new_msb_pos >= 0) + H5T__bit_copy(d, dst.offset, int_buf, (size_t)0, (size_t)new_msb_pos + 1); } else if (except_ret == H5T_CONV_ABORT) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCONVERT, FAIL, @@ -8601,7 +8914,7 @@ H5T__conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, siz /* Allocate enough space for the buffer holding temporary * converted value */ - buf_size = (src.prec > dst.u.f.msize ? src.prec : dst.u.f.msize) / 8 + 1; + buf_size = ((src.prec > dst.u.f.msize ? src.prec : dst.u.f.msize) + 7) / 8; int_buf = (uint8_t *)H5MM_calloc(buf_size); /* Get conversion exception callback property */ diff --git a/src/H5Tinit_float.c b/src/H5Tinit_float.c index 3213f00..7ddd65b 100644 --- a/src/H5Tinit_float.c +++ b/src/H5Tinit_float.c @@ -53,8 +53,8 @@ * Purpose: This macro takes a floating point type like `double' and * 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. + * bit, and exponent bias and initializes a H5T_fpoint_det_t + * structure with those properties. * * Note that these operations can raise floating-point * exceptions and building with some compiler options @@ -306,14 +306,17 @@ H5T__fix_order(int n, int last, int *perm, H5T_order_t *order) if (last <= 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "failed to detect byte order"); - /* We have at least three points to consider */ - if (perm[last] < perm[last - 1] && perm[last - 1] < perm[last - 2]) { + if (perm[last] < perm[last - 1] && + /* Only check perm[last - 2] if we have more than 2 points to consider */ + ((last < 2) || (perm[last - 1] < perm[last - 2]))) { /* Little endian */ *order = H5T_ORDER_LE; for (int i = 0; i < n; i++) perm[i] = i; } - else if (perm[last] > perm[last - 1] && perm[last - 1] > perm[last - 2]) { + else if (perm[last] > perm[last - 1] && + /* Only check perm[last - 2] if we have more than 2 points to consider */ + ((last < 2) || (perm[last - 1] > perm[last - 2]))) { /* Big endian */ *order = H5T_ORDER_BE; for (int i = 0; i < n; i++) @@ -358,7 +361,7 @@ done: * Return: imp_bit will be set to 1 if the most significant bit * of the mantissa is discarded (ie, the mantissa has an * implicit `one' as the most significant bit). Otherwise, - * imp_bit will be set to zero zero. + * imp_bit will be set to zero. * * SUCCEED/FAIL *------------------------------------------------------------------------- @@ -570,6 +573,39 @@ H5T__init_native_float_types(void) */ H5T_native_order_g = det.order; +#ifdef H5_HAVE__FLOAT16 + /* H5T_NATIVE_FLOAT16 */ + + /* Get the type's characteristics */ + memset(&det, 0, sizeof(H5T_fpoint_det_t)); + DETECT_F(H5__Float16, det); + + /* Allocate and fill type structure */ + if (NULL == (dt = H5T__alloc())) + HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, FAIL, "datatype allocation failed"); + dt->shared->state = H5T_STATE_IMMUTABLE; + dt->shared->type = H5T_FLOAT; + dt->shared->size = det.size; + dt->shared->u.atomic.order = det.order; + dt->shared->u.atomic.offset = det.offset; + dt->shared->u.atomic.prec = det.prec; + dt->shared->u.atomic.lsb_pad = H5T_PAD_ZERO; + dt->shared->u.atomic.msb_pad = H5T_PAD_ZERO; + dt->shared->u.atomic.u.f.sign = det.sign; + dt->shared->u.atomic.u.f.epos = det.epos; + dt->shared->u.atomic.u.f.esize = det.esize; + dt->shared->u.atomic.u.f.ebias = det.ebias; + dt->shared->u.atomic.u.f.mpos = det.mpos; + dt->shared->u.atomic.u.f.msize = det.msize; + dt->shared->u.atomic.u.f.norm = det.norm; + dt->shared->u.atomic.u.f.pad = H5T_PAD_ZERO; + + /* Register the type and set global variables */ + if ((H5T_NATIVE_FLOAT16_g = H5I_register(H5I_DATATYPE, dt, false)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't register ID for built-in datatype"); + H5T_NATIVE_FLOAT16_ALIGN_g = det.comp_align; +#endif + done: /* Clear any FE_INVALID exceptions from NaN handling */ if (feclearexcept(FE_INVALID) != 0) diff --git a/src/H5Tmodule.h b/src/H5Tmodule.h index f1b7b17..3654025 100644 --- a/src/H5Tmodule.h +++ b/src/H5Tmodule.h @@ -712,6 +712,14 @@ * </tr> * <tr> * <td> + * #H5T_NATIVE_FLOAT16 + * </td> + * <td span='3'> + * _Float16 + * </td> + * </tr> + * <tr> + * <td> * #H5T_NATIVE_FLOAT * </td> * <td span='3'> @@ -3753,10 +3761,11 @@ filled according to the value of this property. The padding can be: * H5T_NATIVE_INT | H5T_NATIVE_UINT | * H5T_NATIVE_LONG | H5T_NATIVE_ULONG | * H5T_NATIVE_LLONG | H5T_NATIVE_ULLONG - * <float> ::= H5T_IEEE_F32BE | H5T_IEEE_F32LE | + * <float> ::= H5T_IEEE_F16BE | H5T_IEEE_F16LE | + * H5T_IEEE_F32BE | H5T_IEEE_F32LE | * H5T_IEEE_F64BE | H5T_IEEE_F64LE | - * H5T_NATIVE_FLOAT | H5T_NATIVE_DOUBLE | - * H5T_NATIVE_LDOUBLE + * H5T_NATIVE_FLOAT16 | H5T_NATIVE_FLOAT | + * H5T_NATIVE_DOUBLE | H5T_NATIVE_LDOUBLE * <time> ::= H5T_TIME: not yet implemented * <string> ::= H5T_STRING { * STRSIZE <strsize> ; diff --git a/src/H5Tnative.c b/src/H5Tnative.c index f83e9c3..8136f96 100644 --- a/src/H5Tnative.c +++ b/src/H5Tnative.c @@ -50,6 +50,7 @@ static herr_t H5T__cmp_offset(size_t *comp_size, size_t *offset, size_t elem_siz * H5T_NATIVE_LONG H5T_NATIVE_ULONG * H5T_NATIVE_LLONG H5T_NATIVE_ULLONG * + * H5T_NATIVE_FLOAT16 (if available) * H5T_NATIVE_FLOAT * H5T_NATIVE_DOUBLE * H5T_NATIVE_LDOUBLE @@ -703,6 +704,7 @@ H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_ali size_t align = 0; /* Alignment necessary for native datatype */ size_t native_size = 0; /* Datatype size of the native type */ enum match_type { /* The different kinds of floating point types we can match */ + H5T_NATIVE_FLOAT_MATCH_FLOAT16, H5T_NATIVE_FLOAT_MATCH_FLOAT, H5T_NATIVE_FLOAT_MATCH_DOUBLE, H5T_NATIVE_FLOAT_MATCH_LDOUBLE, @@ -715,7 +717,14 @@ H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_ali assert(size > 0); if (direction == H5T_DIR_DEFAULT || direction == H5T_DIR_ASCEND) { - if (size <= sizeof(float)) { +#ifdef H5_HAVE__FLOAT16 + if (size <= sizeof(H5__Float16)) { + match = H5T_NATIVE_FLOAT_MATCH_FLOAT16; + native_size = sizeof(H5__Float16); + } + else +#endif + if (size <= sizeof(float)) { match = H5T_NATIVE_FLOAT_MATCH_FLOAT; native_size = sizeof(float); } @@ -741,14 +750,29 @@ H5T__get_native_float(size_t size, H5T_direction_t direction, size_t *struct_ali match = H5T_NATIVE_FLOAT_MATCH_DOUBLE; native_size = sizeof(double); } - else { + else +#ifdef H5_HAVE__FLOAT16 + if (size > sizeof(H5__Float16)) +#endif + { match = H5T_NATIVE_FLOAT_MATCH_FLOAT; native_size = sizeof(float); } +#ifdef H5_HAVE__FLOAT16 + else { + match = H5T_NATIVE_FLOAT_MATCH_FLOAT16; + native_size = sizeof(H5__Float16); + } +#endif } /* Set the appropriate native floating point information */ switch (match) { + case H5T_NATIVE_FLOAT_MATCH_FLOAT16: + tid = H5T_NATIVE_FLOAT16; + align = H5T_NATIVE_FLOAT16_ALIGN_g; + break; + case H5T_NATIVE_FLOAT_MATCH_FLOAT: tid = H5T_NATIVE_FLOAT; align = H5T_NATIVE_FLOAT_ALIGN_g; diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index ef5ba36..8f063b9 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -416,6 +416,7 @@ H5_DLLVAR size_t H5T_NATIVE_LONG_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_ULONG_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_LLONG_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_ULLONG_ALIGN_g; +H5_DLLVAR size_t H5T_NATIVE_FLOAT16_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_FLOAT_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_DOUBLE_ALIGN_g; H5_DLLVAR size_t H5T_NATIVE_LDOUBLE_ALIGN_g; @@ -451,6 +452,10 @@ H5_DLLVAR size_t H5T_NATIVE_UINT_FAST64_ALIGN_g; /* Useful floating-point values for conversion routines */ /* (+/- Inf for all floating-point types) */ +#ifdef H5_HAVE__FLOAT16 +H5_DLLVAR H5__Float16 H5T_NATIVE_FLOAT16_POS_INF_g; +H5_DLLVAR H5__Float16 H5T_NATIVE_FLOAT16_NEG_INF_g; +#endif H5_DLLVAR float H5T_NATIVE_FLOAT_POS_INF_g; H5_DLLVAR float H5T_NATIVE_FLOAT_NEG_INF_g; H5_DLLVAR double H5T_NATIVE_DOUBLE_POS_INF_g; @@ -831,6 +836,61 @@ H5_DLL herr_t H5T__conv_ldouble_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *c H5_DLL herr_t H5T__conv_ldouble_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +#ifdef H5_HAVE__FLOAT16 +H5_DLL herr_t H5T__conv_schar__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uchar__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_short__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ushort__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_int__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_uint__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_long__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ulong__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_llong__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ullong__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_float__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_double__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv_ldouble__Float16(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv__Float16_schar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv__Float16_uchar(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv__Float16_short(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv__Float16_ushort(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv__Float16_int(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv__Float16_uint(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv__Float16_long(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv__Float16_ulong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv__Float16_llong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv__Float16_ullong(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv__Float16_float(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv__Float16_double(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +H5_DLL herr_t H5T__conv__Float16_ldouble(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, + size_t buf_stride, size_t bkg_stride, void *buf, void *bkg); +#endif + /* Bit twiddling functions */ H5_DLL void H5T__bit_copy(uint8_t *dst, size_t dst_offset, const uint8_t *src, size_t src_offset, size_t size); diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h index a117075..cfeb384 100644 --- a/src/H5Tpublic.h +++ b/src/H5Tpublic.h @@ -251,6 +251,16 @@ typedef H5T_conv_ret_t (*H5T_conv_except_func_t)(H5T_conv_except_t except_type, */ /** * \ingroup PDTIEEE + * 16-bit big-endian IEEE floating-point numbers + */ +#define H5T_IEEE_F16BE (H5OPEN H5T_IEEE_F16BE_g) +/** + * \ingroup PDTIEEE + * 16-bit little-endian IEEE floating-point numbers + */ +#define H5T_IEEE_F16LE (H5OPEN H5T_IEEE_F16LE_g) +/** + * \ingroup PDTIEEE * 32-bit big-endian IEEE floating-point numbers */ #define H5T_IEEE_F32BE (H5OPEN H5T_IEEE_F32BE_g) @@ -269,6 +279,8 @@ typedef H5T_conv_ret_t (*H5T_conv_except_func_t)(H5T_conv_except_t except_type, * 64-bit little-endian IEEE floating-point numbers */ #define H5T_IEEE_F64LE (H5OPEN H5T_IEEE_F64LE_g) +H5_DLLVAR hid_t H5T_IEEE_F16BE_g; +H5_DLLVAR hid_t H5T_IEEE_F16LE_g; H5_DLLVAR hid_t H5T_IEEE_F32BE_g; H5_DLLVAR hid_t H5T_IEEE_F32LE_g; H5_DLLVAR hid_t H5T_IEEE_F64BE_g; @@ -792,6 +804,11 @@ H5_DLLVAR hid_t H5T_VAX_F64_g; #define H5T_NATIVE_ULLONG (H5OPEN H5T_NATIVE_ULLONG_g) /** * \ingroup PDTNAT + * C-style \Code{_Float16} + */ +#define H5T_NATIVE_FLOAT16 (H5OPEN H5T_NATIVE_FLOAT16_g) +/** + * \ingroup PDTNAT * C-style \Code{float} */ #define H5T_NATIVE_FLOAT (H5OPEN H5T_NATIVE_FLOAT_g) @@ -865,6 +882,7 @@ H5_DLLVAR hid_t H5T_NATIVE_LONG_g; H5_DLLVAR hid_t H5T_NATIVE_ULONG_g; H5_DLLVAR hid_t H5T_NATIVE_LLONG_g; H5_DLLVAR hid_t H5T_NATIVE_ULLONG_g; +H5_DLLVAR hid_t H5T_NATIVE_FLOAT16_g; H5_DLLVAR hid_t H5T_NATIVE_FLOAT_g; H5_DLLVAR hid_t H5T_NATIVE_DOUBLE_g; H5_DLLVAR hid_t H5T_NATIVE_LDOUBLE_g; @@ -2319,6 +2337,7 @@ H5_DLL htri_t H5Tis_variable_str(hid_t type_id); * \li #H5T_NATIVE_ULONG * \li #H5T_NATIVE_ULLONG * + * \li #H5T_NATIVE_FLOAT16 (if available) * \li #H5T_NATIVE_FLOAT * \li #H5T_NATIVE_DOUBLE * \li #H5T_NATIVE_LDOUBLE diff --git a/src/H5private.h b/src/H5private.h index 5663c00..0cbda2e 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -27,7 +27,6 @@ #include <errno.h> #include <fcntl.h> #include <fenv.h> -#include <float.h> #include <math.h> #include <setjmp.h> #include <signal.h> @@ -36,6 +35,10 @@ #include <string.h> #include <time.h> +/* Define __STDC_WANT_IEC_60559_TYPES_EXT__ for _FloatN support, if available */ +#define __STDC_WANT_IEC_60559_TYPES_EXT__ +#include <float.h> + /* POSIX headers */ #ifdef H5_HAVE_SYS_TIME_H #include <sys/time.h> @@ -540,6 +543,21 @@ #define H5_GCC_CLANG_DIAG_ON(x) #endif +/* Create a typedef for library usage of the _Float16 type + * to avoid issues when compiling the library with the + * -pedantic flag or similar where we get warnings about + * _Float16 not being an ISO C type. + */ +#ifdef H5_HAVE__FLOAT16 +#if defined(__GNUC__) +__extension__ typedef _Float16 H5__Float16; +#elif defined(__clang__) +/* TODO */ +#else +typedef _Float16 H5__Float16; +#endif +#endif + /* Function pointer typedef for qsort */ typedef int (*H5_sort_func_cb_t)(const void *, const void *); diff --git a/src/H5trace.c b/src/H5trace.c index 7657356..37f45fc 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -1625,12 +1625,20 @@ H5_trace_args(H5RS_str_t *rs, const char *type, va_list ap) H5RS_acat(rs, "H5T_NATIVE_LLONG"); else if (obj == H5T_NATIVE_ULLONG_g) H5RS_acat(rs, "H5T_NATIVE_ULLONG"); +#ifdef H5_HAVE__FLOAT16 + else if (obj == H5T_NATIVE_FLOAT16_g) + H5RS_acat(rs, "H5T_NATIVE_FLOAT16"); +#endif else if (obj == H5T_NATIVE_FLOAT_g) H5RS_acat(rs, "H5T_NATIVE_FLOAT"); else if (obj == H5T_NATIVE_DOUBLE_g) H5RS_acat(rs, "H5T_NATIVE_DOUBLE"); else if (obj == H5T_NATIVE_LDOUBLE_g) H5RS_acat(rs, "H5T_NATIVE_LDOUBLE"); + else if (obj == H5T_IEEE_F16BE_g) + H5RS_acat(rs, "H5T_IEEE_F16BE"); + else if (obj == H5T_IEEE_F16LE_g) + H5RS_acat(rs, "H5T_IEEE_F16LE"); else if (obj == H5T_IEEE_F32BE_g) H5RS_acat(rs, "H5T_IEEE_F32BE"); else if (obj == H5T_IEEE_F32LE_g) diff --git a/test/API/H5_api_dataset_test.c b/test/API/H5_api_dataset_test.c index 2989b70..1aee062 100644 --- a/test/API/H5_api_dataset_test.c +++ b/test/API/H5_api_dataset_test.c @@ -1276,11 +1276,11 @@ test_create_dataset_predefined_types(void) hid_t container_group = H5I_INVALID_HID, group_id = H5I_INVALID_HID; hid_t fspace_id = H5I_INVALID_HID; hid_t dset_id = H5I_INVALID_HID; - hid_t predefined_type_test_table[] = {H5T_STD_U8LE, H5T_STD_U8BE, H5T_STD_I8LE, H5T_STD_I8BE, - H5T_STD_U16LE, H5T_STD_U16BE, H5T_STD_I16LE, H5T_STD_I16BE, - H5T_STD_U32LE, H5T_STD_U32BE, H5T_STD_I32LE, H5T_STD_I32BE, - H5T_STD_U64LE, H5T_STD_U64BE, H5T_STD_I64LE, H5T_STD_I64BE, - H5T_IEEE_F32LE, H5T_IEEE_F32BE, H5T_IEEE_F64LE, H5T_IEEE_F64BE}; + hid_t predefined_type_test_table[] = { + H5T_STD_U8LE, H5T_STD_U8BE, H5T_STD_I8LE, H5T_STD_I8BE, H5T_STD_U16LE, H5T_STD_U16BE, + H5T_STD_I16LE, H5T_STD_I16BE, H5T_STD_U32LE, H5T_STD_U32BE, H5T_STD_I32LE, H5T_STD_I32BE, + H5T_STD_U64LE, H5T_STD_U64BE, H5T_STD_I64LE, H5T_STD_I64BE, H5T_IEEE_F16LE, H5T_IEEE_F16BE, + H5T_IEEE_F32LE, H5T_IEEE_F32BE, H5T_IEEE_F64LE, H5T_IEEE_F64BE}; TESTING("dataset creation with predefined datatypes"); diff --git a/test/API/H5_api_test_util.c b/test/API/H5_api_test_util.c index d0194f7..41640b4 100644 --- a/test/API/H5_api_test_util.c +++ b/test/API/H5_api_test_util.c @@ -44,7 +44,7 @@ /* The number of predefined floating point types in HDF5 */ -#define NUM_PREDEFINED_FLOAT_TYPES 4 +#define NUM_PREDEFINED_FLOAT_TYPES 6 /* The maximum number of members allowed in an HDF5 compound type, as * generated by the generate_random_datatype() function, for ease of @@ -296,15 +296,21 @@ generate_random_datatype_float(H5T_class_t H5_ATTR_UNUSED parent_class, bool H5_ switch (rand() % NUM_PREDEFINED_FLOAT_TYPES) { case 0: - type_to_copy = H5T_IEEE_F32BE; + type_to_copy = H5T_IEEE_F16BE; break; case 1: - type_to_copy = H5T_IEEE_F32LE; + type_to_copy = H5T_IEEE_F16LE; break; case 2: - type_to_copy = H5T_IEEE_F64BE; + type_to_copy = H5T_IEEE_F32BE; break; case 3: + type_to_copy = H5T_IEEE_F32LE; + break; + case 4: + type_to_copy = H5T_IEEE_F64BE; + break; + case 5: type_to_copy = H5T_IEEE_F64LE; break; diff --git a/test/dt_arith.c b/test/dt_arith.c index 4a99811..653a575 100644 --- a/test/dt_arith.c +++ b/test/dt_arith.c @@ -62,6 +62,7 @@ typedef enum dtype_t { INT_ULONG, INT_LLONG, INT_ULLONG, + FLT_FLOAT16, FLT_FLOAT, FLT_DOUBLE, FLT_LDOUBLE, @@ -442,6 +443,9 @@ reset_hdf5(void) SET_ALIGNMENT(FLOAT, H5_SIZEOF_FLOAT); SET_ALIGNMENT(DOUBLE, H5_SIZEOF_DOUBLE); SET_ALIGNMENT(LDOUBLE, H5_SIZEOF_LONG_DOUBLE); +#ifdef H5_HAVE__FLOAT16 + SET_ALIGNMENT(FLOAT16, H5_SIZEOF__FLOAT16); +#endif #endif } @@ -564,13 +568,16 @@ expt_handle(H5T_conv_except_t except_type, hid_t H5_ATTR_UNUSED src_id, hid_t H5 { signed char fill_value1 = 7; int fill_value2 = 13; + short fill_value3 = 25; if (except_type == H5T_CONV_EXCEPT_RANGE_HI || except_type == H5T_CONV_EXCEPT_RANGE_LOW || except_type == H5T_CONV_EXCEPT_TRUNCATE) { - if (*(bool *)user_data) + if (*(int *)user_data == 0) + *(int *)dst_buf = fill_value2; + else if (*(int *)user_data == 1) *(signed char *)dst_buf = fill_value1; else - *(int *)dst_buf = fill_value2; + *(short *)dst_buf = fill_value3; } /* end if */ return H5T_CONV_HANDLED; @@ -601,11 +608,11 @@ static int test_particular_fp_integer(void) { hid_t dxpl_id; - bool flag; + int flag; double src_d = (double)SCHAR_MAX; signed char dst_c; - unsigned char *buf1 = NULL, *buf2 = NULL; - unsigned char *saved_buf1 = NULL, *saved_buf2 = NULL; + unsigned char *buf1 = NULL, *buf2 = NULL, *buf3 = NULL; + unsigned char *saved_buf1 = NULL, *saved_buf2 = NULL, *saved_buf3 = NULL; size_t src_size1, src_size2; size_t dst_size1, dst_size2; float src_f = (float)INT_MAX; @@ -614,6 +621,13 @@ test_particular_fp_integer(void) int endian; /*endianness */ unsigned int fails_this_test = 0; size_t j; +#ifdef H5_HAVE__FLOAT16 + H5__Float16 src_half = (H5__Float16)SHRT_MAX; + short s_fill_val = 25; + short dst_s; + size_t src_size3; + size_t dst_size3; +#endif TESTING("hard particular floating number -> integer conversions"); @@ -718,6 +732,52 @@ test_particular_fp_integer(void) printf(" %29d\n", y); } +#ifdef H5_HAVE__FLOAT16 + /* Test conversion from _Float16 (the value is INT_MAX) to int. */ + src_size3 = H5Tget_size(H5T_NATIVE_FLOAT16); + dst_size3 = H5Tget_size(H5T_NATIVE_SHORT); + buf3 = (unsigned char *)calloc((size_t)1, (size_t)MAX(src_size3, dst_size3)); + saved_buf3 = (unsigned char *)calloc((size_t)1, (size_t)MAX(src_size3, dst_size3)); + memcpy(buf3, &src_half, src_size3); + memcpy(saved_buf3, &src_half, src_size3); + + /* Register exception handling function and signal the destination is "short". */ + flag = 2; + + /* Do conversion */ + if (H5Tconvert(H5T_NATIVE_FLOAT16, H5T_NATIVE_SHORT, (size_t)1, buf3, NULL, dxpl_id) < 0) { + H5_FAILED(); + printf("Can't convert data\n"); + goto error; + } + + memcpy(&dst_s, buf3, dst_size3); + + /* Print errors */ + if (dst_s != s_fill_val) { + H5__Float16 x; + short y; + + if (0 == fails_this_test++) + H5_FAILED(); + + printf(" test _Float16 to short:\n"); + printf(" src = "); + for (j = 0; j < src_size3; j++) + printf(" %02x", saved_buf3[ENDIAN(src_size3, j, endian)]); + + memcpy(&x, saved_buf3, src_size3); + printf(" %29.20e\n", (double)x); + + printf(" dst = "); + for (j = 0; j < dst_size3; j++) + printf(" %02x", buf3[ENDIAN(dst_size3, j, endian)]); + + memcpy(&y, buf3, dst_size3); + printf(" %29d\n", (int)y); + } +#endif + if (fails_this_test) goto error; @@ -731,10 +791,14 @@ test_particular_fp_integer(void) free(buf1); if (buf2) free(buf2); + if (buf3) + free(buf3); if (saved_buf1) free(saved_buf1); if (saved_buf2) free(saved_buf2); + if (saved_buf3) + free(saved_buf3); PASSED(); return 0; @@ -750,10 +814,14 @@ error: free(buf1); if (buf2) free(buf2); + if (buf3) + free(buf3); if (saved_buf1) free(saved_buf1); if (saved_buf2) free(saved_buf2); + if (saved_buf3) + free(saved_buf3); /* Restore the default error handler (set in h5_reset()) */ h5_restore_err(); @@ -1521,17 +1589,16 @@ error: * Function: test_conv_int_1 * * Purpose: Test conversion of integer values from SRC to DST. - * These types should be any combination of: + * These types should be any combination of: * * H5T_NATIVE_SCHAR H5T_NATIVE_UCHAR - * H5T_NATIVE_SHORT H5T_NATIVE_USHORT - * H5T_NATIVE_INT H5T_NATIVE_UINT - * H5T_NATIVE_LONG H5T_NATIVE_ULONG - * H5T_NATIVE_LLONG H5T_NATIVE_ULLONG + * H5T_NATIVE_SHORT H5T_NATIVE_USHORT + * H5T_NATIVE_INT H5T_NATIVE_UINT + * H5T_NATIVE_LONG H5T_NATIVE_ULONG + * H5T_NATIVE_LLONG H5T_NATIVE_ULLONG * * Return: Success: 0 - * - * Failure: number of errors + * Failure: number of errors * *------------------------------------------------------------------------- */ @@ -1772,6 +1839,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); hw_char = (signed char)(*((unsigned long long *)aligned)); break; + case FLT_FLOAT16: case FLT_FLOAT: case FLT_DOUBLE: case FLT_LDOUBLE: @@ -1824,6 +1892,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); hw_uchar = (unsigned char)(*((unsigned long long *)aligned)); break; + case FLT_FLOAT16: case FLT_FLOAT: case FLT_DOUBLE: case FLT_LDOUBLE: @@ -1876,7 +1945,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); hw_short = (short)(*((unsigned long long *)aligned)); break; - + case FLT_FLOAT16: case FLT_FLOAT: case FLT_DOUBLE: case FLT_LDOUBLE: @@ -1929,6 +1998,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); hw_ushort = (unsigned short)(*((unsigned long long *)aligned)); break; + case FLT_FLOAT16: case FLT_FLOAT: case FLT_DOUBLE: case FLT_LDOUBLE: @@ -1981,6 +2051,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); hw_int = (int)(*((unsigned long long *)aligned)); break; + case FLT_FLOAT16: case FLT_FLOAT: case FLT_DOUBLE: case FLT_LDOUBLE: @@ -2033,6 +2104,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); hw_uint = (unsigned int)(*((unsigned long long *)aligned)); break; + case FLT_FLOAT16: case FLT_FLOAT: case FLT_DOUBLE: case FLT_LDOUBLE: @@ -2085,6 +2157,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); hw_long = (long int)(*((unsigned long long *)aligned)); break; + case FLT_FLOAT16: case FLT_FLOAT: case FLT_DOUBLE: case FLT_LDOUBLE: @@ -2137,6 +2210,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); hw_ulong = (unsigned long)(*((unsigned long long *)aligned)); break; + case FLT_FLOAT16: case FLT_FLOAT: case FLT_DOUBLE: case FLT_LDOUBLE: @@ -2189,6 +2263,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); hw_llong = (long long)(*((unsigned long long *)aligned)); break; + case FLT_FLOAT16: case FLT_FLOAT: case FLT_DOUBLE: case FLT_LDOUBLE: @@ -2241,6 +2316,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); hw_ullong = (unsigned long long)(*((unsigned long long *)aligned)); break; + case FLT_FLOAT16: case FLT_FLOAT: case FLT_DOUBLE: case FLT_LDOUBLE: @@ -2423,6 +2499,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); fprintf(stdout, " %29llu\n", *((unsigned long long *)aligned)); break; + case FLT_FLOAT16: case FLT_FLOAT: case FLT_DOUBLE: case FLT_LDOUBLE: @@ -2477,6 +2554,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) memcpy(aligned, buf + j * sizeof(long long), sizeof(unsigned long long)); fprintf(stdout, " %29llu\n", *((unsigned long long *)aligned)); break; + case FLT_FLOAT16: case FLT_FLOAT: case FLT_DOUBLE: case FLT_LDOUBLE: @@ -2521,6 +2599,7 @@ test_conv_int_1(const char *name, hid_t src, hid_t dst) case INT_ULLONG: fprintf(stdout, " %29llu\n", *((unsigned long long *)((void *)hw))); break; + case FLT_FLOAT16: case FLT_FLOAT: case FLT_DOUBLE: case FLT_LDOUBLE: @@ -2653,6 +2732,15 @@ my_isnan(dtype_t type, void *val) retval = isnan(x); #endif } + else if (FLT_FLOAT16 == type) { +#ifdef H5_HAVE__FLOAT16 + H5__Float16 x; + memcpy(&x, val, sizeof(H5__Float16)); + retval = isnan(x); +#else + assert(0 && "Should not reach this point!"); +#endif + } else { return 0; } @@ -2682,6 +2770,16 @@ my_isnan(dtype_t type, void *val) snprintf(s, sizeof(s), "%Lg", x); #endif } + else if (FLT_FLOAT16 == type) { +#ifdef H5_HAVE__FLOAT16 + H5__Float16 x; + + memcpy(&x, val, sizeof(H5__Float16)); + snprintf(s, sizeof(s), "%g", (double)x); +#else + assert(0 && "Should not reach this point!"); +#endif + } else { return 0; } @@ -2727,12 +2825,12 @@ my_isinf(int endian, const unsigned char *val, size_t size, size_t mpos, size_t * Function: test_conv_flt_1 * * Purpose: Test conversion of floating point values from SRC to - * DST. These types should be H5T_NATIVE_FLOAT, - * H5T_NATIVE_DOUBLE, or H5T_NATIVE_LDOUBLE. + * DST. These types should be H5T_NATIVE_FLOAT, + * H5T_NATIVE_DOUBLE, H5T_NATIVE_LDOUBLE or H5T_NATIVE_FLOAT16, + * if available. * * Return: Success: 0 - * - * Failure: number of errors + * Failure: number of errors * *------------------------------------------------------------------------- */ @@ -2753,6 +2851,9 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) void *aligned = NULL; /*aligned buffer */ float hw_f; /*hardware-converted */ double hw_d; /*hardware-converted */ +#ifdef H5_HAVE__FLOAT16 + H5__Float16 hw_half; +#endif #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE long double hw_ld; /*hardware-converted */ #endif @@ -2830,6 +2931,12 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) src_type = FLT_LDOUBLE; #endif } +#ifdef H5_HAVE__FLOAT16 + else if (H5Tequal(src, H5T_NATIVE_FLOAT16)) { + src_type_name = "_Float16"; + src_type = FLT_FLOAT16; + } +#endif else { src_type_name = "UNKNOWN"; src_type = OTHER; @@ -2849,6 +2956,12 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) dst_type = FLT_LDOUBLE; #endif } +#ifdef H5_HAVE__FLOAT16 + else if (H5Tequal(dst, H5T_NATIVE_FLOAT16)) { + dst_type_name = "_Float16"; + dst_type = FLT_FLOAT16; + } +#endif else { dst_type_name = "UNKNOWN"; dst_type = OTHER; @@ -2930,6 +3043,23 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) dst_size, buf, saved, nelmts); #endif } + else if (src_type == FLT_FLOAT16) { +#ifdef H5_HAVE__FLOAT16 + /* Suppress warning about non-standard floating-point literal suffix */ + H5_GCC_CLANG_DIAG_OFF("pedantic") + /* Suppress warning about float conversion in macro code path + * that sets H5__Float16 multiply = 100000000;, which shouldn't + * happen due to the small value of FLT16_MAX_10_EXP. + */ + H5_GCC_CLANG_DIAG_OFF("float-conversion") + INIT_FP_NORM(H5__Float16, FLT16_MAX, FLT16_MIN, FLT16_MAX_10_EXP, FLT16_MIN_10_EXP, src_size, + dst_size, buf, saved, nelmts); + H5_GCC_CLANG_DIAG_ON("float-conversion") + H5_GCC_CLANG_DIAG_ON("pedantic") +#else + assert(0 && "Should not reach this point!"); +#endif + } else goto error; @@ -2949,6 +3079,14 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) nelmts); #endif } + else if (src_type == FLT_FLOAT16) { +#ifdef H5_HAVE__FLOAT16 + INIT_FP_DENORM(H5__Float16, FLT16_MANT_DIG, src_size, src_nbits, sendian, dst_size, buf, + saved, nelmts); +#else + assert(0 && "Should not reach this point!"); +#endif + } else goto error; @@ -2966,6 +3104,13 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) INIT_FP_SPECIAL(src_size, src_nbits, sendian, LDBL_MANT_DIG, dst_size, buf, saved, nelmts); #endif } + else if (src_type == FLT_FLOAT16) { +#ifdef H5_HAVE__FLOAT16 + INIT_FP_SPECIAL(src_size, src_nbits, sendian, FLT16_MANT_DIG, dst_size, buf, saved, nelmts); +#else + assert(0 && "Should not reach this point!"); +#endif + } else goto error; @@ -2986,6 +3131,9 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE hw_ld = 911.0L; #endif +#ifdef H5_HAVE__FLOAT16 + hw_half = 911.0; +#endif /* The hardware conversion */ /* Check for underflow when src is a "larger" float than dst.*/ @@ -3000,11 +3148,27 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) hw = (unsigned char *)&hw_d; #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } - else { + else if (FLT_LDOUBLE == dst_type) { hw_ld = (long double)*((float *)aligned); hw = (unsigned char *)&hw_ld; #endif } + else if (FLT_FLOAT16 == dst_type) { +#ifdef H5_HAVE__FLOAT16 + hw_half = (H5__Float16) * ((float *)aligned); + hw = (unsigned char *)&hw_half; + + /* Suppress warning about non-standard floating-point literal suffix */ + H5_GCC_CLANG_DIAG_OFF("pedantic") + underflow = fabsf(*((float *)aligned)) < (float)FLT16_MIN; + overflow = fabsf(*((float *)aligned)) > (float)FLT16_MAX; + H5_GCC_CLANG_DIAG_ON("pedantic") +#else + assert(0 && "Should not reach this point!"); +#endif + } + else + goto error; } else if (FLT_DOUBLE == src_type) { memcpy(aligned, saved + j * sizeof(double), sizeof(double)); @@ -3019,14 +3183,30 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) hw = (unsigned char *)&hw_d; #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } - else { + else if (FLT_LDOUBLE == dst_type) { hw_ld = (long double)*((double *)aligned); hw = (unsigned char *)&hw_ld; #endif } + else if (FLT_FLOAT16 == dst_type) { +#ifdef H5_HAVE__FLOAT16 + hw_half = (H5__Float16) * ((double *)aligned); + hw = (unsigned char *)&hw_half; + + /* Suppress warning about non-standard floating-point literal suffix */ + H5_GCC_CLANG_DIAG_OFF("pedantic") + underflow = fabs(*((double *)aligned)) < (double)FLT16_MIN; + overflow = fabs(*((double *)aligned)) > (double)FLT16_MAX; + H5_GCC_CLANG_DIAG_ON("pedantic") +#else + assert(0 && "Should not reach this point!"); +#endif + } + else + goto error; #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } - else { + else if (FLT_LDOUBLE == src_type) { memcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); if (FLT_FLOAT == dst_type) { hw_f = (float)*((long double *)aligned); @@ -3040,12 +3220,57 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) underflow = fabsl(*((long double *)aligned)) < (long double)DBL_MIN; overflow = fabsl(*((long double *)aligned)) > (long double)DBL_MAX; } - else { + else if (FLT_LDOUBLE == dst_type) { hw_ld = *((long double *)aligned); hw = (unsigned char *)&hw_ld; } + else if (FLT_FLOAT16 == dst_type) { +#ifdef H5_HAVE__FLOAT16 + hw_half = (H5__Float16) * ((long double *)aligned); + hw = (unsigned char *)&hw_half; + + /* Suppress warning about non-standard floating-point literal suffix */ + H5_GCC_CLANG_DIAG_OFF("pedantic") + underflow = fabsl(*((long double *)aligned)) < (long double)FLT16_MIN; + overflow = fabsl(*((long double *)aligned)) > (long double)FLT16_MAX; + H5_GCC_CLANG_DIAG_ON("pedantic") +#else + assert(0 && "Should not reach this point!"); +#endif + } + else + goto error; #endif } + else if (FLT_FLOAT16 == src_type) { +#ifdef H5_HAVE__FLOAT16 + memcpy(aligned, saved + j * sizeof(H5__Float16), sizeof(H5__Float16)); + if (FLT_FLOAT == dst_type) { + hw_f = (float)*((H5__Float16 *)aligned); + hw = (unsigned char *)&hw_f; + } + else if (FLT_DOUBLE == dst_type) { + hw_d = (double)*((H5__Float16 *)aligned); + hw = (unsigned char *)&hw_d; +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE + } + else if (FLT_LDOUBLE == dst_type) { + hw_ld = (long double)*((H5__Float16 *)aligned); + hw = (unsigned char *)&hw_ld; +#endif + } + else if (FLT_FLOAT16 == dst_type) { + hw_half = *((H5__Float16 *)aligned); + hw = (unsigned char *)&hw_half; + } + else + goto error; +#else + assert(0 && "Should not reach this point!"); +#endif + } + else + goto error; /* For Intel machines, the size of "long double" is 12 bytes, precision * is 80 bits; for Intel IA64 and AMD processors, the size of "long double" @@ -3088,6 +3313,12 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) continue; #endif } +#ifdef H5_HAVE__FLOAT16 + else if (FLT_FLOAT16 == dst_type && my_isnan(dst_type, buf + j * sizeof(H5__Float16)) && + my_isnan(dst_type, hw)) { + continue; + } +#endif /* * Assume same if hardware result is NaN. This is because the @@ -3137,7 +3368,7 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) check_mant[1] = frexp(hw_d, check_expo + 1); #if (H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE) } - else { + else if (FLT_LDOUBLE == dst_type) { long double x = 0.0L; memcpy(&x, &buf[j * dst_size], sizeof(long double)); /* dst is largest float, no need to check underflow. */ @@ -3145,6 +3376,29 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) check_mant[1] = (double)frexpl(hw_ld, check_expo + 1); #endif } + else if (FLT_FLOAT16 == dst_type) { +#ifdef H5_HAVE__FLOAT16 + H5__Float16 x; + memcpy(&x, &buf[j * dst_size], sizeof(H5__Float16)); + + /* Suppress warning about non-standard floating-point literal suffix */ + H5_GCC_CLANG_DIAG_OFF("pedantic") + if (underflow && fabsf(x) <= (float)FLT16_MIN && fabsf(hw_half) <= (float)FLT16_MIN) + continue; /* all underflowed, no error */ + H5_GCC_CLANG_DIAG_ON("pedantic") + + if (overflow && my_isinf(dendian, buf + j * sizeof(H5__Float16), dst_size, dst_mpos, + dst_msize, dst_epos, dst_esize)) + continue; /* all overflowed, no error */ + check_mant[0] = (double)frexpf(x, check_expo + 0); + check_mant[1] = (double)frexpf(hw_half, check_expo + 1); +#else + assert(0 && "Should not reach this point!"); +#endif + } + else + goto error; + /* Special check for denormalized values */ if (check_expo[0] < (-(int)dst_ebias) || check_expo[1] < (-(int)dst_ebias)) { int expo_diff = check_expo[0] - check_expo[1]; @@ -3195,12 +3449,23 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) printf(" %29.20e\n", x); #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } - else { + else if (FLT_LDOUBLE == src_type) { long double x = 0.0L; memcpy(&x, &saved[j * src_size], sizeof(long double)); fprintf(stdout, " %29.20Le\n", x); #endif } + else if (FLT_FLOAT16 == src_type) { +#ifdef H5_HAVE__FLOAT16 + H5__Float16 x; + memcpy(&x, &saved[j * src_size], sizeof(H5__Float16)); + printf(" %29.20e\n", (double)x); +#else + assert(0 && "Should not reach this point!"); +#endif + } + else + goto error; printf(" dst ="); for (k = 0; k < dst_size; k++) @@ -3217,12 +3482,23 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) printf(" %29.20e\n", x); #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE } - else { + else if (FLT_LDOUBLE == src_type) { long double x = 0.0L; memcpy(&x, &buf[j * dst_size], sizeof(long double)); fprintf(stdout, " %29.20Le\n", x); #endif } + else if (FLT_FLOAT16 == src_type) { +#ifdef H5_HAVE__FLOAT16 + H5__Float16 x; + memcpy(&x, &buf[j * dst_size], sizeof(H5__Float16)); + printf(" %29.20e\n", (double)x); +#else + assert(0 && "Should not reach this point!"); +#endif + } + else + goto error; printf(" ans ="); for (k = 0; k < dst_size; k++) @@ -3233,9 +3509,15 @@ test_conv_flt_1(const char *name, int run_test, hid_t src, hid_t dst) else if (FLT_DOUBLE == dst_type) printf(" %29.20e\n", hw_d); #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE - else + else if (FLT_LDOUBLE == dst_type) fprintf(stdout, " %29.20Le\n", hw_ld); #endif +#ifdef H5_HAVE__FLOAT16 + else if (FLT_FLOAT16 == dst_type) + printf(" %29.20e\n", (double)hw_half); +#endif + else + goto error; /* If the source is normalized values, print out error message; if it is * denormalized or special values, print out warning message.*/ @@ -3315,17 +3597,16 @@ error: * Function: test_conv_int_fp * * Purpose: Test conversion between integer and float values - * from SRC to DST. These types should be any combination of: + * from SRC to DST. These types should be any combination of: * * H5T_NATIVE_SCHAR H5T_NATIVE_FLOAT - * H5T_NATIVE_SHORT H5T_NATIVE_DOUBLE - * H5T_NATIVE_INT H5T_NATIVE_LDOUBLE - * H5T_NATIVE_LONG - * H5T_NATIVE_LLONG + * H5T_NATIVE_SHORT H5T_NATIVE_DOUBLE + * H5T_NATIVE_INT H5T_NATIVE_LDOUBLE + * H5T_NATIVE_LONG + * H5T_NATIVE_LLONG * * Return: Success: 0 - * - * Failure: number of errors + * Failure: number of errors * *------------------------------------------------------------------------- */ @@ -3371,6 +3652,9 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) unsigned long hw_ulong = 0; long long hw_llong = 0; unsigned long long hw_ullong = 0; +#ifdef H5_HAVE__FLOAT16 + H5__Float16 hw_half; +#endif /* What is the name of the source type */ if (H5Tequal(src, H5T_NATIVE_SCHAR)) { @@ -3427,6 +3711,12 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) src_type = FLT_LDOUBLE; #endif } +#ifdef H5_HAVE__FLOAT16 + else if (H5Tequal(src, H5T_NATIVE_FLOAT16)) { + src_type_name = "_Float16"; + src_type = FLT_FLOAT16; + } +#endif else { src_type_name = "UNKNOWN"; src_type = OTHER; @@ -3487,6 +3777,12 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) dst_type = FLT_LDOUBLE; #endif } +#ifdef H5_HAVE__FLOAT16 + else if (H5Tequal(dst, H5T_NATIVE_FLOAT16)) { + dst_type_name = "_Float16"; + dst_type = FLT_FLOAT16; + } +#endif else { dst_type_name = "UNKNOWN"; dst_type = OTHER; @@ -3504,7 +3800,8 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) if ((INT_SCHAR == src_type || INT_UCHAR == src_type || INT_SHORT == src_type || INT_USHORT == src_type || INT_INT == src_type || INT_UINT == src_type || INT_LONG == src_type || INT_ULONG == src_type || INT_LLONG == src_type || INT_ULLONG == src_type) && - (FLT_FLOAT != dst_type && FLT_DOUBLE != dst_type && FLT_LDOUBLE != dst_type)) { + (FLT_FLOAT != dst_type && FLT_DOUBLE != dst_type && FLT_LDOUBLE != dst_type && + FLT_FLOAT16 != dst_type)) { snprintf(str, sizeof(str), "Testing %s %s -> %s conversions", name, src_type_name, dst_type_name); printf("%-70s", str); H5_FAILED(); @@ -3512,7 +3809,8 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) goto error; } - if ((FLT_FLOAT == src_type || FLT_DOUBLE == src_type || FLT_LDOUBLE == src_type) && + if ((FLT_FLOAT == src_type || FLT_DOUBLE == src_type || FLT_LDOUBLE == src_type || + FLT_FLOAT16 == src_type) && (INT_SCHAR != dst_type && INT_UCHAR != dst_type && INT_SHORT != dst_type && INT_USHORT != dst_type && INT_INT != dst_type && INT_UINT != dst_type && INT_LONG != dst_type && INT_ULONG != dst_type && INT_LLONG != dst_type && INT_ULLONG != dst_type)) { @@ -3660,6 +3958,32 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) } #endif } + else if (src_type == FLT_FLOAT16) { +#ifdef H5_HAVE__FLOAT16 + if (run_test == TEST_NORMAL) { + /* Suppress warning about non-standard floating-point literal suffix */ + H5_GCC_CLANG_DIAG_OFF("pedantic") + /* Suppress warning about float conversion in macro code path + * that sets H5__Float16 multiply = 100000000;, which shouldn't + * happen due to the small value of FLT16_MAX_10_EXP. + */ + H5_GCC_CLANG_DIAG_OFF("float-conversion") + INIT_FP_NORM(H5__Float16, FLT16_MAX, FLT16_MIN, FLT16_MAX_10_EXP, FLT16_MIN_10_EXP, src_size, + dst_size, buf, saved, nelmts); + H5_GCC_CLANG_DIAG_ON("float-conversion") + H5_GCC_CLANG_DIAG_ON("pedantic") + } + else if (run_test == TEST_DENORM) { + INIT_FP_DENORM(H5__Float16, FLT16_MANT_DIG, src_size, src_nbits, sendian, dst_size, buf, saved, + nelmts); + } + else { + INIT_FP_SPECIAL(src_size, src_nbits, sendian, FLT16_MANT_DIG, dst_size, buf, saved, nelmts); + } +#else + assert(0 && "Should not reach this point!"); +#endif + } else goto error; @@ -3669,7 +3993,8 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) /* Check the results from the library against hardware */ for (j = 0; j < nelmts; j++) { - if (FLT_FLOAT == src_type || FLT_DOUBLE == src_type || FLT_LDOUBLE == src_type) + if (FLT_FLOAT == src_type || FLT_DOUBLE == src_type || FLT_LDOUBLE == src_type || + FLT_FLOAT16 == src_type) if (my_isnan(src_type, saved + j * src_size)) continue; @@ -3716,6 +4041,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); hw_float = (float)(*((unsigned long long *)aligned)); break; + case FLT_FLOAT16: case FLT_FLOAT: case FLT_DOUBLE: case FLT_LDOUBLE: @@ -3768,6 +4094,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); hw_double = (double)(*((unsigned long long *)aligned)); break; + case FLT_FLOAT16: case FLT_FLOAT: case FLT_DOUBLE: case FLT_LDOUBLE: @@ -3820,6 +4147,7 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); hw_ldouble = (long double)(*((unsigned long long *)aligned)); break; + case FLT_FLOAT16: case FLT_FLOAT: case FLT_DOUBLE: case FLT_LDOUBLE: @@ -3829,6 +4157,63 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) break; } } + else if (FLT_FLOAT16 == dst_type) { +#ifdef H5_HAVE__FLOAT16 + hw = (unsigned char *)&hw_half; + switch (src_type) { + case INT_SCHAR: + memcpy(aligned, saved + j * sizeof(signed char), sizeof(signed char)); + hw_half = (H5__Float16)(*((signed char *)aligned)); + break; + case INT_UCHAR: + memcpy(aligned, saved + j * sizeof(unsigned char), sizeof(unsigned char)); + hw_half = (H5__Float16)(*((unsigned char *)aligned)); + break; + case INT_SHORT: + memcpy(aligned, saved + j * sizeof(short), sizeof(short)); + hw_half = (H5__Float16)(*((short *)aligned)); + break; + case INT_USHORT: + memcpy(aligned, saved + j * sizeof(unsigned short), sizeof(unsigned short)); + hw_half = (H5__Float16)(*((unsigned short *)aligned)); + break; + case INT_INT: + memcpy(aligned, saved + j * sizeof(int), sizeof(int)); + hw_half = (H5__Float16)(*((int *)aligned)); + break; + case INT_UINT: + memcpy(aligned, saved + j * sizeof(unsigned), sizeof(unsigned)); + hw_half = (H5__Float16)(*((unsigned *)aligned)); + break; + case INT_LONG: + memcpy(aligned, saved + j * sizeof(long), sizeof(long)); + hw_half = (H5__Float16)(*((long *)aligned)); + break; + case INT_ULONG: + memcpy(aligned, saved + j * sizeof(unsigned long), sizeof(unsigned long)); + hw_half = (H5__Float16)(*((unsigned long *)aligned)); + break; + case INT_LLONG: + memcpy(aligned, saved + j * sizeof(long long), sizeof(long long)); + hw_half = (H5__Float16)(*((long long *)aligned)); + break; + case INT_ULLONG: + memcpy(aligned, saved + j * sizeof(unsigned long long), sizeof(unsigned long long)); + hw_half = (H5__Float16)(*((unsigned long long *)aligned)); + break; + case FLT_FLOAT16: + case FLT_FLOAT: + case FLT_DOUBLE: + case FLT_LDOUBLE: + case OTHER: + default: + assert(0 && "Unknown type"); + break; + } +#else + assert(0 && "Should not reach this point!"); +#endif + } else if (INT_SCHAR == dst_type) { hw = (unsigned char *)&hw_schar; switch (src_type) { @@ -3844,6 +4229,14 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_schar = (signed char)(*((long double *)aligned)); break; + case FLT_FLOAT16: +#ifdef H5_HAVE__FLOAT16 + memcpy(aligned, saved + j * sizeof(H5__Float16), sizeof(H5__Float16)); + hw_schar = (signed char)(*((H5__Float16 *)aligned)); + break; +#else + assert(0 && "Should not reach this point!"); +#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -3875,6 +4268,14 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_uchar = (unsigned char)(*((long double *)aligned)); break; + case FLT_FLOAT16: +#ifdef H5_HAVE__FLOAT16 + memcpy(aligned, saved + j * sizeof(H5__Float16), sizeof(H5__Float16)); + hw_uchar = (unsigned char)(*((H5__Float16 *)aligned)); + break; +#else + assert(0 && "Should not reach this point!"); +#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -3906,6 +4307,14 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_short = (short)(*((long double *)aligned)); break; + case FLT_FLOAT16: +#ifdef H5_HAVE__FLOAT16 + memcpy(aligned, saved + j * sizeof(H5__Float16), sizeof(H5__Float16)); + hw_short = (short)(*((H5__Float16 *)aligned)); + break; +#else + assert(0 && "Should not reach this point!"); +#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -3937,6 +4346,14 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_ushort = (unsigned short)(*((long double *)aligned)); break; + case FLT_FLOAT16: +#ifdef H5_HAVE__FLOAT16 + memcpy(aligned, saved + j * sizeof(H5__Float16), sizeof(H5__Float16)); + hw_ushort = (unsigned short)(*((H5__Float16 *)aligned)); + break; +#else + assert(0 && "Should not reach this point!"); +#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -3968,6 +4385,14 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_int = (int)(*((long double *)aligned)); break; + case FLT_FLOAT16: +#ifdef H5_HAVE__FLOAT16 + memcpy(aligned, saved + j * sizeof(H5__Float16), sizeof(H5__Float16)); + hw_int = (int)(*((H5__Float16 *)aligned)); + break; +#else + assert(0 && "Should not reach this point!"); +#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -3999,6 +4424,14 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_uint = (unsigned int)(*((long double *)aligned)); break; + case FLT_FLOAT16: +#ifdef H5_HAVE__FLOAT16 + memcpy(aligned, saved + j * sizeof(H5__Float16), sizeof(H5__Float16)); + hw_uint = (unsigned int)(*((H5__Float16 *)aligned)); + break; +#else + assert(0 && "Should not reach this point!"); +#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -4030,6 +4463,14 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_long = (long)(*((long double *)aligned)); break; + case FLT_FLOAT16: +#ifdef H5_HAVE__FLOAT16 + memcpy(aligned, saved + j * sizeof(H5__Float16), sizeof(H5__Float16)); + hw_long = (long)(*((H5__Float16 *)aligned)); + break; +#else + assert(0 && "Should not reach this point!"); +#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -4061,6 +4502,14 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_ulong = (unsigned long)(*((long double *)aligned)); break; + case FLT_FLOAT16: +#ifdef H5_HAVE__FLOAT16 + memcpy(aligned, saved + j * sizeof(H5__Float16), sizeof(H5__Float16)); + hw_ulong = (unsigned long)(*((H5__Float16 *)aligned)); + break; +#else + assert(0 && "Should not reach this point!"); +#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -4092,6 +4541,14 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_llong = (long long)(*((long double *)aligned)); break; + case FLT_FLOAT16: +#ifdef H5_HAVE__FLOAT16 + memcpy(aligned, saved + j * sizeof(H5__Float16), sizeof(H5__Float16)); + hw_llong = (long long)(*((H5__Float16 *)aligned)); + break; +#else + assert(0 && "Should not reach this point!"); +#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -4123,6 +4580,14 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); hw_ullong = (unsigned long long)(*((long double *)aligned)); break; + case FLT_FLOAT16: +#ifdef H5_HAVE__FLOAT16 + memcpy(aligned, saved + j * sizeof(H5__Float16), sizeof(H5__Float16)); + hw_ullong = (unsigned long long)(*((H5__Float16 *)aligned)); + break; +#else + assert(0 && "Should not reach this point!"); +#endif case INT_SCHAR: case INT_UCHAR: case INT_SHORT: @@ -4193,7 +4658,8 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) * Try to follow the except_func callback function to check if the * desired value was set. */ - if ((FLT_FLOAT == src_type || FLT_DOUBLE == src_type || FLT_LDOUBLE == src_type) && + if ((FLT_FLOAT == src_type || FLT_DOUBLE == src_type || FLT_LDOUBLE == src_type || + FLT_FLOAT16 == src_type) && (INT_SCHAR == dst_type || INT_SHORT == dst_type || INT_INT == dst_type || INT_LONG == dst_type || INT_LLONG == dst_type)) { if (0 == H5T__bit_get_d(src_bits, src_nbits - 1, (size_t)1) && @@ -4233,7 +4699,8 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) } } - if ((FLT_FLOAT == src_type || FLT_DOUBLE == src_type || FLT_LDOUBLE == src_type) && + if ((FLT_FLOAT == src_type || FLT_DOUBLE == src_type || FLT_LDOUBLE == src_type || + FLT_FLOAT16 == src_type) && (INT_UCHAR == dst_type || INT_USHORT == dst_type || INT_UINT == dst_type || INT_ULONG == dst_type || INT_ULLONG == dst_type)) { if (H5T__bit_get_d(src_bits, src_nbits - 1, (size_t)1)) { @@ -4336,6 +4803,14 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) memcpy(aligned, saved + j * sizeof(long double), sizeof(long double)); printf(" %29Lf\n", *((long double *)aligned)); break; + case FLT_FLOAT16: +#ifdef H5_HAVE__FLOAT16 + memcpy(aligned, saved + j * sizeof(H5__Float16), sizeof(H5__Float16)); + printf(" %29f\n", (double)*((H5__Float16 *)aligned)); + break; +#else + assert(0 && "Should not reach this point!"); +#endif case OTHER: default: assert(0 && "Unknown type"); @@ -4399,6 +4874,14 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) memcpy(aligned, buf + j * sizeof(long double), sizeof(long double)); printf(" %29Lf\n", *((long double *)aligned)); break; + case FLT_FLOAT16: +#ifdef H5_HAVE__FLOAT16 + memcpy(aligned, buf + j * sizeof(H5__Float16), sizeof(H5__Float16)); + printf(" %29f\n", (double)*((H5__Float16 *)aligned)); + break; +#else + assert(0 && "Should not reach this point!"); +#endif case OTHER: default: assert(0 && "Unknown type"); @@ -4449,6 +4932,13 @@ test_conv_int_fp(const char *name, int run_test, hid_t src, hid_t dst) case FLT_LDOUBLE: printf(" %29Lf\n", *((long double *)((void *)hw))); break; + case FLT_FLOAT16: +#ifdef H5_HAVE__FLOAT16 + printf(" %29f\n", (double)*((H5__Float16 *)((void *)hw))); + break; +#else + assert(0 && "Should not reach this point!"); +#endif case OTHER: default: assert(0 && "Unknown type"); @@ -4773,6 +5263,9 @@ run_fp_tests(const char *name) nerrors += test_conv_flt_1("noop", TEST_NOOP, H5T_NATIVE_FLOAT, H5T_NATIVE_FLOAT); nerrors += test_conv_flt_1("noop", TEST_NOOP, H5T_NATIVE_DOUBLE, H5T_NATIVE_DOUBLE); nerrors += test_conv_flt_1("noop", TEST_NOOP, H5T_NATIVE_LDOUBLE, H5T_NATIVE_LDOUBLE); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_flt_1("noop", TEST_NOOP, H5T_NATIVE_FLOAT16, H5T_NATIVE_FLOAT16); +#endif goto done; } @@ -4785,6 +5278,16 @@ run_fp_tests(const char *name) nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_LDOUBLE, H5T_NATIVE_FLOAT); nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_LDOUBLE, H5T_NATIVE_DOUBLE); #endif +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_FLOAT16, H5T_NATIVE_FLOAT); + nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_FLOAT16, H5T_NATIVE_DOUBLE); + nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_FLOAT, H5T_NATIVE_FLOAT16); + nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_DOUBLE, H5T_NATIVE_FLOAT16); +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE + nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_FLOAT16, H5T_NATIVE_LDOUBLE); + nerrors += test_conv_flt_1(name, TEST_NORMAL, H5T_NATIVE_LDOUBLE, H5T_NATIVE_FLOAT16); +#endif +#endif /*Test denormalized values. TEST_DENORM indicates denormalized values.*/ nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_FLOAT, H5T_NATIVE_DOUBLE); @@ -4808,6 +5311,16 @@ run_fp_tests(const char *name) nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_LDOUBLE, H5T_NATIVE_DOUBLE); #endif +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_FLOAT16, H5T_NATIVE_FLOAT); + nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_FLOAT16, H5T_NATIVE_DOUBLE); + nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_FLOAT, H5T_NATIVE_FLOAT16); + nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_DOUBLE, H5T_NATIVE_FLOAT16); +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE + nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_FLOAT16, H5T_NATIVE_LDOUBLE); + nerrors += test_conv_flt_1(name, TEST_DENORM, H5T_NATIVE_LDOUBLE, H5T_NATIVE_FLOAT16); +#endif +#endif /*Test special values, +/-0, +/-infinity, +/-QNaN, +/-SNaN.*/ nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_FLOAT, H5T_NATIVE_DOUBLE); @@ -4830,6 +5343,16 @@ run_fp_tests(const char *name) } #endif #endif +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_FLOAT16, H5T_NATIVE_FLOAT); + nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_FLOAT16, H5T_NATIVE_DOUBLE); + nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_FLOAT, H5T_NATIVE_FLOAT16); + nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_DOUBLE, H5T_NATIVE_FLOAT16); +#if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE + nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_FLOAT16, H5T_NATIVE_LDOUBLE); + nerrors += test_conv_flt_1(name, TEST_SPECIAL, H5T_NATIVE_LDOUBLE, H5T_NATIVE_FLOAT16); +#endif +#endif done: return nerrors; @@ -4851,36 +5374,66 @@ run_int_fp_conv(const char *name) nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_SCHAR, H5T_NATIVE_FLOAT); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_SCHAR, H5T_NATIVE_DOUBLE); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_SCHAR, H5T_NATIVE_FLOAT16); +#endif nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_UCHAR, H5T_NATIVE_FLOAT); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_UCHAR, H5T_NATIVE_DOUBLE); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_UCHAR, H5T_NATIVE_FLOAT16); +#endif nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_SHORT, H5T_NATIVE_FLOAT); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_SHORT, H5T_NATIVE_DOUBLE); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_SHORT, H5T_NATIVE_FLOAT16); +#endif nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_USHORT, H5T_NATIVE_FLOAT); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_USHORT, H5T_NATIVE_DOUBLE); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_USHORT, H5T_NATIVE_FLOAT16); +#endif nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_INT, H5T_NATIVE_FLOAT); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_INT, H5T_NATIVE_DOUBLE); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_INT, H5T_NATIVE_FLOAT16); +#endif nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_UINT, H5T_NATIVE_FLOAT); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_UINT, H5T_NATIVE_DOUBLE); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_UINT, H5T_NATIVE_FLOAT16); +#endif #if H5_SIZEOF_LONG != H5_SIZEOF_INT nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LONG, H5T_NATIVE_FLOAT); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LONG, H5T_NATIVE_DOUBLE); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LONG, H5T_NATIVE_FLOAT16); +#endif nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULONG, H5T_NATIVE_FLOAT); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULONG, H5T_NATIVE_DOUBLE); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULONG, H5T_NATIVE_FLOAT16); +#endif #endif #if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LLONG, H5T_NATIVE_FLOAT); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LLONG, H5T_NATIVE_DOUBLE); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_LLONG, H5T_NATIVE_FLOAT16); +#endif nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULLONG, H5T_NATIVE_FLOAT); nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULLONG, H5T_NATIVE_DOUBLE); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, TEST_NORMAL, H5T_NATIVE_ULLONG, H5T_NATIVE_FLOAT16); +#endif #endif #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE @@ -4956,41 +5509,74 @@ run_fp_int_conv(const char *name) nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_SCHAR); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_SCHAR); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT16, H5T_NATIVE_SCHAR); +#endif nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_UCHAR); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_UCHAR); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT16, H5T_NATIVE_UCHAR); +#endif nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_SHORT); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_SHORT); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT16, H5T_NATIVE_SHORT); +#endif nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_USHORT); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_USHORT); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT16, H5T_NATIVE_USHORT); +#endif nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_INT); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_INT); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT16, H5T_NATIVE_INT); +#endif nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_UINT); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_UINT); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT16, H5T_NATIVE_UINT); +#endif #if H5_SIZEOF_LONG != H5_SIZEOF_INT nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LONG); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LONG); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT16, H5T_NATIVE_LONG); +#endif nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_ULONG); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_ULONG); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT16, H5T_NATIVE_ULONG); +#endif #endif #if H5_SIZEOF_LONG_LONG != H5_SIZEOF_LONG if (!strcmp(name, "hw")) { /* Hardware conversion */ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LLONG); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LLONG); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT16, H5T_NATIVE_LLONG); +#endif } else { /* Software conversion */ nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_LLONG); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_LLONG); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT16, H5T_NATIVE_LLONG); +#endif } nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT, H5T_NATIVE_ULLONG); nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_DOUBLE, H5T_NATIVE_ULLONG); +#ifdef H5_HAVE__FLOAT16 + nerrors += test_conv_int_fp(name, test_values, H5T_NATIVE_FLOAT16, H5T_NATIVE_ULLONG); +#endif #endif #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE diff --git a/test/dtypes.c b/test/dtypes.c index ac8697e..613a5e9 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -73,8 +73,9 @@ } \ } while (0) -static const char *FILENAME[] = {"dtypes0", "dtypes1", "dtypes2", "dtypes3", "dtypes4", "dtypes5", - "dtypes6", "dtypes7", "dtypes8", "dtypes9", "dtypes10", NULL}; +static const char *FILENAME[] = {"dtypes0", "dtypes1", "dtypes2", "dtypes3", "dtypes4", + "dtypes5", "dtypes6", "dtypes7", "dtypes8", "dtypes9", + "dtypes10", "dtypes11", NULL}; #define TESTFILE "bad_compound.h5" @@ -5954,6 +5955,424 @@ error: } /*------------------------------------------------------------------------- + * Function: test__Float16 + * + * Purpose: Tests the _Float16 datatype. + * + * Return: Success: 0 + * Failure: number of errors + *------------------------------------------------------------------------- + */ +static int +test__Float16(void) +{ +#ifdef H5_HAVE__FLOAT16 + H5T_path_t *path = NULL; + hsize_t dims[1]; + htri_t is_little_endian; + H5T_t *native_dtype = NULL; + H5T_t *tmp_dtype = NULL; + hid_t fid = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t dset_id = H5I_INVALID_HID; + hid_t dcpl_id = H5I_INVALID_HID; + hid_t native_type = H5I_INVALID_HID; + char filename[256]; + + TESTING("_Float16 datatype"); + + /* Check that native macro maps to a valid type */ + if (0 == H5Tget_size(H5T_NATIVE_FLOAT16)) { + H5_FAILED(); + printf("Invalid size for H5T_NATIVE_FLOAT16 datatype\n"); + goto error; + } + + /* Check that native type for standard 16-bit float type matches */ + if ((native_type = H5Tget_native_type(H5T_IEEE_F16LE, H5T_DIR_DEFAULT)) < 0) { + H5_FAILED(); + printf("Can't get native type for H5T_IEEE_F16LE\n"); + goto error; + } + + if (0 == H5Tequal(native_type, H5T_NATIVE_FLOAT16)) { + H5_FAILED(); + printf("Native _Float16 type for H5T_IEEE_F16LE wasn't equal to H5T_NATIVE_FLOAT16\n"); + goto error; + } + + if (H5Tclose(native_type) < 0) { + H5_FAILED(); + printf("Can't close datatype\n"); + goto error; + } + + if ((native_type = H5Tget_native_type(H5T_IEEE_F16BE, H5T_DIR_DEFAULT)) < 0) { + H5_FAILED(); + printf("Can't get native type for H5T_IEEE_F16BE\n"); + goto error; + } + + if (0 == H5Tequal(native_type, H5T_NATIVE_FLOAT16)) { + H5_FAILED(); + printf("Native _Float16 type for H5T_IEEE_F16BE wasn't equal to H5T_NATIVE_FLOAT16\n"); + goto error; + } + + if (H5Tclose(native_type) < 0) { + H5_FAILED(); + printf("Can't close datatype\n"); + goto error; + } + + /* + * Ensure that conversion between native _Float16 datatype and + * the matching standard datatype is covered by the no-op conversion + * function. Ensure that conversion between native _Float16 datatype + * and the other standard datatype is covered by the byte-order + * conversion function. + */ + if (NULL == (native_dtype = H5I_object_verify(H5T_NATIVE_FLOAT16, H5I_DATATYPE))) { + H5_FAILED(); + printf("Can't get H5T_t structure for datatype\n"); + goto error; + } + + if ((is_little_endian = H5Tequal(H5T_NATIVE_FLOAT16, H5T_IEEE_F16LE)) < 0) { + H5_FAILED(); + printf("Can't check if native _Float16 type matches standard little-endian type\n"); + goto error; + } + + if (NULL == (tmp_dtype = H5I_object_verify(H5T_IEEE_F16LE, H5I_DATATYPE))) { + H5_FAILED(); + printf("Can't get H5T_t structure for H5T_IEEE_F16LE datatype\n"); + goto error; + } + + if (NULL == (path = H5T_path_find(native_dtype, tmp_dtype))) { + H5_FAILED(); + printf("Can't find datatype conversion path\n"); + goto error; + } + + if (path->is_hard || path->conv.is_app) { + H5_FAILED(); + printf("Invalid conversion path for H5T_NATIVE_FLOAT16 -> H5T_IEEE_F16LE\n"); + goto error; + } + + if (is_little_endian) { + if (path->conv.u.lib_func != H5T__conv_noop) { + H5_FAILED(); + printf("Conversion path for H5T_NATIVE_FLOAT16 -> H5T_IEEE_F16LE was not H5T__conv_noop\n"); + goto error; + } + } + else { + if (path->conv.u.lib_func != H5T__conv_order_opt) { + H5_FAILED(); + printf("Conversion path for H5T_NATIVE_FLOAT16 -> H5T_IEEE_F16LE was not H5T__conv_order\n"); + goto error; + } + } + + if (NULL == (tmp_dtype = H5I_object_verify(H5T_IEEE_F16BE, H5I_DATATYPE))) { + H5_FAILED(); + printf("Can't get H5T_t structure for H5T_IEEE_F16BE datatype\n"); + goto error; + } + + if (NULL == (path = H5T_path_find(native_dtype, tmp_dtype))) { + H5_FAILED(); + printf("Can't find datatype conversion path\n"); + goto error; + } + + if (path->is_hard || path->conv.is_app) { + H5_FAILED(); + printf("Invalid conversion path for H5T_NATIVE_FLOAT16 -> H5T_IEEE_F16BE\n"); + goto error; + } + + if (is_little_endian) { + if (path->conv.u.lib_func != H5T__conv_order_opt) { + H5_FAILED(); + printf("Conversion path for H5T_NATIVE_FLOAT16 -> H5T_IEEE_F16BE was not H5T__conv_order\n"); + goto error; + } + } + else { + if (path->conv.u.lib_func != H5T__conv_noop) { + H5_FAILED(); + printf("Conversion path for H5T_NATIVE_FLOAT16 -> H5T_IEEE_F16BE was not H5T__conv_noop\n"); + goto error; + } + } + + /* + * Ensure that conversion between native _Float16 datatype and a + * couple of other datatypes are the correct type of conversions. + */ + if (is_little_endian) { + /* Check for a native type that matches H5T_STD_I32LE before + * checking for a hard conversion path + */ + if (H5Tequal(H5T_NATIVE_SHORT, H5T_STD_I32LE) == true || + H5Tequal(H5T_NATIVE_INT, H5T_STD_I32LE) == true || + H5Tequal(H5T_NATIVE_LONG, H5T_STD_I32LE) == true) { + if (H5Tcompiler_conv(H5T_NATIVE_FLOAT16, H5T_STD_I32LE) != true) { + H5_FAILED(); + printf("Conversion path for H5T_NATIVE_FLOAT16 -> H5T_STD_I32LE was not a hard conversion\n"); + goto error; + } + } + + if (H5Tcompiler_conv(H5T_NATIVE_FLOAT16, H5T_STD_I32BE) != false) { + H5_FAILED(); + printf("Conversion path for H5T_NATIVE_FLOAT16 -> H5T_STD_I32BE was not a soft conversion\n"); + goto error; + } + } + else { + if (H5Tcompiler_conv(H5T_NATIVE_FLOAT16, H5T_STD_I32LE) != false) { + H5_FAILED(); + printf("Conversion path for H5T_NATIVE_FLOAT16 -> H5T_STD_I32LE was not a soft conversion\n"); + goto error; + } + + /* Check for a native type that matches H5T_STD_I32BE before + * checking for a hard conversion path + */ + if (H5Tequal(H5T_NATIVE_SHORT, H5T_STD_I32BE) == true || + H5Tequal(H5T_NATIVE_INT, H5T_STD_I32BE) == true || + H5Tequal(H5T_NATIVE_LONG, H5T_STD_I32BE) == true) { + if (H5Tcompiler_conv(H5T_NATIVE_FLOAT16, H5T_STD_I32BE) != true) { + H5_FAILED(); + printf("Conversion path for H5T_NATIVE_FLOAT16 -> H5T_STD_I32BE was not a hard conversion\n"); + goto error; + } + } + } + + if (H5Tcompiler_conv(H5T_NATIVE_FLOAT16, H5T_NATIVE_SCHAR) != true) { + H5_FAILED(); + printf("Conversion path for H5T_NATIVE_FLOAT16 -> H5T_NATIVE_SCHAR was not a hard conversion\n"); + goto error; + } + + /* + * Ensure that conversion between standard _Float16 datatypes and a + * couple of other datatypes are the correct type of conversions. + */ + if (is_little_endian) { + if (H5Tcompiler_conv(H5T_IEEE_F16LE, H5T_NATIVE_FLOAT) != true) { + H5_FAILED(); + printf("Conversion path for H5T_IEEE_F16LE -> H5T_NATIVE_FLOAT was not a hard conversion\n"); + goto error; + } + + /* Check for a native type that matches H5T_IEEE_F32LE before + * checking for a hard conversion path + */ + if (H5Tequal(H5T_NATIVE_FLOAT, H5T_IEEE_F32LE) == true || + H5Tequal(H5T_NATIVE_DOUBLE, H5T_IEEE_F32LE) == true || + H5Tequal(H5T_NATIVE_LDOUBLE, H5T_IEEE_F32LE) == true) { + if (H5Tcompiler_conv(H5T_IEEE_F16LE, H5T_IEEE_F32LE) != true) { + H5_FAILED(); + printf("Conversion path for H5T_IEEE_F16LE -> H5T_IEEE_F32LE was not a hard conversion\n"); + goto error; + } + } + + if (H5Tcompiler_conv(H5T_IEEE_F16LE, H5T_IEEE_F32BE) != false) { + H5_FAILED(); + printf("Conversion path for H5T_IEEE_F16LE -> H5T_IEEE_F32BE was not a soft conversion\n"); + goto error; + } + + if (H5Tcompiler_conv(H5T_IEEE_F16BE, H5T_NATIVE_FLOAT) != false) { + H5_FAILED(); + printf("Conversion path for H5T_IEEE_F16BE -> H5T_NATIVE_FLOAT was not a soft conversion\n"); + goto error; + } + + if (H5Tcompiler_conv(H5T_IEEE_F16BE, H5T_IEEE_F32BE) != false) { + H5_FAILED(); + printf("Conversion path for H5T_IEEE_F16BE -> H5T_IEEE_F32BE was not a soft conversion\n"); + goto error; + } + + if (H5Tcompiler_conv(H5T_IEEE_F16BE, H5T_IEEE_F32LE) != false) { + H5_FAILED(); + printf("Conversion path for H5T_IEEE_F16BE -> H5T_IEEE_F32LE was not a soft conversion\n"); + goto error; + } + } + else { + /* big-endian */ + if (H5Tcompiler_conv(H5T_IEEE_F16LE, H5T_NATIVE_FLOAT) != false) { + H5_FAILED(); + printf("Conversion path for H5T_IEEE_F16LE -> H5T_NATIVE_FLOAT was not a soft conversion\n"); + goto error; + } + + if (H5Tcompiler_conv(H5T_IEEE_F16LE, H5T_IEEE_F32LE) != false) { + H5_FAILED(); + printf("Conversion path for H5T_IEEE_F16LE -> H5T_IEEE_F32LE was not a soft conversion\n"); + goto error; + } + + if (H5Tcompiler_conv(H5T_IEEE_F16LE, H5T_IEEE_F32BE) != false) { + H5_FAILED(); + printf("Conversion path for H5T_IEEE_F16LE -> H5T_IEEE_F32BE was not a soft conversion\n"); + goto error; + } + + if (H5Tcompiler_conv(H5T_IEEE_F16BE, H5T_NATIVE_FLOAT) != true) { + H5_FAILED(); + printf("Conversion path for H5T_IEEE_F16BE -> H5T_NATIVE_FLOAT was not a hard conversion\n"); + goto error; + } + + /* Check for a native type that matches H5T_IEEE_F32BE before + * checking for a hard conversion path + */ + if (H5Tequal(H5T_NATIVE_FLOAT, H5T_IEEE_F32LE) == true || + H5Tequal(H5T_NATIVE_DOUBLE, H5T_IEEE_F32LE) == true || + H5Tequal(H5T_NATIVE_LDOUBLE, H5T_IEEE_F32LE) == true) { + if (H5Tcompiler_conv(H5T_IEEE_F16BE, H5T_IEEE_F32BE) != true) { + H5_FAILED(); + printf("Conversion path for H5T_IEEE_F16BE -> H5T_IEEE_F32BE was not a hard conversion\n"); + goto error; + } + } + + if (H5Tcompiler_conv(H5T_IEEE_F16BE, H5T_IEEE_F32LE) != false) { + H5_FAILED(); + printf("Conversion path for H5T_IEEE_F16BE -> H5T_IEEE_F32LE was not a soft conversion\n"); + goto error; + } + } + + /* + * Create a dataset with the datatype and check the dataset raw + * data storage size, as well as the file size + */ + h5_fixname(FILENAME[11], H5P_DEFAULT, filename, sizeof filename); + + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); + printf("Can't create file!\n"); + goto error; + } + + dims[0] = 10000; + if ((space_id = H5Screate_simple(1, dims, NULL)) < 0) { + H5_FAILED(); + AT(); + printf("Can't create dataspace\n"); + goto error; + } + + if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0) { + H5_FAILED(); + AT(); + printf("Can't create DCPL\n"); + goto error; + } + + if (H5Pset_alloc_time(dcpl_id, H5D_ALLOC_TIME_EARLY) < 0) { + H5_FAILED(); + AT(); + printf("Can't set alloc time\n"); + goto error; + } + + if ((dset_id = H5Dcreate2(fid, "Dataset", H5T_NATIVE_FLOAT16, space_id, H5P_DEFAULT, dcpl_id, + H5P_DEFAULT)) < 0) { + H5_FAILED(); + AT(); + printf("Can't create dataset\n"); + goto error; + } + + if (H5Dget_storage_size(dset_id) != dims[0] * sizeof(H5__Float16)) { + H5_FAILED(); + AT(); + printf("Incorrect dataset raw data storage size allocated in file\n"); + goto error; + } + + if (H5Pclose(dcpl_id) < 0) + TEST_ERROR; + if (H5Sclose(space_id) < 0) + TEST_ERROR; + if (H5Dclose(dset_id) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) + TEST_ERROR; + + { + h5_stat_size_t file_size = h5_get_file_size(filename, H5P_DEFAULT); + + if (file_size < 0) + TEST_ERROR; + if ((size_t)file_size < dims[0] * sizeof(H5__Float16)) { + H5_FAILED(); + AT(); + printf("File size value was too small\n"); + goto error; + } + + /* 4096 bytes is arbitrary, but should suffice for now */ + if ((size_t)file_size > (dims[0] * sizeof(H5__Float16)) + 4096) { + H5_FAILED(); + AT(); + printf("File size value was too large\n"); + goto error; + } + } + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY + { + H5Tclose(native_type); + H5Pclose(dcpl_id); + H5Sclose(space_id); + H5Dclose(dset_id); + H5Fclose(fid); + } + H5E_END_TRY + + return 1; +#else + TESTING("that _Float16 datatype is unavailable"); + + /* Make sure H5T_NATIVE_FLOAT16 macro maps to invalid datatype */ + H5E_BEGIN_TRY + { + if (0 != H5Tget_size(H5T_NATIVE_FLOAT16)) { + H5_FAILED(); + AT(); + printf("Valid size was returned for invalid datatype\n"); + return 1; + } + } + H5E_END_TRY + + PASSED(); + + return 0; +#endif +} + +/*------------------------------------------------------------------------- * Function: test_encode * * Purpose: Tests functions of encoding and decoding datatype. @@ -9087,6 +9506,8 @@ main(void) nerrors += test_opaque(); nerrors += test_set_order(); + nerrors += test__Float16(); + if (!driver_is_parallel) { nerrors += test_utf_ascii_conv(); } diff --git a/test/ntypes.c b/test/ntypes.c index f36a600..8439018 100644 --- a/test/ntypes.c +++ b/test/ntypes.c @@ -40,6 +40,9 @@ static const char *FILENAME[] = {"ntypes", NULL}; #define DSET_OPAQUE_NAME "opaque_type" #define DSET1_BITFIELD_NAME "bitfield_type_1" #define DSET2_BITFIELD_NAME "bitfield_type_2" +#ifdef H5_HAVE__FLOAT16 +#define DSET_FLOAT16_NAME "_Float16_type" +#endif #define SPACE1_DIM1 4 #define SPACE1_RANK 1 @@ -3051,6 +3054,119 @@ error: return -1; } /* end test_ninteger() */ +#ifdef H5_HAVE__FLOAT16 +static herr_t +test__Float16(hid_t file) +{ + hsize_t dims[2]; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t dtype = H5I_INVALID_HID; + hid_t native_type = H5I_INVALID_HID; + struct { + H5__Float16 arr[DIM0][DIM1]; + } *ipoints = NULL; + struct { + H5__Float16 arr[DIM0][DIM1]; + } *icheck = NULL; + + TESTING("_Float16 datatype"); + + if (NULL == (ipoints = calloc(1, sizeof(*ipoints)))) + TEST_ERROR; + if (NULL == (icheck = calloc(1, sizeof(*icheck)))) + TEST_ERROR; + + /* Initialize the data */ + for (size_t i = 0; i < DIM0; i++) + for (size_t j = 0; j < DIM1; j++) + ipoints->arr[i][j] = (H5__Float16)(HDrand() / (double)RAND_MAX); + + /* Create the data space */ + dims[0] = DIM0; + dims[1] = DIM1; + if ((space = H5Screate_simple(2, dims, NULL)) < 0) + TEST_ERROR; + + if ((dataset = H5Dcreate2(file, DSET_FLOAT16_NAME, H5T_IEEE_F16BE, space, H5P_DEFAULT, H5P_DEFAULT, + H5P_DEFAULT)) < 0) + TEST_ERROR; + + /* Write the data to the dataset */ + if (H5Dwrite(dataset, H5T_NATIVE_FLOAT16, H5S_ALL, H5S_ALL, H5P_DEFAULT, ipoints) < 0) + TEST_ERROR; + + /* Close dataset */ + if (H5Dclose(dataset) < 0) + TEST_ERROR; + + /* Open dataset again to check H5Tget_native_type */ + if ((dataset = H5Dopen2(file, DSET_FLOAT16_NAME, H5P_DEFAULT)) < 0) + TEST_ERROR; + + if ((dtype = H5Dget_type(dataset)) < 0) + TEST_ERROR; + + if ((native_type = H5Tget_native_type(dtype, H5T_DIR_DEFAULT)) < 0) + TEST_ERROR; + + /* Verify the datatype retrieved and converted */ + if (H5Tget_order(native_type) != H5Tget_order(H5T_NATIVE_FLOAT16)) + TEST_ERROR; + if (H5Tget_size(native_type) != H5Tget_size(H5T_IEEE_F16BE)) + TEST_ERROR; + if (H5T_FLOAT != H5Tget_class(native_type)) + TEST_ERROR; + + /* Read the dataset back */ + if (H5Dread(dataset, native_type, H5S_ALL, H5S_ALL, H5P_DEFAULT, icheck) < 0) + TEST_ERROR; + + /* Check that the values read are the same as the values written */ + for (size_t i = 0; i < DIM0; i++) + for (size_t j = 0; j < DIM1; j++) + if (!H5_FLT_ABS_EQUAL(ipoints->arr[i][j], icheck->arr[i][j])) { + H5_FAILED(); + printf(" Read different values than written.\n"); + printf(" At index %zu,%zu\n", i, j); + goto error; + } /* end if */ + + if (H5Sclose(space) < 0) + TEST_ERROR; + if (H5Dclose(dataset) < 0) + TEST_ERROR; + if (H5Tclose(native_type) < 0) + TEST_ERROR; + if (H5Tclose(dtype) < 0) + TEST_ERROR; + + free(ipoints); + ipoints = NULL; + free(icheck); + icheck = NULL; + + PASSED(); + + return 0; + +error: + H5E_BEGIN_TRY + { + H5Dclose(dataset); + H5Tclose(native_type); + H5Tclose(dtype); + H5Sclose(space); + } + H5E_END_TRY + + free(ipoints); + free(icheck); + + return -1; +} +#endif + /*------------------------------------------------------------------------- * Function: main * @@ -3101,6 +3217,10 @@ main(void) nerrors += test_bitfield_dtype(file) < 0 ? 1 : 0; nerrors += test_ninteger() < 0 ? 1 : 0; +#ifdef H5_HAVE__FLOAT16 + nerrors += test__Float16(file) < 0 ? 1 : 0; +#endif + if (H5Fclose(file) < 0) goto error; diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index d8c9ac6..86d873d 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -145,6 +145,10 @@ static hsize_t diff_double_element(unsigned char *mem1, unsigned char *mem2, hsi diff_opt_t *opts); static hsize_t diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); +#ifdef H5_HAVE__FLOAT16 +static hsize_t diff_float16_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, + diff_opt_t *opts); +#endif static hsize_t diff_schar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts); static hsize_t diff_uchar_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, @@ -233,7 +237,20 @@ diff_array(void *_mem1, void *_mem2, diff_opt_t *opts, hid_t container1_id, hid_ */ case H5T_FLOAT: H5TOOLS_DEBUG("type_class:H5T_FLOAT"); - if (H5Tequal(opts->m_tid, H5T_NATIVE_FLOAT)) { +#ifdef H5_HAVE__FLOAT16 + if (H5Tequal(opts->m_tid, H5T_NATIVE_FLOAT16)) { + for (i = 0; i < opts->hs_nelmts; i++) { + nfound += diff_float16_element(mem1, mem2, i, opts); + + mem1 += sizeof(H5__Float16); + mem2 += sizeof(H5__Float16); + if (opts->count_bool && nfound >= opts->count) + return nfound; + } + } + else +#endif + if (H5Tequal(opts->m_tid, H5T_NATIVE_FLOAT)) { for (i = 0; i < opts->hs_nelmts; i++) { nfound += diff_float_element(mem1, mem2, i, opts); @@ -263,6 +280,7 @@ diff_array(void *_mem1, void *_mem2, diff_opt_t *opts, hid_t container1_id, hid_ return nfound; } /* nelmts */ } + break; case H5T_INTEGER: @@ -1221,38 +1239,50 @@ diff_datum(void *_mem1, void *_mem2, hsize_t elemtno, diff_opt_t *opts, hid_t co *------------------------------------------------------------------------- */ case H5T_FLOAT: - /*------------------------------------------------------------------------- - * H5T_NATIVE_FLOAT - *------------------------------------------------------------------------- - */ H5TOOLS_DEBUG("H5T_FLOAT"); - if (type_size == 4) { - if (type_size != sizeof(float)) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not float size"); - nfound += diff_float_element(mem1, mem2, elemtno, opts); - } +#ifdef H5_HAVE__FLOAT16 /*------------------------------------------------------------------------- - * H5T_NATIVE_DOUBLE + * H5T_NATIVE_FLOAT16 *------------------------------------------------------------------------- */ - else if (type_size == 8) { - if (type_size != sizeof(double)) - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not double size"); - nfound += diff_double_element(mem1, mem2, elemtno, opts); + if (type_size == H5_SIZEOF__FLOAT16) { + if (type_size != sizeof(H5__Float16)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not _Float16 size"); + nfound += diff_float16_element(mem1, mem2, elemtno, opts); } + else +#endif + /*------------------------------------------------------------------------- + * H5T_NATIVE_FLOAT + *------------------------------------------------------------------------- + */ + if (type_size == 4) { + if (type_size != sizeof(float)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not float size"); + nfound += diff_float_element(mem1, mem2, elemtno, opts); + } + /*------------------------------------------------------------------------- + * H5T_NATIVE_DOUBLE + *------------------------------------------------------------------------- + */ + else if (type_size == 8) { + if (type_size != sizeof(double)) + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not double size"); + nfound += diff_double_element(mem1, mem2, elemtno, opts); + } #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE - /*------------------------------------------------------------------------- - * H5T_NATIVE_LDOUBLE - *------------------------------------------------------------------------- - */ - else if (type_size == H5_SIZEOF_LONG_DOUBLE) { - if (type_size != sizeof(long double)) { - H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long double size"); - } - nfound += diff_ldouble_element(mem1, mem2, elemtno, opts); - } /*H5T_NATIVE_LDOUBLE*/ -#endif /* H5_SIZEOF_LONG_DOUBLE */ + /*------------------------------------------------------------------------- + * H5T_NATIVE_LDOUBLE + *------------------------------------------------------------------------- + */ + else if (type_size == H5_SIZEOF_LONG_DOUBLE) { + if (type_size != sizeof(long double)) { + H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Type size is not long double size"); + } + nfound += diff_ldouble_element(mem1, mem2, elemtno, opts); + } /*H5T_NATIVE_LDOUBLE*/ +#endif /* H5_SIZEOF_LONG_DOUBLE */ break; /* H5T_FLOAT class */ @@ -2178,6 +2208,189 @@ diff_ldouble_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, return nfound; } +#ifdef H5_HAVE__FLOAT16 +/*------------------------------------------------------------------------- + * Function: diff_float16_element + * + * Purpose: diff a single H5T_NATIVE_FLOAT16 type + * + * Return: number of differences found + * + *------------------------------------------------------------------------- + */ +static hsize_t +diff_float16_element(unsigned char *mem1, unsigned char *mem2, hsize_t elem_idx, diff_opt_t *opts) +{ + hsize_t nfound = 0; /* number of differences found */ + H5__Float16 temp1_float16; + H5__Float16 temp2_float16; + double per; + bool both_zero = false; + bool isnan1 = false; + bool isnan2 = false; + + H5TOOLS_START_DEBUG("delta_bool:%d - percent_bool:%d", opts->delta_bool, opts->percent_bool); + + memcpy(&temp1_float16, mem1, sizeof(H5__Float16)); + memcpy(&temp2_float16, mem2, sizeof(H5__Float16)); + + /* logic for detecting NaNs is different with opts -d, -p and no opts */ + + /*------------------------------------------------------------------------- + * -d and !-p + *------------------------------------------------------------------------- + */ + if (opts->delta_bool && !opts->percent_bool) { + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if (opts->do_nans) { + isnan1 = isnan(temp1_float16); + isnan2 = isnan(temp2_float16); + } + + /* both not NaN, do the comparison */ + if (!isnan1 && !isnan2) { + if ((double)ABS(temp1_float16 - temp2_float16) > opts->delta) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT, (double)temp1_float16, (double)temp2_float16, + (double)ABS(temp1_float16 - temp2_float16)); + } + nfound++; + } + } + /* only one is NaN, assume difference */ + else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT, (double)temp1_float16, (double)temp2_float16, + (double)ABS(temp1_float16 - temp2_float16)); + } + nfound++; + } + } + /*------------------------------------------------------------------------- + * !-d and -p + *------------------------------------------------------------------------- + */ + else if (!opts->delta_bool && opts->percent_bool) { + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if (opts->do_nans) { + isnan1 = isnan(temp1_float16); + isnan2 = isnan(temp2_float16); + } + /* both not NaN, do the comparison */ + if ((!isnan1 && !isnan2)) { + PER(temp1_float16, temp2_float16); + + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT_P_NOTCOMP, (double)temp1_float16, (double)temp2_float16, + (double)ABS(temp1_float16 - temp2_float16)); + } + nfound++; + } + else if (per > opts->percent) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT_P, (double)temp1_float16, (double)temp2_float16, + (double)ABS(temp1_float16 - temp2_float16), + (double)ABS(1 - temp2_float16 / temp1_float16)); + } + nfound++; + } + } + /* only one is NaN, assume difference */ + else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT, (double)temp1_float16, (double)temp2_float16, + (double)ABS(temp1_float16 - temp2_float16)); + } + nfound++; + } + } + /*------------------------------------------------------------------------- + * -d and -p + *------------------------------------------------------------------------- + */ + else if (opts->delta_bool && opts->percent_bool) { + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if (opts->do_nans) { + isnan1 = isnan(temp1_float16); + isnan2 = isnan(temp2_float16); + } + + /* both not NaN, do the comparison */ + if (!isnan1 && !isnan2) { + PER(temp1_float16, temp2_float16); + + if (not_comparable && !both_zero) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT_P_NOTCOMP, (double)temp1_float16, (double)temp2_float16, + (double)ABS(temp1_float16 - temp2_float16)); + } + nfound++; + } + else if (per > opts->percent && (double)ABS(temp1_float16 - temp2_float16) > opts->delta) { + opts->print_percentage = 1; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT_P, (double)temp1_float16, (double)temp2_float16, + (double)ABS(temp1_float16 - temp2_float16), + (double)ABS(1 - temp2_float16 / temp1_float16)); + } + nfound++; + } + } + /* only one is NaN, assume difference */ + else if ((isnan1 && !isnan2) || (!isnan1 && isnan2)) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT, (double)temp1_float16, (double)temp2_float16, + (double)ABS(temp1_float16 - temp2_float16)); + } + nfound++; + } + } + /*------------------------------------------------------------------------- + * no -d and -p + *------------------------------------------------------------------------- + */ + else { + if (equal_float(temp1_float16, temp2_float16, opts) == false) { + opts->print_percentage = 0; + print_pos(opts, elem_idx, 0); + if (print_data(opts)) { + parallel_print(F_FORMAT, (double)temp1_float16, (double)temp2_float16, + (double)ABS(temp1_float16 - temp2_float16)); + } + nfound++; + } + } + + H5TOOLS_ENDDEBUG(": %" PRIuHSIZE " zero:%d", nfound, both_zero); + return nfound; +} +#endif + /*------------------------------------------------------------------------- * Function: diff_schar_element * diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c index 4641c93..26cde1b 100644 --- a/tools/lib/h5diff_util.c +++ b/tools/lib/h5diff_util.c @@ -120,7 +120,11 @@ print_type(hid_t type) break; case H5T_FLOAT: - if (H5Tequal(type, H5T_IEEE_F32BE)) + if (H5Tequal(type, H5T_IEEE_F16BE)) + parallel_print("H5T_IEEE_F16BE"); + else if (H5Tequal(type, H5T_IEEE_F16LE)) + parallel_print("H5T_IEEE_F16LE"); + else if (H5Tequal(type, H5T_IEEE_F32BE)) parallel_print("H5T_IEEE_F32BE"); else if (H5Tequal(type, H5T_IEEE_F32LE)) parallel_print("H5T_IEEE_F32LE"); @@ -128,6 +132,10 @@ print_type(hid_t type) parallel_print("H5T_IEEE_F64BE"); else if (H5Tequal(type, H5T_IEEE_F64LE)) parallel_print("H5T_IEEE_F64LE"); +#ifdef H5_HAVE__FLOAT16 + else if (H5Tequal(type, H5T_NATIVE_FLOAT16)) + parallel_print("H5T_NATIVE_FLOAT16"); +#endif else if (H5Tequal(type, H5T_NATIVE_FLOAT)) parallel_print("H5T_NATIVE_FLOAT"); else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c index efaddee..5a8c401 100644 --- a/tools/lib/h5tools_dump.c +++ b/tools/lib/h5tools_dump.c @@ -2190,7 +2190,11 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ break; case H5T_FLOAT: - if (H5Tequal(type, H5T_IEEE_F32BE) == true) + if (H5Tequal(type, H5T_IEEE_F16BE) == true) + h5tools_str_append(buffer, "H5T_IEEE_F16BE"); + else if (H5Tequal(type, H5T_IEEE_F16LE) == true) + h5tools_str_append(buffer, "H5T_IEEE_F16LE"); + else if (H5Tequal(type, H5T_IEEE_F32BE) == true) h5tools_str_append(buffer, "H5T_IEEE_F32BE"); else if (H5Tequal(type, H5T_IEEE_F32LE) == true) h5tools_str_append(buffer, "H5T_IEEE_F32LE"); @@ -2202,6 +2206,10 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_ h5tools_str_append(buffer, "H5T_VAX_F32"); else if (H5Tequal(type, H5T_VAX_F64) == true) h5tools_str_append(buffer, "H5T_VAX_F64"); +#ifdef H5_HAVE__FLOAT16 + else if (H5Tequal(type, H5T_NATIVE_FLOAT16) == true) + h5tools_str_append(buffer, "H5T_NATIVE_FLOAT16"); +#endif else if (H5Tequal(type, H5T_NATIVE_FLOAT) == true) h5tools_str_append(buffer, "H5T_NATIVE_FLOAT"); else if (H5Tequal(type, H5T_NATIVE_DOUBLE) == true) diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 5ef86fb..47893ec 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -700,7 +700,17 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai switch (type_class) { case H5T_FLOAT: H5TOOLS_DEBUG("H5T_FLOAT"); - if (sizeof(float) == nsize) { +#ifdef H5_HAVE__FLOAT16 + if (sizeof(H5__Float16) == nsize) { + /* if (H5Tequal(type, H5T_NATIVE_FLOAT16)) */ + H5__Float16 tempfloat16; + + memcpy(&tempfloat16, vp, sizeof(H5__Float16)); + h5tools_str_append(str, OPT(info->fmt_float, "%g"), (double)tempfloat16); + } + else +#endif + if (sizeof(float) == nsize) { /* if (H5Tequal(type, H5T_NATIVE_FLOAT)) */ float tempfloat; diff --git a/tools/lib/h5tools_type.c b/tools/lib/h5tools_type.c index 7e9f6f7..c5e7472 100644 --- a/tools/lib/h5tools_type.c +++ b/tools/lib/h5tools_type.c @@ -55,7 +55,9 @@ h5tools_get_little_endian_type(hid_t tid) break; case H5T_FLOAT: - if (size == 4) + if (size == 2) + p_type = H5Tcopy(H5T_IEEE_F16LE); + else if (size == 4) p_type = H5Tcopy(H5T_IEEE_F32LE); else if (size == 8) p_type = H5Tcopy(H5T_IEEE_F64LE); @@ -134,7 +136,9 @@ h5tools_get_big_endian_type(hid_t tid) break; case H5T_FLOAT: - if (size == 4) + if (size == 2) + p_type = H5Tcopy(H5T_IEEE_F16BE); + else if (size == 4) p_type = H5Tcopy(H5T_IEEE_F32BE); else if (size == 8) p_type = H5Tcopy(H5T_IEEE_F64BE); diff --git a/tools/src/h5import/h5import.c b/tools/src/h5import/h5import.c index 663f68a..a375b57 100644 --- a/tools/src/h5import/h5import.c +++ b/tools/src/h5import/h5import.c @@ -3114,6 +3114,48 @@ getInputClassType(struct Input *in, char *buffer) kindex = 7; } + else if (!strcmp(buffer, "H5T_IEEE_F16BE")) { + in->inputSize = 16; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("IEEE")) == -1) { + (void)fprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("BE")) == -1) { + (void)fprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; +#ifdef H5DEBUGIMPORT + printf("h5dump inputByteOrder %d\n", in->inputByteOrder); +#endif + + kindex = 3; + } + else if (!strcmp(buffer, "H5T_IEEE_F16LE")) { + in->inputSize = 16; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("IEEE")) == -1) { + (void)fprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + if ((kindex = OutputByteOrderStrToInt("LE")) == -1) { + (void)fprintf(stderr, "%s", err3); + return (-1); + } + in->outputByteOrder = kindex; +#ifdef H5DEBUGIMPORT + printf("h5dump inputByteOrder %d\n", in->inputByteOrder); +#endif + + kindex = 3; + } else if (!strcmp(buffer, "H5T_IEEE_F32BE")) { in->inputSize = 32; in->configOptionVector[INPUT_SIZE] = 1; @@ -3210,6 +3252,20 @@ getInputClassType(struct Input *in, char *buffer) kindex = 3; } +#ifdef H5_HAVE__FLOAT16 + else if (!strcmp(buffer, "H5T_NATIVE_FLOAT16")) { + in->inputSize = 16; + in->configOptionVector[INPUT_SIZE] = 1; + + if ((kindex = OutputArchStrToInt("NATIVE")) == -1) { + (void)fprintf(stderr, "%s", err2); + return (-1); + } + in->outputArchitecture = kindex; + + kindex = 3; + } +#endif else if (!strcmp(buffer, "H5T_NATIVE_FLOAT")) { in->inputSize = 32; in->configOptionVector[INPUT_SIZE] = 1; @@ -3936,6 +3992,12 @@ createOutputDataType(struct Input *in) switch (in->outputArchitecture) { case 0: switch (in->outputSize) { +#ifdef H5_HAVE__FLOAT16 + case 16: + new_type = H5Tcopy(H5T_NATIVE_FLOAT16); + break; +#endif + case 32: new_type = H5Tcopy(H5T_NATIVE_FLOAT); break; @@ -3971,6 +4033,23 @@ createOutputDataType(struct Input *in) case 2: switch (in->outputSize) { + case 16: + switch (in->outputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_IEEE_F16BE); + break; + + case 1: + new_type = H5Tcopy(H5T_IEEE_F16LE); + break; + + default: + (void)fprintf(stderr, "%s", err3); + return (-1); + } + break; + case 32: switch (in->outputByteOrder) { case -1: @@ -4291,6 +4370,12 @@ createInputDataType(struct Input *in) switch (in->inputArchitecture) { case 0: switch (in->inputSize) { +#ifdef H5_HAVE__FLOAT16 + case 16: + new_type = H5Tcopy(H5T_NATIVE_FLOAT16); + break; +#endif + case 32: new_type = H5Tcopy(H5T_NATIVE_FLOAT); break; @@ -4326,6 +4411,23 @@ createInputDataType(struct Input *in) case 2: switch (in->inputSize) { + case 16: + switch (in->inputByteOrder) { + case -1: + case 0: + new_type = H5Tcopy(H5T_IEEE_F16BE); + break; + + case 1: + new_type = H5Tcopy(H5T_IEEE_F16LE); + break; + + default: + (void)fprintf(stderr, "%s", err3); + return (-1); + } + break; + case 32: switch (in->inputByteOrder) { case -1: @@ -4535,6 +4637,12 @@ createInputDataType(struct Input *in) case 2: case 3: switch (in->inputSize) { +#ifdef H5_HAVE__FLOAT16 + case 16: + new_type = H5Tcopy(H5T_NATIVE_FLOAT16); + break; +#endif + case 32: new_type = H5Tcopy(H5T_NATIVE_FLOAT); break; diff --git a/tools/src/h5ls/h5ls.c b/tools/src/h5ls/h5ls.c index 04c5ff3..bc0781c 100644 --- a/tools/src/h5ls/h5ls.c +++ b/tools/src/h5ls/h5ls.c @@ -427,6 +427,11 @@ print_native_type(h5tools_str_t *buffer, hid_t type, int ind) else if (H5Tequal(type, H5T_NATIVE_ULLONG) == true) { h5tools_str_append(buffer, "native unsigned long long"); } +#ifdef H5_HAVE__FLOAT16 + else if (H5Tequal(type, H5T_NATIVE_FLOAT16) == true) { + h5tools_str_append(buffer, "native _Float16"); + } +#endif else if (H5Tequal(type, H5T_NATIVE_FLOAT) == true) { h5tools_str_append(buffer, "native float"); } @@ -551,7 +556,13 @@ print_native_type(h5tools_str_t *buffer, hid_t type, int ind) static bool print_ieee_type(h5tools_str_t *buffer, hid_t type, int ind) { - if (H5Tequal(type, H5T_IEEE_F32BE) == true) { + if (H5Tequal(type, H5T_IEEE_F16BE) == true) { + h5tools_str_append(buffer, "IEEE 16-bit big-endian float"); + } + else if (H5Tequal(type, H5T_IEEE_F16LE) == true) { + h5tools_str_append(buffer, "IEEE 16-bit little-endian float"); + } + else if (H5Tequal(type, H5T_IEEE_F32BE) == true) { h5tools_str_append(buffer, "IEEE 32-bit big-endian float"); } else if (H5Tequal(type, H5T_IEEE_F32LE) == true) { diff --git a/tools/test/h5dump/CMakeTests.cmake b/tools/test/h5dump/CMakeTests.cmake index e997aa8..9a452e2 100644 --- a/tools/test/h5dump/CMakeTests.cmake +++ b/tools/test/h5dump/CMakeTests.cmake @@ -103,6 +103,7 @@ tfletcher32.ddl #tfloatsattrs.ddl #native #tfloatsattrs.wddl #special for windows + tfloat16.ddl tfpformat.ddl tgroup-1.ddl tgroup-2.ddl @@ -291,6 +292,7 @@ tfcontents2.h5 tfilters.h5 tfloatsattrs.h5 + tfloat16.h5 tfpformat.h5 tfvalues.h5 tgroup.h5 @@ -1302,6 +1304,9 @@ ADD_H5_TEST (tldouble 0 --enable-error-stack tldouble.h5) ADD_H5_TEST (tldouble_scalar 0 -p --enable-error-stack tldouble_scalar.h5) + # Add test for _Float16 type + ADD_H5_TEST (tfloat16 0 --enable-error-stack tfloat16.h5) + # test for vms ADD_H5_TEST (tvms 0 --enable-error-stack tvms.h5) diff --git a/tools/test/h5dump/expected/tfloat16.ddl b/tools/test/h5dump/expected/tfloat16.ddl new file mode 100644 index 0000000..a98200c --- /dev/null +++ b/tools/test/h5dump/expected/tfloat16.ddl @@ -0,0 +1,46 @@ +HDF5 "tfloat16.h5" { +GROUP "/" { + DATASET "DS16BITS" { + DATATYPE H5T_IEEE_F16LE + DATASPACE SIMPLE { ( 8, 16 ) / ( 8, 16 ) } + DATA { + (0,0): 16, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, 7.5, + (1,0): 15, 0.5625, 1.0625, 1.5625, 2.0625, 2.5625, 3.0625, 3.5625, + (1,8): 4.0625, 4.5625, 5.0625, 5.5625, 6.0625, 6.5625, 7.0625, 7.5625, + (2,0): 14, 0.625, 1.125, 1.625, 2.125, 2.625, 3.125, 3.625, 4.125, + (2,9): 4.625, 5.125, 5.625, 6.125, 6.625, 7.125, 7.625, + (3,0): 13, 0.6875, 1.1875, 1.6875, 2.1875, 2.6875, 3.1875, 3.6875, + (3,8): 4.1875, 4.6875, 5.1875, 5.6875, 6.1875, 6.6875, 7.1875, 7.6875, + (4,0): 12, 0.75, 1.25, 1.75, 2.25, 2.75, 3.25, 3.75, 4.25, 4.75, 5.25, + (4,11): 5.75, 6.25, 6.75, 7.25, 7.75, + (5,0): 11, 0.8125, 1.3125, 1.8125, 2.3125, 2.8125, 3.3125, 3.8125, + (5,8): 4.3125, 4.8125, 5.3125, 5.8125, 6.3125, 6.8125, 7.3125, 7.8125, + (6,0): 10, 0.875, 1.375, 1.875, 2.375, 2.875, 3.375, 3.875, 4.375, + (6,9): 4.875, 5.375, 5.875, 6.375, 6.875, 7.375, 7.875, + (7,0): 9, 0.9375, 1.4375, 1.9375, 2.4375, 2.9375, 3.4375, 3.9375, + (7,8): 4.4375, 4.9375, 5.4375, 5.9375, 6.4375, 6.9375, 7.4375, 7.9375 + } + ATTRIBUTE "DS16BITS" { + DATATYPE H5T_IEEE_F16LE + DATASPACE SIMPLE { ( 128 ) / ( 128 ) } + DATA { + (0): 16, 0.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5, 5, 5.5, 6, 6.5, 7, + (15): 7.5, 15, 0.5625, 1.0625, 1.5625, 2.0625, 2.5625, 3.0625, + (23): 3.5625, 4.0625, 4.5625, 5.0625, 5.5625, 6.0625, 6.5625, + (30): 7.0625, 7.5625, 14, 0.625, 1.125, 1.625, 2.125, 2.625, 3.125, + (39): 3.625, 4.125, 4.625, 5.125, 5.625, 6.125, 6.625, 7.125, 7.625, + (48): 13, 0.6875, 1.1875, 1.6875, 2.1875, 2.6875, 3.1875, 3.6875, + (56): 4.1875, 4.6875, 5.1875, 5.6875, 6.1875, 6.6875, 7.1875, + (63): 7.6875, 12, 0.75, 1.25, 1.75, 2.25, 2.75, 3.25, 3.75, 4.25, + (73): 4.75, 5.25, 5.75, 6.25, 6.75, 7.25, 7.75, 11, 0.8125, 1.3125, + (83): 1.8125, 2.3125, 2.8125, 3.3125, 3.8125, 4.3125, 4.8125, + (90): 5.3125, 5.8125, 6.3125, 6.8125, 7.3125, 7.8125, 10, 0.875, + (98): 1.375, 1.875, 2.375, 2.875, 3.375, 3.875, 4.375, 4.875, 5.375, + (107): 5.875, 6.375, 6.875, 7.375, 7.875, 9, 0.9375, 1.4375, 1.9375, + (116): 2.4375, 2.9375, 3.4375, 3.9375, 4.4375, 4.9375, 5.4375, + (123): 5.9375, 6.4375, 6.9375, 7.4375, 7.9375 + } + } + } +} +} diff --git a/tools/test/h5dump/h5dumpgentest.c b/tools/test/h5dump/h5dumpgentest.c index e12690c..2612259 100644 --- a/tools/test/h5dump/h5dumpgentest.c +++ b/tools/test/h5dump/h5dumpgentest.c @@ -119,6 +119,9 @@ #define FILE90 "tst_onion_dset_1d.h5" #define FILE91 "tst_onion_objs.h5" #define FILE92 "tst_onion_dset_ext.h5" +#ifdef H5_HAVE__FLOAT16 +#define FILE93 "tfloat16.h5" +#endif #define ONION_TEST_FIXNAME_SIZE 1024 #define ONION_TEST_PAGE_SIZE (uint32_t)32 @@ -412,6 +415,13 @@ typedef struct s1_t { #define F89_DATASETF128 "DS128BITS" #define F89_YDIM128 128 +#ifdef H5_HAVE__FLOAT16 +/* "FILE93" macros */ +#define F93_XDIM 8 +#define F93_YDIM 16 +#define F93_DATASET "DS16BITS" +#endif + static void gent_group(void) { @@ -11993,6 +12003,78 @@ error: return -1; } /* gent_onion_dset_extension */ +#ifdef H5_HAVE__FLOAT16 +static void +gent_float16(void) +{ + hid_t fid = H5I_INVALID_HID; + hid_t tid = H5I_INVALID_HID; + hid_t attr = H5I_INVALID_HID; + hid_t dataset = H5I_INVALID_HID; + hid_t space = H5I_INVALID_HID; + hid_t aspace = H5I_INVALID_HID; + hsize_t dims[2], adims[1]; + + struct { + H5__Float16 arr[F93_XDIM][F93_YDIM]; + } * dset16; + + H5__Float16 *aset16 = NULL; + H5__Float16 val16bits; + + dset16 = malloc(sizeof(*dset16)); + + aset16 = calloc(F93_XDIM * F93_YDIM, sizeof(H5__Float16)); + + fid = H5Fcreate(FILE93, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + + if ((tid = H5Tcopy(H5T_NATIVE_FLOAT16)) < 0) + goto error; + + if (H5Tget_size(tid) == 0) + goto error; + + /* Dataset of 16-bit float */ + dims[0] = F93_XDIM; + dims[1] = F93_YDIM; + space = H5Screate_simple(2, dims, NULL); + dataset = H5Dcreate2(fid, F93_DATASET, H5T_IEEE_F16LE, space, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + + val16bits = (H5__Float16)F93_YDIM; + for (size_t i = 0; i < dims[0]; i++) { + dset16->arr[i][0] = val16bits; + aset16[i * dims[1]] = dset16->arr[i][0]; + + for (size_t j = 1; j < dims[1]; j++) { + dset16->arr[i][j] = (H5__Float16)(j * dims[0] + i) / (H5__Float16)F93_YDIM; + aset16[i * dims[1] + j] = dset16->arr[i][j]; + } + + val16bits -= (H5__Float16)1; + } + + H5Dwrite(dataset, H5T_IEEE_F16LE, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset16); + + /* Attribute of 16-bit float */ + adims[0] = F93_XDIM * F93_YDIM; + aspace = H5Screate_simple(1, adims, NULL); + attr = H5Acreate2(dataset, F93_DATASET, H5T_IEEE_F16LE, aspace, H5P_DEFAULT, H5P_DEFAULT); + + H5Awrite(attr, H5T_IEEE_F16LE, aset16); + + H5Aclose(attr); + H5Sclose(aspace); + H5Sclose(space); + H5Dclose(dataset); + +error: + free(aset16); + free(dset16); + + H5Fclose(fid); +} +#endif + int main(void) { @@ -12097,5 +12179,9 @@ main(void) gent_onion_create_delete_objects(); gent_onion_dset_extension(); +#ifdef H5_HAVE__FLOAT16 + gent_float16(); +#endif + return 0; } diff --git a/tools/test/h5dump/testfiles/tfloat16.h5 b/tools/test/h5dump/testfiles/tfloat16.h5 Binary files differnew file mode 100644 index 0000000..a0cccc5 --- /dev/null +++ b/tools/test/h5dump/testfiles/tfloat16.h5 diff --git a/tools/test/h5dump/testh5dump.sh.in b/tools/test/h5dump/testh5dump.sh.in index fdeb17d..911ffc7 100644 --- a/tools/test/h5dump/testh5dump.sh.in +++ b/tools/test/h5dump/testh5dump.sh.in @@ -133,6 +133,7 @@ $SRC_H5DUMP_TESTFILES/tfcontents1.h5 $SRC_H5DUMP_TESTFILES/tfcontents2.h5 $SRC_H5DUMP_TESTFILES/tfilters.h5 $SRC_H5DUMP_TESTFILES/tfloatsattrs.h5 +$SRC_H5DUMP_TESTFILES/tfloat16.h5 $SRC_H5DUMP_TESTFILES/tfpformat.h5 $SRC_H5DUMP_TESTFILES/tfvalues.h5 $SRC_H5DUMP_TESTFILES/tgroup.h5 @@ -273,6 +274,7 @@ $SRC_H5DUMP_OUTFILES/tfamily.ddl $SRC_H5DUMP_OUTFILES/tfill.ddl $SRC_H5DUMP_OUTFILES/tfletcher32.ddl $SRC_H5DUMP_OUTFILES/tfloatsattrs.ddl +$SRC_H5DUMP_OUTFILES/tfloat16.ddl $SRC_H5DUMP_OUTFILES/tfpformat.ddl $SRC_H5DUMP_OUTFILES/tgroup-1.ddl $SRC_H5DUMP_OUTFILES/tgroup-2.ddl @@ -1404,6 +1406,9 @@ TOOLTEST tfloatsattrs.ddl -p --enable-error-stack tfloatsattrs.h5 TOOLTEST tldouble.ddl --enable-error-stack tldouble.h5 TOOLTEST tldouble_scalar.ddl -p --enable-error-stack tldouble_scalar.h5 +# test for _Float16 type +TOOLTEST tfloat16.ddl --enable-error-stack tfloat16.h5 + # test for vms TOOLTEST tvms.ddl --enable-error-stack tvms.h5 diff --git a/tools/test/h5ls/CMakeTests.cmake b/tools/test/h5ls/CMakeTests.cmake index 2d932b2..596162b 100644 --- a/tools/test/h5ls/CMakeTests.cmake +++ b/tools/test/h5ls/CMakeTests.cmake @@ -35,6 +35,7 @@ textlink.h5 textlinksrc.h5 textlinktar.h5 + tfloat16.h5 tgroup.h5 tgrp_comments.h5 tgrpnullspace.h5 @@ -88,6 +89,8 @@ textlinksrc-7-old.ls textlinksrc-nodangle-1.ls textlinksrc-nodangle-2.ls + tfloat16.ls + tfloat16_nosupport.ls tgroup.ls tgroup-1.ls tgroup-2.ls @@ -314,6 +317,23 @@ # when used file with no dangling links - expected exit code 0 ADD_H5_TEST (thlinks-nodangle-1 0 -w80 --follow-symlinks --no-dangling-links thlink.h5) + # tests for _Float16 type + if (${${HDF_PREFIX}_HAVE__FLOAT16}) + # If support is available for _Float16 type, the second test + # will fail as the type will be printed out as "native _Float16" + # rather than "IEEE 16-bit little-endian float". + ADD_H5_TEST (tfloat16 0 -w80 -v tfloat16.h5) + ADD_H5_TEST (tfloat16_nosupport 0 -w80 -v tfloat16.h5) + set_tests_properties (H5LS-tfloat16_nosupport PROPERTIES WILL_FAIL "true") + else () + # If support is NOT available for _Float16 type, the first test + # will fail as the type will be printed out as + # "IEEE 16-bit little-endian float" rather than "native _Float16" + ADD_H5_TEST (tfloat16 0 -w80 -v tfloat16.h5) + set_tests_properties (H5LS-tfloat16 PROPERTIES WILL_FAIL "true") + ADD_H5_TEST (tfloat16_nosupport 0 -w80 -v tfloat16.h5) + endif () + # test for wildcards in filename (does not work with cmake) # ADD_H5_TEST (tstarfile 0 -w80 t*link.h5) # ADD_H5_TEST (tqmarkfile 0 -w80 t?link.h5) diff --git a/tools/test/h5ls/expected/tfloat16.ls b/tools/test/h5ls/expected/tfloat16.ls new file mode 100644 index 0000000..68c0fe7 --- /dev/null +++ b/tools/test/h5ls/expected/tfloat16.ls @@ -0,0 +1,8 @@ +Opened "tfloat16.h5" with sec2 driver. +DS16BITS Dataset {8/8, 16/16} + Attribute: DS16BITS {128} + Type: native _Float16 + Location: 1:800 + Links: 1 + Storage: 256 logical bytes, 256 allocated bytes, 100.00% utilization + Type: native _Float16 diff --git a/tools/test/h5ls/expected/tfloat16_nosupport.ls b/tools/test/h5ls/expected/tfloat16_nosupport.ls new file mode 100644 index 0000000..70253c6 --- /dev/null +++ b/tools/test/h5ls/expected/tfloat16_nosupport.ls @@ -0,0 +1,8 @@ +Opened "tfloat16.h5" with sec2 driver. +DS16BITS Dataset {8/8, 16/16} + Attribute: DS16BITS {128} + Type: IEEE 16-bit little-endian float + Location: 1:800 + Links: 1 + Storage: 256 logical bytes, 256 allocated bytes, 100.00% utilization + Type: IEEE 16-bit little-endian float diff --git a/tools/test/h5ls/testh5ls.sh.in b/tools/test/h5ls/testh5ls.sh.in index 01f9402..3d306df 100644 --- a/tools/test/h5ls/testh5ls.sh.in +++ b/tools/test/h5ls/testh5ls.sh.in @@ -16,6 +16,7 @@ srcdir=@srcdir@ USE_FILTER_SZIP="@USE_FILTER_SZIP@" USE_FILTER_DEFLATE="@USE_FILTER_DEFLATE@" +HAVE__FLOAT16="@HAVE__FLOAT16@" TESTNAME=h5ls EXIT_SUCCESS=0 @@ -78,6 +79,7 @@ $SRC_H5DUMP_TESTFILES/tempty.h5 $SRC_H5DUMP_TESTFILES/textlink.h5 $SRC_H5DUMP_TESTFILES/textlinksrc.h5 $SRC_H5DUMP_TESTFILES/textlinktar.h5 +$SRC_H5DUMP_TESTFILES/tfloat16.h5 $SRC_H5DUMP_TESTFILES/tgroup.h5 $SRC_H5DUMP_TESTFILES/tgrp_comments.h5 $SRC_H5DUMP_TESTFILES/tgrpnullspace.h5 @@ -128,6 +130,8 @@ $SRC_H5LS_OUTFILES/textlinksrc-2-old.ls $SRC_H5LS_OUTFILES/textlinksrc-3-old.ls $SRC_H5LS_OUTFILES/textlinksrc-6-old.ls $SRC_H5LS_OUTFILES/textlinksrc-7-old.ls +$SRC_H5LS_OUTFILES/tfloat16.ls +$SRC_H5LS_OUTFILES/tfloat16_nosupport.ls $SRC_H5LS_OUTFILES/tsoftlinks-1.ls $SRC_H5LS_OUTFILES/tsoftlinks-2.ls $SRC_H5LS_OUTFILES/tsoftlinks-3.ls @@ -361,6 +365,13 @@ TOOLTEST tsoftlinks-nodangle-1.ls 1 -w80 --follow-symlinks --no-dangling-links t # when used file with no dangling links - expected exit code 0 TOOLTEST thlinks-nodangle-1.ls 0 -w80 --follow-symlinks --no-dangling-links thlink.h5 +# test for _Float16 type +if test $HAVE__FLOAT16 = "yes" ; then + TOOLTEST tfloat16.ls 0 -w80 -v tfloat16.h5 +else + TOOLTEST tfloat16_nosupport.ls 0 -w80 -v tfloat16.h5 +fi + # test for wildcards in filename (does not work with cmake) # this h5ls test script does not pass the filename properly like the h5dump test script??? #TOOLTEST tstarfile.ls 0 -w80 t*link.h5 |