diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2009-04-18 21:19:56 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2009-04-18 21:19:56 (GMT) |
commit | f38ae770ca0942ec1c7edfa91650f04118ec0627 (patch) | |
tree | 537ed038c5511373763d08f389ed41ba1a9c7539 /tools/lib | |
parent | cbd195409d3e0292fcf59291ed23f9c09e7074b6 (diff) | |
download | hdf5-f38ae770ca0942ec1c7edfa91650f04118ec0627.zip hdf5-f38ae770ca0942ec1c7edfa91650f04118ec0627.tar.gz hdf5-f38ae770ca0942ec1c7edfa91650f04118ec0627.tar.bz2 |
[svn-r16786] merge 16785
added missing test and compare cases inside compounds for nan
tested: linux
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5diff_array.c | 655 |
1 files changed, 483 insertions, 172 deletions
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index c1b3f0e..2cda3ba 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -274,12 +274,10 @@ hsize_t diff_array( void *_mem1, nfound=diff_float(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph); else if (H5Tequal(m_type, H5T_NATIVE_DOUBLE)) nfound=diff_double(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph); - #if H5_SIZEOF_LONG_DOUBLE !=0 else if (H5Tequal(m_type, H5T_NATIVE_LDOUBLE)) nfound=diff_ldouble(mem1,mem2,nelmts,hyper_start,rank,dims,acc,pos,options,name1,name2,&ph); -#endif - +#endif break; case H5T_INTEGER: @@ -1843,7 +1841,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_FLOAT,&temp2_float); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { if (ABS(temp1_float-temp2_float) > options->delta) @@ -1857,7 +1856,19 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } /* NaN */ + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); + } + nfound++; + + } } /*------------------------------------------------------------------------- * !-d and -p @@ -1876,7 +1887,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_FLOAT,&temp2_float); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { PER(temp1_float,temp2_float); @@ -1907,7 +1919,19 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } /* NaN */ + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); + } + nfound++; + + } } /*------------------------------------------------------------------------- @@ -1928,7 +1952,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_FLOAT,&temp2_float); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { PER(temp1_float,temp2_float); @@ -1960,7 +1985,19 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } /* NaN */ + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_float,temp2_float,ABS(temp1_float-temp2_float)); + } + nfound++; + + } } /*------------------------------------------------------------------------- @@ -1992,7 +2029,6 @@ hsize_t diff_datum(void *_mem1, int isnan1=0; int isnan2=0; - assert(type_size==sizeof(double)); memcpy(&temp1_double, mem1, sizeof(double)); @@ -2017,7 +2053,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_DOUBLE,&temp2_double); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { if (ABS(temp1_double-temp2_double) > options->delta) @@ -2031,8 +2068,20 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } /* NaN */ - } + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + } + nfound++; + + } + } /* options->d && !options->p */ /*------------------------------------------------------------------------- * !-d and -p @@ -2051,7 +2100,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_DOUBLE,&temp2_double); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { PER(temp1_double,temp2_double); @@ -2083,7 +2133,19 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } /* NaN */ + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + } + nfound++; + + } } /*------------------------------------------------------------------------- @@ -2103,7 +2165,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_DOUBLE,&temp2_double); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { PER(temp1_double,temp2_double); @@ -2136,7 +2199,19 @@ hsize_t diff_datum(void *_mem1, nfound++; } - } /* NaN */ + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + if ( print_data(options) ) + { + print_pos(ph,0,i,acc,pos,rank,dims,obj1,obj2); + parallel_print(SPACES); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + } + nfound++; + + } } /*------------------------------------------------------------------------- @@ -2195,7 +2270,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { if (ABS(temp1_double-temp2_double) > options->delta) @@ -2229,7 +2305,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { PER(temp1_double,temp2_double); @@ -2281,7 +2358,8 @@ hsize_t diff_datum(void *_mem1, isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { PER(temp1_double,temp2_double); @@ -2792,7 +2870,8 @@ hsize_t diff_float(unsigned char *mem1, isnan2 = my_isnan(FLT_FLOAT,&temp2_float); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { if (ABS(temp1_float-temp2_float) > options->delta) { @@ -2804,7 +2883,19 @@ hsize_t diff_float(unsigned char *mem1, } nfound++; } - } /* NaN */ + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + 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_float,temp2_float,ABS(temp1_float-temp2_float)); + } + nfound++; + + } mem1+=sizeof(float); mem2+=sizeof(float); if (options->n && nfound>=options->count) @@ -2832,8 +2923,8 @@ hsize_t diff_float(unsigned char *mem1, isnan1 = my_isnan(FLT_FLOAT,&temp1_float); isnan2 = my_isnan(FLT_FLOAT,&temp2_float); } - - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { PER(temp1_float,temp2_float); @@ -2864,7 +2955,19 @@ hsize_t diff_float(unsigned char *mem1, } nfound++; } - } /* NaN */ + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + 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_float,temp2_float,ABS(temp1_float-temp2_float)); + } + nfound++; + + } mem1+=sizeof(float); mem2+=sizeof(float); if (options->n && nfound>=options->count) @@ -2894,7 +2997,8 @@ hsize_t diff_float(unsigned char *mem1, isnan2 = my_isnan(FLT_FLOAT,&temp2_float); } - if ( !isnan1 && !isnan2) + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) { PER(temp1_float,temp2_float); @@ -2926,7 +3030,19 @@ hsize_t diff_float(unsigned char *mem1, nfound++; } - } /* NaN */ + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + 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_float,temp2_float,ABS(temp1_float-temp2_float)); + } + nfound++; + + } mem1+=sizeof(float); mem2+=sizeof(float); if (options->n && nfound>=options->count) @@ -2977,7 +3093,6 @@ hsize_t diff_float(unsigned char *mem1, } - /*------------------------------------------------------------------------- * Function: diff_double * @@ -2988,17 +3103,17 @@ hsize_t diff_float(unsigned char *mem1, *------------------------------------------------------------------------- */ hsize_t diff_double(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph) + unsigned char *mem2, + hsize_t nelmts, + hsize_t hyper_start, + int rank, + hsize_t *dims, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph) { hsize_t nfound=0; /* number of differences found */ @@ -3007,18 +3122,48 @@ hsize_t diff_double(unsigned char *mem1, hsize_t i; double per; int both_zero; + int isnan1=0; + int isnan2=0; - /* -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) + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if ( options->do_nans ) + { + isnan1 = my_isnan(FLT_DOUBLE,&temp1_double); + isnan2 = my_isnan(FLT_DOUBLE,&temp2_double); + } + + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) + { + if (ABS(temp1_double-temp2_double) > options->delta) + { + 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++; + } + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) { if ( print_data(options) ) { @@ -3027,59 +3172,91 @@ hsize_t diff_double(unsigned char *mem1, parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); } nfound++; + } 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 */ + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if ( options->do_nans ) { - 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)); - } - nfound++; + isnan1 = my_isnan(FLT_DOUBLE,&temp1_double); + isnan2 = my_isnan(FLT_DOUBLE,&temp2_double); } + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) + { - else + PER(temp1_double,temp2_double); - if ( per > options->percent ) + 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)); } 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++; + } + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + 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++; + + } + 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) { @@ -3088,48 +3265,84 @@ 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 */ + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if ( options->do_nans ) { - 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)); - } - nfound++; + isnan1 = my_isnan(FLT_DOUBLE,&temp1_double); + isnan2 = my_isnan(FLT_DOUBLE,&temp2_double); } - else + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) + { + + 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)); } 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++; + } + + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + 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++; + + } + mem1+=sizeof(double); + mem2+=sizeof(double); + if (options->n && nfound>=options->count) + return nfound; + } /* i */ } + + /*------------------------------------------------------------------------- + * no -d and -p + *------------------------------------------------------------------------- + */ else { + + for ( i = 0; i < nelmts; i++) { memcpy(&temp1_double, mem1, sizeof(double)); memcpy(&temp2_double, mem2, sizeof(double)); + if (equal_double(temp1_double,temp2_double,options)==FALSE) { if ( print_data(options) ) @@ -3145,14 +3358,22 @@ hsize_t diff_double(unsigned char *mem1, mem2+=sizeof(double); if (options->n && nfound>=options->count) return nfound; + } /* nelmts */ + + + + } return nfound; } + + + /*------------------------------------------------------------------------- * Function: diff_ldouble * @@ -3163,19 +3384,19 @@ hsize_t diff_double(unsigned char *mem1, *------------------------------------------------------------------------- */ #if H5_SIZEOF_LONG_DOUBLE !=0 - + hsize_t diff_ldouble(unsigned char *mem1, - unsigned char *mem2, - hsize_t nelmts, - hsize_t hyper_start, - int rank, - hsize_t *dims, - hsize_t *acc, - hsize_t *pos, - diff_opt_t *options, - const char *obj1, - const char *obj2, - int *ph) + unsigned char *mem2, + hsize_t nelmts, + hsize_t hyper_start, + int rank, + hsize_t *dims, + hsize_t *acc, + hsize_t *pos, + diff_opt_t *options, + const char *obj1, + const char *obj2, + int *ph) { hsize_t nfound=0; /* number of differences found */ @@ -3184,79 +3405,141 @@ hsize_t diff_ldouble(unsigned char *mem1, hsize_t i; double per; int both_zero; + int isnan1=0; + int isnan2=0; - /* -d and !-p */ + /*------------------------------------------------------------------------- + * -d and !-p + *------------------------------------------------------------------------- + */ + if (options->d && !options->p) { - for ( i = 0; i < nelmts; i++) { memcpy(&temp1_double, mem1, sizeof(long double)); memcpy(&temp2_double, mem2, sizeof(long double)); - if (ABS(temp1_double-temp2_double) > options->delta) + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if ( options->do_nans ) + { + isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double); + isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double); + } + + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) + { + if (ABS(temp1_double-temp2_double) > options->delta) + { + 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++; + } + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) { if ( print_data(options) ) { print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2); parallel_print(SPACES); - parallel_print(LD_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); } nfound++; + } mem1+=sizeof(long double); mem2+=sizeof(long 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(long double)); memcpy(&temp2_double, mem2, sizeof(long double)); - PER(temp1_double,temp2_double); - - if (not_comparable && !both_zero) /* not comparable */ + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if ( options->do_nans ) { - if ( print_data(options) ) - { - print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(LD_FORMAT_P_NOTCOMP,temp1_double,temp2_double, - ABS(temp1_double-temp2_double)); - } - nfound++; + isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double); + isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double); } + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) + { - else + PER(temp1_double,temp2_double); - if ( per > options->percent ) + 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(LD_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)); } nfound++; } - mem1+=sizeof(long double); - mem2+=sizeof(long 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++; + } + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + 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++; + + } + mem1+=sizeof(long double); + mem2+=sizeof(long double); + if (options->n && nfound>=options->count) + return nfound; + } /* i */ } - /* -d and -p */ + /*------------------------------------------------------------------------- + * -d and -p + *------------------------------------------------------------------------- + */ else if ( options->d && options->p) { @@ -3265,55 +3548,91 @@ hsize_t diff_ldouble(unsigned char *mem1, memcpy(&temp1_double, mem1, sizeof(long double)); memcpy(&temp2_double, mem2, sizeof(long double)); - PER(temp1_double,temp2_double); - - if (not_comparable && !both_zero) /* not comparable */ + /*------------------------------------------------------------------------- + * detect NaNs + *------------------------------------------------------------------------- + */ + if ( options->do_nans ) { - if ( print_data(options) ) - { - print_pos(ph,1,hyper_start+i,acc,pos,rank,dims,obj1,obj2); - parallel_print(SPACES); - parallel_print(LD_FORMAT_P_NOTCOMP,temp1_double,temp2_double, - ABS(temp1_double-temp2_double)); - } - nfound++; + isnan1 = my_isnan(FLT_LDOUBLE,&temp1_double); + isnan2 = my_isnan(FLT_LDOUBLE,&temp2_double); } - else + /* both not NaN, do the comparison */ + if ( isnan1==0 && isnan2==0) + { + + 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(LD_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)); } nfound++; } - mem1+=sizeof(long double); - mem2+=sizeof(long 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++; + } + + } + /* one is NaN, assume difference */ + else if ( isnan1==1 || isnan2==1) + { + 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++; + + } + mem1+=sizeof(long double); + mem2+=sizeof(long double); + if (options->n && nfound>=options->count) + return nfound; + } /* i */ } + + /*------------------------------------------------------------------------- + * no -d and -p + *------------------------------------------------------------------------- + */ else { + + for ( i = 0; i < nelmts; i++) { memcpy(&temp1_double, mem1, sizeof(long double)); memcpy(&temp2_double, mem2, sizeof(long double)); + if (equal_ldouble(temp1_double,temp2_double,options)==FALSE) { if ( print_data(options) ) { print_pos(ph,0,hyper_start+i,acc,pos,rank,dims,obj1,obj2); parallel_print(SPACES); - parallel_print(LD_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); + parallel_print(F_FORMAT,temp1_double,temp2_double,ABS(temp1_double-temp2_double)); } nfound++; } @@ -3322,15 +3641,24 @@ hsize_t diff_ldouble(unsigned char *mem1, mem2+=sizeof(long double); if (options->n && nfound>=options->count) return nfound; + } /* nelmts */ + + + + } return nfound; } - #endif /* H5_SIZEOF_LONG_DOUBLE */ + + + + + /*------------------------------------------------------------------------- * Function: diff_schar * @@ -5209,12 +5537,7 @@ hbool_t equal_double(double value, double expected, diff_opt_t *options) if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) ) { return FALSE; - } - - /*------------------------------------------------------------------------- - * both are not NaNs, compare - *------------------------------------------------------------------------- - */ + } } BOTH_ZERO(value,expected) @@ -5275,13 +5598,7 @@ hbool_t equal_ldouble(long double value, long double expected, diff_opt_t *optio if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) ) { return FALSE; - } - - /*------------------------------------------------------------------------- - * both are not NaNs, compare - *------------------------------------------------------------------------- - */ - + } } BOTH_ZERO(value,expected) @@ -5345,13 +5662,7 @@ hbool_t equal_float(float value, float expected, diff_opt_t *options) if ( (isnan1 && !isnan2) || ( !isnan1 && isnan2 ) ) { return FALSE; - } - - /*------------------------------------------------------------------------- - * both are not NaNs, compare - *------------------------------------------------------------------------- - */ - + } } BOTH_ZERO(value,expected) |