summaryrefslogtreecommitdiffstats
path: root/tools/h5diff/ph5diff_main.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2011-02-17 21:43:07 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2011-02-17 21:43:07 (GMT)
commit40d2ecb45f317bf2a91fbf937e8cc11c45d9898b (patch)
tree4669d7a1324976383eff561a9f32458fe043a902 /tools/h5diff/ph5diff_main.c
parent264f76847ea696d02465e31c8ced62ca43a11458 (diff)
downloadhdf5-40d2ecb45f317bf2a91fbf937e8cc11c45d9898b.zip
hdf5-40d2ecb45f317bf2a91fbf937e8cc11c45d9898b.tar.gz
hdf5-40d2ecb45f317bf2a91fbf937e8cc11c45d9898b.tar.bz2
[svn-r20119] Description:
Clean up MPI resource leaks in parallel tests, along with a bunch of compiler warnings. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, w/threadsafe, in production mode Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode Mac OS X/32 10.6.6 (amazon) in debug mode Mac OS X/32 10.6.6 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'tools/h5diff/ph5diff_main.c')
-rw-r--r--tools/h5diff/ph5diff_main.c200
1 files changed, 100 insertions, 100 deletions
diff --git a/tools/h5diff/ph5diff_main.c b/tools/h5diff/ph5diff_main.c
index f6b0dba..bac1086 100644
--- a/tools/h5diff/ph5diff_main.c
+++ b/tools/h5diff/ph5diff_main.c
@@ -87,31 +87,34 @@ int main(int argc, const char *argv[])
h5diff(fname1, fname2, objname1, objname2, &options);
print_info(&options);
+ }
+ /* Parallel h5diff */
+ else {
- MPI_Finalize();
+ /* Have the manager process the command-line */
+ if(nID == 0)
+ {
+ parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &options);
- return 0;
- }
+ h5diff(fname1, fname2, objname1, objname2, &options);
- /* Have the manager process the command-line */
- if(nID == 0)
- {
- parse_command_line(argc, argv, &fname1, &fname2, &objname1, &objname2, &options);
+ MPI_Barrier(MPI_COMM_WORLD);
- h5diff(fname1, fname2, objname1, objname2, &options);
+ print_info(&options);
+ print_manager_output();
+ }
+ /* All other tasks become workers and wait for assignments. */
+ else {
+ ph5diff_worker(nID);
- MPI_Barrier(MPI_COMM_WORLD);
+ MPI_Barrier(MPI_COMM_WORLD);
+ } /* end else */
- print_info(&options);
- print_manager_output();
+ } /* end else */
- MPI_Finalize();
+ MPI_Finalize();
- return 0;
- }
- /* All other tasks become workers and wait for assignments. */
- else
- ph5diff_worker(nID);
+ return 0;
}
/*-------------------------------------------------------------------------
@@ -141,107 +144,104 @@ ph5diff_worker(int nID)
int i;
MPI_Status Status;
- MPI_Comm_rank(MPI_COMM_WORLD, &nID);
outBuffOffset = 0;
MPI_Recv(filenames, MAX_FILENAME*2, MPI_CHAR, 0, MPI_ANY_TAG, MPI_COMM_WORLD, &Status);
if(Status.MPI_TAG == MPI_TAG_PARALLEL)
{
- /* disable error reporting */
- H5E_BEGIN_TRY
- {
- /* Open the files */
- if ((file1_id = H5Fopen (filenames[0], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
- {
- printf ("h5diff Task [%d]: <%s>: unable to open file\n", nID, filenames[0]);
- MPI_Abort(MPI_COMM_WORLD, 0);
- }
- if ((file2_id = H5Fopen (filenames[1], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ /* disable error reporting */
+ H5E_BEGIN_TRY
{
- printf ("h5diff Task [%d]: <%s>: unable to open file\n", nID, filenames[1]);
- MPI_Abort(MPI_COMM_WORLD, 0);
+ /* Open the files */
+ if ((file1_id = H5Fopen (filenames[0], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ {
+ printf ("h5diff Task [%d]: <%s>: unable to open file\n", nID, filenames[0]);
+ MPI_Abort(MPI_COMM_WORLD, 0);
+ }
+ if ((file2_id = H5Fopen (filenames[1], H5F_ACC_RDONLY, H5P_DEFAULT)) < 0)
+ {
+ printf ("h5diff Task [%d]: <%s>: unable to open file\n", nID, filenames[1]);
+ MPI_Abort(MPI_COMM_WORLD, 0);
+ }
+ /* enable error reporting */
}
- /* enable error reporting */
- }
- H5E_END_TRY;
+ H5E_END_TRY;
- while(1)
- {
- MPI_Probe(0, MPI_ANY_TAG, MPI_COMM_WORLD, &Status);
-
- if(Status.MPI_TAG == MPI_TAG_ARGS)
+ while(1)
{
- /*Recv parameters for diff from manager task */
- MPI_Recv(&args, sizeof(args), MPI_BYTE, 0, MPI_TAG_ARGS, MPI_COMM_WORLD, &Status);
- /*Do the diff */
- diffs.nfound = diff(file1_id, args.name1, file2_id, args.name2, &(args.options), args.type);
- diffs.not_cmp = args.options.not_cmp;
-
- /*If print buffer has something in it, request print token.*/
- if(outBuffOffset>0)
- {
- MPI_Send(NULL, 0, MPI_BYTE, 0, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD);
- /*Wait for print token. */
- MPI_Recv(NULL, 0, MPI_BYTE, 0, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD, &Status);
-
- /*When get token, send all of our output to the manager task and then return the token */
- for(i=0; i<outBuffOffset; i+=PRINT_DATA_MAX_SIZE)
- MPI_Send(outBuff+i, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD);
-
-
- /* An overflow file exists, so we send it's output to the manager too and then delete it */
- if(overflow_file)
- {
- int tmp;
- memset(out_data, 0, PRINT_DATA_MAX_SIZE);
- i=0;
+ MPI_Probe(0, MPI_ANY_TAG, MPI_COMM_WORLD, &Status);
- rewind(overflow_file);
- while((tmp = getc(overflow_file)) >= 0)
+ if(Status.MPI_TAG == MPI_TAG_ARGS)
{
- *(out_data + i++) = (char)tmp;
- if(i==PRINT_DATA_MAX_SIZE)
+ /*Recv parameters for diff from manager task */
+ MPI_Recv(&args, sizeof(args), MPI_BYTE, 0, MPI_TAG_ARGS, MPI_COMM_WORLD, &Status);
+ /*Do the diff */
+ diffs.nfound = diff(file1_id, args.name1, file2_id, args.name2, &(args.options), args.type);
+ diffs.not_cmp = args.options.not_cmp;
+
+ /*If print buffer has something in it, request print token.*/
+ if(outBuffOffset>0)
{
- MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD);
- i=0;
- memset(out_data, 0, PRINT_DATA_MAX_SIZE);
+ MPI_Send(NULL, 0, MPI_BYTE, 0, MPI_TAG_TOK_REQUEST, MPI_COMM_WORLD);
+ /*Wait for print token. */
+ MPI_Recv(NULL, 0, MPI_BYTE, 0, MPI_TAG_PRINT_TOK, MPI_COMM_WORLD, &Status);
+
+ /*When get token, send all of our output to the manager task and then return the token */
+ for(i=0; i<outBuffOffset; i+=PRINT_DATA_MAX_SIZE)
+ MPI_Send(outBuff+i, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD);
+
+
+ /* An overflow file exists, so we send it's output to the manager too and then delete it */
+ if(overflow_file)
+ {
+ int tmp;
+
+ memset(out_data, 0, PRINT_DATA_MAX_SIZE);
+ i=0;
+
+ rewind(overflow_file);
+ while((tmp = getc(overflow_file)) >= 0)
+ {
+ *(out_data + i++) = (char)tmp;
+ if(i==PRINT_DATA_MAX_SIZE)
+ {
+ MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD);
+ i=0;
+ memset(out_data, 0, PRINT_DATA_MAX_SIZE);
+ }
+ }
+
+ if(i>0)
+ MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD);
+
+ fclose(overflow_file);
+ overflow_file = NULL;
+ }
+
+ fflush(stdout);
+ memset(outBuff, 0, OUTBUFF_SIZE);
+ outBuffOffset = 0;
+
+ MPI_Send(&diffs, sizeof(diffs), MPI_BYTE, 0, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD);
}
+ else
+ MPI_Send(&diffs, sizeof(diffs), MPI_BYTE, 0, MPI_TAG_DONE, MPI_COMM_WORLD);
}
-
- if(i>0)
- MPI_Send(out_data, PRINT_DATA_MAX_SIZE, MPI_BYTE, 0, MPI_TAG_PRINT_DATA, MPI_COMM_WORLD);
-
- fclose(overflow_file);
- overflow_file = NULL;
+ else if(Status.MPI_TAG == MPI_TAG_END)
+ {
+ MPI_Recv(NULL, 0, MPI_BYTE, 0, MPI_TAG_END, MPI_COMM_WORLD, &Status);
+ /* printf("exiting..., task: %d\n", nID);
+ fflush(stdout);*/
+ break;
+ }
+ else
+ {
+ printf("ph5diff_worker: ERROR: invalid tag (%d) received\n", Status.MPI_TAG);
+ MPI_Abort(MPI_COMM_WORLD, 0);
}
- fflush(stdout);
- memset(outBuff, 0, OUTBUFF_SIZE);
- outBuffOffset = 0;
-
- MPI_Send(&diffs, sizeof(diffs), MPI_BYTE, 0, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD);
- }
- else
- MPI_Send(&diffs, sizeof(diffs), MPI_BYTE, 0, MPI_TAG_DONE, MPI_COMM_WORLD);
- }
- else if(Status.MPI_TAG == MPI_TAG_END)
- {
- MPI_Recv(NULL, 0, MPI_BYTE, 0, MPI_TAG_END, MPI_COMM_WORLD, &Status);
- /* printf("exiting..., task: %d\n", nID);
- fflush(stdout);*/
- break;
- }
- else
- {
- printf("ph5diff_worker: ERROR: invalid tag (%d) received\n", Status.MPI_TAG);
- MPI_Abort(MPI_COMM_WORLD, 0);
}
-
- }
}
-
- MPI_Barrier(MPI_COMM_WORLD);
- MPI_Finalize();
}