summaryrefslogtreecommitdiffstats
path: root/testpar
diff options
context:
space:
mode:
Diffstat (limited to 'testpar')
-rw-r--r--testpar/t_chunk_alloc.c131
1 files changed, 42 insertions, 89 deletions
diff --git a/testpar/t_chunk_alloc.c b/testpar/t_chunk_alloc.c
index 92fdd58..7186099 100644
--- a/testpar/t_chunk_alloc.c
+++ b/testpar/t_chunk_alloc.c
@@ -49,7 +49,7 @@ get_filesize(const char *filename)
return(filesize);
}
-typedef enum write_ {
+typedef enum write_pattern {
none,
sec_last,
all
@@ -68,7 +68,7 @@ typedef enum access_ {
* routine will open this in parallel for extension test.
*/
void
-create_chunked_dataset(const char *filename, int nchunks, write_type write)
+create_chunked_dataset(const char *filename, int nchunks, write_type write_pattern)
{
hid_t file_id, dataset; /* handles */
hid_t dataspace,memspace;
@@ -106,7 +106,8 @@ create_chunked_dataset(const char *filename, int nchunks, write_type write)
VRFY((memspace >= 0), "");
/* Create a new file. If file exists its contents will be overwritten. */
- file_id = H5Fcreate (h5_rmprefix(filename), H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ file_id = H5Fcreate(h5_rmprefix(filename), H5F_ACC_TRUNC, H5P_DEFAULT,
+ H5P_DEFAULT);
VRFY((file_id >= 0), "H5Fcreate");
/* Modify dataset creation properties, i.e. enable chunking */
@@ -123,7 +124,7 @@ create_chunked_dataset(const char *filename, int nchunks, write_type write)
dataset = H5Dcreate (file_id, DATASETNAME, H5T_NATIVE_UCHAR, dataspace, cparms);
VRFY((dataset >= 0), "");
- switch (write) {
+ switch (write_pattern) {
/* writes only the second to last chunk */
case sec_last:
@@ -251,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);
+ 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];
- 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];
+ 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;
@@ -336,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 */
@@ -393,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++){
+ /* 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);
- 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), "");
@@ -416,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++)
@@ -430,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), "");