Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle IBM long double issues in dsets.c test_floattypes test #4116

Merged
merged 2 commits into from
Mar 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 20 additions & 26 deletions test/dsets.c
Original file line number Diff line number Diff line change
Expand Up @@ -5891,41 +5891,35 @@ test_floattypes(hid_t file)
(long double)1.0711093225222612990711093225222612,
(long double)-9.8971679387636870998971679387636870e-1}};
long double new_data[2][5];
size_t old_precision;
size_t ld_spos, ld_epos, ld_esize, ld_mpos, ld_msize;
size_t tgt_precision = 128;

TESTING(" long double (setup)");

/* Define user-defined quad-precision floating-point type for dataset */
datatype = H5Tcopy(H5T_NATIVE_LDOUBLE);
offset = 5;
precision = 123;
if (0 == (old_precision = H5Tget_precision(datatype)))
if ((datatype = H5Tcopy(H5T_NATIVE_LDOUBLE)) < 0)
goto error;
if (old_precision < precision) {

/* Get the layout of the native long double type */
if (H5Tget_fields(datatype, &ld_spos, &ld_epos, &ld_esize, &ld_mpos, &ld_msize) < 0)
goto error;

/* Check if all "tgt_precision"+ bits are already used. If not, define
* a custom floating-point type where the mantissa takes up the extra
* extra bits. Otherwise, just write and read using the native long
Copy link
Member

@hyoklee hyoklee Mar 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the extra extra bits -> the extra bits?

* double type.
*/
if (ld_esize + ld_msize + 1 < tgt_precision) {
size_t extra_bits = tgt_precision - ld_esize - ld_msize - 1;

/* Increasing precision, call H5Tset_precision first */
if (H5Tset_precision(datatype, precision) < 0)
if (H5Tset_precision(datatype, tgt_precision) < 0)
goto error;
/* H5Tset_precision may have changed our offset */
if (H5Tset_offset(datatype, offset) < 0)
if (H5Tset_fields(datatype, ld_spos + extra_bits, ld_epos + extra_bits, ld_esize, 0,
ld_msize + extra_bits) < 0)
goto error;
if (H5Tset_fields(datatype, (size_t)127, (size_t)112, (size_t)15, (size_t)offset, (size_t)107) <
0)
if (H5Tset_size(datatype, 16) < 0)
goto error;
}
else {
/* Decreasing precision, call H5Tset_fields first */
if (H5Tset_offset(datatype, offset) < 0)
goto error;
if (H5Tset_fields(datatype, (size_t)127, (size_t)112, (size_t)15, (size_t)offset, (size_t)107) <
0)
goto error;
if (H5Tset_precision(datatype, precision) < 0)
goto error;
}
if (H5Tset_size(datatype, (size_t)16) < 0)
goto error;
if (H5Tset_ebias(datatype, (size_t)255) < 0)
goto error;

/* Create the data space */
if ((space = H5Screate_simple(2, size, NULL)) < 0)
Expand Down
Loading