Skip to content

Commit 441d83a

Browse files
Add predefined datatypes for FP6 formats (#6097)
Adds predefined datatypes for FP6 data in E2M3 and E3M2 formats Does not add support for any native FP6 types; datatype conversions are performed in software
1 parent 0b0ed3a commit 441d83a

40 files changed

Lines changed: 2033 additions & 738 deletions

c++/src/H5PredType.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ PredType *PredType::FLOAT_BFLOAT16BE_;
156156
PredType *PredType::FLOAT_BFLOAT16LE_;
157157
PredType *PredType::FLOAT_F8E4M3_;
158158
PredType *PredType::FLOAT_F8E5M2_;
159+
PredType *PredType::FLOAT_F6E2M3_;
160+
PredType *PredType::FLOAT_F6E3M2_;
159161

160162
PredType *PredType::UNIX_D32BE_;
161163
PredType *PredType::UNIX_D32LE_;
@@ -348,6 +350,8 @@ PredType::makePredTypes()
348350
FLOAT_BFLOAT16LE_ = new PredType(H5T_FLOAT_BFLOAT16LE);
349351
FLOAT_F8E4M3_ = new PredType(H5T_FLOAT_F8E4M3);
350352
FLOAT_F8E5M2_ = new PredType(H5T_FLOAT_F8E5M2);
353+
FLOAT_F6E2M3_ = new PredType(H5T_FLOAT_F6E2M3);
354+
FLOAT_F6E3M2_ = new PredType(H5T_FLOAT_F6E3M2);
351355

352356
UNIX_D32BE_ = new PredType(H5T_UNIX_D32BE);
353357
UNIX_D32LE_ = new PredType(H5T_UNIX_D32LE);
@@ -506,6 +510,8 @@ PredType::deleteConstants()
506510
delete FLOAT_BFLOAT16LE_;
507511
delete FLOAT_F8E4M3_;
508512
delete FLOAT_F8E5M2_;
513+
delete FLOAT_F6E2M3_;
514+
delete FLOAT_F6E3M2_;
509515

510516
delete UNIX_D32BE_;
511517
delete UNIX_D32LE_;
@@ -668,6 +674,8 @@ const PredType &PredType::FLOAT_BFLOAT16BE = *FLOAT_BFLOAT16BE_;
668674
const PredType &PredType::FLOAT_BFLOAT16LE = *FLOAT_BFLOAT16LE_;
669675
const PredType &PredType::FLOAT_F8E4M3 = *FLOAT_F8E4M3_;
670676
const PredType &PredType::FLOAT_F8E5M2 = *FLOAT_F8E5M2_;
677+
const PredType &PredType::FLOAT_F6E2M3 = *FLOAT_F6E2M3_;
678+
const PredType &PredType::FLOAT_F6E3M2 = *FLOAT_F6E3M2_;
671679

672680
const PredType &PredType::UNIX_D32BE = *UNIX_D32BE_;
673681
const PredType &PredType::UNIX_D32LE = *UNIX_D32LE_;

c++/src/H5PredType.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ class H5CPP_DLL PredType : public AtomType {
9696
static const PredType &FLOAT_BFLOAT16LE;
9797
static const PredType &FLOAT_F8E4M3;
9898
static const PredType &FLOAT_F8E5M2;
99+
static const PredType &FLOAT_F6E2M3;
100+
static const PredType &FLOAT_F6E3M2;
99101

100102
static const PredType &UNIX_D32BE;
101103
static const PredType &UNIX_D32LE;
@@ -271,6 +273,8 @@ class H5CPP_DLL PredType : public AtomType {
271273
static PredType *FLOAT_BFLOAT16LE_;
272274
static PredType *FLOAT_F8E4M3_;
273275
static PredType *FLOAT_F8E5M2_;
276+
static PredType *FLOAT_F6E2M3_;
277+
static PredType *FLOAT_F6E3M2_;
274278

275279
static PredType *UNIX_D32BE_;
276280
static PredType *UNIX_D32LE_;

doxygen/dox/DDLBNF200.dox

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ This section contains a brief explanation of the symbols used in the DDL.
101101
H5T_IEEE_F64BE | H5T_IEEE_F64LE |
102102
H5T_FLOAT_BFLOAT16BE | H5T_FLOAT_BFLOAT16LE |
103103
H5T_FLOAT_F8E4M3 | H5T_FLOAT_F8E5M2 |
104+
H5T_FLOAT_F6E2M3 | H5T_FLOAT_F6E3M2 |
104105
H5T_NATIVE_FLOAT16 | H5T_NATIVE_FLOAT |
105106
H5T_NATIVE_DOUBLE | H5T_NATIVE_LDOUBLE
106107

doxygen/examples/tables/predefinedDatatypes.dox

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@
5858
<td>#H5T_FLOAT_F8E5M2</td>
5959
<td>8-bit FP8 E5M2 (5 exponent bits, 2 mantissa bits) floating point</td>
6060
</tr>
61+
<tr>
62+
<td>#H5T_FLOAT_F6E2M3</td>
63+
<td>6-bit FP6 E2M3 (2 exponent bits, 3 mantissa bits) floating point</td>
64+
</tr>
65+
<tr>
66+
<td>#H5T_FLOAT_F6E3M2</td>
67+
<td>6-bit FP6 E3M2 (3 exponent bits, 2 mantissa bits) floating point</td>
68+
</tr>
6169
</table>
6270
//! [predefined_alt_float_datatypes_table]
6371
*

fortran/src/H5_f.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,10 @@ h5init_types_c(hid_t_f *types, hid_t_f *floatingtypes, hid_t_f *integertypes)
257257
return ret_value;
258258
if ((floatingtypes[9] = (hid_t_f)H5Tcopy(H5T_FLOAT_F8E5M2)) < 0)
259259
return ret_value;
260+
if ((floatingtypes[10] = (hid_t_f)H5Tcopy(H5T_FLOAT_F6E2M3)) < 0)
261+
return ret_value;
262+
if ((floatingtypes[11] = (hid_t_f)H5Tcopy(H5T_FLOAT_F6E3M2)) < 0)
263+
return ret_value;
260264

261265
if ((integertypes[0] = (hid_t_f)H5Tcopy(H5T_STD_I8BE)) < 0)
262266
return ret_value;

fortran/src/H5_ff.F90

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,8 @@ END FUNCTION h5init1_flags_c
297297
H5T_FLOAT_BFLOAT16LE = floating_types(8)
298298
H5T_FLOAT_F8E4M3 = floating_types(9)
299299
H5T_FLOAT_F8E5M2 = floating_types(10)
300+
H5T_FLOAT_F6E2M3 = floating_types(11)
301+
H5T_FLOAT_F6E3M2 = floating_types(12)
300302

301303
H5T_STD_I8BE = integer_types(1)
302304
H5T_STD_I8LE = integer_types(2)

fortran/src/H5f90global.F90

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ MODULE H5GLOBAL
6363
! Do not forget to change these values when new predefined
6464
! datatypes are added
6565
INTEGER, PARAMETER :: PREDEF_TYPES_LEN = 19
66-
INTEGER, PARAMETER :: FLOATING_TYPES_LEN = 10
66+
INTEGER, PARAMETER :: FLOATING_TYPES_LEN = 12
6767
INTEGER, PARAMETER :: INTEGER_TYPES_LEN = 28
6868

6969
! These arrays need to be global because they are used in
@@ -93,6 +93,8 @@ MODULE H5GLOBAL
9393
!DEC$ATTRIBUTES DLLEXPORT :: H5T_FLOAT_BFLOAT16LE
9494
!DEC$ATTRIBUTES DLLEXPORT :: H5T_FLOAT_F8E4M3
9595
!DEC$ATTRIBUTES DLLEXPORT :: H5T_FLOAT_F8E5M2
96+
!DEC$ATTRIBUTES DLLEXPORT :: H5T_FLOAT_F6E2M3
97+
!DEC$ATTRIBUTES DLLEXPORT :: H5T_FLOAT_F6E3M2
9698
!DEC$ATTRIBUTES DLLEXPORT :: H5T_STD_I8BE
9799
!DEC$ATTRIBUTES DLLEXPORT :: H5T_STD_I8LE
98100
!DEC$ATTRIBUTES DLLEXPORT :: H5T_STD_I16BE
@@ -149,6 +151,8 @@ MODULE H5GLOBAL
149151
INTEGER(HID_T) :: H5T_FLOAT_BFLOAT16LE !< H5T_FLOAT_BFLOAT16LE
150152
INTEGER(HID_T) :: H5T_FLOAT_F8E4M3 !< H5T_FLOAT_F8E4M3
151153
INTEGER(HID_T) :: H5T_FLOAT_F8E5M2 !< H5T_FLOAT_F8E5M2
154+
INTEGER(HID_T) :: H5T_FLOAT_F6E2M3 !< H5T_FLOAT_F6E2M3
155+
INTEGER(HID_T) :: H5T_FLOAT_F6E3M2 !< H5T_FLOAT_F6E3M2
152156
INTEGER(HID_T) :: H5T_STD_I8BE !< H5T_STD_I8BE
153157
INTEGER(HID_T) :: H5T_STD_I8LE !< H5T_STD_I8LE
154158
INTEGER(HID_T) :: H5T_STD_I16BE !< H5T_STD_I16BE

hl/src/H5LT.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2317,6 +2317,12 @@ H5LT_dtype_to_text(hid_t dtype, char *dt_str, H5LT_lang_t lang, size_t *slen, bo
23172317
else if (H5Tequal(dtype, H5T_FLOAT_F8E5M2)) {
23182318
snprintf(dt_str, *slen, "H5T_FLOAT_F8E5M2");
23192319
}
2320+
else if (H5Tequal(dtype, H5T_FLOAT_F6E2M3)) {
2321+
snprintf(dt_str, *slen, "H5T_FLOAT_F6E2M3");
2322+
}
2323+
else if (H5Tequal(dtype, H5T_FLOAT_F6E3M2)) {
2324+
snprintf(dt_str, *slen, "H5T_FLOAT_F6E3M2");
2325+
}
23202326
#ifdef H5_HAVE__FLOAT16
23212327
else if (H5Tequal(dtype, H5T_NATIVE_FLOAT16)) {
23222328
snprintf(dt_str, *slen, "H5T_NATIVE_FLOAT16");

0 commit comments

Comments
 (0)