diff options
Diffstat (limited to 'testpar')
-rw-r--r-- | testpar/t_chunk_alloc.c | 124 |
1 files changed, 38 insertions, 86 deletions
diff --git a/testpar/t_chunk_alloc.c b/testpar/t_chunk_alloc.c index 31846b9..6c857eb 100644 --- a/testpar/t_chunk_alloc.c +++ b/testpar/t_chunk_alloc.c @@ -252,40 +252,22 @@ parallel_access_dataset(const char *filename, int nchunks, access_type action, h /* all chunks are written by all the processes in an interleaved way*/ case write_all: - for (i=0; i<nchunks/mpi_size; i++){ - - memset(buffer, mpi_rank+1, CHUNKSIZE); - - offset[0] = (i*mpi_size+mpi_rank)*chunk_dims[0]; - count[0] = 1; - stride[0] = 1; - block[0] = chunk_dims[0]; - - hrc = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, offset, stride, count, block); - VRFY((hrc >= 0), ""); - - /* Write the buffer out */ - hrc = H5Dwrite(*dataset, H5T_NATIVE_UCHAR, memspace, dataspace, H5P_DEFAULT, buffer); - VRFY((hrc >= 0), "H5Dwrite"); - - } - - /* remainder writing */ - if (mpi_rank < nchunks%mpi_size){ - - memset(buffer, mpi_rank+1, CHUNKSIZE); - - offset[0] = ((nchunks/mpi_size)*mpi_size+mpi_rank)*chunk_dims[0]; - count[0] = 1; - stride[0] = 1; - block[0] = chunk_dims[0]; + memset(buffer, mpi_rank+1, CHUNKSIZE); + count[0] = 1; + stride[0] = 1; + block[0] = chunk_dims[0]; + for (i=0; i<(nchunks+mpi_size-1)/mpi_size; i++){ + if (i*mpi_size+mpi_rank < nchunks){ + offset[0] = (i*mpi_size+mpi_rank)*chunk_dims[0]; + + hrc = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, offset, stride, count, block); + VRFY((hrc >= 0), ""); - hrc = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, offset, stride, count, block); - VRFY((hrc >= 0), ""); + /* Write the buffer out */ + hrc = H5Dwrite(*dataset, H5T_NATIVE_UCHAR, memspace, dataspace, H5P_DEFAULT, buffer); + VRFY((hrc >= 0), "H5Dwrite"); + } - /* Write the buffer out */ - hrc = H5Dwrite(*dataset, H5T_NATIVE_UCHAR, memspace, dataspace, H5P_DEFAULT, buffer); - VRFY((hrc >= 0), "H5Dwrite"); } break; @@ -337,13 +319,13 @@ parallel_access_dataset(const char *filename, int nchunks, access_type action, h /* * This routine verifies the data written in the dataset. It does one of the - * three cases according to the value of parameter `write'. + * three cases according to the value of parameter `write_pattern'. * 1. it returns correct fill values though the dataset has not been written; * 2. it still returns correct fill values though only a small part is written; * 3. it returns correct values when the whole dataset has been written in an * interleaved pattern. */ -void verify_data(const char *filename, int nchunks, write_type write, int close, hid_t *file_id, hid_t *dataset) +void verify_data(const char *filename, int nchunks, write_type write_pattern, int close, hid_t *file_id, hid_t *dataset) { /* HDF5 gubbins */ hid_t dataspace, memspace; /* HDF5 file identifier */ @@ -394,21 +376,15 @@ void verify_data(const char *filename, int nchunks, write_type write, int close, dataspace = H5Dget_space(*dataset); VRFY((dataspace >= 0), ""); - /* expected value in the dataset */ - if (write == all) - value = mpi_rank + 1; - else - value =0; - - /* checks main portion of the dataset */ - for (i=0; i<nchunks/mpi_size; i++){ - - memset(buffer, -1, CHUNKSIZE); + /* all processes check all chunks. */ + count[0] = 1; + stride[0] = 1; + block[0] = chunk_dims[0]; + for (i=0; i<nchunks; i++){ + /* reset buffer values */ + memset(buffer, -1, CHUNKSIZE); - offset[0] = (i*mpi_size+mpi_rank)*chunk_dims[0]; - count[0] = 1; - stride[0] = 1; - block[0] = chunk_dims[0]; + offset[0] = i*chunk_dims[0]; hrc = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, offset, stride, count, block); VRFY((hrc >= 0), ""); @@ -417,13 +393,20 @@ void verify_data(const char *filename, int nchunks, write_type write, int close, hrc = H5Dread(*dataset, H5T_NATIVE_UCHAR, memspace, dataspace, H5P_DEFAULT, buffer); VRFY((hrc >= 0), "H5Dread"); - /* adjust expected value for sec_last chunk */ - if (i == nchunks/mpi_size-1 && !(nchunks%mpi_size) && write==sec_last){ - if (mpi_rank == mpi_size-2) - value = 100; - else - value = 0; - } + /* set expected value according the write pattern */ + switch (write_pattern) { + case all: + value = i%mpi_size + 1; + break; + case none: + value = 0; + break; + case sec_last: + if (i==(nchunks-2)) + value = 100; + else + value = 0; + } /* verify content of the chunk */ for (index = 0; index < CHUNKSIZE; index++) @@ -431,37 +414,6 @@ void verify_data(const char *filename, int nchunks, write_type write, int close, } - /* remainder checking */ - if (mpi_rank < nchunks%mpi_size){ - - memset(buffer, -1, CHUNKSIZE); - - offset[0] = ((nchunks/mpi_size)*mpi_size+mpi_rank)*chunk_dims[0]; - count[0] = 1; - stride[0] = 1; - block[0] = chunk_dims[0]; - - hrc = H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, offset, stride, count, block); - VRFY((hrc >= 0), ""); - - /* read the buffer out */ - hrc = H5Dread(*dataset, H5T_NATIVE_UCHAR, memspace, dataspace, H5P_DEFAULT, buffer); - VRFY((hrc >= 0), "H5Dread"); - - /* adjust expected value for sec_last chunk */ - if (write == sec_last){ - if (mpi_rank == nchunks%mpi_size-2) - value = 100; - else - value = 0; - } - - /* verify content of the chunk */ - for (index = 0; index < CHUNKSIZE; index++) - VRFY((buffer[index] == value), "data verification"); - - } - hrc = H5Sclose (dataspace); VRFY((hrc >= 0), ""); |