summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/lib/h5diff_array.c188
1 files changed, 119 insertions, 69 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index a348ca0..c5646ed 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -119,7 +119,7 @@ static int not_comparable;
is_zero=1; \
}
-# define PDIFF(a,b) ( (b>a) ? (b-a) : (a-b))
+#define PDIFF(a,b) ( (b>a) ? (b-a) : (a-b))
/*-------------------------------------------------------------------------
* local prototypes
@@ -127,11 +127,12 @@ static int not_comparable;
*/
static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id,hid_t region1_id, hid_t region2_id, diff_opt_t *options);
static hbool_t all_zero(const void *_mem, size_t size);
-static int ull2float(unsigned long_long ull_value, float *f_value);
static hsize_t character_compare(unsigned char *mem1,unsigned char *mem2,hsize_t i,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph);
static hsize_t character_compare_opt(unsigned char *mem1,unsigned char *mem2,hsize_t i,int rank,hsize_t *dims,hsize_t *acc,hsize_t *pos,diff_opt_t *options,const char *obj1,const char *obj2,int *ph);
static hbool_t equal_float(float value, float expected);
static hbool_t equal_double(double value, double expected);
+static int ull2float(unsigned long_long ull_value, float *f_value);
+
/*-------------------------------------------------------------------------
* NaN detection
@@ -691,7 +692,6 @@ hsize_t diff_datum(void *_mem1,
H5Tclose(memb_type);
}
break;
-
/*-------------------------------------------------------------------------
@@ -2861,7 +2861,6 @@ hsize_t diff_float(unsigned char *mem1,
}
-
/*-------------------------------------------------------------------------
* Function: diff_double
*
@@ -2891,80 +2890,111 @@ hsize_t diff_double(unsigned char *mem1,
hsize_t i;
double per;
int both_zero;
+ int isnan1;
+ int isnan2;
-
- /* -d and !-p */
+
+ /*-------------------------------------------------------------------------
+ * -d and !-p
+ *-------------------------------------------------------------------------
+ */
+
if (options->d && !options->p)
{
-
for ( i = 0; i < nelmts; i++)
{
memcpy(&temp1_double, mem1, sizeof(double));
memcpy(&temp2_double, mem2, sizeof(double));
-
- if (ABS(temp1_double-temp2_double) > options->delta)
- {
- if ( print_data(options) )
+
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
+ isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
+
+ if ( !isnan1 && !isnan2)
+ {
+ if (ABS(temp1_double-temp2_double) > options->delta)
{
- print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
+ if ( print_data(options) )
+ {
+ print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double));
+ }
+ nfound++;
}
- nfound++;
- }
+ } /* NaN */
mem1+=sizeof(double);
mem2+=sizeof(double);
if (options->n && nfound>=options->count)
return nfound;
- }
+ } /* i */
}
-
- /* !-d and -p */
+
+ /*-------------------------------------------------------------------------
+ * !-d and -p
+ *-------------------------------------------------------------------------
+ */
else if (!options->d && options->p)
{
-
for ( i = 0; i < nelmts; i++)
{
memcpy(&temp1_double, mem1, sizeof(double));
memcpy(&temp2_double, mem2, sizeof(double));
- PER(temp1_double,temp2_double);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
- }
- options->not_cmp=1;
- nfound++;
- }
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
+ isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
- else
+ if ( !isnan1 && !isnan2)
+ {
- if ( per > options->percent )
+ PER(temp1_double,temp2_double);
+
+ if (not_comparable && !both_zero) /* not comparable */
{
if ( print_data(options) )
{
print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double),
- ABS(1-temp2_double/temp1_double));
+ parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
+ ABS(temp1_double-temp2_double));
}
+ options->not_cmp=1;
nfound++;
}
- mem1+=sizeof(double);
- mem2+=sizeof(double);
- if (options->n && nfound>=options->count)
- return nfound;
- }
+
+ else
+
+ if ( per > options->percent )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT_P,temp1_double,temp2_double,
+ ABS(temp1_double-temp2_double),
+ ABS(1-temp2_double/temp1_double));
+ }
+ nfound++;
+ }
+ } /* NaN */
+ mem1+=sizeof(double);
+ mem2+=sizeof(double);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* i */
}
- /* -d and -p */
+ /*-------------------------------------------------------------------------
+ * -d and -p
+ *-------------------------------------------------------------------------
+ */
else if ( options->d && options->p)
{
@@ -2973,41 +3003,58 @@ hsize_t diff_double(unsigned char *mem1,
memcpy(&temp1_double, mem1, sizeof(double));
memcpy(&temp2_double, mem2, sizeof(double));
- PER(temp1_double,temp2_double);
-
- if (not_comparable && !both_zero) /* not comparable */
- {
- if ( print_data(options) )
- {
- print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
- parallel_print(SPACES);
- parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double));
- }
- options->not_cmp=1;
- nfound++;
- }
+ /*-------------------------------------------------------------------------
+ * detect NaNs
+ *-------------------------------------------------------------------------
+ */
+ isnan1 = my_isnan(FLT_DOUBLE,&temp1_double);
+ isnan2 = my_isnan(FLT_DOUBLE,&temp2_double);
- else
+ if ( !isnan1 && !isnan2)
+ {
+
+ PER(temp1_double,temp2_double);
- if ( per > options->percent && ABS(temp1_double-temp2_double) > options->delta )
+ if (not_comparable && !both_zero) /* not comparable */
{
if ( print_data(options) )
{
print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
parallel_print(SPACES);
- parallel_print(F_FORMAT_P,temp1_double,temp2_double,
- ABS(temp1_double-temp2_double),
- ABS(1-temp2_double/temp1_double));
+ parallel_print(F_FORMAT_P_NOTCOMP,temp1_double,temp2_double,
+ ABS(temp1_double-temp2_double));
}
+ options->not_cmp=1;
nfound++;
}
- mem1+=sizeof(double);
- mem2+=sizeof(double);
- if (options->n && nfound>=options->count)
- return nfound;
- }
+
+ else
+
+ if ( per > options->percent && ABS(temp1_double-temp2_double) > options->delta )
+ {
+ if ( print_data(options) )
+ {
+ print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2);
+ parallel_print(SPACES);
+ parallel_print(F_FORMAT_P,temp1_double,temp2_double,
+ ABS(temp1_double-temp2_double),
+ ABS(1-temp2_double/temp1_double));
+ }
+ nfound++;
+ }
+
+ } /* NaN */
+ mem1+=sizeof(double);
+ mem2+=sizeof(double);
+ if (options->n && nfound>=options->count)
+ return nfound;
+ } /* i */
}
+
+ /*-------------------------------------------------------------------------
+ * no -d and -p
+ *-------------------------------------------------------------------------
+ */
else
{
@@ -3038,6 +3085,9 @@ hsize_t diff_double(unsigned char *mem1,
return nfound;
}
+
+
+
/*-------------------------------------------------------------------------
* Function: diff_schar
*