diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2008-10-21 19:10:01 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2008-10-21 19:10:01 (GMT) |
commit | 27ae4bccfd866a9bf334dc191631499d3cea1b19 (patch) | |
tree | 828abaa9099bc36b176c8440f0d905ae267d5b02 /tools/lib/h5diff.c | |
parent | 22378dbd24c08d7153f4f295b5bca057191edc38 (diff) | |
download | hdf5-27ae4bccfd866a9bf334dc191631499d3cea1b19.zip hdf5-27ae4bccfd866a9bf334dc191631499d3cea1b19.tar.gz hdf5-27ae4bccfd866a9bf334dc191631499d3cea1b19.tar.bz2 |
[svn-r15922] Description:
Bring revisions 15289:15457 from trunk into metadata journaling
branch.
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.5.2 (amazon) in debug mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in production mode
Diffstat (limited to 'tools/lib/h5diff.c')
-rw-r--r-- | tools/lib/h5diff.c | 147 |
1 files changed, 110 insertions, 37 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index 9d64e44..25e5f83 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -347,9 +347,17 @@ out: * * Date: May 9, 2003 * - * Modifications: Jan 2005 Leon Arber, larber@uiuc.edu + * Modifications: + * + * Jan 2005 Leon Arber, larber@uiuc.edu * Added support for parallel diffing * + * Aug 2008 Pedro Vicente, pvn@hdfgroup.org + * Added a "contents" mode check. + * If this mode is present, objects in both files must match (must be exactly the same) + * If this does not happen, the tool returns an error code of 1 + * (instead of the success code of 0) + * *------------------------------------------------------------------------- */ hsize_t diff_match(hid_t file1_id, @@ -373,7 +381,8 @@ hsize_t diff_match(hid_t file1_id, curr1 = 0; curr2 = 0; - while(curr1 < info1->nused && curr2 < info2->nused) { + while(curr1 < info1->nused && curr2 < info2->nused) + { /* criteria is string compare */ int cmp = HDstrcmp(info1->paths[curr1].path, info2->paths[curr2].path); @@ -385,13 +394,15 @@ hsize_t diff_match(hid_t file1_id, curr1++; curr2++; } /* end if */ - else if(cmp < 0) { + 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 { + else + { infile[0] = 0; infile[1] = 1; trav_table_addflags(infile, info2->paths[curr2].path, info2->paths[curr2].type, table); @@ -402,7 +413,8 @@ hsize_t diff_match(hid_t file1_id, /* list1 did not end */ infile[0] = 1; infile[1] = 0; - while(curr1 < info1->nused) { + while(curr1 < info1->nused) + { trav_table_addflags(infile, info1->paths[curr1].path, info1->paths[curr1].type, table); curr1++; } /* end while */ @@ -410,7 +422,8 @@ hsize_t diff_match(hid_t file1_id, /* list2 did not end */ infile[0] = 0; infile[1] = 1; - while(curr2 < info2->nused) { + while(curr2 < info2->nused) + { trav_table_addflags(infile, info2->paths[curr2].path, info2->paths[curr2].type, table); curr2++; } /* end while */ @@ -435,6 +448,35 @@ hsize_t diff_match(hid_t file1_id, } /* end if */ + + /*------------------------------------------------------------------------- + * contents mode. we do an "absolute" compare criteria, the number of objects + * in file1 must be the same as in file2 + *------------------------------------------------------------------------- + */ + if ( options->m_contents ) + { + /* assume equal contents initially */ + options->contents = 1; + + /* number of different objects */ + if ( info1->nused != info2->nused ) + { + options->contents = 0; + } + + + for( i = 0; i < table->nobjs; i++) + { + if( table->objs[i].flags[0] != table->objs[i].flags[1] ) + { + options->contents = 0; + } + } + + } + + /*------------------------------------------------------------------------- * do the diff for common objects *------------------------------------------------------------------------- @@ -453,17 +495,21 @@ hsize_t diff_match(hid_t file1_id, 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) { + 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 - else { + else + { int workerFound = 0; h5diffdebug("beginning of big else block\n"); @@ -476,7 +522,8 @@ hsize_t diff_match(hid_t file1_id, */ /*Set up args to pass to worker task. */ - if(HDstrlen(table->objs[i].name) > 255) { + if(HDstrlen(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 */ @@ -487,14 +534,16 @@ hsize_t diff_match(hid_t file1_id, h5diffdebug2("busyTasks=%d\n", busyTasks); /* if there are any outstanding print requests, let's handle one. */ - if(busyTasks > 0) { + 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) { + 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; @@ -503,7 +552,8 @@ hsize_t diff_match(hid_t file1_id, } /* end if */ /* check to see if the print token was returned. */ - if(!havePrintToken) { + if(!havePrintToken) + { /* If we don't have the token, someone is probably sending us output */ print_incoming_data(); @@ -522,10 +572,12 @@ hsize_t diff_match(hid_t file1_id, } /* end if */ /* check to see if anyone needs the print token. */ - if(havePrintToken) { + 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) { + 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; @@ -536,8 +588,10 @@ hsize_t diff_match(hid_t file1_id, /* 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]) { + 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(args), MPI_BYTE, n, MPI_TAG_ARGS, MPI_COMM_WORLD); @@ -551,20 +605,24 @@ hsize_t diff_match(hid_t file1_id, } /* end for */ h5diffdebug2("workerfound is %d \n", workerFound); - if(!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) { + 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) { + 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; @@ -575,23 +633,27 @@ hsize_t diff_match(hid_t file1_id, } /* 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 { + 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) { + 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(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); } /* end if */ - else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) { + 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 { + do + { MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); print_incoming_data(); @@ -602,7 +664,8 @@ hsize_t diff_match(hid_t file1_id, options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); } /* end else-if */ - else { + else + { printf("ERROR: Invalid tag (%d) received \n", Status.MPI_TAG); MPI_Abort(MPI_COMM_WORLD, 0); MPI_Finalize(); @@ -616,26 +679,32 @@ hsize_t diff_match(hid_t file1_id, h5diffdebug("done with for loop\n"); #ifdef H5_HAVE_PARALLEL - if(g_Parallel) { + if(g_Parallel) + { /* make sure all tasks are done */ - while(busyTasks > 0) { + while(busyTasks > 0) + { MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &Status); - if(Status.MPI_TAG == MPI_TAG_DONE) { + 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) { + 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) { + 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) { + if(havePrintToken) + { int incomingMessage; MPI_Send(NULL, 0, MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD); @@ -652,11 +721,13 @@ hsize_t diff_match(hid_t file1_id, 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 { + else + { int source = Status.MPI_SOURCE; int incomingMessage; - do { + do + { MPI_Iprobe(MPI_ANY_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &incomingMessage, &Status); print_incoming_data(); @@ -670,7 +741,8 @@ hsize_t diff_match(hid_t file1_id, 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) { + 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; @@ -686,7 +758,8 @@ hsize_t diff_match(hid_t file1_id, printf("%s", data); } /* end else-if */ - else { + else + { printf("ph5diff-manager: ERROR!! Invalid tag (%d) received \n", Status.MPI_TAG); MPI_Abort(MPI_COMM_WORLD, 0); } /* end else */ |