diff options
Diffstat (limited to 'tools/lib')
-rw-r--r-- | tools/lib/h5diff.c | 1213 | ||||
-rw-r--r-- | tools/lib/h5diff.h | 293 | ||||
-rw-r--r-- | tools/lib/h5diff_array.c | 304 | ||||
-rw-r--r-- | tools/lib/h5tools.c | 252 | ||||
-rw-r--r-- | tools/lib/h5tools_ref.c | 208 | ||||
-rw-r--r-- | tools/lib/h5tools_ref.h | 11 | ||||
-rw-r--r-- | tools/lib/h5tools_str.c | 134 | ||||
-rw-r--r-- | tools/lib/h5tools_str.h | 2 | ||||
-rw-r--r-- | tools/lib/h5tools_utils.c | 73 | ||||
-rw-r--r-- | tools/lib/h5trav.c | 20 | ||||
-rw-r--r-- | tools/lib/h5trav.h | 37 | ||||
-rw-r--r-- | tools/lib/ph5diff.h | 9 |
12 files changed, 1207 insertions, 1349 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 2d7cc7d..e0174b0 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -192,15 +192,13 @@ hsize_t h5diff(const char *fname1, char filenames[2][1024]; hsize_t nfound = 0; - memset(filenames, 0, 1024*2); + HDmemset(filenames, 0, 1024 * 2); - if(options->m_quiet && - (options->m_verbose || options->m_report)) - { + if(options->m_quiet && (options->m_verbose || options->m_report)) { printf("Error: -q (quiet mode) cannot be added to verbose or report modes\n"); options->err_stat=1; return 0; - } + } /* end if */ /*------------------------------------------------------------------------- * open the files first; if they are not valid, no point in continuing @@ -208,42 +206,32 @@ hsize_t h5diff(const char *fname1, */ /* disable error reporting */ - H5E_BEGIN_TRY - { + H5E_BEGIN_TRY { /* Open the files */ - if ((file1_id = H5Fopen (fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - { - printf ("h5diff: <%s>: unable to open file\n", fname1); + if((file1_id = H5Fopen(fname1, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { + printf("h5diff: <%s>: unable to open file\n", fname1); 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; - } - if ((file2_id = H5Fopen (fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) - { - printf ("h5diff: <%s>: unable to open file\n", fname2); + } /* end if */ + if((file2_id = H5Fopen(fname2, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) { + printf("h5diff: <%s>: unable to open file\n", fname2); 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; - } + } /* end if */ /* enable error reporting */ - } - H5E_END_TRY; + } H5E_END_TRY; /*------------------------------------------------------------------------- * Initialize the info structs @@ -256,84 +244,69 @@ hsize_t h5diff(const char *fname1, * get the list of objects in the files *------------------------------------------------------------------------- */ - if(h5trav_getinfo(file1_id, info1) < 0 || h5trav_getinfo(file2_id, info2) < 0) - { + if(h5trav_getinfo(file1_id, info1) < 0 || h5trav_getinfo(file2_id, info2) < 0) { printf("Error: Could not 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; - } + } /* end if */ /*------------------------------------------------------------------------- * object name was supplied *------------------------------------------------------------------------- */ - - if (objname1) - { - + if(objname1) { #ifdef H5_HAVE_PARALLEL if(g_Parallel) - { /* Let tasks know that they won't be needed */ phdiff_dismiss_workers(); - } #endif - assert (objname2); + assert(objname2); options->cmn_objs = 1; /* eliminate warning */ - nfound = diff_compare (file1_id, fname1, objname1, info1, - file2_id, fname2, objname2, info2, - options); - } + nfound = diff_compare(file1_id, fname1, objname1, info1, + file2_id, fname2, objname2, info2, + options); + } /* end if */ /*------------------------------------------------------------------------- * compare all *------------------------------------------------------------------------- */ - else - { - + else { #ifdef H5_HAVE_PARALLEL - if(g_Parallel) - { + if(g_Parallel) { int i; - if((HDstrlen(fname1) > 1024) || (HDstrlen(fname2) > 1024)) - { + if((HDstrlen(fname1) > 1024) || (HDstrlen(fname2) > 1024)) { fprintf(stderr, "The parallel diff only supports path names up to 1024 characters\n"); MPI_Abort(MPI_COMM_WORLD, 0); - } + } /* end if */ HDstrcpy(filenames[0], fname1); HDstrcpy(filenames[1], fname2); /* Alert the worker tasks that there's going to be work. */ - for(i = 1; i < g_nTasks; i++) - MPI_Send(filenames, 1024 * 2, MPI_CHAR, i, MPI_TAG_PARALLEL, MPI_COMM_WORLD); - } + MPI_Send(filenames, (1024 * 2), MPI_CHAR, i, MPI_TAG_PARALLEL, MPI_COMM_WORLD); + } /* end if */ #endif nfound = diff_match(file1_id, info1, file2_id, info2, options); - } + } /* end else */ trav_info_free(info1); trav_info_free(info2); out: /* close */ - H5E_BEGIN_TRY - { + H5E_BEGIN_TRY { H5Fclose(file1_id); H5Fclose(file2_id); - } - H5E_END_TRY; + } H5E_END_TRY; return nfound; } @@ -358,411 +331,360 @@ out: * *------------------------------------------------------------------------- */ -hsize_t diff_match (hid_t file1_id, +hsize_t diff_match(hid_t file1_id, trav_info_t * info1, hid_t file2_id, trav_info_t * info2, diff_opt_t * options) { - int more_names_exist = (info1->nused > 0 && info2->nused > 0) ? 1 : 0; - trav_table_t *table = NULL; - int cmp; - size_t curr1 = 0; - size_t curr2 = 0; - unsigned infile[2]; - char c1, c2; - hsize_t nfound = 0; - unsigned i; - -/*------------------------------------------------------------------------- - * build the list - *------------------------------------------------------------------------- - */ - trav_table_init (&table); - - while (more_names_exist) - { - /* criteria is string compare */ - cmp = HDstrcmp(info1->paths[curr1].path, info2->paths[curr2].path); - if (cmp == 0) - { - infile[0] = 1; - infile[1] = 1; - trav_table_addflags (infile, info1->paths[curr1].path, info1->paths[curr1].type, - table); - - curr1++; - curr2++; - } - else if (cmp < 0) - { - infile[0] = 1; - infile[1] = 0; - trav_table_addflags (infile, info1->paths[curr1].path, info1->paths[curr1].type, - table); - curr1++; - } - else - { - infile[0] = 0; - infile[1] = 1; - trav_table_addflags (infile, info2->paths[curr2].path, info2->paths[curr2].type, - table); - curr2++; - } - - more_names_exist = (curr1 < info1->nused && curr2 < info2->nused) ? 1 : 0; - - } /* end while */ - - /* list1 did not end */ - if (curr1 < info1->nused) - { - while (curr1 < info1->nused) - { - infile[0] = 1; - infile[1] = 0; - trav_table_addflags (infile, info1->paths[curr1].path, info1->paths[curr1].type, - table); - curr1++; - } - } + trav_table_t *table = NULL; + size_t curr1, curr2; + unsigned infile[2]; + hsize_t nfound = 0; + unsigned i; - /* list2 did not end */ - if (curr2 < info2->nused) - { - while (curr2 < info2->nused) - { - infile[0] = 0; - infile[1] = 1; - trav_table_addflags (infile, info2->paths[curr2].path, info2->paths[curr2].type, - table); - curr2++; - } - } + /*------------------------------------------------------------------------- + * build the list + *------------------------------------------------------------------------- + */ + trav_table_init(&table); + + curr1 = 0; + curr2 = 0; + while(curr1 < info1->nused && curr2 < info2->nused) { + /* criteria is string compare */ + int cmp = HDstrcmp(info1->paths[curr1].path, info2->paths[curr2].path); + + if(cmp == 0) { + infile[0] = 1; + infile[1] = 1; + trav_table_addflags(infile, info1->paths[curr1].path, info1->paths[curr1].type, table); + + curr1++; + curr2++; + } /* end if */ + else if(cmp < 0) { + infile[0] = 1; + infile[1] = 0; + trav_table_addflags(infile, info1->paths[curr1].path, info1->paths[curr1].type, table); + curr1++; + } /* end else-if */ + else { + infile[0] = 0; + infile[1] = 1; + trav_table_addflags(infile, info2->paths[curr2].path, info2->paths[curr2].type, table); + curr2++; + } /* end else */ + } /* end while */ + + /* list1 did not end */ + infile[0] = 1; + infile[1] = 0; + while(curr1 < info1->nused) { + trav_table_addflags(infile, info1->paths[curr1].path, info1->paths[curr1].type, table); + curr1++; + } /* end while */ + + /* list2 did not end */ + infile[0] = 0; + infile[1] = 1; + while(curr2 < info2->nused) { + trav_table_addflags(infile, info2->paths[curr2].path, info2->paths[curr2].type, table); + curr2++; + } /* end while */ -/*------------------------------------------------------------------------- - * print the list - *------------------------------------------------------------------------- - */ + /*------------------------------------------------------------------------- + * print the list + *------------------------------------------------------------------------- + */ + if(options->m_verbose) { + printf("\n"); + printf("file1 file2\n"); + printf("---------------------------------------\n"); + for(i = 0; i < table->nobjs; i++) { + char c1, c2; - if (options->m_verbose) - { - printf ("\n"); - printf ("file1 file2\n"); - printf ("---------------------------------------\n"); - for (i = 0; i < table->nobjs; i++) - { - c1 = (table->objs[i].flags[0]) ? 'x' : ' '; - c2 = (table->objs[i].flags[1]) ? 'x' : ' '; - printf ("%5c %6c %-15s\n", c1, c2, table->objs[i].name); - } - printf ("\n"); - } + c1 = (table->objs[i].flags[0]) ? 'x' : ' '; + c2 = (table->objs[i].flags[1]) ? 'x' : ' '; + printf("%5c %6c %-15s\n", c1, c2, table->objs[i].name); + } /* end for */ + printf ("\n"); + } /* end if */ -/*------------------------------------------------------------------------- - * do the diff for common objects - *------------------------------------------------------------------------- - */ - { + /*------------------------------------------------------------------------- + * do the diff for common objects + *------------------------------------------------------------------------- + */ #ifdef H5_HAVE_PARALLEL - char* workerTasks = malloc((g_nTasks-1) * sizeof(char)); - int n; - int busyTasks=0; - struct diffs_found nFoundbyWorker; - struct diff_args args; - int havePrintToken = 1; - MPI_Status Status; - - /*set all tasks as free */ - memset(workerTasks, 1, g_nTasks-1); +{ + char *workerTasks = HDmalloc((g_nTasks - 1) * sizeof(char)); + int n; + int busyTasks = 0; + struct diffs_found nFoundbyWorker; + struct diff_args args; + int havePrintToken = 1; + MPI_Status Status; + + /*set all tasks as free */ + HDmemset(workerTasks, 1, (g_nTasks - 1)); #endif - for (i = 0; i < table->nobjs; i++) - { - if (table->objs[i].flags[0] && table->objs[i].flags[1]) - { + for(i = 0; i < table->nobjs; i++) { + if(table->objs[i].flags[0] && table->objs[i].flags[1]) { + options->cmn_objs = 1; + if(!g_Parallel) { + nfound += diff(file1_id, + table->objs[i].name, + file2_id, + table->objs[i].name, options, table->objs[i].type); + } /* end if */ #ifdef H5_HAVE_PARALLEL - int workerFound = 0; + else { + int workerFound = 0; + + h5diffdebug("beginning of big else block\n"); + /* We're in parallel mode */ + /* Since the data type of diff value is hsize_t which can + * be arbitary large such that there is no MPI type that + * matches it, the value is passed between processes as + * an array of bytes in order to be portable. But this + * may not work in non-homogeneous MPI environments. + */ + + /*Set up args to pass to worker task. */ + if(strlen(table->objs[i].name) > 255) { + printf("The parallel diff only supports object names up to 255 characters\n"); + MPI_Abort(MPI_COMM_WORLD, 0); + } /* end if */ + + HDstrcpy(args.name, table->objs[i].name); + args.options = *options; + args.type= table->objs[i].type; + + h5diffdebug2("busyTasks=%d\n", busyTasks); + /* if there are any outstanding print requests, let's handle one. */ + if(busyTasks > 0) { + int incomingMessage; + + /* check if any tasks freed up, and didn't need to print. */ + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &incomingMessage, &Status); + + /* first block*/ + if(incomingMessage) { + workerTasks[Status.MPI_SOURCE - 1] = 1; + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + busyTasks--; + } /* end if */ + + /* check to see if the print token was returned. */ + if(!havePrintToken) { + /* If we don't have the token, someone is probably sending us output */ + print_incoming_data(); + + /* check incoming queue for token */ + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); + + /* incoming token implies free task. */ + if(incomingMessage) { + workerTasks[Status.MPI_SOURCE - 1] = 1; + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + busyTasks--; + havePrintToken = 1; + } /* end if */ + } /* end if */ + + /* check to see if anyone needs the print token. */ + if(havePrintToken) { + /* check incoming queue for print token requests */ + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &incomingMessage, &Status); + if(incomingMessage) { + MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); + MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); + havePrintToken = 0; + } /* end if */ + } /* end if */ + } /* end if */ + + /* check array of tasks to see which ones are free. + * Manager task never does work, so freeTasks[0] is really + * worker task 0. */ + for(n = 1; (n < g_nTasks) && !workerFound; n++) { + if(workerTasks[n-1]) { + /* send file id's and names to first free worker */ + MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, n, MPI_TAG_ARGS, MPI_COMM_WORLD); + + /* increment counter for total number of prints. */ + busyTasks++; + + /* mark worker as busy */ + workerTasks[n - 1] = 0; + workerFound = 1; + } /* end if */ + } /* end for */ + + h5diffdebug2("workerfound is %d \n", workerFound); + if(!workerFound) { + /* if they were all busy, we've got to wait for one free up + * before we can move on. If we don't have the token, some + * task is currently printing so we'll wait for that task to + * return it. + */ + + if(!havePrintToken) { + while(!havePrintToken) { + int incomingMessage; + + print_incoming_data(); + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); + if(incomingMessage) { + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + havePrintToken = 1; + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + /* send this task the work unit. */ + MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); + } /* end if */ + } /* end while */ + } /* end if */ + /* if we do have the token, check for task to free up, or wait for a task to request it */ + else { + /* But first print all the data in our incoming queue */ + print_incoming_data(); + MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); + if(Status.MPI_TAG == MPI_TAG_DONE) { + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); + } /* end if */ + else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) { + int incomingMessage; + + MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); + MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); + + do { + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); + + print_incoming_data(); + } while(!incomingMessage); + + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); + } /* end else-if */ + else { + printf("ERROR: Invalid tag (%d) received \n", Status.MPI_TAG); + MPI_Abort(MPI_COMM_WORLD, 0); + MPI_Finalize(); + } /* end else */ + } /* end else */ + } /* end if */ + } /* end else */ #endif /* H5_HAVE_PARALLEL */ - options->cmn_objs = 1; - if(!g_Parallel) - { - nfound += diff (file1_id, - table->objs[i].name, - file2_id, - table->objs[i].name, options, table->objs[i].type); - } -#ifdef H5_HAVE_PARALLEL - else - { - h5diffdebug("beginning of big else block\n"); - /* We're in parallel mode */ - /* Since the data type of diff value is hsize_t which can - * be arbitary large such that there is no MPI type that - * matches it, the value is passed between processes as - * an array of bytes in order to be portable. But this - * may not work in non-homogeneous MPI environments. - */ - - /*Set up args to pass to worker task. */ - if(strlen(table->objs[i].name) > 255) - { - printf("The parallel diff only supports object names up to 255 characters\n"); - MPI_Abort(MPI_COMM_WORLD, 0); - } - - strcpy(args.name, table->objs[i].name); - args.options = *options; - args.type= table->objs[i].type; - - h5diffdebug2("busyTasks=%d\n", busyTasks); - /* if there are any outstanding print requests, let's handle one. */ - if(busyTasks > 0) - { - int incomingMessage; - /* check if any tasks freed up, and didn't need to print. */ - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &incomingMessage, &Status); - - /* first block*/ - if(incomingMessage) - { - workerTasks[Status.MPI_SOURCE-1] = 1; - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - } - - /* check to see if the print token was returned. */ - if(!havePrintToken) - { - /* If we don't have the token, someone is probably sending us output */ - print_incoming_data(); - - /* check incoming queue for token */ - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); - - /* incoming token implies free task. */ - if(incomingMessage) - { - workerTasks[Status.MPI_SOURCE-1] = 1; - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - havePrintToken = 1; - } - } - - /* check to see if anyone needs the print token. */ - if(havePrintToken) - { - /* check incoming queue for print token requests */ - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &incomingMessage, &Status); - if(incomingMessage) - { - MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); - MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); - havePrintToken = 0; - } - } - } - - /* check array of tasks to see which ones are free. - * Manager task never does work, so freeTasks[0] is really - * worker task 0. */ + } /* end if */ + } /* end for */ + h5diffdebug("done with for loop\n"); - for(n=1; (n<g_nTasks) && !workerFound; n++) - { - if(workerTasks[n-1]) - { - /* send file id's and names to first free worker */ - MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, n, MPI_TAG_ARGS, MPI_COMM_WORLD); - - /* increment counter for total number of prints. */ - busyTasks++; +#ifdef H5_HAVE_PARALLEL + if(g_Parallel) { + /* make sure all tasks are done */ + while(busyTasks > 0) { + MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); + if(Status.MPI_TAG == MPI_TAG_DONE) { + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + busyTasks--; + } /* end if */ + else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN) { + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + busyTasks--; + havePrintToken = 1; + } /* end else-if */ + else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) { + MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); + if(havePrintToken) { + int incomingMessage; + + MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); + + do { + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); + + print_incoming_data(); + } while(!incomingMessage); + + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + busyTasks--; + } /* end if */ + /* someone else must have it...wait for them to return it, then give it to the task that just asked for it. */ + else { + int source = Status.MPI_SOURCE; + int incomingMessage; + + do { + MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); + + print_incoming_data(); + } while(!incomingMessage); + + + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + busyTasks--; + MPI_Send(NULL, 0, MPI_BYTE, source, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); + } /* end else */ + } /* end else-if */ + else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN) { + MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); + nfound += nFoundbyWorker.nfound; + options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; + busyTasks--; + havePrintToken = 1; + } /* end else-if */ + else if(Status.MPI_TAG == MPI_TAG_PRINT_DATA) + { + char data[PRINT_DATA_MAX_SIZE + 1]; + HDmemset(data, 0, PRINT_DATA_MAX_SIZE + 1); - /* mark worker as busy */ - workerTasks[n-1] = 0; - workerFound = 1; - } - - } + MPI_Recv(data, PRINT_DATA_MAX_SIZE, MPI_CHAR, Status.MPI_SOURCE, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD, &Status); + printf("%s", data); + } /* end else-if */ + else { + printf("ph5diff-manager: ERROR!! Invalid tag (%d) received \n", Status.MPI_TAG); + MPI_Abort(MPI_COMM_WORLD, 0); + } /* end else */ + } /* end while */ - h5diffdebug2("workerfound is %d \n", workerFound); - if(!workerFound) - { - /* if they were all busy, we've got to wait for one free up before we can move on. - * if we don't have the token, some task is currently printing so we'll wait for that task to return it. */ + for(i = 1; i < g_nTasks; i++) + MPI_Send(NULL, 0, MPI_BYTE, i, MPI_TAG_END, MPI_COMM_WORLD); - if(!havePrintToken) - { - while(!havePrintToken) { - int incomingMessage; + /* Print any final data waiting in our queue */ print_incoming_data(); - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); - if(incomingMessage) - { - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); - havePrintToken = 1; - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - /* send this task the work unit. */ - MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); - } - } - } - /* if we do have the token, check for task to free up, or wait for a task to request it */ - else - { - /* But first print all the data in our incoming queue */ - print_incoming_data(); - MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); - if(Status.MPI_TAG == MPI_TAG_DONE) - { - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); - } - else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) - { - int incomingMessage; - MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); - MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); - - do - { - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); - - print_incoming_data(); - } - while(!incomingMessage); - - - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); - } - else - { - printf("ERROR: Invalid tag (%d) received \n", Status.MPI_TAG); - MPI_Abort(MPI_COMM_WORLD, 0); - MPI_Finalize(); - } - } - } - } -#endif /* H5_HAVE_PARALLEL */ - } - } - h5diffdebug("done with for loop\n"); - -#ifdef H5_HAVE_PARALLEL - if(g_Parallel) - { - while(busyTasks > 0) /* make sure all tasks are done */ - { - MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); - if(Status.MPI_TAG == MPI_TAG_DONE) - { - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - } - else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN) - { - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - havePrintToken = 1; - } - else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) - { - MPI_Recv(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD, &Status); - if(havePrintToken) - { - int incomingMessage; - MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); - do - { - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); - - print_incoming_data(); - } - while(!incomingMessage); - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - } - else /* someone else must have it...wait for them to return it, then give it to the task that just asked for it. */ - { - int source = Status.MPI_SOURCE; - int incomingMessage; - do - { - MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); - - print_incoming_data(); - } - while(!incomingMessage); - - - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - MPI_Send(NULL, 0, MPI_BYTE, source, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); - } - } - else if(Status.MPI_TAG == MPI_TAG_TOK_RETURN) - { - MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); - nfound += nFoundbyWorker.nfound; - options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - busyTasks--; - havePrintToken = 1; - } - else if(Status.MPI_TAG == MPI_TAG_PRINT_DATA) - { - char data[PRINT_DATA_MAX_SIZE+1]; - memset(data, 0, PRINT_DATA_MAX_SIZE+1); - - MPI_Recv(data, PRINT_DATA_MAX_SIZE, MPI_CHAR, Status.MPI_SOURCE, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD, &Status); - - printf("%s", data); - } - else - { - printf("ph5diff-manager: ERROR!! Invalid tag (%d) received \n", Status.MPI_TAG); - MPI_Abort(MPI_COMM_WORLD, 0); - } - } - - for(i=1; i<g_nTasks; i++) - MPI_Send(NULL, 0, MPI_BYTE, i, MPI_TAG_END, MPI_COMM_WORLD); - - /* Print any final data waiting in our queue */ - print_incoming_data(); + } /* end if */ + h5diffdebug("done with if block\n"); - } - h5diffdebug("done with if block\n"); - - free(workerTasks); + free(workerTasks); +} #endif /* H5_HAVE_PARALLEL */ - } - /* free table */ - trav_table_free (table); + /* free table */ + trav_table_free(table); - return nfound; + return nfound; } @@ -856,173 +778,157 @@ hsize_t diff_compare (hid_t file1_id, *------------------------------------------------------------------------- */ -hsize_t diff (hid_t file1_id, +hsize_t diff(hid_t file1_id, const char *path1, hid_t file2_id, const char *path2, diff_opt_t * options, - H5G_obj_t1 type) + h5trav_type_t type) { - hid_t type1_id=(-1); - hid_t type2_id=(-1); - hid_t grp1_id=(-1); - hid_t grp2_id=(-1); + 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; hsize_t nfound = 0; - switch (type) - { - - /*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ - case H5G_DATASET: - + switch(type) { /*------------------------------------------------------------------------- - * verbose, always print name + * H5TRAV_TYPE_DATASET *------------------------------------------------------------------------- */ - if (options->m_verbose) - { - if (print_objname(options,(hsize_t)1)) - do_print_objname ("dataset", path1, path2); - nfound=diff_dataset(file1_id,file2_id,path1,path2,options); - print_found(nfound); + case H5TRAV_TYPE_DATASET: + /*------------------------------------------------------------------------- + * verbose, always print name + *------------------------------------------------------------------------- + */ + if(options->m_verbose) { + if(print_objname(options, (hsize_t)1)) + do_print_objname("dataset", path1, path2); + nfound = diff_dataset(file1_id, file2_id, path1, path2, options); + print_found(nfound); + } /* end if */ + /*------------------------------------------------------------------------- + * non verbose, check first if we have differences by enabling quiet mode + * so that printing is off, and compare again if differences found, + * disabling quite mode + *------------------------------------------------------------------------- + */ + else { + 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)) + do_print_objname("dataset", path1, path2); + nfound = diff_dataset(file1_id, file2_id, path1, path2, options); + print_found(nfound); + } /* end if */ + } /* end if */ + /* in quiet mode, just count differences */ + else + nfound = diff_dataset(file1_id, file2_id, path1, path2, options); + } /* end else */ + break; - } /*------------------------------------------------------------------------- - * non verbose, check first if we have differences by enabling quiet mode - * so that printing is off, and compare again if differences found, - * disabling quite mode + * H5TRAV_TYPE_NAMED_DATATYPE *------------------------------------------------------------------------- */ - else - { - 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)) - do_print_objname ("dataset", path1, path2); - nfound=diff_dataset(file1_id,file2_id,path1,path2,options); - print_found(nfound); - } - } - /* in quiet mode, just count differences */ - else - { - nfound=diff_dataset(file1_id,file2_id,path1,path2,options); - } - } - - 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)) - do_print_objname ("datatype", path1, path2); - - /* always print the number of differences found in verbose mode */ - if (options->m_verbose) - print_found(nfound); - - /*------------------------------------------------------------------------- - * compare attributes - * the if condition refers to cases when the dataset is a referenced object - *------------------------------------------------------------------------- - */ - if (path1) - nfound += 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: + case H5TRAV_TYPE_NAMED_DATATYPE: + 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)) + do_print_objname("datatype", path1, path2); - ret = HDstrcmp(path1, path2); - - /* if "path1" != "path2" then the groups are "different" */ - nfound = (ret != 0) ? 1 : 0; + /* always print the number of differences found in verbose mode */ + if(options->m_verbose) + print_found(nfound); + + /*------------------------------------------------------------------------- + * compare attributes + * the if condition refers to cases when the dataset is a referenced object + *------------------------------------------------------------------------- + */ + if(path1) + nfound += diff_attr(type1_id, type2_id, path1, path2, options); + + if(H5Tclose(type1_id) < 0) + goto out; + if(H5Tclose(type2_id) < 0) + goto out; + break; + + /*------------------------------------------------------------------------- + * H5TRAV_TYPE_GROUP + *------------------------------------------------------------------------- + */ + case H5TRAV_TYPE_GROUP: + ret = HDstrcmp(path1, path2); - if(print_objname(options, nfound)) - do_print_objname("group", path1, path2); + /* if "path1" != "path2" then the groups are "different" */ + nfound = (ret != 0) ? 1 : 0; + + if(print_objname(options, nfound)) + do_print_objname("group", path1, path2); - /* always print the number of differences found in verbose mode */ - if(options->m_verbose) - print_found(nfound); - - if((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0) - goto out; - if((grp2_id = H5Gopen2(file2_id, path2, H5P_DEFAULT)) < 0) - goto out; + /* always print the number of differences found in verbose mode */ + if(options->m_verbose) + print_found(nfound); + + if((grp1_id = H5Gopen2(file1_id, path1, H5P_DEFAULT)) < 0) + goto out; + if((grp2_id = H5Gopen2(file2_id, path2, H5P_DEFAULT)) < 0) + goto out; - /*------------------------------------------------------------------------- - * compare attributes - * the if condition refers to cases when the dataset is a referenced object - *------------------------------------------------------------------------- - */ - if(path1) - nfound += 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: - { - char *buf1 = NULL; - char *buf2 = NULL; + /*------------------------------------------------------------------------- + * compare attributes + * the if condition refers to cases when the dataset is a referenced object + *------------------------------------------------------------------------- + */ + if(path1) + nfound += diff_attr(grp1_id, grp2_id, path1, path2, options); + + if(H5Gclose(grp1_id) < 0) + goto out; + if(H5Gclose(grp2_id) < 0) + goto out; + break; + - if(H5Gget_objinfo(file1_id, path1, FALSE, &sb1) < 0) + /*------------------------------------------------------------------------- + * H5TRAV_TYPE_LINK + *------------------------------------------------------------------------- + */ + case H5TRAV_TYPE_LINK: + { + H5L_info_t li1, li2; + char *buf1, *buf2; + + if(H5Lget_info(file1_id, path1, &li1, H5P_DEFAULT) < 0) goto out; - if(H5Gget_objinfo(file1_id, path1, FALSE, &sb2) < 0) + if(H5Lget_info(file1_id, path1, &li2, H5P_DEFAULT) < 0) goto out; - buf1 = HDmalloc(sb1.linklen); - buf2 = HDmalloc(sb2.linklen); + buf1 = HDmalloc(li1.u.val_size); + buf2 = HDmalloc(li2.u.val_size); - if(H5Lget_val(file1_id, path1, buf1, sb1.linklen, H5P_DEFAULT) < 0) + if(H5Lget_val(file1_id, path1, buf1, li1.u.val_size, H5P_DEFAULT) < 0) goto out; - if(H5Lget_val(file2_id, path2, buf2, sb2.linklen, H5P_DEFAULT) < 0) + if(H5Lget_val(file2_id, path2, buf2, li2.u.val_size, H5P_DEFAULT) < 0) goto out; ret = HDstrcmp(buf1, buf2); @@ -1039,19 +945,16 @@ hsize_t diff (hid_t file1_id, HDfree(buf1); HDfree(buf2); - } - break; - - /*------------------------------------------------------------------------- - * H5G_UDLINK - *------------------------------------------------------------------------- - */ - case H5G_UDLINK: - { - char *buf1 = NULL; - char *buf2 = NULL; - H5L_info_t li1; - H5L_info_t li2; + } + break; + + /*------------------------------------------------------------------------- + * H5TRAV_TYPE_UDLINK + *------------------------------------------------------------------------- + */ + case H5TRAV_TYPE_UDLINK: + { + H5L_info_t li1, li2; if(H5Lget_info(file1_id, path1, &li1, H5P_DEFAULT) < 0) goto out; @@ -1059,36 +962,36 @@ hsize_t diff (hid_t file1_id, goto out; /* Only external links will have a query function registered */ - if(li1.type == H5L_TYPE_EXTERNAL && li2.type == H5L_TYPE_EXTERNAL) - { - buf1 = HDmalloc (li1.u.val_size); - buf2 = HDmalloc (li2.u.val_size); + if(li1.type == H5L_TYPE_EXTERNAL && li2.type == H5L_TYPE_EXTERNAL) { + char *buf1, *buf2; + + buf1 = HDmalloc(li1.u.val_size); + buf2 = HDmalloc(li2.u.val_size); - if(H5Lget_val(file1_id, path1, buf1, li1.u.val_size, H5P_DEFAULT) < 0) - { - HDfree (buf1); HDfree (buf2); + if(H5Lget_val(file1_id, path1, buf1, li1.u.val_size, H5P_DEFAULT) < 0) { + HDfree(buf1); + HDfree(buf2); goto out; - } - if(H5Lget_val(file2_id, path2, buf2, li2.u.val_size, H5P_DEFAULT) < 0) - { - HDfree (buf1); HDfree (buf2); + } /* end if */ + if(H5Lget_val(file2_id, path2, buf2, li2.u.val_size, H5P_DEFAULT) < 0) { + HDfree(buf1); + HDfree(buf2); goto out; - } + } /* end if */ /* If the buffers are the same size, compare them */ - if(li1.u.val_size == li2.u.val_size) - { - if(H5Lget_val(file1_id, path1, buf1, li1.u.val_size, H5P_DEFAULT) < 0) - { - HDfree (buf1); HDfree (buf2); + if(li1.u.val_size == li2.u.val_size) { + if(H5Lget_val(file1_id, path1, buf1, li1.u.val_size, H5P_DEFAULT) < 0) { + HDfree(buf1); + HDfree(buf2); goto out; - } - if(H5Lget_val(file2_id, path2, buf2, li2.u.val_size, H5P_DEFAULT) < 0) - { - HDfree (buf1); HDfree (buf2); + } /* end if */ + if(H5Lget_val(file2_id, path2, buf2, li2.u.val_size, H5P_DEFAULT) < 0) { + HDfree(buf1); + HDfree(buf2); goto out; - } - ret = HDmemcmp (buf1, buf2, li1.u.val_size); + } /* end if */ + ret = HDmemcmp(buf1, buf2, li1.u.val_size); } else ret = 1; @@ -1096,18 +999,20 @@ hsize_t diff (hid_t file1_id, /* if "buf1" != "buf2" then the links are "different" */ nfound = (ret != 0) ? 1 : 0; - if (print_objname (options, nfound)) - do_print_objname ("external link", path1, path2); - } - else - { - /* If one or both of these links isn't an external link, we can only - * compare information from H5Lget_info since we don't have a query - * function registered for them. - * - * If the link classes or the buffer length are not the - * same, the links are "different" - */ + if(print_objname(options, nfound)) + do_print_objname("external link", path1, path2); + + HDfree(buf1); + HDfree(buf2); + } /* end if */ + else { + /* If one or both of these links isn't an external link, we can only + * compare information from H5Lget_info since we don't have a query + * function registered for them. + * + * If the link classes or the buffer length are not the + * same, the links are "different" + */ if((li1.type != li2.type) || (li1.u.val_size != li2.u.val_size)) nfound = 1; else @@ -1115,47 +1020,37 @@ hsize_t diff (hid_t file1_id, if (print_objname (options, nfound)) do_print_objname ("user defined link", path1, path2); - } + } /* end else */ /* always print the number of differences found in verbose mode */ - if (options->m_verbose) + if(options->m_verbose) print_found(nfound); + } + break; - HDfree (buf1); - HDfree (buf2); - } - break; - - default: - if (options->m_verbose) - { - printf("Comparison not supported: <%s> and <%s> are of type %s\n", - path1, path2, get_type(type) ); - } - options->not_cmp=1; - break; - } - + default: + if(options->m_verbose) + printf("Comparison not supported: <%s> and <%s> are of type %s\n", + path1, path2, get_type(type) ); + options->not_cmp = 1; + break; + } - return nfound; + return nfound; out: + options->err_stat = 1; - options->err_stat=1; - - /* 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; - - return nfound; -} + /* 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; + return nfound; +} diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h index e22502f..60e96b2 100644 --- a/tools/lib/h5diff.h +++ b/tools/lib/h5diff.h @@ -25,18 +25,18 @@ */ typedef struct { - int m_quiet; /* quiet mide: no output at all */ - int m_report; /* report mode: print the data */ - int m_verbose; /* verbose mode: print the data, list of objcets, warnings */ - int d; /* delta, absolute value to compare */ - double delta; /* delta value */ - int p; /* relative error to compare*/ - double percent; /* relative error value */ - int n; /* count, compare up to count */ - hsize_t count; /* count value */ - int err_stat; /* an error ocurred (1, error, 0, no error) */ - int cmn_objs; /* do we have comparable objects */ - int not_cmp; /* are the objects comparable */ + int m_quiet; /* quiet mide: no output at all */ + int m_report; /* report mode: print the data */ + int m_verbose; /* verbose mode: print the data, list of objcets, warnings */ + int d; /* delta, absolute value to compare */ + double delta; /* delta value */ + int p; /* relative error to compare*/ + double percent; /* relative error value */ + int n; /* count, compare up to count */ + hsize_t count; /* count value */ + int err_stat; /* an error ocurred (1, error, 0, no error) */ + int cmn_objs; /* do we have comparable objects */ + int not_cmp; /* are the objects comparable */ } diff_opt_t; @@ -89,7 +89,7 @@ hsize_t diff( hid_t file1_id, hid_t file2_id, const char *path2, diff_opt_t *options, - H5G_obj_t type ); + h5trav_type_t type ); hsize_t diff_compare( hid_t file1_id, const char *file1_name, @@ -177,161 +177,160 @@ hsize_t diff_datum(void *_mem1, hsize_t diff_float(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 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 diff_schar(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 diff_uchar(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 diff_short(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 diff_ushort(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 diff_int(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 diff_uint(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 diff_long(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 diff_ulong(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 diff_llong(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 diff_ullong(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); #endif /* H5DIFF_H__ */ + diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c index 45f46ad..f83a36d 100644 --- a/tools/lib/h5diff_array.c +++ b/tools/lib/h5diff_array.c @@ -2178,189 +2178,165 @@ hsize_t diff_region(hid_t obj1_id, diff_opt_t *options) { - hssize_t nblocks1, npoints1; - hssize_t nblocks2, npoints2; - H5G_stat_t sb1; - H5G_stat_t sb2; - hsize_t alloc_size; - hsize_t *ptdata1; - hsize_t *ptdata2; - int ndims1; - int ndims2; - int i, j; - haddr_t objno1, objno2; /* compact form of object's location */ - hsize_t nfound_b=0; /* block differences found */ - hsize_t nfound_p=0; /* point differences found */ - - ndims1 = H5Sget_simple_extent_ndims(region1_id); - ndims2 = H5Sget_simple_extent_ndims(region2_id); - - H5Gget_objinfo(obj1_id, ".", FALSE, &sb1); - H5Gget_objinfo(obj2_id, ".", FALSE, &sb2); - - objno1 = (haddr_t)sb1.objno[0] | ((haddr_t)sb1.objno[1] << (8 * sizeof(long))); - objno2 = (haddr_t)sb2.objno[0] | ((haddr_t)sb2.objno[1] << (8 * sizeof(long))); - -/* - * These two functions fail if the region does not have blocks or points, - * respectively. They do not currently know how to translate from one to - * the other. - */ - H5E_BEGIN_TRY { - nblocks1 = H5Sget_select_hyper_nblocks(region1_id); - nblocks2 = H5Sget_select_hyper_nblocks(region2_id); - - npoints1 = H5Sget_select_elem_npoints(region1_id); - npoints2 = H5Sget_select_elem_npoints(region2_id); - } H5E_END_TRY; - - if (nblocks1!=nblocks2 || npoints1!=npoints2 || ndims1!=ndims2) - { - options->not_cmp=1; - return 0; - } - -/*------------------------------------------------------------------------- - * compare block information - *------------------------------------------------------------------------- - */ - if (nblocks1 > 0) - { - - alloc_size = nblocks1 * ndims1 * 2 * sizeof(ptdata1[0]); - assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ - - ptdata1 = malloc((size_t)alloc_size); - H5_CHECK_OVERFLOW(nblocks1, hssize_t, hsize_t); - H5Sget_select_hyper_blocklist(region1_id, (hsize_t)0, (hsize_t)nblocks1, ptdata1); - - ptdata2 = malloc((size_t)alloc_size); - H5_CHECK_OVERFLOW(nblocks2, hssize_t, hsize_t); - H5Sget_select_hyper_blocklist(region2_id, (hsize_t)0, (hsize_t)nblocks2, ptdata2); - - for (i = 0; i < nblocks1; i++) - { - /* start coordinates and opposite corner */ - for (j = 0; j < ndims1; j++) - { - hsize_t start1, start2, end1, end2; - start1 = ptdata1[i * 2 * ndims1 + j]; - start2 = ptdata2[i * 2 * ndims1 + j]; - end1 = ptdata1[i * 2 * ndims1 + j + ndims1]; - end2 = ptdata2[i * 2 * ndims1 + j + ndims1]; - if (start1 != start2 || end1 != end2) - { - nfound_b++; + hssize_t nblocks1, npoints1; + hssize_t nblocks2, npoints2; + hsize_t alloc_size; + hsize_t *ptdata1; + hsize_t *ptdata2; + int ndims1; + int ndims2; + int i, j; + hsize_t nfound_b = 0; /* block differences found */ + hsize_t nfound_p = 0; /* point differences found */ + + ndims1 = H5Sget_simple_extent_ndims(region1_id); + ndims2 = H5Sget_simple_extent_ndims(region2_id); + + /* + * These two functions fail if the region does not have blocks or points, + * respectively. They do not currently know how to translate from one to + * the other. + */ + H5E_BEGIN_TRY { + nblocks1 = H5Sget_select_hyper_nblocks(region1_id); + nblocks2 = H5Sget_select_hyper_nblocks(region2_id); + + npoints1 = H5Sget_select_elem_npoints(region1_id); + npoints2 = H5Sget_select_elem_npoints(region2_id); + } H5E_END_TRY; + + if(nblocks1 != nblocks2 || npoints1 != npoints2 || ndims1 != ndims2) { + options->not_cmp = 1; + return 0; } - } - } + /*------------------------------------------------------------------------- + * compare block information + *------------------------------------------------------------------------- + */ + if(nblocks1 > 0) { + alloc_size = nblocks1 * ndims1 * 2 * sizeof(ptdata1[0]); + assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ + + ptdata1 = malloc((size_t)alloc_size); + H5_CHECK_OVERFLOW(nblocks1, hssize_t, hsize_t); + H5Sget_select_hyper_blocklist(region1_id, (hsize_t)0, (hsize_t)nblocks1, ptdata1); + + ptdata2 = malloc((size_t)alloc_size); + H5_CHECK_OVERFLOW(nblocks2, hssize_t, hsize_t); + H5Sget_select_hyper_blocklist(region2_id, (hsize_t)0, (hsize_t)nblocks2, ptdata2); + + for (i = 0; i < nblocks1; i++) { + /* start coordinates and opposite corner */ + for (j = 0; j < ndims1; j++) { + hsize_t start1, start2, end1, end2; + + start1 = ptdata1[i * 2 * ndims1 + j]; + start2 = ptdata2[i * 2 * ndims1 + j]; + end1 = ptdata1[i * 2 * ndims1 + j + ndims1]; + end2 = ptdata2[i * 2 * ndims1 + j + ndims1]; + if (start1 != start2 || end1 != end2) + nfound_b++; + } + } - /* print differences if found */ - if (nfound_b && options->m_verbose) - { - parallel_print("Referenced dataset %lu %lu\n", - (unsigned long)objno1,(unsigned long)objno2); - parallel_print("------------------------------------------------------------\n"); - - parallel_print("Region blocks\n"); - for (i = 0; i < nblocks1; i++) - { - parallel_print("block #%d", i); - print_region_block(i, ptdata1, ndims1); - print_region_block(i, ptdata2, ndims1); - parallel_print("\n"); - - } - } - HDfree(ptdata1); - HDfree(ptdata2); - } + /* print differences if found */ + if (nfound_b && options->m_verbose) { + H5O_info_t oi1, oi2; -/*------------------------------------------------------------------------- - * compare point information - *------------------------------------------------------------------------- - */ + H5Oget_info(obj1_id, ".", &oi1, H5P_DEFAULT); + H5Oget_info(obj2_id, ".", &oi2, H5P_DEFAULT); - if (npoints1 > 0) - { - alloc_size = npoints1 * ndims1 * sizeof(ptdata1[0]); - assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ - - ptdata1 = malloc((size_t)alloc_size); - H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t); - H5Sget_select_elem_pointlist(region1_id, (hsize_t)0, (hsize_t)npoints1, ptdata1); + parallel_print("Referenced dataset %lu %lu\n", + (unsigned long)oi1.addr, (unsigned long)oi2.addr); + parallel_print("------------------------------------------------------------\n"); - ptdata2 = malloc((size_t)alloc_size); - H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t); - H5Sget_select_elem_pointlist(region2_id, (hsize_t)0, (hsize_t)npoints2, ptdata2); + parallel_print("Region blocks\n"); + for (i = 0; i < nblocks1; i++) { + parallel_print("block #%d", i); + print_region_block(i, ptdata1, ndims1); + print_region_block(i, ptdata2, ndims1); + parallel_print("\n"); + } + } - for (i = 0; i < npoints1; i++) - { - hsize_t pt1, pt2; + HDfree(ptdata1); + HDfree(ptdata2); + } - for (j = 0; j < ndims1; j++) - { - pt1 = ptdata1[i * ndims1 + j]; - pt2 = ptdata2[i * ndims1 + j]; - if (pt1 != pt2) - nfound_p++; - } - } + /*------------------------------------------------------------------------- + * compare point information + *------------------------------------------------------------------------- + */ + if(npoints1 > 0) { + alloc_size = npoints1 * ndims1 * sizeof(ptdata1[0]); + assert(alloc_size == (hsize_t)((size_t)alloc_size)); /*check for overflow*/ + + ptdata1 = malloc((size_t)alloc_size); + H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t); + H5Sget_select_elem_pointlist(region1_id, (hsize_t)0, (hsize_t)npoints1, ptdata1); + + ptdata2 = malloc((size_t)alloc_size); + H5_CHECK_OVERFLOW(npoints1,hssize_t,hsize_t); + H5Sget_select_elem_pointlist(region2_id, (hsize_t)0, (hsize_t)npoints2, ptdata2); + + for(i = 0; i < npoints1; i++) { + hsize_t pt1, pt2; + + for(j = 0; j < ndims1; j++) { + pt1 = ptdata1[i * ndims1 + j]; + pt2 = ptdata2[i * ndims1 + j]; + if(pt1 != pt2) + nfound_p++; + } + } - if (nfound_p && options->m_verbose) - { - parallel_print("Region points\n"); - for (i = 0; i < npoints1; i++) - { - hsize_t pt1, pt2; - int diff_data = 0; - for (j = 0; j < ndims1; j++) - { - pt1 = ptdata1[i * ndims1 + j]; - pt2 = ptdata2[i * ndims1 + j]; - if (pt1 != pt2) - { - diff_data = 1; - break; - } - } - if (diff_data) - { - parallel_print("point #%d", i); - print_points(i, ptdata1, ndims1); - print_points(i, ptdata2, ndims1); - parallel_print("\n"); - } - } - } + if(nfound_p && options->m_verbose) { + parallel_print("Region points\n"); + for(i = 0; i < npoints1; i++) { + hsize_t pt1, pt2; + int diff_data = 0; + + for(j = 0; j < ndims1; j++) { + pt1 = ptdata1[i * ndims1 + j]; + pt2 = ptdata2[i * ndims1 + j]; + if(pt1 != pt2) { + diff_data = 1; + break; + } + } + if(diff_data) { + parallel_print("point #%d", i); + print_points(i, ptdata1, ndims1); + print_points(i, ptdata2, ndims1); + parallel_print("\n"); + } + } + } #if defined (H5DIFF_DEBUG) - for (i = 0; i < npoints1; i++) - { - int j; + for (i = 0; i < npoints1; i++) { + int j; - parallel_print("%sPt%lu: " , - i ? "," : "", - (unsigned long)i); + parallel_print("%sPt%lu: " , i ? "," : "", (unsigned long)i); - for (j = 0; j < ndims1; j++) - parallel_print("%s%lu", j ? "," : "(", - (unsigned long)(ptdata1[i * ndims1 + j])); + for (j = 0; j < ndims1; j++) + parallel_print("%s%lu", j ? "," : "(", + (unsigned long)(ptdata1[i * ndims1 + j])); - parallel_print(")"); - } + parallel_print(")"); + } #endif - HDfree(ptdata1); - HDfree(ptdata2); - } + HDfree(ptdata1); + HDfree(ptdata2); + } - nfound_b = nfound_b/ndims1; - nfound_p = nfound_p/ndims1; - return (nfound_p + nfound_b); + nfound_b = nfound_b/ndims1; + nfound_p = nfound_p/ndims1; + return (nfound_p + nfound_b); } diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c index 50bc6cd..44154cd 100644 --- a/tools/lib/h5tools.c +++ b/tools/lib/h5tools.c @@ -128,12 +128,12 @@ void h5tools_close(void) { if (h5tools_init_g) { - if (rawdatastream && rawdatastream != stdout) { - if (fclose(rawdatastream)) - perror("closing rawdatastream"); - else - rawdatastream = NULL; - } + if (rawdatastream && rawdatastream != stdout) { + if (fclose(rawdatastream)) + perror("closing rawdatastream"); + else + rawdatastream = NULL; + } /* Clean up the reference path table, if it's been used */ term_ref_path_table(); @@ -141,7 +141,7 @@ h5tools_close(void) /* Shut down the library */ H5close(); - h5tools_init_g = 0; + h5tools_init_g = 0; } } @@ -554,152 +554,150 @@ h5tools_dump_simple_data(FILE *stream, const h5tool_format_t *info, hid_t contai *to the ctx->size_last_dim. */ /* binary dump */ - if (bin_output) - { - do_bin_output(stream,nelmts,type,_mem); - bin_output=0; - } - else - { - /* Setup */ - memset(&buffer, 0, sizeof(h5tools_str_t)); - size = H5Tget_size(type); + if(bin_output) { + do_bin_output(stream, nelmts, type, _mem); + bin_output = 0; + } /* end if */ + else { + /* Setup */ + HDmemset(&buffer, 0, sizeof(h5tools_str_t)); + size = H5Tget_size(type); - if (info->line_ncols > 0) - ncols = info->line_ncols; + if(info->line_ncols > 0) + ncols = info->line_ncols; - /* pass to the prefix in h5tools_simple_prefix the total position - instead of the current stripmine position i; this is necessary - to print the array indices */ - curr_pos = ctx->sm_pos; + /* pass to the prefix in h5tools_simple_prefix the total position + * instead of the current stripmine position i; this is necessary + * to print the array indices + */ + curr_pos = ctx->sm_pos; - h5tools_simple_prefix(stream, info, ctx, curr_pos, 0); + h5tools_simple_prefix(stream, info, ctx, curr_pos, 0); - for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) { - /* Render the element */ - h5tools_str_reset(&buffer); - h5tools_str_sprint(&buffer, info, container, type, mem + i * size, ctx); + for (i = 0; i < nelmts; i++, ctx->cur_elmt++, elmt_counter++) { + /* Render the element */ + h5tools_str_reset(&buffer); + h5tools_str_sprint(&buffer, info, container, type, mem + i * size, ctx); - if (i + 1 < nelmts || (flags & END_OF_DATA) == 0) - h5tools_str_append(&buffer, "%s", OPT(info->elmt_suf1, ",")); + if (i + 1 < nelmts || (flags & END_OF_DATA) == 0) + h5tools_str_append(&buffer, "%s", OPT(info->elmt_suf1, ",")); - s = h5tools_str_fmt(&buffer, 0, "%s"); + s = h5tools_str_fmt(&buffer, 0, "%s"); - /* - * If the element would split on multiple lines if printed at our - * current location... - */ - if (info->line_multi_new == 1 && - (ctx->cur_column + h5tools_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) { - if (ctx->prev_multiline) { - /* - * ... and the previous element also occupied more than one - * line, then start this element at the beginning of a line. - */ - ctx->need_prefix = TRUE; - } else if ((ctx->prev_prefix_len + h5tools_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) <= ncols) { - /* - * ...but *could* fit on one line otherwise, then we - * should end the current line and start this element on its - * own line. - */ - ctx->need_prefix = TRUE; + /* + * If the element would split on multiple lines if printed at our + * current location... + */ + if (info->line_multi_new == 1 && + (ctx->cur_column + h5tools_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + + strlen(OPT(info->line_suf, ""))) > ncols) { + if (ctx->prev_multiline) { + /* + * ... and the previous element also occupied more than one + * line, then start this element at the beginning of a line. + */ + ctx->need_prefix = TRUE; + } else if ((ctx->prev_prefix_len + h5tools_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + + strlen(OPT(info->line_suf, ""))) <= ncols) { + /* + * ...but *could* fit on one line otherwise, then we + * should end the current line and start this element on its + * own line. + */ + ctx->need_prefix = TRUE; + } } - } - /* - * We need to break after each row of a dimension---> we should - * break at the end of the each last dimension well that is the - * way the dumper did it before - */ - if (info->arr_linebreak && ctx->cur_elmt) { - if (ctx->size_last_dim && (ctx->cur_elmt % ctx->size_last_dim) == 0) - ctx->need_prefix = TRUE; + /* + * We need to break after each row of a dimension---> we should + * break at the end of the each last dimension well that is the + * way the dumper did it before + */ + if (info->arr_linebreak && ctx->cur_elmt) { + if (ctx->size_last_dim && (ctx->cur_elmt % ctx->size_last_dim) == 0) + ctx->need_prefix = TRUE; - if ((hsize_t)elmt_counter == ctx->size_last_dim) { - ctx->need_prefix = TRUE; - elmt_counter = 0; + if ((hsize_t)elmt_counter == ctx->size_last_dim) { + ctx->need_prefix = TRUE; + elmt_counter = 0; + } } - } - - /* - * If the previous element occupied multiple lines and this element - * is too long to fit on a line then start this element at the - * beginning of the line. - */ - if (info->line_multi_new == 1 && ctx->prev_multiline && - (ctx->cur_column + h5tools_ncols(s) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) - ctx->need_prefix = TRUE; - - /* - * If too many elements have already been printed then we need to - * start a new line. - */ - if (info->line_per_line > 0 && ctx->cur_elmt >= info->line_per_line) - ctx->need_prefix = TRUE; - /* - * Each OPTIONAL_LINE_BREAK embedded in the rendered string can cause - * the data to split across multiple lines. We display the sections - * one-at a time. - */ - for (secnum = 0, multiline = 0; - (section = strtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK)); - secnum++) { /* - * If the current section plus possible suffix and end-of-line - * information would cause the output to wrap then we need to - * start a new line. + * If the previous element occupied multiple lines and this element + * is too long to fit on a line then start this element at the + * beginning of the line. */ + if (info->line_multi_new == 1 && ctx->prev_multiline && + (ctx->cur_column + h5tools_ncols(s) + + strlen(OPT(info->elmt_suf2, " ")) + + strlen(OPT(info->line_suf, ""))) > ncols) + ctx->need_prefix = TRUE; /* - * Added the info->skip_first because the dumper does not want - * this check to happen for the first line + * If too many elements have already been printed then we need to + * start a new line. */ - if ((!info->skip_first || i) && - (ctx->cur_column + strlen(section) + - strlen(OPT(info->elmt_suf2, " ")) + - strlen(OPT(info->line_suf, ""))) > ncols) - ctx->need_prefix = 1; + if (info->line_per_line > 0 && ctx->cur_elmt >= info->line_per_line) + ctx->need_prefix = TRUE; /* - * Print the prefix or separate the beginning of this element - * from the previous element. + * Each OPTIONAL_LINE_BREAK embedded in the rendered string can cause + * the data to split across multiple lines. We display the sections + * one-at a time. */ - if (ctx->need_prefix) { - if (secnum) - multiline++; - - /* pass to the prefix in h5tools_simple_prefix the total position - instead of the current stripmine position i; this is necessary - to print the array indices */ - curr_pos = ctx->sm_pos + i; - - h5tools_simple_prefix(stream, info, ctx, curr_pos, secnum); - } else if ((i || ctx->continuation) && secnum == 0) { - fputs(OPT(info->elmt_suf2, " "), stream); - ctx->cur_column += strlen(OPT(info->elmt_suf2, " ")); - } + for (secnum = 0, multiline = 0; + (section = strtok(secnum ? NULL : s, OPTIONAL_LINE_BREAK)); + secnum++) { + /* + * If the current section plus possible suffix and end-of-line + * information would cause the output to wrap then we need to + * start a new line. + */ - /* Print the section */ - fputs(section, stream); - ctx->cur_column += strlen(section); - } + /* + * Added the info->skip_first because the dumper does not want + * this check to happen for the first line + */ + if ((!info->skip_first || i) && + (ctx->cur_column + strlen(section) + + strlen(OPT(info->elmt_suf2, " ")) + + strlen(OPT(info->line_suf, ""))) > ncols) + ctx->need_prefix = 1; - ctx->prev_multiline = multiline; - } + /* + * Print the prefix or separate the beginning of this element + * from the previous element. + */ + if (ctx->need_prefix) { + if (secnum) + multiline++; + + /* pass to the prefix in h5tools_simple_prefix the total + * position instead of the current stripmine position i; + * this is necessary to print the array indices + */ + curr_pos = ctx->sm_pos + i; + + h5tools_simple_prefix(stream, info, ctx, curr_pos, secnum); + } else if ((i || ctx->continuation) && secnum == 0) { + fputs(OPT(info->elmt_suf2, " "), stream); + ctx->cur_column += strlen(OPT(info->elmt_suf2, " ")); + } - h5tools_str_close(&buffer); + /* Print the section */ + fputs(section, stream); + ctx->cur_column += strlen(section); + } - }/* else bin */ + ctx->prev_multiline = multiline; + } + h5tools_str_close(&buffer); + }/* else bin */ } diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c index 0b17b41..715d05e 100644 --- a/tools/lib/h5tools_ref.c +++ b/tools/lib/h5tools_ref.c @@ -49,49 +49,8 @@ extern int d_status; static int ref_path_table_put(const char *, haddr_t objno); static hbool_t ref_path_table_find(haddr_t objno); - -/*------------------------------------------------------------------------- - * Function: init_ref_path_table - * - * Purpose: Enter the root group ("/") into the path table - * - * Return: Non-negative on success, negative on failure - * - * Programmer: Quincey Koziol - * - * Modifications: - * - *------------------------------------------------------------------------- - */ -int -init_ref_path_table(hid_t fid) -{ - H5G_stat_t sb; - haddr_t objno; /* Compact form of object's location */ - char *root_path; - - /* Set file ID for later queries (XXX: this should be fixed) */ - thefile = fid; - - /* Create skip list to store reference path information */ - if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)16))==NULL) - return (-1); - - if((root_path = HDstrdup("/")) == NULL) - return (-1); - - if(H5Gget_objinfo(fid, "/", TRUE, &sb)<0) { - /* fatal error? */ - HDfree(root_path); - return (-1); - } - objno = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); - - /* Insert into table (takes ownership of path) */ - ref_path_table_put(root_path, objno); - - return(0); -} +static herr_t fill_ref_path_table_cb(hid_t group, const char *obj_name, + const H5L_info_t *linfo, void *op_data); /*------------------------------------------------------------------------- * Function: free_ref_path_info @@ -158,35 +117,31 @@ term_ref_path_table(void) haddr_t ref_path_table_lookup(const char *thepath) { - H5G_stat_t sb; - haddr_t objno; /* Compact form of object's location */ - - /* Check for external link first, so we don't return the OID of an object in another file */ - if(H5Gget_objinfo(thefile, thepath, FALSE, &sb)<0) - return HADDR_UNDEF; - if(sb.type == H5G_LINK) { - /* Get object ID for object at path */ - /* (If the object is not a soft link, we've already retrieved the - * correct information and don't have to perform this call. -QAK - */ - if(H5Gget_objinfo(thefile, thepath, TRUE, &sb)<0) - /* fatal error ? */ + H5O_info_t oi; + + /* Allow lookups on the root group, even though it doesn't have any link info */ + if(HDstrcmp(thepath, "/")) { + H5L_info_t li; + + /* Check for external link first, so we don't return the OID of an object in another file */ + if(H5Lget_info(thefile, thepath, &li, H5P_DEFAULT) < 0) + return HADDR_UNDEF; + + /* UD links can't be followed, so they always "dangle" like soft links. */ + if(li.type >= H5L_TYPE_UD_MIN) return HADDR_UNDEF; - } else if(sb.type == H5G_UDLINK) - { - /* UD links can't be followed, so they always "dangle" like - * soft links. - */ - return HADDR_UNDEF; } /* end if */ - objno = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); + /* Get the object info now */ + /* (returns failure for dangling soft links) */ + if(H5Oget_info(thefile, thepath, &oi, H5P_DEFAULT) < 0) + return HADDR_UNDEF; /* All existing objects in the file had better be in the table */ - HDassert(ref_path_table_find(objno)); + HDassert(ref_path_table_find(oi.addr)); /* Return OID */ - return(objno); + return(oi.addr); } /*------------------------------------------------------------------------- @@ -325,6 +280,65 @@ lookup_ref_path(haddr_t ref) } /*------------------------------------------------------------------------- + * Function: fill_ref_path_table_cb + * + * Purpose: Called by interator to create references for + * all objects and enter them in the table. + * + * Return: Error status. + * + * Programmer: REMcG + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +fill_ref_path_table_cb(hid_t group, const char *obj_name, const H5L_info_t *linfo, + void *op_data) +{ + if(linfo->type == H5L_TYPE_HARD) { + H5O_info_t oinfo; + + H5Oget_info(group, obj_name, &oinfo, H5P_DEFAULT); + + /* Check if the object is already in the path table */ + if(!ref_path_table_find(oinfo.addr)) { + const char *obj_prefix = (const char *)op_data; + size_t tmp_len; + char *thepath; + + /* Compute length for this object's path */ + tmp_len = HDstrlen(obj_prefix) + HDstrlen(obj_name) + 2; + + /* Allocate room for the path for this object */ + if((thepath = (char *)HDmalloc(tmp_len)) == NULL) + return FAIL; + + /* Build the name for this object */ + HDstrcpy(thepath, obj_prefix); + HDstrcat(thepath, "/"); + HDstrcat(thepath, obj_name); + + /* Insert the object into the path table (takes ownership of the path) */ + ref_path_table_put(thepath, oinfo.addr); + + if(oinfo.type == H5O_TYPE_GROUP) { + /* Iterate over objects in this group, using this group's + * name as their prefix + */ + if(H5Literate(group, obj_name, H5_INDEX_NAME, H5_ITER_INC, NULL, fill_ref_path_table_cb, thepath, H5P_DEFAULT) < 0) { + error_msg(progname, "unable to dump group \"%s\"\n", thepath); + d_status = EXIT_FAILURE; + } /* end if */ + } /* end if */ + } /* end if */ + } /* end if */ + + return 0; +} + +/*------------------------------------------------------------------------- * Function: fill_ref_path_table * * Purpose: Called by interator to create references for @@ -339,46 +353,32 @@ lookup_ref_path(haddr_t ref) *------------------------------------------------------------------------- */ herr_t -fill_ref_path_table(hid_t group, const char *obj_name, const H5L_info_t UNUSED *linfo, - void *op_data) +fill_ref_path_table(hid_t fid) { - const char *obj_prefix = (const char *)op_data; - H5G_stat_t statbuf; - haddr_t objno; /* Compact form of object's location */ - - H5Gget_objinfo(group, obj_name, FALSE, &statbuf); - objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long))); - - /* Check if the object is in the path table */ - if (!ref_path_table_find(objno)) { - size_t tmp_len; - char *thepath; - - /* Compute length for this object's path */ - tmp_len = HDstrlen(obj_prefix) + HDstrlen(obj_name) + 2; - - /* Allocate room for the path for this object */ - if ((thepath = (char *) HDmalloc(tmp_len)) == NULL) - return FAIL; - - /* Build the name for this object */ - HDstrcpy(thepath, obj_prefix); - HDstrcat(thepath, "/"); - HDstrcat(thepath, obj_name); - - /* Insert the object into the path table */ - ref_path_table_put(thepath, objno); - - if(statbuf.type == H5G_GROUP) { - /* Iterate over objects in this group, using this group's - * name as their prefix - */ - if(H5Literate(group, obj_name, H5_INDEX_NAME, H5_ITER_INC, NULL, fill_ref_path_table, thepath, H5P_DEFAULT) < 0) { - error_msg(progname, "unable to dump group \"%s\"\n", obj_name); - d_status = EXIT_FAILURE; - } - } - } + H5O_info_t oinfo; + char *root_path; + + /* Set file ID for later queries (XXX: this should be fixed) */ + thefile = fid; + + /* Create skip list to store reference path information */ + if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, 0.5, (size_t)16))==NULL) + return (-1); + + /* Build the name for root group */ + root_path = HDstrdup("/"); + + /* Get info for root group */ + H5Oget_info(fid, root_path, &oinfo, H5P_DEFAULT); + + /* Insert the root group into the path table (takes ownership of path) */ + ref_path_table_put(root_path, oinfo.addr); + + /* Iterate over objects in this file */ + if(H5Literate(fid, root_path, H5_INDEX_NAME, H5_ITER_INC, NULL, fill_ref_path_table_cb, (void *)"", H5P_DEFAULT) < 0) { + error_msg(progname, "unable to dump root group\n"); + d_status = EXIT_FAILURE; + } /* end if */ return 0; } diff --git a/tools/lib/h5tools_ref.h b/tools/lib/h5tools_ref.h index d996114..567ca4b 100644 --- a/tools/lib/h5tools_ref.h +++ b/tools/lib/h5tools_ref.h @@ -22,14 +22,13 @@ extern "C" { #endif -int init_ref_path_table(hid_t fid); +herr_t fill_ref_path_table(hid_t fid); const char *lookup_ref_path(haddr_t ref); -herr_t fill_ref_path_table(hid_t, const char *, const H5L_info_t *, void *); int get_next_xid(void); -haddr_t get_fake_xid (void); -haddr_t ref_path_table_lookup(const char *); -haddr_t ref_path_table_gen_fake(const char *); -int term_ref_path_table(void); +haddr_t get_fake_xid(void); +haddr_t ref_path_table_lookup(const char *); +haddr_t ref_path_table_gen_fake(const char *); +int term_ref_path_table(void); #ifdef __cplusplus } diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c index 737c68a..f877baa 100644 --- a/tools/lib/h5tools_str.c +++ b/tools/lib/h5tools_str.c @@ -308,12 +308,12 @@ h5tools_str_fmt(h5tools_str_t *str/*in,out*/, size_t start, const char *fmt) */ char * h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, - hsize_t elmtno, int ndims, hsize_t min_idx[], + hsize_t elmtno, unsigned ndims, hsize_t min_idx[], hsize_t max_idx[], h5tools_context_t *ctx) { hsize_t p_prod[H5S_MAX_RANK]; size_t i = 0; - hsize_t curr_pos=elmtno; + hsize_t curr_pos = elmtno; h5tools_str_reset(str); @@ -325,10 +325,9 @@ h5tools_str_prefix(h5tools_str_t *str/*in,out*/, const h5tool_format_t *info, for (i = ndims - 1, p_prod[ndims - 1] = 1; i > 0; --i) p_prod[i - 1] = (max_idx[i] - min_idx[i]) * p_prod[i]; - for ( i = 0; i < (size_t)ndims; i++) - { - ctx->pos[i] = curr_pos/ctx->acc[i]; - curr_pos -= ctx->acc[i]*ctx->pos[i]; + for ( i = 0; i < (size_t)ndims; i++) { + ctx->pos[i] = curr_pos/ctx->acc[i]; + curr_pos -= ctx->acc[i]*ctx->pos[i]; } assert( curr_pos == 0 ); @@ -580,31 +579,22 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai char *cp_vp = (char *)vp; hid_t memb, obj, region; unsigned nmembs; - int otype; static char fmt_llong[8], fmt_ullong[8]; H5T_str_t pad; - H5G_stat_t sb; /* * some tempvars to store the value before we append it to the string to * get rid of the memory alignment problem */ - double tempdouble; - float tempfloat; unsigned long_long tempullong; long_long templlong; unsigned long tempulong; long templong; unsigned int tempuint; int tempint; - unsigned short tempushort; - short tempshort; -#if H5_SIZEOF_LONG_DOUBLE !=0 - long double templdouble; -#endif /* Build default formats for long long types */ - if (!fmt_llong[0]) { + if(!fmt_llong[0]) { sprintf(fmt_llong, "%%%sd", H5_PRINTF_LL_WIDTH); sprintf(fmt_ullong, "%%%su", H5_PRINTF_LL_WIDTH); } @@ -612,29 +602,37 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai /* Append value depending on data type */ start = h5tools_str_len(str); - if (info->raw) { + if(info->raw) { size_t i; + n = H5Tget_size(type); if (1==n) { h5tools_str_append(str, OPT(info->fmt_raw, "0x%02x"), ucp_vp[0]); } else { - for (i = 0; i < n; i++) { - if (i) h5tools_str_append(str, ":"); - h5tools_str_append(str, OPT(info->fmt_raw, "%02x"), ucp_vp[i]); + for(i = 0; i < n; i++) { + if(i) + h5tools_str_append(str, ":"); + h5tools_str_append(str, OPT(info->fmt_raw, "%02x"), ucp_vp[i]); } } } else if (H5Tequal(type, H5T_NATIVE_FLOAT)) { - memcpy(&tempfloat, vp, sizeof(float)); + float tempfloat; + + HDmemcpy(&tempfloat, vp, sizeof(float)); h5tools_str_append(str, OPT(info->fmt_float, "%g"), tempfloat); } else if (H5Tequal(type, H5T_NATIVE_DOUBLE)) { - memcpy(&tempdouble, vp, sizeof(double)); - h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble); + double tempdouble; + + HDmemcpy(&tempdouble, vp, sizeof(double)); + h5tools_str_append(str, OPT(info->fmt_double, "%g"), tempdouble); #if H5_SIZEOF_LONG_DOUBLE !=0 } else if (H5Tequal(type, H5T_NATIVE_LDOUBLE)) { - memcpy(&templdouble, vp, sizeof(long double)); - h5tools_str_append(str, "%Lf", templdouble); + long double templdouble; + + HDmemcpy(&templdouble, vp, sizeof(long double)); + h5tools_str_append(str, "%Lf", templdouble); #endif - } else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) || + } else if (info->ascii && (H5Tequal(type, H5T_NATIVE_SCHAR) || H5Tequal(type, H5T_NATIVE_UCHAR))) { h5tools_print_char(str, info, (char)(*ucp_vp)); } else if (H5T_STRING == H5Tget_class(type)) { @@ -713,32 +711,36 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai h5tools_str_append(str, "\"\""); } /* end else */ } else if (H5Tequal(type, H5T_NATIVE_INT)) { - memcpy(&tempint, vp, sizeof(int)); + HDmemcpy(&tempint, vp, sizeof(int)); h5tools_str_append(str, OPT(info->fmt_int, "%d"), tempint); } else if (H5Tequal(type, H5T_NATIVE_UINT)) { - memcpy(&tempuint, vp, sizeof(unsigned int)); + HDmemcpy(&tempuint, vp, sizeof(unsigned int)); h5tools_str_append(str, OPT(info->fmt_uint, "%u"), tempuint); } else if (H5Tequal(type, H5T_NATIVE_SCHAR)) { h5tools_str_append(str, OPT(info->fmt_schar, "%d"), *cp_vp); } else if (H5Tequal(type, H5T_NATIVE_UCHAR)) { h5tools_str_append(str, OPT(info->fmt_uchar, "%u"), *ucp_vp); } else if (H5Tequal(type, H5T_NATIVE_SHORT)) { - memcpy(&tempshort, vp, sizeof(short)); + short tempshort; + + HDmemcpy(&tempshort, vp, sizeof(short)); h5tools_str_append(str, OPT(info->fmt_short, "%d"), tempshort); } else if (H5Tequal(type, H5T_NATIVE_USHORT)) { - memcpy(&tempushort, vp, sizeof(unsigned short)); + unsigned short tempushort; + + HDmemcpy(&tempushort, vp, sizeof(unsigned short)); h5tools_str_append(str, OPT(info->fmt_ushort, "%u"), tempushort); } else if (H5Tequal(type, H5T_NATIVE_LONG)) { - memcpy(&templong, vp, sizeof(long)); + HDmemcpy(&templong, vp, sizeof(long)); h5tools_str_append(str, OPT(info->fmt_long, "%ld"), templong); } else if (H5Tequal(type, H5T_NATIVE_ULONG)) { - memcpy(&tempulong, vp, sizeof(unsigned long)); + HDmemcpy(&tempulong, vp, sizeof(unsigned long)); h5tools_str_append(str, OPT(info->fmt_ulong, "%lu"), tempulong); } else if (H5Tequal(type, H5T_NATIVE_LLONG)) { - memcpy(&templlong, vp, sizeof(long_long)); + HDmemcpy(&templlong, vp, sizeof(long_long)); h5tools_str_append(str, OPT(info->fmt_llong, fmt_llong), templlong); } else if (H5Tequal(type, H5T_NATIVE_ULLONG)) { - memcpy(&tempullong, vp, sizeof(unsigned long_long)); + HDmemcpy(&tempullong, vp, sizeof(unsigned long_long)); h5tools_str_append(str, OPT(info->fmt_ullong, fmt_ullong), tempullong); } else if (H5Tequal(type, H5T_NATIVE_HSSIZE)) { if (sizeof(hssize_t) == sizeof(int)) { @@ -849,7 +851,6 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai obj = H5Rdereference(container, H5R_DATASET_REGION, vp); region = H5Rget_region(container, H5R_DATASET_REGION, vp); - H5Gget_objinfo(obj, ".", FALSE, &sb); /* get name of the dataset the region reference points to using H5Rget_name */ H5Rget_name(obj, H5R_DATASET_REGION, vp, (char*)ref_name, 1024); @@ -867,47 +868,46 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai if (h5tools_is_zero(vp, H5Tget_size(type))) { h5tools_str_append(str, "NULL"); } else { - haddr_t objno; /* Compact form of object's location */ + H5O_info_t oi; const char *path; - otype = H5Rget_obj_type(container, H5R_OBJECT, vp); obj = H5Rdereference(container, H5R_OBJECT, vp); - H5Gget_objinfo(obj, ".", FALSE, &sb); + H5Oget_info(obj, ".", &oi, H5P_DEFAULT); /* Print object type and close object */ - switch (otype) { - case H5G_GROUP: + switch(oi.type) { + case H5O_TYPE_GROUP: h5tools_str_append(str, H5_TOOLS_GROUP); - H5Gclose(obj); break; - case H5G_DATASET: + + case H5O_TYPE_DATASET: h5tools_str_append(str, H5_TOOLS_DATASET); - H5Dclose(obj); break; - case H5G_TYPE: + + case H5O_TYPE_NAMED_DATATYPE: h5tools_str_append(str, H5_TOOLS_DATATYPE); - H5Tclose(obj); break; + default: - h5tools_str_append(str, "%u-", otype); + h5tools_str_append(str, "%u-", (unsigned)oi.type); break; - } + } /* end switch */ + H5Oclose(obj); /* Print OID */ - objno = (haddr_t)sb.objno[0] | ((haddr_t)sb.objno[1] << (8 * sizeof(long))); - if (info->obj_hidefileno) - h5tools_str_append(str, info->obj_format, objno); + if(info->obj_hidefileno) + h5tools_str_append(str, info->obj_format, oi.addr); else - h5tools_str_append(str, info->obj_format, sb.fileno[0], objno); + h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr); /* Print name */ path = lookup_ref_path(*(haddr_t *)vp); if (path) { - h5tools_str_append(str, " "); - h5tools_str_append(str, path); - h5tools_str_append(str, " "); - } - } + h5tools_str_append(str, " "); + h5tools_str_append(str, path); + h5tools_str_append(str, " "); + } /* end if */ + } /* end else */ } else if (H5Tget_class(type) == H5T_ARRAY) { int k, ndims; hsize_t i, dims[H5S_MAX_RANK],temp_nelmts; @@ -929,25 +929,23 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai /* Print the opening bracket */ h5tools_str_append(str, "%s", OPT(info->arr_pre, "[")); - for (i = 0; i < nelmts; i++) { - if (i) + for(i = 0; i < nelmts; i++) { + if(i) h5tools_str_append(str, "%s", OPT(info->arr_sep, "," OPTIONAL_LINE_BREAK)); - if (info->arr_linebreak && i && i % dims[ndims - 1] == 0) { + if(info->arr_linebreak && i && i % dims[ndims - 1] == 0) { int x; h5tools_str_append(str, "%s", "\n"); - /*need to indent some more here*/ - if (ctx->indent_level >= 0 ) - { - if (!info->pindex) - h5tools_str_append(str, "%s", OPT(info->line_pre, "")); - } + /* need to indent some more here*/ + if(ctx->indent_level >= 0) + if(!info->pindex) + h5tools_str_append(str, "%s", OPT(info->line_pre, "")); - for (x = 0; x < ctx->indent_level + 1; x++) - h5tools_str_append(str,"%s",OPT(info->line_indent,"")); + for(x = 0; x < ctx->indent_level + 1; x++) + h5tools_str_append(str, "%s", OPT(info->line_indent, "")); } /* end if */ else if(i && info->arr_sep) h5tools_str_append(str, " "); @@ -961,7 +959,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai } /* end for */ /* Print the closing bracket */ - h5tools_str_append(str, "%s", OPT(info->arr_suf, "]")); + h5tools_str_append(str, "%s", OPT(info->arr_suf, "]")); H5Tclose(memb); } else if (H5Tget_class(type) == H5T_VLEN) { unsigned int i; diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h index 0964b7b..607d412 100644 --- a/tools/lib/h5tools_str.h +++ b/tools/lib/h5tools_str.h @@ -33,7 +33,7 @@ extern char *h5tools_str_reset(h5tools_str_t *str); extern char *h5tools_str_trunc(h5tools_str_t *str, size_t size); extern char *h5tools_str_fmt(h5tools_str_t *str, size_t start, const char *fmt); extern char *h5tools_str_prefix(h5tools_str_t *str, const h5tool_format_t *info, - hsize_t elmtno, int ndims, hsize_t min_idx[], + hsize_t elmtno, unsigned ndims, hsize_t min_idx[], hsize_t max_idx[], h5tools_context_t *ctx); extern int h5tools_str_dump_region(h5tools_str_t *, hid_t, const h5tool_format_t *); extern char *h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index b04f3c6..4aabe09 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -483,26 +483,23 @@ build_obj_path_name(const char *prefix, const char *name) static herr_t find_objs_cb(hid_t group, const char *name, const H5L_info_t UNUSED *linfo, void *op_data) { - H5G_stat_t statbuf; + H5O_info_t oinfo; find_objs_t *info = (find_objs_t*)op_data; herr_t ret_value = 0; - if(H5Gget_objinfo(group, name, FALSE, &statbuf) < 0) + if(H5Oget_info(group, name, &oinfo, H5P_DEFAULT) < 0) ; /* keep going */ else { - haddr_t objno; /* Compact form of object's location */ - - objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long))); - switch (statbuf.type) { + switch(oinfo.type) { char *tmp; size_t tmp_len; - case H5G_GROUP: - if (search_obj(info->group_table, objno) == NULL) { + case H5O_TYPE_GROUP: + if(search_obj(info->group_table, oinfo.addr) == NULL) { char *old_prefix; tmp = build_obj_path_name(info->prefix, name); - add_obj(info->group_table, objno, tmp, TRUE); + add_obj(info->group_table, oinfo.addr, tmp, TRUE); old_prefix = info->prefix; tmp_len = HDstrlen(tmp); @@ -516,44 +513,42 @@ find_objs_cb(hid_t group, const char *name, const H5L_info_t UNUSED *linfo, void } /* end if */ break; - case H5G_DATASET: - if (search_obj(info->dset_table, objno) == NULL) { + case H5O_TYPE_DATASET: + if(search_obj(info->dset_table, oinfo.addr) == NULL) { hid_t dset; tmp = build_obj_path_name(info->prefix, name); - add_obj(info->dset_table, objno, tmp, TRUE); + add_obj(info->dset_table, oinfo.addr, tmp, TRUE); - if ((dset = H5Dopen (group, name)) >= 0) { + if((dset = H5Dopen (group, name)) >= 0) { hid_t type; type = H5Dget_type(dset); - if (H5Tcommitted(type) > 0) { - H5Gget_objinfo(type, ".", TRUE, &statbuf); - objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long))); - - if (search_obj(info->type_table, objno) == NULL) { + if(H5Tcommitted(type) > 0) { + H5Oget_info(type, ".", &oinfo, H5P_DEFAULT); + if (search_obj(info->type_table, oinfo.addr) == NULL) { char *type_name = HDstrdup(tmp); - add_obj(info->type_table, objno, type_name, FALSE); + add_obj(info->type_table, oinfo.addr, type_name, FALSE); } /* end if */ - } + } /* end if */ H5Tclose(type); H5Dclose(dset); - } else { + } /* end if */ + else ret_value = FAIL; - } } /* end if */ break; - case H5G_TYPE: + case H5O_TYPE_NAMED_DATATYPE: { obj_t *found_obj; tmp = build_obj_path_name(info->prefix, name); - if ((found_obj = search_obj(info->type_table, objno)) == NULL) - add_obj(info->type_table, objno, tmp, TRUE); + if((found_obj = search_obj(info->type_table, oinfo.addr)) == NULL) + add_obj(info->type_table, oinfo.addr, tmp, TRUE); else { /* Use latest version of name */ HDfree(found_obj->objname); @@ -594,6 +589,8 @@ herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table) { + H5O_info_t oinfo; + /* Initialize the tables */ init_table(group_table); init_table(dset_table); @@ -605,25 +602,15 @@ init_objs(hid_t fid, find_objs_t *info, table_t **group_table, info->type_table = *type_table; info->dset_table = *dset_table; - { - /* add the root group as an object, it may have hard links to it */ - - H5G_stat_t statbuf; - haddr_t objno; /* compact form of object's location */ - char* tmp; - - if(H5Gget_objinfo(fid, "/", FALSE, &statbuf) < 0) - return FAIL; - else - { - objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long))); - /* call with an empty string, it appends group separator */ - tmp = build_obj_path_name(info->prefix, ""); - add_obj(info->group_table, objno, tmp, TRUE); - } - } - + /* add the root group as an object, it may have hard links to it */ + if(H5Oget_info(fid, "/", &oinfo, H5P_DEFAULT) < 0) + return FAIL; + else { + /* call with an empty string, it appends '/' group separator */ + char *tmp = build_obj_path_name(info->prefix, ""); + add_obj(info->group_table, oinfo.addr, tmp, TRUE); + } /* end else */ /* Find all shared objects */ return(H5Literate(fid, "/", H5_INDEX_NAME, H5_ITER_INC, NULL, find_objs_cb, (void *)info, H5P_DEFAULT)); diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c index 65cca66..58d618d 100644 --- a/tools/lib/h5trav.c +++ b/tools/lib/h5trav.c @@ -171,11 +171,13 @@ traverse_cb(hid_t loc_id, const char *link_name, const H5L_info_t *linfo, is_group = (oinfo.type == H5O_TYPE_GROUP) ? TRUE : FALSE; /* Make 'visit object' callback */ - (*udata->visitor->visit_obj)(link_path, &oinfo, already_visited, udata->visitor->udata); + if(udata->visitor->visit_obj) + (*udata->visitor->visit_obj)(link_path, &oinfo, already_visited, udata->visitor->udata); } /* end if */ else { /* Make 'visit link' callback */ - (*udata->visitor->visit_lnk)(link_path, linfo, udata->visitor->udata); + if(udata->visitor->visit_lnk) + (*udata->visitor->visit_lnk)(link_path, linfo, udata->visitor->udata); } /* end else */ /* Check for group that we haven't visited yet & recurse */ @@ -267,7 +269,7 @@ traverse(hid_t file_id, const trav_visitor_t *visitor) *------------------------------------------------------------------------- */ static void -trav_info_add(trav_info_t *info, const char *path, H5G_obj_t obj_type) +trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type) { size_t idx; /* Index of address to use */ @@ -302,8 +304,8 @@ trav_info_visit_obj(const char *path, const H5O_info_t *oinfo, hbool_t UNUSED already_visited, void *udata) { /* Add the object to the 'info' struct */ - /* (object types map directly to "group" types) */ - trav_info_add((trav_info_t *)udata, path, (H5G_obj_t)oinfo->type); + /* (object types map directly to "traversal" types) */ + trav_info_add((trav_info_t *)udata, path, (h5trav_type_t)oinfo->type); return(0); } /* end trav_info_visit_obj() */ @@ -326,7 +328,7 @@ static int trav_info_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata) { /* Add the link to the 'info' struct */ - trav_info_add((trav_info_t *)udata, path, ((linfo->type == H5L_TYPE_SOFT) ? H5G_LINK : H5G_UDLINK)); + trav_info_add((trav_info_t *)udata, path, ((linfo->type == H5L_TYPE_SOFT) ? H5TRAV_TYPE_LINK : H5TRAV_TYPE_UDLINK)); return(0); } /* end trav_info_visit_lnk() */ @@ -647,7 +649,7 @@ trav_table_add(trav_table_t *table, table->objs[new].objno = oinfo ? oinfo->addr : HADDR_UNDEF; table->objs[new].flags[0] = table->objs[new].flags[1] = 0; table->objs[new].name = (char *)HDstrdup(path); - table->objs[new].type = oinfo ? (H5G_obj_t)oinfo->type : H5G_LINK; + table->objs[new].type = oinfo ? (h5trav_type_t)oinfo->type : H5TRAV_TYPE_LINK; table->objs[new].nlinks = 0; table->objs[new].sizelinks = 0; table->objs[new].links = NULL; @@ -707,7 +709,7 @@ trav_table_addlink(trav_table_t *table, void trav_table_addflags(unsigned *flags, char *name, - H5G_obj_t type, + h5trav_type_t type, trav_table_t *table) { unsigned int new; @@ -715,7 +717,7 @@ void trav_table_addflags(unsigned *flags, if(table->nobjs == table->size) { table->size = MAX(1, table->size * 2); table->objs = (trav_obj_t *)HDrealloc(table->objs, table->size * sizeof(trav_obj_t)); - } + } /* end if */ new = table->nobjs++; table->objs[new].objno = 0; diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h index 4218013..05bc3cb 100644 --- a/tools/lib/h5trav.h +++ b/tools/lib/h5trav.h @@ -19,22 +19,32 @@ #include "hdf5.h" /*------------------------------------------------------------------------- - * public struct to store name and type of an object + * public enum to specify type of an object * the TYPE can be: - * H5G_UNKNOWN = -1, - * H5G_GROUP, Object is a group - * H5G_DATASET, Object is a dataset - * H5G_TYPE, Object is a named data type - * H5G_LINK, Object is a symbolic link + * H5TRAV_TYPE_UNKNOWN = -1, + * H5TRAV_TYPE_GROUP, Object is a group + * H5TRAV_TYPE_DATASET, Object is a dataset + * H5TRAV_TYPE_TYPE, Object is a named datatype + * H5TRAV_TYPE_LINK, Object is a symbolic link + * H5TRAV_TYPE_UDLINK, Object is a user-defined link *------------------------------------------------------------------------- */ +typedef enum { + H5TRAV_TYPE_UNKNOWN = -1, /* Unknown object type */ + H5TRAV_TYPE_GROUP, /* Object is a group */ + H5TRAV_TYPE_DATASET, /* Object is a dataset */ + H5TRAV_TYPE_NAMED_DATATYPE, /* Object is a named datatype */ + H5TRAV_TYPE_LINK, /* Object is a symbolic link */ + H5TRAV_TYPE_UDLINK /* Object is a user-defined link */ +} h5trav_type_t; -typedef H5G_obj_t H5G_obj_t1; - - +/*------------------------------------------------------------------------- + * public struct to store name and type of an object + *------------------------------------------------------------------------- + */ typedef struct trav_path_t { char *path; - H5G_obj_t type; + h5trav_type_t type; } trav_path_t; typedef struct trav_info_t { @@ -59,10 +69,10 @@ typedef struct trav_link_t { */ typedef struct trav_obj_t { - haddr_t objno; /* object number from H5Gget_objinfo */ + haddr_t objno; /* object address */ unsigned flags[2]; /* h5diff.object is present or not in both files*/ char *name; /* name */ - H5G_obj_t type; /* type of object */ + h5trav_type_t type; /* type of object */ trav_link_t *links; /* array of possible link names */ size_t sizelinks; /* size of links array */ size_t nlinks; /* number of links */ @@ -135,9 +145,8 @@ void trav_table_free(trav_table_t *table); void trav_table_addflags(unsigned *flags, char *objname, - H5G_obj_t type, + h5trav_type_t type, trav_table_t *table); #endif /* H5TRAV_H__ */ - diff --git a/tools/lib/ph5diff.h b/tools/lib/ph5diff.h index 8ef59bd..d904095 100644 --- a/tools/lib/ph5diff.h +++ b/tools/lib/ph5diff.h @@ -16,12 +16,7 @@ #ifndef _PH5DIFF_H__ #define _PH5DIFF_H__ -/* use a larger output buffer for Tflops which does not support vsnprintf. */ -#ifdef __PUMAGON__ #define PRINT_DATA_MAX_SIZE 512 -#else -#define PRINT_DATA_MAX_SIZE 512 -#endif #define OUTBUFF_SIZE (PRINT_DATA_MAX_SIZE*4) /* Send from manager to workers */ #define MPI_TAG_ARGS 1 @@ -41,7 +36,7 @@ extern int g_nTasks; extern unsigned char g_Parallel; extern char outBuff[]; extern int outBuffOffset; -extern FILE* overflow_file; +extern FILE * overflow_file; struct diff_args { @@ -60,5 +55,5 @@ struct diffs_found #include <mpi.h> #endif - #endif /* _PH5DIFF_H__ */ + |