From 04a2d20bba020444686642d593e1be0529113d5d Mon Sep 17 00:00:00 2001 From: kmu Date: Wed, 22 Jan 2020 12:55:01 -0600 Subject: fix float type cmp warning --- testpar/t_mdset.c | 9 +++++---- tools/lib/h5diff_array.c | 6 +++--- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/testpar/t_mdset.c b/testpar/t_mdset.c index 63ac8d3..1c561c9 100644 --- a/testpar/t_mdset.c +++ b/testpar/t_mdset.c @@ -13,6 +13,7 @@ #include "testphdf5.h" #include "H5Dprivate.h" +#include "H5private.h" #define DIM 2 #define SIZE 32 @@ -332,7 +333,7 @@ void compact_dataset(void) /* Verify data value */ for(i = 0; i < size; i++) for(j = 0; j < size; j++) - if(inme[(i * size) + j] != outme[(i * size) + j]) + if(!H5_DBL_ABS_EQUAL(inme[(i * size) + j], outme[(i * size) + j])) if(err_num++ < MAX_ERR_REPORT || VERBOSE_MED) HDprintf("Dataset Verify failed at [%d][%d]: expect %f, got %f\n", i, j, outme[(i * size) + j], inme[(i * size) + j]); @@ -2477,7 +2478,7 @@ void rr_obj_hdr_flush_confusion_reader(MPI_Comm comm) /* compare read data with expected data */ for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) - if (data_read[j] != data[j]){ + if (!H5_DBL_ABS_EQUAL(data_read[j], data[j])){ HDfprintf(stdout, "%0d:%s: Reading datasets value failed in " "Dataset %d, at position %d: expect %f, got %f.\n", @@ -2540,7 +2541,7 @@ void rr_obj_hdr_flush_confusion_reader(MPI_Comm comm) VRFY((err >= 0), "H5Aread failed.\n"); /* compare read attribute data with expected data */ for ( j = 0; j < LOCAL_DATA_SIZE; j++ ) - if (att_read[j] != att[j]){ + if (!H5_DBL_ABS_EQUAL(att_read[j], att[j])){ HDfprintf(stdout, "%0d:%s: Mismatched attribute data read in Dataset %d, at position %d: expect %f, got %f.\n", mpi_rank, fcn_name, i, j, att[j], att_read[j]); @@ -2592,7 +2593,7 @@ void rr_obj_hdr_flush_confusion_reader(MPI_Comm comm) VRFY((err >= 0), "H5Aread failed.\n"); /* compare read attribute data with expected data */ for ( j = 0; j < LARGE_ATTR_SIZE; j++ ) - if (lg_att_read[j] != lg_att[j]){ + if (!H5_DBL_ABS_EQUAL(lg_att_read[j], lg_att[j])){ HDfprintf(stdout, "%0d:%s: Mismatched large attribute data read in Dataset %d, at position %d: expect %f, got %f.\n", mpi_rank, fcn_name, i, j, lg_att[j], lg_att_read[j]); diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 8321a98..e99b2cc 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -4584,7 +4584,7 @@ static hbool_t equal_double(double value, double expected, diff_opt_t *opts) { return FALSE; } - if (value == expected) + if (H5_DBL_ABS_EQUAL(value, expected)) return TRUE; if (opts->use_system_epsilon) @@ -4628,7 +4628,7 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *opts) return FALSE; } - if (value == expected) + if (H5_DBL_ABS_EQUAL(value, expected)) return TRUE; if (opts->use_system_epsilon) @@ -4670,7 +4670,7 @@ static hbool_t equal_float(float value, float expected, diff_opt_t *opts) { return FALSE; } - if (value == expected) + if (H5_FLT_ABS_EQUAL(value, expected)) return TRUE; if (opts->use_system_epsilon) -- cgit v0.12 From 9cc63d81fb1f311e849e2d098d31e6cfd4f549b5 Mon Sep 17 00:00:00 2001 From: kmu Date: Wed, 22 Jan 2020 12:55:21 -0600 Subject: fix float type cmp warning --- tools/test/perform/pio_perf.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/test/perform/pio_perf.c b/tools/test/perform/pio_perf.c index 5977731..74855cb 100644 --- a/tools/test/perform/pio_perf.c +++ b/tools/test/perform/pio_perf.c @@ -59,6 +59,7 @@ #include #include +#include "H5private.h" #include "hdf5.h" #ifdef H5_HAVE_PARALLEL @@ -82,6 +83,7 @@ /* report 0.0 in case t is zero too */ #define MB_PER_SEC(bytes,t) (((t)==0.0) ? 0.0 : ((((double)bytes) / ONE_MB) / (t))) +#define MB_PER_SEC(bytes,t) (H5_DBL_ABS_EQUAL((t), 0.0) ? 0.0 : ((((double)bytes) / ONE_MB) / (t))) #ifndef TRUE #define TRUE 1 -- cgit v0.12 From 9afaf94bef740f89958a1a8aae369d5f607845f4 Mon Sep 17 00:00:00 2001 From: kmu Date: Wed, 22 Jan 2020 14:15:40 -0600 Subject: not use hdf5 private header --- tools/test/perform/pio_perf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/test/perform/pio_perf.c b/tools/test/perform/pio_perf.c index 74855cb..1a40f44 100644 --- a/tools/test/perform/pio_perf.c +++ b/tools/test/perform/pio_perf.c @@ -59,7 +59,6 @@ #include #include -#include "H5private.h" #include "hdf5.h" #ifdef H5_HAVE_PARALLEL @@ -81,6 +80,9 @@ #define PIO_MPI 0x2 #define PIO_HDF5 0x4 +#define DBL_EPSILON 2.2204460492503131e-16 +#define H5_DBL_ABS_EQUAL(X,Y) (fabsf((X)-(Y)) < DBL_EPSILON) + /* report 0.0 in case t is zero too */ #define MB_PER_SEC(bytes,t) (((t)==0.0) ? 0.0 : ((((double)bytes) / ONE_MB) / (t))) #define MB_PER_SEC(bytes,t) (H5_DBL_ABS_EQUAL((t), 0.0) ? 0.0 : ((((double)bytes) / ONE_MB) / (t))) -- cgit v0.12