summaryrefslogtreecommitdiffstats
path: root/testpar/t_mdset.c
diff options
context:
space:
mode:
Diffstat (limited to 'testpar/t_mdset.c')
-rw-r--r--testpar/t_mdset.c101
1 files changed, 71 insertions, 30 deletions
diff --git a/testpar/t_mdset.c b/testpar/t_mdset.c
index 11f81af..9b4bfd1 100644
--- a/testpar/t_mdset.c
+++ b/testpar/t_mdset.c
@@ -306,11 +306,11 @@ void big_dataset(const char *filename)
VRFY((ret >= 0), "H5Pclose succeeded");
}
-/* Example of using PHDF5 to read "short" datasets. These datasets don't have
- * actual data written to the entire raw data area and rely on the "fill with
- * zeros" code in the VFL driver read routine to work correctly.
+/* Example of using PHDF5 to read a partial written dataset. The dataset does
+ * not have actual data written to the entire raw data area and relies on the
+ * default fill value of zeros to work correctly.
*/
-void short_dataset(const char *filename)
+void dataset_fillvalue(const char *filename)
{
int mpi_size, mpi_rank; /* MPI info */
hbool_t use_gpfs = FALSE; /* Don't use GPFS stuff for this test */
@@ -322,11 +322,12 @@ void short_dataset(const char *filename)
memspace, /* Memory dataspace ID */
filespace; /* Dataset's dataspace ID */
char dname[]="dataset"; /* Name of dataset */
- hsize_t dset_size[4] = {0, 6, 7, 8};
+ hsize_t dset_dims[4] = {0, 6, 7, 8};
hssize_t req_start[4] = {0, 0, 0, 0};
hsize_t req_count[4] = {1, 6, 7, 8};
+ hsize_t dset_size; /* Dataset size */
int *rdata, *wdata; /* Buffers for data to read and write */
- int *tdata, *tdata2; /* Temporary pointer into buffer */
+ int *twdata, *trdata; /* Temporary pointer into buffer */
int acc, i, j, k, l; /* Local index variables */
herr_t ret; /* Generic return value */
@@ -335,22 +336,17 @@ void short_dataset(const char *filename)
VRFY((mpi_size <= SIZE), "mpi_size <= SIZE");
+ /* Set the dataset dimension to be one row more than number of processes */
+ /* and calculate the actual dataset size. */
+ dset_dims[0]=mpi_size+1;
+ dset_size=dset_dims[0]*dset_dims[1]*dset_dims[2]*dset_dims[3];
+
/* Allocate space for the buffers */
- dset_size[0]=mpi_size+1;
- rdata=HDmalloc((size_t)(dset_size[0]*dset_size[1]*dset_size[2]*dset_size[3]*sizeof(int)));
+ rdata=HDmalloc((size_t)(dset_size*sizeof(int)));
VRFY((rdata != NULL), "HDcalloc succeeded for read buffer");
- wdata=HDmalloc((size_t)(dset_size[0]*dset_size[1]*dset_size[2]*dset_size[3]*sizeof(int)));
+ wdata=HDmalloc((size_t)(dset_size*sizeof(int)));
VRFY((wdata != NULL), "HDmalloc succeeded for write buffer");
- /* Initialize write buffer */
- HDmemset(rdata,2,(size_t)(dset_size[0]*dset_size[1]*dset_size[2]*dset_size[3]*sizeof(int)));
- tdata=wdata;
- for (i=0, acc=0; i<(int)dset_size[0]; i++)
- for (j=0; j<(int)dset_size[1]; j++)
- for (k=0; k<(int)dset_size[2]; k++)
- for (l=0; l<(int)dset_size[3]; l++)
- *tdata++ = acc++;
-
fapl = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type, use_gpfs);
VRFY((fapl >= 0), "create_faccess_plist succeeded");
@@ -360,15 +356,47 @@ void short_dataset(const char *filename)
iof = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl);
VRFY((iof >= 0), "H5Fcreate succeeded");
- filespace = H5Screate_simple(4, dset_size, NULL);
+ filespace = H5Screate_simple(4, dset_dims, NULL);
VRFY((filespace >= 0), "File H5Screate_simple succeeded");
dataset = H5Dcreate(iof, dname, H5T_NATIVE_INT, filespace, H5P_DEFAULT);
VRFY((dataset >= 0), "H5Dcreate succeeded");
- memspace = H5Screate_simple(4, dset_size, NULL);
+ memspace = H5Screate_simple(4, dset_dims, NULL);
VRFY((memspace >= 0), "Memory H5Screate_simple succeeded");
+ /*
+ * Read dataset before any data is written.
+ */
+ /* set entire read buffer with the constant 2 */
+ HDmemset(rdata,2,(size_t)(dset_size*sizeof(int)));
+ /* Independently read the entire dataset back */
+ ret=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
+ VRFY((ret >= 0), "H5Dread succeeded");
+
+ /* Verify all data read are the fill value 0 */
+ trdata=rdata;
+ err_num=0;
+ for (i=0; i<(int)dset_dims[0]; i++)
+ for (j=0; j<(int)dset_dims[1]; j++)
+ for (k=0; k<(int)dset_dims[2]; k++)
+ for (l=0; l<(int)dset_dims[3]; l++, twdata++, trdata++)
+ if( *trdata != 0)
+ if(err_num++ < MAX_ERR_REPORT || verbose)
+ printf("Dataset Verify failed at [%d][%d][%d][%d]: expect 0, got %d\n", i,j,k,l, *trdata);
+ if(err_num > MAX_ERR_REPORT && !verbose)
+ printf("[more errors ...]\n");
+ if(err_num){
+ printf("%d errors found in check_value\n", err_num);
+ nerrors++;
+ }
+
+ /* Barrier to ensure all processes have completed the above test. */
+ MPI_Barrier(MPI_COMM_WORLD);
+
+ /*
+ * Each process writes 1 row of data. Thus last row is not written.
+ */
/* Create hyperslabs in memory and file dataspaces */
req_start[0]=mpi_rank;
ret=H5Sselect_hyperslab(filespace, H5S_SELECT_SET, req_start, NULL, req_count, NULL);
@@ -383,6 +411,14 @@ void short_dataset(const char *filename)
ret=H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE);
VRFY((ret >= 0), "H5Pset_dxpl_mpio succeeded");
+ /* Fill write buffer with some values */
+ twdata=wdata;
+ for (i=0, acc=0; i<(int)dset_dims[0]; i++)
+ for (j=0; j<(int)dset_dims[1]; j++)
+ for (k=0; k<(int)dset_dims[2]; k++)
+ for (l=0; l<(int)dset_dims[3]; l++)
+ *twdata++ = acc++;
+
/* Collectively write a hyperslab of data to the dataset */
ret=H5Dwrite(dataset, H5T_NATIVE_INT, memspace, filespace, dxpl, wdata);
VRFY((ret >= 0), "H5Dwrite succeeded");
@@ -390,27 +426,32 @@ void short_dataset(const char *filename)
/* Barrier here, to allow MPI-posix I/O to sync */
MPI_Barrier(MPI_COMM_WORLD);
+ /*
+ * Read dataset after partial write.
+ */
+ /* set entire read buffer with the constant 2 */
+ HDmemset(rdata,2,(size_t)(dset_size*sizeof(int)));
/* Independently read the entire dataset back */
ret=H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rdata);
VRFY((ret >= 0), "H5Dread succeeded");
/* Verify correct data read */
- tdata=wdata;
- tdata2=rdata;
+ twdata=wdata;
+ trdata=rdata;
err_num=0;
- for (i=0; i<(int)dset_size[0]; i++)
- for (j=0; j<(int)dset_size[1]; j++)
- for (k=0; k<(int)dset_size[2]; k++)
- for (l=0; l<(int)dset_size[3]; l++, tdata++, tdata2++)
+ for (i=0; i<(int)dset_dims[0]; i++)
+ for (j=0; j<(int)dset_dims[1]; j++)
+ for (k=0; k<(int)dset_dims[2]; k++)
+ for (l=0; l<(int)dset_dims[3]; l++, twdata++, trdata++)
if(i<mpi_size) {
- if( *tdata != *tdata2 )
+ if( *twdata != *trdata )
if(err_num++ < MAX_ERR_REPORT || verbose)
- printf("Dataset Verify failed at [%d][%d][%d][%d]: expect %d, got %d\n", i,j,k,l, *tdata, *tdata2);
+ printf("Dataset Verify failed at [%d][%d][%d][%d]: expect %d, got %d\n", i,j,k,l, *twdata, *trdata);
} /* end if */
else {
- if( *tdata2 != 0)
+ if( *trdata != 0)
if(err_num++ < MAX_ERR_REPORT || verbose)
- printf("Dataset Verify failed at [%d][%d][%d][%d]: expect 0, got %d\n", i,j,k,l, *tdata2);
+ printf("Dataset Verify failed at [%d][%d][%d][%d]: expect 0, got %d\n", i,j,k,l, *trdata);
} /* end else */
if(err_num > MAX_ERR_REPORT && !verbose)
printf("[more errors ...]\n");