diff options
author | Albert Cheng <acheng@hdfgroup.org> | 2005-09-05 20:23:02 (GMT) |
---|---|---|
committer | Albert Cheng <acheng@hdfgroup.org> | 2005-09-05 20:23:02 (GMT) |
commit | c12eeffd9ffbb4547607800daea873508f2c1f00 (patch) | |
tree | cc9a48a131a9a932c551cbc6b9d116f8be12bb79 | |
parent | 1fa5f8bccbbb181069de79de7eae2d9fbca8a34f (diff) | |
download | hdf5-c12eeffd9ffbb4547607800daea873508f2c1f00.zip hdf5-c12eeffd9ffbb4547607800daea873508f2c1f00.tar.gz hdf5-c12eeffd9ffbb4547607800daea873508f2c1f00.tar.bz2 |
[svn-r11349] Purpose:
Bug fix.
Description:
Some tests showed the filesize was not as expected. But the error was
intermittent. This was a racing condition as some processes finish
extend_chunked_dataset() sooner than others and return to the main
body which proceeds to call the next test which also uses the same
test data file and alters it. That messes up the "slower" processes
which then see unexpected filesize.
Also, the routine create_chunked_dataset() which creates test data file
actually was executed by all processes. That is wrong.
Solution:
Added a barrier at the end of extend_chunked_dataset to make sure all
processes are done with the test data file before returning.
Changed create_chunked_dataset such that only one process would create
the test data file. The rest does nothing but just wait for it to finish.
Platforms tested:
Tested in TG-NCSA in which the errors were detected.
Misc. update:
-rw-r--r-- | testpar/t_chunk_alloc.c | 65 |
1 files changed, 40 insertions, 25 deletions
diff --git a/testpar/t_chunk_alloc.c b/testpar/t_chunk_alloc.c index 10f8a9d..0cfa328 100644 --- a/testpar/t_chunk_alloc.c +++ b/testpar/t_chunk_alloc.c @@ -71,31 +71,40 @@ create_chunked_dataset(const char *filename) MPI_Comm_size(MPI_COMM_WORLD,&mpi_size); MPI_Comm_rank(MPI_COMM_WORLD,&mpi_rank); - /* Create the data space with unlimited dimensions. */ - dataspace = H5Screate_simple (1, dims, maxdims); - VRFY((dataspace >= 0), ""); - - /* Create a new file. If file exists its contents will be overwritten. */ - file = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); - VRFY((file >= 0), ""); - - /* Modify dataset creation properties, i.e. enable chunking */ - cparms = H5Pcreate (H5P_DATASET_CREATE); - VRFY((cparms >= 0), ""); - - hrc = H5Pset_chunk ( cparms, 1, chunk_dims); - VRFY((hrc >= 0), ""); - - /* Create a new dataset within the file using cparms creation properties. */ - dataset = H5Dcreate (file, DATASETNAME, H5T_NATIVE_INT, dataspace, cparms); - VRFY((dataset >= 0), ""); - - /* Close resources */ - hrc = H5Dclose (dataset); - VRFY((hrc >= 0), ""); - - hrc = H5Fclose (file); - VRFY((hrc >= 0), ""); + /* Only MAINPROCESS should create the file. Others just wait. */ + if (MAINPROCESS){ + /* Create the data space with unlimited dimensions. */ + dataspace = H5Screate_simple (1, dims, maxdims); + VRFY((dataspace >= 0), ""); + + /* Create a new file. If file exists its contents will be overwritten. */ + file = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + VRFY((file >= 0), ""); + + /* Modify dataset creation properties, i.e. enable chunking */ + cparms = H5Pcreate (H5P_DATASET_CREATE); + VRFY((cparms >= 0), ""); + + hrc = H5Pset_chunk ( cparms, 1, chunk_dims); + VRFY((hrc >= 0), ""); + + /* Create a new dataset within the file using cparms creation properties. */ + dataset = H5Dcreate (file, DATASETNAME, H5T_NATIVE_INT, dataspace, cparms); + VRFY((dataset >= 0), ""); + + /* Close resources */ + hrc = H5Dclose (dataset); + VRFY((hrc >= 0), ""); + + hrc = H5Fclose (file); + VRFY((hrc >= 0), ""); + } + + /* Make sure all processes are done before exiting this routine. Otherwise, + * other tests may start and change the test data file before some processes + * of this test are still accessing the file. + */ + MPI_Barrier(MPI_COMM_WORLD); } /* @@ -160,6 +169,12 @@ extend_chunked_dataset(const char *filename) /* Can close some plists */ hrc = H5Pclose(access_plist); VRFY((hrc >= 0), ""); + + /* Make sure all processes are done before exiting this routine. Otherwise, + * other tests may start and change the test data file before some processes + * of this test are still accessing the file. + */ + MPI_Barrier(MPI_COMM_WORLD); } void |