summaryrefslogtreecommitdiffstats
path: root/testpar
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2003-02-18 21:50:42 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2003-02-18 21:50:42 (GMT)
commit941509ab25e444f4e66f0f9d7e355e1ecef9b245 (patch)
treef9036787cf306f868242a2e22cf0839d8588f86f /testpar
parente384b7fa03c02475f23f1d4cd67011cd45de32d1 (diff)
downloadhdf5-941509ab25e444f4e66f0f9d7e355e1ecef9b245.zip
hdf5-941509ab25e444f4e66f0f9d7e355e1ecef9b245.tar.gz
hdf5-941509ab25e444f4e66f0f9d7e355e1ecef9b245.tar.bz2
[svn-r6419]
Purpose: More test. Description: Test independent read of groups and chunked dataset. Solution: This test is similar to multiple group test. So just add it in the testphdf5.c,h. Platforms tested: modi4, eirene.
Diffstat (limited to 'testpar')
-rw-r--r--testpar/t_mdset.c147
-rw-r--r--testpar/testphdf5.c22
-rw-r--r--testpar/testphdf5.h2
3 files changed, 169 insertions, 2 deletions
diff --git a/testpar/t_mdset.c b/testpar/t_mdset.c
index dae0e0f..e3ef984 100644
--- a/testpar/t_mdset.c
+++ b/testpar/t_mdset.c
@@ -12,6 +12,7 @@ void write_dataset(hid_t, hid_t, hid_t);
int read_dataset(hid_t, hid_t, hid_t);
void create_group_recursive(hid_t, hid_t, hid_t, int);
void recursive_read_group(hid_t, hid_t, hid_t, int);
+void group_dataset_read(hid_t fid, int mpi_rank, int mpi_size, int m);
void write_attribute(hid_t, int, int);
int read_attribute(hid_t, int, int);
int check_value(DATATYPE *, DATATYPE *);
@@ -201,6 +202,152 @@ void compact_dataset(char *filename)
H5Fclose(iof);
}
+/* Write multiple groups with a chunked dataset in each group collectively.
+ * These groups and datasets are for testing independent read later.
+ */
+void collective_group_write(char *filename, int ngroups)
+{
+ int mpi_rank, mpi_size;
+ int i, j, m;
+ char gname[64], dname[32];
+ hid_t fid, gid, did, plist, dcpl, memspace, filespace;
+ DATATYPE outme[SIZE][SIZE];
+ hssize_t chunk_origin[DIM];
+ hsize_t chunk_dims[DIM], file_dims[DIM], count[DIM];
+ const hsize_t chunk_size[2] = {SIZE/2, SIZE/2}; /* Chunk dimensions */
+ herr_t ret1, ret2;
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
+
+ plist = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type);
+ fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, plist);
+ H5Pclose(plist);
+
+ /* decide the hyperslab according to process number. */
+ get_slab(chunk_origin, chunk_dims, count, file_dims);
+
+ /* select hyperslab in memory and file spaces. These two operations are
+ * identical since the datasets are the same. */
+ memspace = H5Screate_simple(DIM, file_dims, NULL);
+ ret1 = H5Sselect_hyperslab(memspace, H5S_SELECT_SET, chunk_origin,
+ chunk_dims, count, chunk_dims);
+ filespace = H5Screate_simple(DIM, file_dims, NULL);
+ ret2 = H5Sselect_hyperslab(filespace, H5S_SELECT_SET, chunk_origin,
+ chunk_dims, count, chunk_dims);
+ VRFY((memspace>=0), "memspace");
+ VRFY((filespace>=0), "filespace");
+ VRFY((ret1>=0), "mgroup memspace selection");
+ VRFY((ret2>=0), "mgroup filespace selection");
+
+ dcpl = H5Pcreate(H5P_DATASET_CREATE);
+ ret1 = H5Pset_chunk (dcpl, 2, chunk_size);
+ VRFY((dcpl>=0), "dataset creation property");
+ VRFY((ret1>=0), "set chunk for dataset creation property");
+
+ /* creates ngroups groups under the root group, writes chunked
+ * datasets in parallel. */
+ for(m = 0; m < ngroups; m++) {
+ sprintf(gname, "group%d", m);
+ gid = H5Gcreate(fid, gname, 0);
+ VRFY((gid > 0), gname);
+
+ sprintf(dname, "dataset%d", m);
+ did = H5Dcreate(gid, dname, H5T_NATIVE_INT, filespace, dcpl);
+ VRFY((did > 0), dname);
+
+ for(i=0; i < SIZE; i++)
+ for(j=0; j < SIZE; j++)
+ outme[i][j] = (i+j)*1000 + mpi_rank;
+
+ H5Dwrite(did, H5T_NATIVE_INT, memspace, filespace, H5P_DEFAULT,
+ outme);
+
+ H5Dclose(did);
+ H5Gclose(gid);
+
+#ifdef BARRIER_CHECKS
+ if(! ((m+1) % 10)) {
+ printf("created %d groups\n", m+1);
+ MPI_Barrier(MPI_COMM_WORLD);
+ }
+#endif /* BARRIER_CHECKS */
+ }
+
+ H5Pclose(dcpl);
+ H5Sclose(filespace);
+ H5Sclose(memspace);
+ H5Fclose(fid);
+}
+
+/* Let two sets of processes open and read different groups and chunked
+ * datasets independently.
+ */
+void independent_group_read(char *filename, int ngroups)
+{
+ int mpi_rank, mpi_size, m;
+ hid_t plist, fid;
+
+ MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
+ MPI_Comm_size(MPI_COMM_WORLD, &mpi_size);
+
+ plist = create_faccess_plist(MPI_COMM_WORLD, MPI_INFO_NULL, facc_type);
+ fid = H5Fopen(filename, H5F_ACC_RDONLY, plist);
+ H5Pclose(plist);
+
+ /* open groups and read datasets. Odd number processes read even number
+ * groups from the end; even number processes read odd number groups
+ * from the beginning. */
+ if(mpi_rank%2==0) {
+ for(m=ngroups-1; m==0; m-=2)
+ group_dataset_read(fid, mpi_rank, mpi_size, m);
+ } else {
+ for(m=0; m<ngroups; m+=2)
+ group_dataset_read(fid, mpi_rank, mpi_size, m);
+ }
+
+ H5Fclose(fid);
+}
+
+/* Open and read datasets and compare data */
+void group_dataset_read(hid_t fid, int mpi_rank, int mpi_size, int m)
+{
+ int ret, i, j;
+ char gname[64], dname[32];
+ hid_t gid, did;
+ DATATYPE *outdata, *indata;
+
+ indata = (DATATYPE*)malloc(SIZE*SIZE*sizeof(DATATYPE));
+ outdata = (DATATYPE*)malloc(SIZE*SIZE*sizeof(DATATYPE));
+
+ /* open every group under root group. */
+ sprintf(gname, "group%d", m);
+ gid = H5Gopen(fid, gname);
+ VRFY((gid > 0), gname);
+
+ /* check the data. */
+ sprintf(dname, "dataset%d", m);
+ did = H5Dopen(gid, dname);
+ VRFY((did>0), dname);
+
+ H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, indata);
+
+ /* this is the original value */
+ for(i=0; i<SIZE; i++)
+ for(j=0; j<SIZE; j++) {
+ *outdata = (i+j)*1000 + mpi_rank;
+ outdata++;
+ }
+ outdata -= SIZE*SIZE;
+
+ /* compare the original value(outdata) to the value in file(indata).*/
+ ret = check_value(indata, outdata);
+ VRFY((ret==0), "check the data");
+
+ H5Dclose(did);
+ H5Gclose(gid);
+}
+
/*
* 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 95dbf03..ea41e93 100644
--- a/testpar/testphdf5.c
+++ b/testpar/testphdf5.c
@@ -29,16 +29,19 @@ void *old_client_data; /* previous error handler arg.*/
int doread=1; /* read test */
int dowrite=1; /* write test */
int docompact=1; /* compact dataset test */
+int doindependent=1; /* independent test */
+
/* FILENAME and filenames must have the same number of names */
-const char *FILENAME[7]={
+const char *FILENAME[8]={
"ParaEg1",
"ParaEg2",
"ParaEg3",
"ParaMdset",
"ParaMgroup",
"ParaCompact",
+ "ParaIndividual",
NULL};
-char filenames[7][PATH_MAX];
+char filenames[8][PATH_MAX];
hid_t fapl; /* file access property list */
#ifdef USE_PAUSE
@@ -107,6 +110,7 @@ usage(void)
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-i\t\tno independent read 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");
@@ -157,6 +161,8 @@ parse_options(int argc, char **argv)
break;
case 'o': docompact = 0;
break;
+ case 'i': doindependent = 0;
+ break;
case 'v': verbose = 1;
break;
case 'f': if (--argc < 1) {
@@ -392,6 +398,18 @@ int main(int argc, char **argv)
else {
MPI_BANNER("compact dataset test skipped");
}
+
+ if (doindependent){
+ MPI_BANNER("collective group and dataset write ...");
+ collective_group_write(filenames[6], ngroups);
+ if (doread) {
+ MPI_BANNER("indepenent group and dataset read ...");
+ independent_group_read(filenames[6], ngroups);
+ }
+ }
+ else{
+ MPI_BANNER("Independent test skipped");
+ }
if (!(dowrite || doread || ndatasets || ngroups || docompact)){
usage();
diff --git a/testpar/testphdf5.h b/testpar/testphdf5.h
index 57d6112..53ea52e 100644
--- a/testpar/testphdf5.h
+++ b/testpar/testphdf5.h
@@ -104,6 +104,8 @@ hid_t create_faccess_plist(MPI_Comm comm, MPI_Info info, int l_facc_type );
void multiple_dset_write(char *filename, int ndatasets);
void multiple_group_write(char *filename, int ngroups);
void multiple_group_read(char *filename, int ngroups);
+void collective_group_write(char *filename, int ngroups);
+void independent_group_read(char *filename, int ngroups);
void test_split_comm_access(char *filename);
void dataset_writeInd(char *filename);
void dataset_writeAll(char *filename);