From d1efeba7be60e021cf329f9bb79987acaec8fb9d Mon Sep 17 00:00:00 2001 From: jhendersonHDF Date: Wed, 31 Dec 2025 11:44:08 -0600 Subject: [PATCH] Add predefined datatype for FP4 format (#6122) Adds predefined datatype for FP4 data in E2M1 format Does not add support for any native FP4 types; datatype conversions are performed in software --- c++/src/H5PredType.cpp | 4 + c++/src/H5PredType.h | 2 + doxygen/dox/DDLBNF200.dox | 5 +- .../examples/tables/predefinedDatatypes.dox | 4 + fortran/src/H5_f.c | 2 + fortran/src/H5_ff.F90 | 1 + fortran/src/H5f90global.F90 | 4 +- hl/src/H5LT.c | 3 + hl/src/H5LTanalyze.c | 500 ++++----- hl/src/H5LTanalyze.l | 1 + hl/src/H5LTparse.c | 971 +++++++++--------- hl/src/H5LTparse.h | 75 +- hl/src/H5LTparse.y | 2 + hl/test/test_lite.c | 7 + java/src-jni/hdf/hdf5lib/HDF5Constants.java | 4 + java/src-jni/jni/h5Constants.c | 5 + java/src-jni/jni/h5util.c | 8 + release_docs/CHANGELOG.md | 15 + src/H5T.c | 20 + src/H5Tmodule.h | 5 +- src/H5Tnative.c | 12 +- src/H5Tpublic.h | 17 + src/H5trace.c | 2 + test/API/H5_api_dataset_test.c | 4 +- test/API/H5_api_test_util.c | 5 +- test/dtypes.c | 271 ++++- test/ntypes.c | 57 + tools/lib/h5diff_util.c | 2 + tools/lib/h5tools_dump.c | 2 + tools/lib/h5tools_type.c | 8 + tools/src/h5import/h5import.c | 54 + tools/src/h5ls/h5ls.c | 3 + tools/test/h5dump/CMakeTests.cmake | 11 + tools/test/h5dump/expected/tfloat4.ddl | 46 + tools/test/h5dump/h5dumpgentest.c | 180 ++++ tools/test/h5dump/h5dumpgentest.h | 1 + tools/test/h5gentest.c | 1 + tools/test/h5ls/CMakeTests.cmake | 5 + tools/test/h5ls/expected/tfloat4.ls | 22 + tools/test/testfiles/tfloat4.h5 | Bin 0 -> 4544 bytes 40 files changed, 1564 insertions(+), 777 deletions(-) create mode 100644 tools/test/h5dump/expected/tfloat4.ddl create mode 100644 tools/test/h5ls/expected/tfloat4.ls create mode 100644 tools/test/testfiles/tfloat4.h5 diff --git a/c++/src/H5PredType.cpp b/c++/src/H5PredType.cpp index df26b98b489..7212f06917c 100644 --- a/c++/src/H5PredType.cpp +++ b/c++/src/H5PredType.cpp @@ -158,6 +158,7 @@ PredType *PredType::FLOAT_F8E4M3_; PredType *PredType::FLOAT_F8E5M2_; PredType *PredType::FLOAT_F6E2M3_; PredType *PredType::FLOAT_F6E3M2_; +PredType *PredType::FLOAT_F4E2M1_; PredType *PredType::UNIX_D32BE_; PredType *PredType::UNIX_D32LE_; @@ -352,6 +353,7 @@ PredType::makePredTypes() FLOAT_F8E5M2_ = new PredType(H5T_FLOAT_F8E5M2); FLOAT_F6E2M3_ = new PredType(H5T_FLOAT_F6E2M3); FLOAT_F6E3M2_ = new PredType(H5T_FLOAT_F6E3M2); + FLOAT_F4E2M1_ = new PredType(H5T_FLOAT_F4E2M1); UNIX_D32BE_ = new PredType(H5T_UNIX_D32BE); UNIX_D32LE_ = new PredType(H5T_UNIX_D32LE); @@ -512,6 +514,7 @@ PredType::deleteConstants() delete FLOAT_F8E5M2_; delete FLOAT_F6E2M3_; delete FLOAT_F6E3M2_; + delete FLOAT_F4E2M1_; delete UNIX_D32BE_; delete UNIX_D32LE_; @@ -676,6 +679,7 @@ const PredType &PredType::FLOAT_F8E4M3 = *FLOAT_F8E4M3_; const PredType &PredType::FLOAT_F8E5M2 = *FLOAT_F8E5M2_; const PredType &PredType::FLOAT_F6E2M3 = *FLOAT_F6E2M3_; const PredType &PredType::FLOAT_F6E3M2 = *FLOAT_F6E3M2_; +const PredType &PredType::FLOAT_F4E2M1 = *FLOAT_F4E2M1_; const PredType &PredType::UNIX_D32BE = *UNIX_D32BE_; const PredType &PredType::UNIX_D32LE = *UNIX_D32LE_; diff --git a/c++/src/H5PredType.h b/c++/src/H5PredType.h index 45d403fd990..d962e7d0a3a 100644 --- a/c++/src/H5PredType.h +++ b/c++/src/H5PredType.h @@ -98,6 +98,7 @@ class H5CPP_DLL PredType : public AtomType { static const PredType &FLOAT_F8E5M2; static const PredType &FLOAT_F6E2M3; static const PredType &FLOAT_F6E3M2; + static const PredType &FLOAT_F4E2M1; static const PredType &UNIX_D32BE; static const PredType &UNIX_D32LE; @@ -275,6 +276,7 @@ class H5CPP_DLL PredType : public AtomType { static PredType *FLOAT_F8E5M2_; static PredType *FLOAT_F6E2M3_; static PredType *FLOAT_F6E3M2_; + static PredType *FLOAT_F4E2M1_; static PredType *UNIX_D32BE_; static PredType *UNIX_D32LE_; diff --git a/doxygen/dox/DDLBNF200.dox b/doxygen/dox/DDLBNF200.dox index 6ba1f2a39cd..0bea24ce0a2 100644 --- a/doxygen/dox/DDLBNF200.dox +++ b/doxygen/dox/DDLBNF200.dox @@ -102,8 +102,9 @@ This section contains a brief explanation of the symbols used in the DDL. H5T_FLOAT_BFLOAT16BE | H5T_FLOAT_BFLOAT16LE | H5T_FLOAT_F8E4M3 | H5T_FLOAT_F8E5M2 | H5T_FLOAT_F6E2M3 | H5T_FLOAT_F6E3M2 | - H5T_NATIVE_FLOAT16 | H5T_NATIVE_FLOAT | - H5T_NATIVE_DOUBLE | H5T_NATIVE_LDOUBLE + H5T_FLOAT_F4E2M1 | H5T_NATIVE_FLOAT16 | + H5T_NATIVE_FLOAT | H5T_NATIVE_DOUBLE | + H5T_NATIVE_LDOUBLE