summaryrefslogtreecommitdiffstats
path: root/testpar
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2002-08-20 16:18:02 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2002-08-20 16:18:02 (GMT)
commit29da4951f8aa861cc972c48fef03334c47ff0136 (patch)
tree07183a9df7ec5d173943197c69c00b2a9f199470 /testpar
parent45a34cf267b823c6f1b62cce215b38546c18a031 (diff)
downloadhdf5-29da4951f8aa861cc972c48fef03334c47ff0136.zip
hdf5-29da4951f8aa861cc972c48fef03334c47ff0136.tar.gz
hdf5-29da4951f8aa861cc972c48fef03334c47ff0136.tar.bz2
[svn-r5879]
Purpose: Design for compact dataset Description: Compact dataset is stored in the header message for dataset layout. Platforms tested: arabica, eirene.
Diffstat (limited to 'testpar')
-rw-r--r--testpar/t_mdset.c111
-rw-r--r--testpar/testphdf5.c21
2 files changed, 128 insertions, 4 deletions
diff --git a/testpar/t_mdset.c b/testpar/t_mdset.c
index 0a97e5e..c03de3c 100644
--- a/testpar/t_mdset.c
+++ b/testpar/t_mdset.c
@@ -80,6 +80,117 @@ void multiple_dset_write(char *filename, int ndatasets)
H5Fclose (iof);
}
+/* Example of using PHDF5 to create, write, and read compact dataset.
+ * Hyperslab is prohibited for write.
+ */
+void compact_dataset(char *filename)
+{
+ int i, j, n, mpi_size, mpi_rank, err_num=0;
+ hid_t iof, plist, dcpl, dxpl, dataset, memspace, filespace;
+ hssize_t chunk_origin [DIM];
+ hsize_t chunk_dims [DIM], file_dims [DIM];
+ hsize_t count[DIM]={1,1};
+ double outme [SIZE][SIZE], inme[SIZE][SIZE];
+ char dname[]="dataset";
+ herr_t ret;
+
+ MPI_Comm_rank (MPI_COMM_WORLD, &mpi_rank);
+ MPI_Comm_size (MPI_COMM_WORLD, &mpi_size);
+
+ VRFY((mpi_size <= SIZE), "mpi_size <= SIZE");
+
+ chunk_origin [0] = mpi_rank * (SIZE / mpi_size);
+ chunk_origin [1] = 0;
+ chunk_dims [0] = SIZE / mpi_size;
+ chunk_dims [1] = SIZE;
+
+ for (i = 0; i < DIM; i++)
+ file_dims [i] = SIZE;
+
+ plist = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type);
+ iof = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist);
+
+ /* Define data space */
+ memspace = H5Screate_simple (DIM, chunk_dims, NULL);
+ filespace = H5Screate_simple (DIM, file_dims, NULL);
+
+ /* Create a compact dataset */
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ VRFY((dcpl>=0), "dataset creation property list succeeded");
+ ret=H5Pset_layout(dcpl, H5D_COMPACT);
+ VRFY((dcpl >= 0), "set property list for compact dataset");
+ ret=H5Pset_space_time(dcpl, H5D_SPACE_ALLOC_EARLY);
+ VRFY((ret >= 0), "set space allocation time for compact dataset");
+
+ dataset = H5Dcreate (iof, dname, H5T_NATIVE_DOUBLE, filespace, dcpl);
+ VRFY((dataset >= 0), "H5Dcreate succeeded");
+
+ /* Define hyperslab */
+ ret = H5Sselect_hyperslab (filespace, H5S_SELECT_SET, chunk_origin, chunk_dims, count, chunk_dims);
+ VRFY((ret>=0), "mdata hyperslab selection");
+
+ /* set up the collective transfer properties list */
+ dxpl = H5Pcreate (H5P_DATASET_XFER);
+ VRFY((dxpl >= 0), "");
+ ret=H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE);
+ VRFY((ret >= 0), "H5Pcreate xfer succeeded");
+
+ /* calculate data to write */
+ for (i = 0; i < SIZE; i++)
+ for (j = 0; j < SIZE; j++)
+ outme [i][j] = (i+j)*1000 + mpi_rank;
+
+ /* Test hyperslab writing. Supposed to fail */
+ H5E_BEGIN_TRY {
+ ret=H5Dwrite(dataset, H5T_NATIVE_DOUBLE, memspace, filespace, dxpl, outme);
+ } H5E_END_TRY;
+ VRFY((ret < 0), "H5Dwrite hyperslab write failed as expected");
+
+ /* Recalculate data to write. Each process writes the same data. */
+ for (i = 0; i < SIZE; i++)
+ for (j = 0; j < SIZE; j++)
+ outme [i][j] = (i+j)*1000;
+
+ ret=H5Dwrite (dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, dxpl, outme);
+ VRFY((ret >= 0), "H5Dwrite succeeded");
+
+ H5Pclose (dcpl);
+ H5Pclose (plist);
+ H5Dclose (dataset);
+ H5Sclose (filespace);
+ H5Sclose (memspace);
+ H5Fclose (iof);
+
+ /* Open the file and dataset, read and compare the data. */
+ plist = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type);
+ iof = H5Fopen(filename, H5F_ACC_RDONLY, plist);
+ VRFY((iof >= 0), "H5Fopen succeeded");
+
+ /* set up the collective transfer properties list */
+ dxpl = H5Pcreate (H5P_DATASET_XFER);
+ VRFY((dxpl >= 0), "");
+ ret=H5Pset_dxpl_mpio(dxpl, H5FD_MPIO_COLLECTIVE);
+ VRFY((ret >= 0), "H5Pcreate xfer succeeded");
+
+ dataset = H5Dopen(iof, dname);
+ VRFY((dataset >= 0), "H5Dcreate succeeded");
+
+ ret = H5Dread(dataset, H5T_NATIVE_DOUBLE, H5S_ALL, H5S_ALL, dxpl, inme);
+ VRFY((ret >= 0), "H5Dread succeeded");
+
+ /* Verify data value */
+ for (i = 0; i < SIZE; i++)
+ for (j = 0; j < SIZE; j++)
+ if(inme[i][j] != outme[i][j])
+ if(err_num++ < MAX_ERR_REPORT || verbose)
+ printf("Dataset Verify failed at [%d][%d]: expect %f, got %f\n", i, j, outme[i][j], inme[i][j]);
+
+ H5Pclose(plist);
+ H5Pclose(dxpl);
+ H5Dclose(dataset);
+ H5Fclose(iof);
+}
+
/*
* Example of using PHDF5 to create multiple groups. Under the root group,
* it creates ngroups groups. Under the first group just created, it creates
diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c
index b650e00..95fe93c 100644
--- a/testpar/testphdf5.c
+++ b/testpar/testphdf5.c
@@ -28,15 +28,17 @@ void *old_client_data; /* previous error handler arg.*/
/* other option flags */
int doread=1; /* read test */
int dowrite=1; /* write test */
+int docompact=1; /* compact dataset test */
/* FILENAME and filenames must have the same number of names */
-const char *FILENAME[6]={
+const char *FILENAME[7]={
"ParaEg1",
"ParaEg2",
"ParaEg3",
"ParaMdset",
"ParaMgroup",
+ "ParaCompact",
NULL};
-char filenames[6][PATH_MAX];
+char filenames[7][PATH_MAX];
hid_t fapl; /* file access property list */
#ifdef USE_PAUSE
@@ -97,13 +99,14 @@ static void
usage(void)
{
printf("Usage: testphdf5 [-r] [-w] [-v] [-m<n_datasets>] [-n<n_groups>] "
- "[-f <prefix>] [-d <dim0> <dim1>]\n");
+ "[-o] [-f <prefix>] [-d <dim0> <dim1>]\n");
printf("\t-r\t\tno read test\n");
printf("\t-w\t\tno write test\n");
printf("\t-m<n_datasets>"
"\tset number of datasets for the multiple dataset test\n");
printf("\t-n<n_groups>"
"\tset number of groups for the multiple group test\n");
+ printf("\t-o\t\tno compact dataset test\n");
printf("\t-v\t\tverbose on\n");
printf("\t-f <prefix>\tfilename prefix\n");
printf("\t-s\t\tuse Split-file together with MPIO\n");
@@ -152,6 +155,8 @@ parse_options(int argc, char **argv)
return(1);
}
break;
+ case 'o': docompact = 0;
+ break;
case 'v': verbose = 1;
break;
case 'f': if (--argc < 1) {
@@ -380,7 +385,15 @@ int main(int argc, char **argv)
MPI_BANNER("read tests skipped");
}
- if (!(dowrite || doread || ndatasets || ngroups)){
+ if (docompact){
+ MPI_BANNER("compact dataset test...");
+ compact_dataset(filenames[5]);
+ }
+ else {
+ MPI_BANNER("compact dataset test skipped");
+ }
+
+ if (!(dowrite || doread || ndatasets || ngroups || docompact)){
usage();
nerrors++;
}