diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/h5diff/h5diff_main.c | 13 | ||||
-rwxr-xr-x | tools/h5diff/testh5diff.sh | 5 | ||||
-rwxr-xr-x | tools/h5diff/testph5diff.sh | 1 | ||||
-rw-r--r-- | tools/lib/h5diff.c | 453 | ||||
-rw-r--r-- | tools/lib/h5diff_attr.c | 518 | ||||
-rw-r--r-- | tools/lib/h5diff_util.c | 12 | ||||
-rw-r--r-- | tools/lib/ph5diff.h | 2 |
7 files changed, 533 insertions, 471 deletions
diff --git a/tools/h5diff/h5diff_main.c b/tools/h5diff/h5diff_main.c index 4a15f78..5c15d16 100644 --- a/tools/h5diff/h5diff_main.c +++ b/tools/h5diff/h5diff_main.c @@ -55,6 +55,8 @@ static void ph5diff_worker( void ); *------------------------------------------------------------------------- */ + int nID = 0; + int main(int argc, const char *argv[]) { int i; @@ -64,7 +66,6 @@ int main(int argc, const char *argv[]) const char *objname1 = NULL; const char *objname2 = NULL; hsize_t nfound=0; - int nID = 0; int ret; diff_opt_t options; @@ -91,7 +92,7 @@ int main(int argc, const char *argv[]) MPI_Comm_rank(MPI_COMM_WORLD, &nID); MPI_Comm_size(MPI_COMM_WORLD, &g_nTasks); #else - printf("You cannot run ph5diff unless you compiles a parallel build of HDF5\n"); + printf("You cannot run ph5diff unless you compile a parallel build of HDF5\n"); h5diff_exit(2); #endif } @@ -263,7 +264,10 @@ int main(int argc, const char *argv[]) else { if (!options.err_stat) + { print_found(nfound); + print_manager_output(); + } } } @@ -365,6 +369,7 @@ ph5diff_worker(void) /*When get token, print stuff out and return token */ printf("%s", outBuff); + fflush(stdout); memset(outBuff, 0, OUTBUFF_SIZE); outBuffOffset = 0; @@ -377,7 +382,7 @@ ph5diff_worker(void) else if(Status.MPI_TAG == MPI_TAG_END) { MPI_Recv(NULL, 0, MPI_BYTE, 0, MPI_TAG_END, MPI_COMM_WORLD, &Status); - /*printf("exiting..., task: %d\n", nID);*/ + /* printf("exiting..., task: %d\n", nID); */ break; } else @@ -388,6 +393,7 @@ ph5diff_worker(void) } } + MPI_Barrier(MPI_COMM_WORLD); MPI_Finalize(); } @@ -546,6 +552,7 @@ void usage(void) */ void h5diff_exit(int status) { + #ifdef H5_HAVE_PARALLEL /* if in parallel mode, dismiss workers, close down MPI, then exit */ if(g_nTasks > 1){ diff --git a/tools/h5diff/testh5diff.sh b/tools/h5diff/testh5diff.sh index 437210c..52879c5 100755 --- a/tools/h5diff/testh5diff.sh +++ b/tools/h5diff/testh5diff.sh @@ -80,11 +80,16 @@ TOOLTEST() { actual="../testfiles/`basename $1 .txt`.out" actual_err="../testfiles/`basename $1 .txt`.err" shift +#echo $pmode if test -n "$pmode"; then RUNCMD=$RUNPARALLEL + sleep 2 else RUNCMD=$RUNSERIAL fi +# set -x +# echo RUNCMD=$RUNCMD +# $RUNCMD /bin/true # Run test. # Tflops interprets "$@" as "" when no parameter is given (e.g., the diff --git a/tools/h5diff/testph5diff.sh b/tools/h5diff/testph5diff.sh index 947b53b..85baea7 100755 --- a/tools/h5diff/testph5diff.sh +++ b/tools/h5diff/testph5diff.sh @@ -13,7 +13,6 @@ ## access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. ## - # The build (current) directory might be different than the source directory. if test -z "$srcdir"; then srcdir=. diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index bfeb35b..a157818 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -33,6 +33,55 @@ print_objname (diff_opt_t * options, hsize_t nfound) return ((options->m_verbose || nfound) && !options->m_quiet) ? 1 : 0; } +#ifdef H5_HAVE_PARALLEL +/*------------------------------------------------------------------------- + * Function: phdiff_dismiss_workers + * + * Purpose: tell all workers to end. + * + * Return: none + * + * Programmer: Albert Cheng + * + * Date: Feb 6, 2005 + * + *------------------------------------------------------------------------- + */ +void phdiff_dismiss_workers(void) +{ + int i; + + for(i=1; i<g_nTasks; i++) + MPI_Send(NULL, 0, MPI_BYTE, i, MPI_TAG_END, MPI_COMM_WORLD); +} + +/*------------------------------------------------------------------------- + * Function: print_manager_output + * + * Purpose: special function that prints any output accumulated by the + * manager task. + * + * Return: none + * + * Programmer: Leon Arber + * + * Date: Feb 7, 2005 + * + *------------------------------------------------------------------------- + */ +void print_manager_output(void) +{ + /* If there was something we buffered, let's print it now */ + if(outBuffOffset>0) + { + printf("%s", outBuff); + fflush(stdout); + memset(outBuff, 0, OUTBUFF_SIZE); + outBuffOffset = 0; + } +} + +#endif /*------------------------------------------------------------------------- * Function: h5diff @@ -93,8 +142,7 @@ h5diff (const char *fname1, if(g_Parallel) { /* Let tasks know that they won't be needed */ - for(i=1; i<g_nTasks; i++) - MPI_Send(filenames, 1024*2, MPI_CHAR, i, MPI_TAG_END, MPI_COMM_WORLD); + phdiff_dismiss_workers(); } #endif @@ -109,8 +157,7 @@ h5diff (const char *fname1, if(g_Parallel) { /* Let tasks know that they won't be needed */ - for(i=1; i<g_nTasks; i++) - MPI_Send(filenames, 1024*2, MPI_CHAR, i, MPI_TAG_END, MPI_COMM_WORLD); + phdiff_dismiss_workers(); } #endif @@ -132,6 +179,13 @@ h5diff (const char *fname1, { printf ("Error: Could not get get file contents\n"); options->err_stat = 1; +#ifdef H5_HAVE_PARALLEL + if(g_Parallel) + { + /* Let tasks know that they won't be needed */ + phdiff_dismiss_workers(); + } +#endif goto out; } @@ -153,6 +207,13 @@ h5diff (const char *fname1, h5trav_freeinfo (info1, nobjects1); if (info2) h5trav_freeinfo (info2, nobjects1); +#ifdef H5_HAVE_PARALLEL + if(g_Parallel) + { + /* Let tasks know that they won't be needed */ + phdiff_dismiss_workers(); + } +#endif goto out; } @@ -180,6 +241,10 @@ h5diff (const char *fname1, nfound = diff_compare (file1_id, fname1, objname1, nobjects1, info1, file2_id, fname2, objname2, nobjects2, info2, options); +#ifdef H5_HAVE_PARALLEL + /* If there was something we buffered, let's print it now */ + print_manager_output(); +#endif } /*------------------------------------------------------------------------- @@ -593,6 +658,10 @@ diff_match (hid_t file1_id, /* the manager can do this. */ nfound += diff (file1_id, "/", file2_id, "/", options, H5G_GROUP); +#ifdef H5_HAVE_PARALLEL + /* If there was something we buffered, let's print it now */ + print_manager_output(); +#endif return nfound; } @@ -694,225 +763,201 @@ diff (hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_opt_t * options, H5G_obj_t type) { - hid_t type1_id=(-1); - hid_t type2_id=(-1); - hid_t grp1_id=(-1); - hid_t grp2_id=(-1); - int ret; - H5G_stat_t sb1; - H5G_stat_t sb2; - char *buf1 = NULL; - char *buf2 = NULL; - hsize_t nfound = 0; + hid_t type1_id=(-1); + hid_t type2_id=(-1); + hid_t grp1_id=(-1); + hid_t grp2_id=(-1); + int ret; + H5G_stat_t sb1; + H5G_stat_t sb2; + char *buf1 = NULL; + char *buf2 = NULL; + hsize_t nfound = 0; - switch (type) + switch (type) { -/*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ - case H5G_DATASET: - - /* always print name */ - if (options->m_verbose) - { - if (print_objname (options, (hsize_t)1)) - parallel_print("Dataset: <%s> and <%s>\n", path1, path2); - nfound = diff_dataset (file1_id, file2_id, path1, path2, options); + /*------------------------------------------------------------------------- + * H5G_DATASET + *------------------------------------------------------------------------- + */ + case H5G_DATASET: + + /* always print name */ + if (options->m_verbose) + { + if (print_objname (options, (hsize_t)1)) + parallel_print("Dataset: <%s> and <%s>\n", path1, path2); + nfound = diff_dataset (file1_id, file2_id, path1, path2, options); - } - /* check first if we have differences */ - else - { - if (options->m_quiet == 0) + } + /* check first if we have differences */ + else { - /* shut up temporarily */ - options->m_quiet = 1; - nfound = - diff_dataset (file1_id, file2_id, path1, path2, options); - /* print again */ - options->m_quiet = 0; - if (nfound) + if (options->m_quiet == 0) + { + /* shut up temporarily */ + options->m_quiet = 1; + nfound = + diff_dataset (file1_id, file2_id, path1, path2, options); + /* print again */ + options->m_quiet = 0; + if (nfound) + { + if (print_objname (options, nfound)) + parallel_print("Dataset: <%s> and <%s>\n", path1, path2); + nfound = diff_dataset (file1_id, file2_id, path1, path2, options); + } /*if */ + } /*if */ + /* in quiet mode, just count differences */ + else { - if (print_objname (options, nfound)) - parallel_print("Dataset: <%s> and <%s>\n", path1, path2); - nfound = - diff_dataset (file1_id, file2_id, path1, path2, options); - } /*if */ - } /*if */ - /* in quiet mode, just count differences */ - else + nfound = diff_dataset (file1_id, file2_id, path1, path2, options); + } + } /*else */ + + break; + + /*------------------------------------------------------------------------- + * H5G_TYPE + *------------------------------------------------------------------------- + */ + case H5G_TYPE: + if ((type1_id = H5Topen (file1_id, path1)) < 0) + goto out; + if ((type2_id = H5Topen (file2_id, path2)) < 0) + goto out; + + if ((ret = H5Tequal (type1_id, type2_id)) < 0) + goto out; + + /* if H5Tequal is > 0 then the datatypes refer to the same datatype */ + nfound = (ret > 0) ? 0 : 1; + + if (print_objname (options, nfound)) + parallel_print("Datatype: <%s> and <%s>\n", path1, path2); + + /*------------------------------------------------------------------------- + * compare attributes + * the if condition refers to cases when the dataset is a referenced object + *------------------------------------------------------------------------- + */ + if (path1) + diff_attr (type1_id, type2_id, path1, path2, options); + + if (H5Tclose (type1_id) < 0) + goto out; + if (H5Tclose (type2_id) < 0) + goto out; + + break; + + /*------------------------------------------------------------------------- + * H5G_GROUP + *------------------------------------------------------------------------- + */ + case H5G_GROUP: + if ((grp1_id = H5Gopen (file1_id, path1)) < 0) + goto out; + if ((grp2_id = H5Gopen (file2_id, path2)) < 0) + goto out; + + ret = HDstrcmp (path1, path2); + + /* if "path1" != "path2" then the groups are "different" */ + nfound = (ret != 0) ? 1 : 0; + + if (print_objname (options, nfound)) + parallel_print("Group: <%s> and <%s>\n", path1, path2); + + /*------------------------------------------------------------------------- + * compare attributes + * the if condition refers to cases when the dataset is a referenced object + *------------------------------------------------------------------------- + */ + if (path1) + diff_attr (grp1_id, grp2_id, path1, path2, options); + + if (H5Gclose (grp1_id) < 0) + goto out; + if (H5Gclose (grp2_id) < 0) + goto out; + + break; + + + /*------------------------------------------------------------------------- + * H5G_LINK + *------------------------------------------------------------------------- + */ + case H5G_LINK: + if (H5Gget_objinfo (file1_id, path1, FALSE, &sb1) < 0) + goto out; + if (H5Gget_objinfo (file1_id, path1, FALSE, &sb2) < 0) + goto out; + + buf1 = malloc (sb1.linklen); + buf2 = malloc (sb2.linklen); + + if (H5Gget_linkval (file1_id, path1, sb1.linklen, buf1) < 0) + goto out; + if (H5Gget_linkval (file2_id, path2, sb1.linklen, buf2) < 0) + goto out; + + ret = HDstrcmp (buf1, buf2); + + /* if "buf1" != "buf2" then the links are "different" */ + nfound = (ret != 0) ? 1 : 0; + + if (print_objname (options, nfound)) + parallel_print("Link: <%s> and <%s>\n", path1, path2); + + if (buf1) { - nfound = - diff_dataset (file1_id, file2_id, path1, path2, options); + free (buf1); + buf1 = NULL; } - } /*else */ - - break; - -/*------------------------------------------------------------------------- - * H5G_TYPE - *------------------------------------------------------------------------- - */ - case H5G_TYPE: - if ((type1_id = H5Topen (file1_id, path1)) < 0) - goto out; - if ((type2_id = H5Topen (file2_id, path2)) < 0) - goto out; - - if ((ret = H5Tequal (type1_id, type2_id)) < 0) - goto out; - - /* if H5Tequal is > 0 then the datatypes refer to the same datatype */ - nfound = (ret > 0) ? 0 : 1; - - if (print_objname (options, nfound)) - parallel_print("Datatype: <%s> and <%s>\n", path1, path2); - -/*------------------------------------------------------------------------- - * compare attributes - * the if condition refers to cases when the dataset is a referenced object - *------------------------------------------------------------------------- - */ - if (path1) - diff_attr (type1_id, type2_id, path1, path2, options); - - if (H5Tclose (type1_id) < 0) - goto out; - if (H5Tclose (type2_id) < 0) - goto out; - - break; -/*------------------------------------------------------------------------- - * H5G_GROUP - *------------------------------------------------------------------------- - */ - case H5G_GROUP: - if ((grp1_id = H5Gopen (file1_id, path1)) < 0) - goto out; - if ((grp2_id = H5Gopen (file2_id, path2)) < 0) - goto out; - - ret = HDstrcmp (path1, path2); - - /* if "path1" != "path2" then the groups are "different" */ - nfound = (ret != 0) ? 1 : 0; - - if (print_objname (options, nfound)) - parallel_print("Group: <%s> and <%s>\n", path1, path2); - - /*------------------------------------------------------------------------- - * compare attributes - * the if condition refers to cases when the dataset is a referenced object - *------------------------------------------------------------------------- - */ - if (path1) - diff_attr (grp1_id, grp2_id, path1, path2, options); - - if (H5Gclose (grp1_id) < 0) - goto out; - if (H5Gclose (grp2_id) < 0) - goto out; - - break; - - -/*------------------------------------------------------------------------- - * H5G_LINK - *------------------------------------------------------------------------- - */ - case H5G_LINK: - if (H5Gget_objinfo (file1_id, path1, FALSE, &sb1) < 0) - goto out; - if (H5Gget_objinfo (file1_id, path1, FALSE, &sb2) < 0) - goto out; - - buf1 = malloc (sb1.linklen); - buf2 = malloc (sb2.linklen); - - if (H5Gget_linkval (file1_id, path1, sb1.linklen, buf1) < 0) - goto out; - if (H5Gget_linkval (file2_id, path2, sb1.linklen, buf2) < 0) - goto out; - - ret = HDstrcmp (buf1, buf2); - - /* if "buf1" != "buf2" then the links are "different" */ - nfound = (ret != 0) ? 1 : 0; - - if (print_objname (options, nfound)) - parallel_print("Link: <%s> and <%s>\n", path1, path2); - - if (buf1) - { - free (buf1); - buf1 = NULL; - } + if (buf2) + { + free (buf2); + buf2 = NULL; + } - if (buf2) - { - free (buf2); - buf2 = NULL; - } + break; - break; + default: + nfound = 0; + if (options->m_verbose) + { + parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n", + path1, path2, get_type (type)); + } - default: - nfound = 0; - if (options->m_verbose) - { - parallel_print("Comparison not supported: <%s> and <%s> are of type %s\n", - path1, path2, get_type (type)); - } - - break; + break; } out: - /* close */ - /* disable error reporting */ - H5E_BEGIN_TRY - { - H5Tclose (type1_id); - H5Tclose (type2_id); - H5Gclose (grp1_id); - H5Tclose (grp2_id); - /* enable error reporting */ - } - H5E_END_TRY; + /* close */ + /* disable error reporting */ + H5E_BEGIN_TRY + { + H5Tclose (type1_id); + H5Tclose (type2_id); + H5Gclose (grp1_id); + H5Tclose (grp2_id); + /* enable error reporting */ + } + H5E_END_TRY; - if (buf1) - free (buf1); - if (buf2) - free (buf2); + if (buf1) + free (buf1); + if (buf2) + free (buf2); - return nfound; + return nfound; } -#ifdef H5_HAVE_PARALLEL -/*------------------------------------------------------------------------- - * Function: phdiff_dismiss_workers - * - * Purpose: tell all workers to end. - * - * Return: none - * - * Programmer: Albert Cheng - * - * Date: Feb 6, 2005 - * - *------------------------------------------------------------------------- - */ -void phdiff_dismiss_workers(void) -{ - int i; - - for(i=1; i<g_nTasks; i++) - MPI_Send(NULL, 0, MPI_BYTE, i, MPI_TAG_END, MPI_COMM_WORLD); -} -#endif diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c index d1f18df..24ade01 100644 --- a/tools/lib/h5diff_attr.c +++ b/tools/lib/h5diff_attr.c @@ -38,276 +38,276 @@ */ int diff_attr(hid_t loc1_id, - hid_t loc2_id, - const char *path1, - const char *path2, - diff_opt_t *options - ) + hid_t loc2_id, + const char *path1, + const char *path2, + diff_opt_t *options + ) { - hid_t attr1_id=-1; /* attr ID */ - hid_t attr2_id=-1; /* attr ID */ - hid_t space1_id=-1; /* space ID */ - hid_t space2_id=-1; /* space ID */ - hid_t ftype1_id=-1; /* file data type ID */ - hid_t ftype2_id=-1; /* file data type ID */ - hid_t mtype1_id=-1; /* memory data type ID */ - hid_t mtype2_id=-1; /* memory data type ID */ - size_t msize1; /* memory size of memory type */ - size_t msize2; /* memory size of memory type */ - void *buf1=NULL; /* data buffer */ - void *buf2=NULL; /* data buffer */ - hsize_t nelmts1; /* number of elements in dataset */ - int rank1; /* rank of dataset */ - int rank2; /* rank of dataset */ - hsize_t dims1[H5S_MAX_RANK];/* dimensions of dataset */ - hsize_t dims2[H5S_MAX_RANK];/* dimensions of dataset */ - char name1[255]; - char name2[255]; - int n1, n2, i, j; - int ret=0; - hsize_t nfound; - int cmp=1; - - if ((n1 = H5Aget_num_attrs(loc1_id))<0) - goto error; - if ((n2 = H5Aget_num_attrs(loc2_id))<0) - goto error; - - if (n1!=n2) - return 1; - - for ( i = 0; i < n1; i++) - { - - /* reset buffers for every attribute, we might goto out and call free */ - buf1=NULL; - buf2=NULL; + hid_t attr1_id=-1; /* attr ID */ + hid_t attr2_id=-1; /* attr ID */ + hid_t space1_id=-1; /* space ID */ + hid_t space2_id=-1; /* space ID */ + hid_t ftype1_id=-1; /* file data type ID */ + hid_t ftype2_id=-1; /* file data type ID */ + hid_t mtype1_id=-1; /* memory data type ID */ + hid_t mtype2_id=-1; /* memory data type ID */ + size_t msize1; /* memory size of memory type */ + size_t msize2; /* memory size of memory type */ + void *buf1=NULL; /* data buffer */ + void *buf2=NULL; /* data buffer */ + hsize_t nelmts1; /* number of elements in dataset */ + int rank1; /* rank of dataset */ + int rank2; /* rank of dataset */ + hsize_t dims1[H5S_MAX_RANK];/* dimensions of dataset */ + hsize_t dims2[H5S_MAX_RANK];/* dimensions of dataset */ + char name1[255]; + char name2[255]; + int n1, n2, i, j; + int ret=0; + hsize_t nfound; + int cmp=1; -/*------------------------------------------------------------------------- - * open - *------------------------------------------------------------------------- - */ - /* open attribute */ - if ((attr1_id = H5Aopen_idx(loc1_id, (unsigned)i))<0) - goto error; - if ((attr2_id = H5Aopen_idx(loc2_id, (unsigned)i))<0) - goto error; - - /* get name */ - if (H5Aget_name( attr1_id, 255, name1 )<0) - goto error; - if (H5Aget_name( attr2_id, 255, name2 )<0) - goto error; - - if (HDstrcmp(name1,name2)!=0) - { - if (options->m_verbose) - { - parallel_print("Different name for attributes: <%s> and <%s>\n", name1, name2); - } - H5Aclose(attr1_id); - H5Aclose(attr2_id); - ret=1; - continue; - } - - /* get the file datatype */ - if ((ftype1_id = H5Aget_type( attr1_id )) < 0 ) - goto error; - if ((ftype2_id = H5Aget_type( attr2_id )) < 0 ) - goto error; - - /* get the dataspace handle */ - if ((space1_id = H5Aget_space( attr1_id )) < 0 ) - goto error; - if ((space2_id = H5Aget_space( attr2_id )) < 0 ) - goto error; - - /* get dimensions */ - if ( (rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0 ) - goto error; - if ( (rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0 ) - goto error; + if ((n1 = H5Aget_num_attrs(loc1_id))<0) + goto error; + if ((n2 = H5Aget_num_attrs(loc2_id))<0) + goto error; + if (n1!=n2) + return 1; -/*------------------------------------------------------------------------- - * check for comparable TYPE and SPACE - *------------------------------------------------------------------------- - */ + for ( i = 0; i < n1; i++) + { - if (diff_can_type(ftype1_id, - ftype2_id, - rank1, - rank2, - dims1, - dims2, - NULL, - NULL, - name1, - name2, - options)!=1) - cmp=0; -/*------------------------------------------------------------------------- - * only attempt to compare if possible - *------------------------------------------------------------------------- - */ - if (cmp) - { - -/*------------------------------------------------------------------------- - * read to memory - *------------------------------------------------------------------------- - */ - nelmts1=1; - for (j=0; j<rank1; j++) - nelmts1*=dims1[j]; - - if ((mtype1_id=h5tools_get_native_type(ftype1_id))<0) - goto error; - - if ((mtype2_id=h5tools_get_native_type(ftype2_id))<0) - goto error; - - if ((msize1=H5Tget_size(mtype1_id))==0) - goto error; - if ((msize2=H5Tget_size(mtype2_id))==0) - goto error; - - assert(msize1==msize2); - - buf1=(void *) HDmalloc((unsigned)(nelmts1*msize1)); - buf2=(void *) HDmalloc((unsigned)(nelmts1*msize2)); - if ( buf1==NULL || buf2==NULL){ - parallel_print( "cannot read into memory\n" ); - goto error; - } - if (H5Aread(attr1_id,mtype1_id,buf1)<0) - goto error; - if (H5Aread(attr2_id,mtype2_id,buf2)<0) - goto error; - - -/*------------------------------------------------------------------------- - * array compare - *------------------------------------------------------------------------- - */ - sprintf(name1,"%s of <%s>",name1,path1); - sprintf(name2,"%s of <%s>",name2,path2); - - /* always print name */ - if (options->m_verbose) - { - parallel_print( "Attribute: <%s> and <%s>\n",name1,name2); - nfound = diff_array(buf1, - buf2, - nelmts1, - rank1, - dims1, - options, - name1, - name2, - mtype1_id, - attr1_id, - attr2_id); - print_found(nfound); - - } - /* check first if we have differences */ - else - { - if (options->m_quiet==0) - { - /* shut up temporarily */ - options->m_quiet=1; - nfound = diff_array(buf1, - buf2, - nelmts1, - rank1, - dims1, - options, - name1, - name2, - mtype1_id, - attr1_id, - attr2_id); - /* print again */ - options->m_quiet=0; - if (nfound) - { - parallel_print( "Attribute: <%s> and <%s>\n",name1,name2); - nfound = diff_array(buf1, - buf2, - nelmts1, - rank1, - dims1, - options, - name1, - name2, - mtype1_id, - attr1_id, - attr2_id); - print_found(nfound); - } /*if*/ - } /*if*/ - /* in quiet mode, just count differences */ - else - { - nfound = diff_array(buf1, - buf2, - nelmts1, - rank1, - dims1, - options, - name1, - name2, - mtype1_id, - attr1_id, - attr2_id); - } /*else quiet */ - } /*else verbose */ - }/*cmp*/ + /* reset buffers for every attribute, we might goto out and call free */ + buf1=NULL; + buf2=NULL; + /*------------------------------------------------------------------------- + * open + *------------------------------------------------------------------------- + */ + /* open attribute */ + if ((attr1_id = H5Aopen_idx(loc1_id, (unsigned)i))<0) + goto error; + if ((attr2_id = H5Aopen_idx(loc2_id, (unsigned)i))<0) + goto error; + /* get name */ + if (H5Aget_name( attr1_id, 255, name1 )<0) + goto error; + if (H5Aget_name( attr2_id, 255, name2 )<0) + goto error; -/*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ + if (HDstrcmp(name1,name2)!=0) + { + if (options->m_verbose) + { + parallel_print("Different name for attributes: <%s> and <%s>\n", name1, name2); + } + H5Aclose(attr1_id); + H5Aclose(attr2_id); + ret=1; + continue; + } + + /* get the file datatype */ + if ((ftype1_id = H5Aget_type( attr1_id )) < 0 ) + goto error; + if ((ftype2_id = H5Aget_type( attr2_id )) < 0 ) + goto error; + + /* get the dataspace handle */ + if ((space1_id = H5Aget_space( attr1_id )) < 0 ) + goto error; + if ((space2_id = H5Aget_space( attr2_id )) < 0 ) + goto error; - if (H5Tclose(ftype1_id)<0) goto error; - if (H5Tclose(ftype2_id)<0) goto error; - if (H5Tclose(mtype1_id)<0) goto error; - if (H5Tclose(mtype2_id)<0) goto error; - if (H5Sclose(space1_id)<0) goto error; - if (H5Sclose(space2_id)<0) goto error; - if (H5Aclose(attr1_id)<0) goto error; - if (H5Aclose(attr2_id)<0) goto error; - if (buf1) - HDfree(buf1); - if (buf2) - HDfree(buf2); - } /* i */ - - return ret; + /* get dimensions */ + if ( (rank1 = H5Sget_simple_extent_dims(space1_id, dims1, NULL)) < 0 ) + goto error; + if ( (rank2 = H5Sget_simple_extent_dims(space2_id, dims2, NULL)) < 0 ) + goto error; + + + /*------------------------------------------------------------------------- + * check for comparable TYPE and SPACE + *------------------------------------------------------------------------- + */ + + if (diff_can_type(ftype1_id, + ftype2_id, + rank1, + rank2, + dims1, + dims2, + NULL, + NULL, + name1, + name2, + options)!=1) + cmp=0; + /*------------------------------------------------------------------------- + * only attempt to compare if possible + *------------------------------------------------------------------------- + */ + if (cmp) + { + + /*------------------------------------------------------------------------- + * read to memory + *------------------------------------------------------------------------- + */ + nelmts1=1; + for (j=0; j<rank1; j++) + nelmts1*=dims1[j]; + + if ((mtype1_id=h5tools_get_native_type(ftype1_id))<0) + goto error; + + if ((mtype2_id=h5tools_get_native_type(ftype2_id))<0) + goto error; + + if ((msize1=H5Tget_size(mtype1_id))==0) + goto error; + if ((msize2=H5Tget_size(mtype2_id))==0) + goto error; + + assert(msize1==msize2); + + buf1=(void *) HDmalloc((unsigned)(nelmts1*msize1)); + buf2=(void *) HDmalloc((unsigned)(nelmts1*msize2)); + if ( buf1==NULL || buf2==NULL){ + parallel_print( "cannot read into memory\n" ); + goto error; + } + if (H5Aread(attr1_id,mtype1_id,buf1)<0) + goto error; + if (H5Aread(attr2_id,mtype2_id,buf2)<0) + goto error; + + + /*------------------------------------------------------------------------- + * array compare + *------------------------------------------------------------------------- + */ + sprintf(name1,"%s of <%s>",name1,path1); + sprintf(name2,"%s of <%s>",name2,path2); + + /* always print name */ + if (options->m_verbose) + { + parallel_print( "Attribute: <%s> and <%s>\n",name1,name2); + nfound = diff_array(buf1, + buf2, + nelmts1, + rank1, + dims1, + options, + name1, + name2, + mtype1_id, + attr1_id, + attr2_id); + print_found(nfound); + + } + /* check first if we have differences */ + else + { + if (options->m_quiet==0) + { + /* shut up temporarily */ + options->m_quiet=1; + nfound = diff_array(buf1, + buf2, + nelmts1, + rank1, + dims1, + options, + name1, + name2, + mtype1_id, + attr1_id, + attr2_id); + /* print again */ + options->m_quiet=0; + if (nfound) + { + parallel_print( "Attribute: <%s> and <%s>\n",name1,name2); + nfound = diff_array(buf1, + buf2, + nelmts1, + rank1, + dims1, + options, + name1, + name2, + mtype1_id, + attr1_id, + attr2_id); + print_found(nfound); + } /*if*/ + } /*if*/ + /* in quiet mode, just count differences */ + else + { + nfound = diff_array(buf1, + buf2, + nelmts1, + rank1, + dims1, + options, + name1, + name2, + mtype1_id, + attr1_id, + attr2_id); + } /*else quiet */ + } /*else verbose */ + }/*cmp*/ + + + + /*------------------------------------------------------------------------- + * close + *------------------------------------------------------------------------- + */ + + if (H5Tclose(ftype1_id)<0) goto error; + if (H5Tclose(ftype2_id)<0) goto error; + if (H5Tclose(mtype1_id)<0) goto error; + if (H5Tclose(mtype2_id)<0) goto error; + if (H5Sclose(space1_id)<0) goto error; + if (H5Sclose(space2_id)<0) goto error; + if (H5Aclose(attr1_id)<0) goto error; + if (H5Aclose(attr2_id)<0) goto error; + if (buf1) + HDfree(buf1); + if (buf2) + HDfree(buf2); + } /* i */ + + return ret; error: - H5E_BEGIN_TRY { - H5Tclose(ftype1_id); - H5Tclose(ftype2_id); - H5Tclose(mtype1_id); - H5Tclose(mtype2_id); - H5Sclose(space1_id); - H5Sclose(space2_id); - H5Aclose(attr1_id); - H5Aclose(attr2_id); - if (buf1) - HDfree(buf1); - if (buf2) - HDfree(buf2); - } H5E_END_TRY; - - options->err_stat=1; - return 0; + H5E_BEGIN_TRY { + H5Tclose(ftype1_id); + H5Tclose(ftype2_id); + H5Tclose(mtype1_id); + H5Tclose(mtype2_id); + H5Sclose(space1_id); + H5Sclose(space2_id); + H5Aclose(attr1_id); + H5Aclose(attr2_id); + if (buf1) + HDfree(buf1); + if (buf2) + HDfree(buf2); + } H5E_END_TRY; + + options->err_stat=1; + return 0; } diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c index c29b085..dfd93c8 100644 --- a/tools/lib/h5diff_util.c +++ b/tools/lib/h5diff_util.c @@ -22,6 +22,7 @@ unsigned char g_Parallel = 0; /*0 for serial, 1 for parallel */ char outBuff[OUTBUFF_SIZE]; unsigned int outBuffOffset; +extern int nID; /*------------------------------------------------------------------------- * Function: parallel_print @@ -43,8 +44,10 @@ void parallel_print(const char* format, ...) if(!g_Parallel) vprintf(format, ap); else - outBuffOffset += HDvsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, format, ap); - + { + if((OUTBUFF_SIZE-outBuffOffset) > 0) + outBuffOffset += HDvsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, format, ap); + } va_end(ap); } @@ -375,7 +378,10 @@ get_class(H5T_class_t tclass) */ void print_found(hsize_t nfound) { - HDfprintf(stdout,"%Hu differences found\n",nfound); + if(g_Parallel) + outBuffOffset += HDsnprintf(outBuff+outBuffOffset, OUTBUFF_SIZE-outBuffOffset, "%lld differences found\n", nfound); + else + HDfprintf(stdout,"%Hu differences found\n",nfound); } diff --git a/tools/lib/ph5diff.h b/tools/lib/ph5diff.h index 8a9510e..91d7050 100644 --- a/tools/lib/ph5diff.h +++ b/tools/lib/ph5diff.h @@ -16,7 +16,7 @@ #define _PH5DIFF_H__ -#define OUTBUFF_SIZE 10000 +#define OUTBUFF_SIZE 50000 /* Send from manager to workers */ #define MPI_TAG_ARGS 1 #define MPI_TAG_PRINT_TOK 2 |