summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--testpar/t_span_tree.c810
-rw-r--r--testpar/testphdf5.c13
-rw-r--r--testpar/testphdf5.h96
3 files changed, 642 insertions, 277 deletions
diff --git a/testpar/t_span_tree.c b/testpar/t_span_tree.c
index 58c2885..7eaa050 100644
--- a/testpar/t_span_tree.c
+++ b/testpar/t_span_tree.c
@@ -14,14 +14,23 @@
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*
- * This program shows how the H5Sselect_hyperslab and H5Sselect_elements
- * functions are used to write selected data from memory to the file.
- * Program takes 48 elements from the linear buffer and writes them into
- * the matrix using 3x2 blocks, (4,3) stride and (2,4) count.
- * Then four elements of the matrix are overwritten with the new values and
- * file is closed. Program reopens the file and selects the union of two
- * hyperslabs in the dataset in the file. Then it reads the selection into the
- * memory dataset preserving the shape of the selection.
+ This program will test irregular hyperslab selections with collective write and read.
+ The way to test whether collective write and read works is to use independent IO
+ output to verify the collective output.
+
+ 1) We will write two datasets with the same hyperslab selection settings;
+ one in independent mode,
+ one in collective mode,
+ 2) We will read two datasets with the same hyperslab selection settings,
+ 1. independent read to read independent output,
+ independent read to read collecive output,
+ Compare the result,
+ If the result is the same, then collective write succeeds.
+ 2. collective read to read independent output,
+ independent read to read independent output,
+ Compare the result,
+ If the result is the same, then collective read succeeds.
+
*/
#include "hdf5.h"
@@ -29,280 +38,555 @@
#include "testphdf5.h"
-void t_span_tree()
+void coll_irregular_cont_write()
{
- char *filename;
- hid_t acc_plist,xfer_plist;
- hid_t file, dataset; /* File and dataset identifiers */
- hid_t mid1, mid2, mid, fid; /* Dataspace identifiers */
- hid_t plist; /* Dataset property list identifier */
-
- hsize_t dim1[] = {MSPACE1_DIM}; /* Dimension size of the first dataset
- (in memory) */
- hsize_t dim2[] = {MSPACE2_DIM}; /* Dimension size of the second dataset
- (in memory */
- hsize_t fdim[] = {FSPACE_DIM1, FSPACE_DIM2};
- /* Dimension sizes of the dataset (on disk) */
- hsize_t mdim[] = {MSPACE_DIM1, MSPACE_DIM2}; /* Dimension sizes of the
- dataset in memory when we
- read selection from the
- dataset on the disk */
-
- hssize_t start[2]; /* Start of hyperslab */
- hsize_t stride[2]; /* Stride of hyperslab */
- hsize_t count[2]; /* Block count */
- hsize_t block[2]; /* Block sizes */
-
- hssize_t coord[NPOINTS][FSPACE_RANK]; /* Array to store selected points
- from the file dataspace */
- herr_t ret;
- unsigned i,j;
- int fillvalue = 0; /* Fill value for the dataset */
-
- int matrix_out[MSPACE_DIM1][MSPACE_DIM2]; /* Buffer to read from the
- dataset */
- int vector[MSPACE1_DIM];
- int values[] = {53, 59, 61, 67}; /* New values to be written */
-
- int mpi_size,mpi_rank;
- hsize_t testdims[2];
- MPI_Comm comm = MPI_COMM_WORLD;
- MPI_Info info = MPI_INFO_NULL;
-
- /*set up MPI parameters */
- MPI_Comm_size(comm,&mpi_size);
- MPI_Comm_rank(comm,&mpi_rank);
-
- printf("mpi_size %d\n",mpi_size);
- printf("mpi_rank %d\n",mpi_rank);
-
- /* Obtain file name */
- filename = (char *) GetTestParameters();
-
-
- /*
- * Buffers' initialization.
- */
- vector[0] = vector[MSPACE1_DIM - 1] = -1;
- for (i = 1; i < MSPACE1_DIM - 1; i++) vector[i] = i;
-
- acc_plist = H5Pcreate(H5P_FILE_ACCESS);
- ret = H5Pset_fapl_mpio(acc_plist,comm,info);
+ char *filename;
+ hid_t acc_plist,xfer_plist;
+ hid_t file, datasetc,dataseti; /* File and dataset identifiers */
+ hid_t mspaceid1, mspaceid, fspaceid,fspaceid1; /* Dataspace identifiers */
+ hid_t plist; /* Dataset property list identifier */
+
+ hsize_t mdim1[] = {MSPACE1_DIM}; /* Dimension size of the first dataset
+ (in memory) */
+
+ hsize_t fsdim[] = {FSPACE_DIM1, FSPACE_DIM2};
+ /* Dimension sizes of the dataset (on disk) */
+ hsize_t mdim[] = {MSPACE_DIM1, MSPACE_DIM2}; /* Dimension sizes of the
+ dataset in memory when we
+ read selection from the
+ dataset on the disk */
+
+ hssize_t start[2]; /* Start of hyperslab */
+ hsize_t stride[2]; /* Stride of hyperslab */
+ hsize_t count[2]; /* Block count */
+ hsize_t block[2]; /* Block sizes */
+
+
+ herr_t ret;
+ unsigned i,j;
+ int fillvalue = 0; /* Fill value for the dataset */
+
+ int matrix_out[MSPACE_DIM1][MSPACE_DIM2];
+ int matrix_out1[MSPACE_DIM1][MSPACE_DIM2]; /* Buffer to read from the
+ dataset */
+ int vector[MSPACE1_DIM];
+
+ int mpi_size,mpi_rank;
+
+ MPI_Comm comm = MPI_COMM_WORLD;
+ MPI_Info info = MPI_INFO_NULL;
+
+ /*set up MPI parameters */
+ MPI_Comm_size(comm,&mpi_size);
+ MPI_Comm_rank(comm,&mpi_rank);
+
+
+ /* Obtain file name */
+ filename = (char *) GetTestParameters();
+
+ /*
+ * Buffers' initialization.
+ */
+ vector[0] = vector[MSPACE1_DIM - 1] = -1;
+ for (i = 1; i < MSPACE1_DIM - 1; i++) vector[i] = i;
+
+ acc_plist = H5Pcreate(H5P_FILE_ACCESS);
+ VRFY((acc_plist >= 0),"");
+
+ ret = H5Pset_fapl_mpio(acc_plist,comm,info);
+ VRFY((ret >= 0),"MPIO creation property list succeeded");
+
+ /*
+ * Create a file.
+ */
+ file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_plist);
+ VRFY((file >= 0),"H5Fcreate succeeded");
+
+ /*
+ * Create property list for a dataset and set up fill values.
+ */
+ plist = H5Pcreate(H5P_DATASET_CREATE);
+ VRFY((acc_plist >= 0),"");
+
+ ret = H5Pset_fill_value(plist, H5T_NATIVE_INT, &fillvalue);
+ VRFY((ret >= 0),"Fill value creation property list succeeded");
- /*
- * Create a file.
- */
- file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, acc_plist);
-
- /*
- * Create property list for a dataset and set up fill values.
- */
- plist = H5Pcreate(H5P_DATASET_CREATE);
- ret = H5Pset_fill_value(plist, H5T_NATIVE_INT, &fillvalue);
-
- /*
- * Create dataspace for the dataset in the file.
- */
- fid = H5Screate_simple(FSPACE_RANK, fdim, NULL);
-
- /*
- * Create dataset in the file. Notice that creation
- * property list plist is used.
- */
- dataset = H5Dcreate(file, "Matrix in file", H5T_NATIVE_INT, fid, plist);
-
-
- /*
- * Select hyperslab for the dataset in the file, using 3x2 blocks,
- * (4,3) stride and (1,4) count starting at the position (0,1)
- for the first selection
- */
- start[0] = 0; start[1] = 1;
- stride[0] = 4; stride[1] = 3;
- count[0] = 1; count[1] = 4;
- block[0] = 3; block[1] = 2;
- ret = H5Sselect_hyperslab(fid, H5S_SELECT_SET, start, stride, count, block);
-
- if(ret < 0) printf("hyperslab selection is wrong. \n");
-
- /*
- * Select hyperslab for the dataset in the file, using 3x2*4 blocks,
- * stride 1 and (1,1) count starting at the position (4,0).
- */
- /* start[0] = 4; start[1] = 0;
- stride[0] = 1; stride[1] = 1;
- count[0] = 1; count[1] = 1;
- block[0] = 3; block[1] = 8;*/
-
- start[0] = 4; start[1] = 0;
- stride[0] = 1; stride[1] = 1;
- count[0] = 1; count[1] = 1;
- block[0] = 3; block[1] = 8;
- ret = H5Sselect_hyperslab(fid, H5S_SELECT_OR, start, stride, count, block);
+ /*
+ * Create dataspace for the dataset in the file.
+ */
+ fspaceid = H5Screate_simple(FSPACE_RANK, fsdim, NULL);
+ VRFY((fspaceid >= 0),"file dataspace created succeeded");
+
+ /*
+ * Create dataset in the file. Notice that creation
+ * property list plist is used.
+ */
+ datasetc = H5Dcreate(file, "collect_write", H5T_NATIVE_INT, fspaceid, plist);
+ VRFY((datasetc >= 0),"dataset created succeeded");
+
+ dataseti = H5Dcreate(file, "independ_write", H5T_NATIVE_INT, fspaceid, plist);
+ VRFY((dataseti >= 0),"dataset created succeeded");
+ /*
+ * Select hyperslab for the dataset in the file, using 3x2 blocks,
+ * (4,3) stride and (1,4) count starting at the position (0,1)
+ for the first selection
+ */
+
+ start[0] = FHSTART0;
+ start[1] = FHSTART1+mpi_rank*FHSTRIDE1*FHCOUNT1/mpi_size;
+ stride[0] = FHSTRIDE0;
+ stride[1] = FHSTRIDE1;
+ count[0] = FHCOUNT0;
+ count[1] = FHCOUNT1/mpi_size;
+ block[0] = FHBLOCK0;
+ block[1] = FHBLOCK1;
+
+ ret = H5Sselect_hyperslab(fspaceid, H5S_SELECT_SET, start, stride, count, block);
+ VRFY((ret >= 0),"hyperslab selection succeeded");
+
+ /*
+ * Select hyperslab for the dataset in the file, using 3x2*4 blocks,
+ * stride 1 and (1,1) count starting at the position (4,0).
+ */
+
+ start[0] = SHSTART0;
+ start[1] = SHSTART1+SHCOUNT1*SHBLOCK1*mpi_rank/mpi_size;
+ stride[0] = SHSTRIDE0;
+ stride[1] = SHSTRIDE1;
+ count[0] = SHCOUNT0;
+ count[1] = SHCOUNT1;
+ block[0] = SHBLOCK0;
+ block[1] = SHBLOCK1/mpi_size;
+
+ ret = H5Sselect_hyperslab(fspaceid, H5S_SELECT_OR, start, stride, count, block);
+ VRFY((ret >= 0),"hyperslab selection succeeded");
+
+ /*
+ * Create dataspace for the first dataset.
+ */
+ mspaceid1 = H5Screate_simple(MSPACE1_RANK, mdim1, NULL);
+ VRFY((mspaceid1 >= 0),"memory dataspace created succeeded");
+
+ /*
+ * Select hyperslab.
+ * We will use 48 elements of the vector buffer starting at the second element.
+ * Selected elements are 1 2 3 . . . 48
+ */
+ start[0] = MHSTART0;
+ stride[0] = MHSTRIDE0;
+ count[0] = MHCOUNT0/mpi_size;
+ block[0] = MHBLOCK0;
+
+ ret = H5Sselect_hyperslab(mspaceid1, H5S_SELECT_SET, start, stride, count, block);
+ VRFY((ret >= 0),"hyperslab selection succeeded");
+
+
+ ret = H5Dwrite(dataseti, H5T_NATIVE_INT, mspaceid1, fspaceid, H5P_DEFAULT, vector);
+ VRFY((ret >= 0),"dataset independent write succeed");
+ xfer_plist = H5Pcreate(H5P_DATASET_XFER);
+ VRFY((xfer_plist >= 0),"");
+
+ ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
+ VRFY((ret >= 0),"MPIO data transfer property list succeed");
+
+
+ ret = H5Dwrite(datasetc, H5T_NATIVE_INT, mspaceid1, fspaceid, xfer_plist, vector);
+ VRFY((ret >= 0),"dataset collective write succeed");
+
+ ret = H5Sclose(mspaceid1);
+ VRFY((ret >= 0),"");
+
+ ret = H5Sclose(fspaceid);
+ VRFY((ret >= 0),"");
- if(ret < 0) printf("hyperslab selection is wrong with or selection. \n");
- /*
- * Create dataspace for the first dataset.
- */
- mid1 = H5Screate_simple(MSPACE1_RANK, dim1, NULL);
-
- /*
- * Select hyperslab.
- * We will use 48 elements of the vector buffer starting at the second element.
- * Selected elements are 1 2 3 . . . 48
- */
- start[0] = 1;
- stride[0] = 1;
- count[0] = 48;
- block[0] = 1;
- ret = H5Sselect_hyperslab(mid1, H5S_SELECT_SET, start, stride, count, block);
+ /*
+ * Close dataset.
+ */
+ ret = H5Dclose(datasetc);
+ VRFY((ret >= 0),"");
+ ret = H5Dclose(dataseti);
+ VRFY((ret >= 0),"");
+
+ /*
+ * Close the file.
+ */
+ ret = H5Fclose(file);
+ VRFY((ret >= 0),"");
+ /*
+ * Close property list
+ */
+
+ ret = H5Pclose(acc_plist);
+ VRFY((ret >= 0),"");
+ ret = H5Pclose(xfer_plist);
+ VRFY((ret >= 0),"");
+ ret = H5Pclose(plist);
+ VRFY((ret >= 0),"");
+
+ /*
+ * Open the file.
+ */
+
+ /*** For testing collective hyperslab selection write ***/
+
+ acc_plist = H5Pcreate(H5P_FILE_ACCESS);
+ VRFY((acc_plist >= 0),"");
+
+ ret = H5Pset_fapl_mpio(acc_plist,comm,info);
+ VRFY((ret >= 0),"MPIO creation property list succeeded");
+
+ file = H5Fopen(filename, H5F_ACC_RDONLY, acc_plist);
+ VRFY((file >= 0),"H5Fopen succeeded");
+
+ /*
+ * Open the dataset.
+ */
+ datasetc = H5Dopen(file,"collect_write");
+ VRFY((datasetc >= 0),"H5Dopen succeeded");
+ dataseti = H5Dopen(file,"independ_write");
+ VRFY((dataseti >= 0),"H5Dopen succeeded");
+
+ /*
+ * Get dataspace of the open dataset.
+ */
+ fspaceid = H5Dget_space(datasetc);
+ VRFY((fspaceid >= 0),"file dataspace obtained succeeded");
+
+ fspaceid1 = H5Dget_space(dataseti);
+ VRFY((fspaceid1 >= 0),"file dataspace obtained succeeded");
+
+
+
+ start[0] = RFFHSTART0;
+ start[1] = RFFHSTART1+mpi_rank*RFFHCOUNT1/mpi_size;
+ block[0] = RFFHBLOCK0;
+ block[1] = RFFHBLOCK1;
+ stride[0] = RFFHSTRIDE0;
+ stride[1] = RFFHSTRIDE1;
+ count[0] = RFFHCOUNT0;
+ count[1] = RFFHCOUNT1/mpi_size;
- /*
- * Write selection from the vector buffer to the dataset in the file.
- *
- * File dataset should look like this:
- * 0 1 2 0 3 4 0 5 6 0 7 8
- * 0 9 10 0 11 12 0 13 14 0 15 16
- * 0 17 18 0 19 20 0 21 22 0 23 24
- * 0 0 0 0 0 0 0 0 0 0 0 0
- * 0 25 26 0 27 28 0 29 30 0 31 32
- * 0 33 34 0 35 36 0 37 38 0 39 40
- * 0 41 42 0 43 44 0 45 46 0 47 48
- * 0 0 0 0 0 0 0 0 0 0 0 0
- */
-
- xfer_plist = H5Pcreate(H5P_DATASET_XFER);
-
- ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
-
- for (i = 0; i < MSPACE_DIM1; i++) {
- for (j = 0; j < MSPACE_DIM2; j++)
- matrix_out[i][j] = 3;
- }
- /* ret = H5Dwrite(dataset, H5T_NATIVE_INT, mid1, fid, xfer_plist, vector);*/
- ret = H5Dwrite(dataset, H5T_NATIVE_INT, mid1, fid, xfer_plist, vector);
- if(ret < 0) printf("failing to write data .\n");
+ ret = H5Sselect_hyperslab(fspaceid, H5S_SELECT_SET, start, stride, count, block);
+ VRFY((ret >= 0),"hyperslab selection succeeded");
+ ret = H5Sselect_hyperslab(fspaceid1, H5S_SELECT_SET, start, stride, count, block);
+ VRFY((ret >= 0),"hyperslab selection succeeded");
+
+ /*start[0] = RFSHSTART0+mpi_rank*RFSHCOUNT1/mpi_size; */
+ start[0] = RFSHSTART0;
+ start[1] = RFSHSTART1+RFSHCOUNT1*mpi_rank/mpi_size;
+ block[0] = RFSHBLOCK0;
+ block[1] = RFSHBLOCK1;
+ stride[0] = RFSHSTRIDE0;
+ stride[1] = RFSHSTRIDE0;
+ count[0] = RFSHCOUNT0;
+ count[1] = RFSHCOUNT1/mpi_size;
+ ret = H5Sselect_hyperslab(fspaceid, H5S_SELECT_OR, start, stride, count, block);
+ VRFY((ret >= 0),"hyperslab selection succeeded");
+ ret = H5Sselect_hyperslab(fspaceid1, H5S_SELECT_OR, start, stride, count, block);
+ VRFY((ret >= 0),"hyperslab selection succeeded");
+
+
+ /*
+ * Create memory dataspace.
+ */
+ mspaceid = H5Screate_simple(MSPACE_RANK, mdim, NULL);
+
+ /*
+ * Select two hyperslabs in memory. Hyperslabs has the same
+ * size and shape as the selected hyperslabs for the file dataspace.
+ */
+
+
+ start[0] = RMFHSTART0;
+ start[1] = RMFHSTART1+mpi_rank*RMFHCOUNT1/mpi_size;
+ block[0] = RMFHBLOCK0;
+ block[1] = RMFHBLOCK1;
+ stride[0] = RMFHSTRIDE0;
+ stride[1] = RMFHSTRIDE1;
+ count[0] = RMFHCOUNT0;
+ count[1] = RMFHCOUNT1/mpi_size;
+ ret = H5Sselect_hyperslab(mspaceid, H5S_SELECT_SET, start, stride, count, block);
+ VRFY((ret >= 0),"hyperslab selection succeeded");
+
+ start[0] = RMSHSTART0;
+ start[1] = RMSHSTART1+mpi_rank*RMSHCOUNT1/mpi_size;
+ block[0] = RMSHBLOCK0;
+ block[1] = RMSHBLOCK1;
+ stride[0] = RMSHSTRIDE0;
+ stride[1] = RMSHSTRIDE1;
+ count[0] = RMSHCOUNT0;
+ count[1] = RMSHCOUNT1/mpi_size;
- /*
- * Initialize data buffer.
- */
- for (i = 0; i < MSPACE_DIM1; i++) {
- for (j = 0; j < MSPACE_DIM2; j++)
- matrix_out[i][j] = 1;
+
+ ret = H5Sselect_hyperslab(mspaceid, H5S_SELECT_OR, start, stride, count, block);
+ VRFY((ret >= 0),"hyperslab selection succeeded");
+
+ /*
+ * Initialize data buffer.
+ */
+ for (i = 0; i < MSPACE_DIM1; i++) {
+ for (j = 0; j < MSPACE_DIM2; j++)
+ matrix_out[i][j] = 0;
+ }
+
+ /*
+ * Read data back to the buffer matrix_out.
+ */
+
+ ret = H5Dread(datasetc, H5T_NATIVE_INT, mspaceid, fspaceid,
+ H5P_DEFAULT, matrix_out);
+ VRFY((ret >= 0),"H5D independent read succeed");
+
+
+ for (i = 0; i < MSPACE_DIM1; i++) {
+ for (j = 0; j < MSPACE_DIM2; j++)
+ matrix_out1[i][j] = 0;
+ }
+ ret = H5Dread(dataseti, H5T_NATIVE_INT, mspaceid, fspaceid,
+ H5P_DEFAULT, matrix_out1);
+ VRFY((ret >= 0),"H5D independent read succeed");
+
+ ret = 0;
+ for (i = 0; i < MSPACE_DIM1; i++){
+ for (j = 0; j < MSPACE_DIM2; j++){
+ if(matrix_out[i][j]!=matrix_out1[i][j]) ret = -1;
+ if(ret < 0) break;
}
+ }
+ VRFY((ret >= 0),"H5D contiguous irregular collective write succeed");
+
+ /*
+ * Close memory file and memory dataspaces.
+ */
+ ret = H5Sclose(mspaceid);
+ VRFY((ret >= 0),"");
+ ret = H5Sclose(fspaceid);
+ VRFY((ret >= 0),"");
+
+ /*
+ * Close dataset.
+ */
+ ret = H5Dclose(dataseti);
+ VRFY((ret >= 0),"");
- for (i=0; i < MSPACE_DIM1; i++) {
- for(j=0; j < MSPACE_DIM2; j++) printf("%3d ", matrix_out[i][j]);
- printf("\n");
- }
-
+ ret = H5Dclose(datasetc);
+ VRFY((ret >= 0),"");
+ /*
+ * Close property list
+ */
-#if 0
+ ret = H5Pclose(acc_plist);
+ VRFY((ret >= 0),"");
- /* for dataset reading */
- xfer_plist = H5Pcreate(H5P_DATASET_XFER);
+
+ /*
+ * Close the file.
+ */
+ ret = H5Fclose(file);
+ VRFY((ret >= 0),"");
- ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
- ret = H5Dread(dataset, H5T_NATIVE_INT, fid, fid,
- xfer_plist, matrix_out);
+ return ;
+}
- /* ret = H5Dread(dataset, H5T_NATIVE_INT, fid, fid,
- H5P_DEFAULT, matrix_out);*/
+void coll_irregular_cont_read()
+{
- if(ret < 0) printf("fail to read the dataset afterwards.\n");
- for (i=0; i < MSPACE_DIM1; i++) {
- for(j=0; j < MSPACE_DIM2; j++) printf("%3d ", matrix_out[i][j]);
- printf("\n");
- }
-#endif
-
- ret = H5Sclose(mid1);
- ret = H5Sclose(fid);
+ char *filename;
+ hid_t acc_plist,xfer_plist;
+ hid_t file, dataseti; /* File and dataset identifiers */
+ hid_t mspaceid, fspaceid1; /* Dataspace identifiers */
- /*
- * Close dataset.
- */
- ret = H5Dclose(dataset);
-
- /*
- * Close the file.
- */
- ret = H5Fclose(file);
-
- /*
- * Close property list
- */
-
- ret = H5Pclose(acc_plist);
-
- ret = H5Pclose(xfer_plist);
- ret = H5Pclose(plist);
-
-#if 0
- /*
- * Open the file.
- */
- file = H5Fopen(filename, H5F_ACC_RDONLY, acc_plist);
- if(file <0) printf("fail to open the file.\n");
-
- /*
- * Open the dataset.
- */
- dataset = H5Dopen(file,"Matrix in file");
- if(dataset < 0) printf("fail to open the dataset.\n");
-
- /*
- * Get dataspace of the open dataset.
- */
- fid = H5Dget_space(dataset);
- if(fid < 0) printf("cannot obtain the correct file space.\n");
- H5Sget_simple_extent_dims(fid,testdims,NULL);
- HDfprintf(stdout,"testdims[0] %Hu\n",testdims[0]);
- HDfprintf(stdout, "testdims[1] %Hu\n",testdims[1]);
-
- /*
- * Initialize data buffer.
- */
- for (i = 0; i < MSPACE_DIM1; i++) {
- for (j = 0; j < MSPACE_DIM2; j++)
- matrix_out[i][j] = 1;
- }
+ /* Dimension sizes of the dataset (on disk) */
+ hsize_t mdim[] = {MSPACE_DIM1, MSPACE_DIM2}; /* Dimension sizes of the
+ dataset in memory when we
+ read selection from the
+ dataset on the disk */
- ret = H5Dread(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL,
- H5P_DEFAULT, matrix_out);
+ hssize_t start[2]; /* Start of hyperslab */
+ hsize_t stride[2]; /* Stride of hyperslab */
+ hsize_t count[2]; /* Block count */
+ hsize_t block[2]; /* Block sizes */
- if(ret < 0) printf("fail to read the dataset.\n");
- for (i=0; i < MSPACE_DIM1; i++) {
- for(j=0; j < MSPACE_DIM2; j++) printf("%3d ", matrix_out[i][j]);
- printf("\n");
- }
+ herr_t ret;
+ unsigned i,j;
+
+ int matrix_out[MSPACE_DIM1][MSPACE_DIM2];
+ int matrix_out1[MSPACE_DIM1][MSPACE_DIM2]; /* Buffer to read from the
+ dataset */
+
+ int mpi_size,mpi_rank;
+
+ MPI_Comm comm = MPI_COMM_WORLD;
+ MPI_Info info = MPI_INFO_NULL;
+
+ /*set up MPI parameters */
+ MPI_Comm_size(comm,&mpi_size);
+ MPI_Comm_rank(comm,&mpi_rank);
- /*
- * Close memory file and memory dataspaces.
- */
- ret = H5Sclose(mid);
- ret = H5Sclose(fid);
+
+ /* Obtain file name */
+ filename = (char *) GetTestParameters();
+
+ /*
+ * Buffers' initialization.
+ */
+
+ /*
+ * Open the file.
+ */
+
+ /*** For testing collective hyperslab selection read ***/
+
+ acc_plist = H5Pcreate(H5P_FILE_ACCESS);
+ VRFY((acc_plist >= 0),"");
+
+ ret = H5Pset_fapl_mpio(acc_plist,comm,info);
+ VRFY((ret >= 0),"MPIO creation property list succeeded");
+
+ file = H5Fopen(filename, H5F_ACC_RDONLY, acc_plist);
+ VRFY((file >= 0),"H5Fopen succeeded");
+
+ /*
+ * Open the dataset.
+ */
+ dataseti = H5Dopen(file,"independ_write");
+ VRFY((dataseti >= 0),"H5Dopen succeeded");
+
+ /*
+ * Get dataspace of the open dataset.
+ */
+
+ fspaceid1 = H5Dget_space(dataseti);
+ VRFY((fspaceid1 >= 0),"file dataspace obtained succeeded");
+
+ start[0] = RFFHSTART0;
+ start[1] = RFFHSTART1+mpi_rank*RFFHCOUNT1/mpi_size;
+ block[0] = RFFHBLOCK0;
+ block[1] = RFFHBLOCK1;
+ stride[0] = RFFHSTRIDE0;
+ stride[1] = RFFHSTRIDE1;
+ count[0] = RFFHCOUNT0;
+ count[1] = RFFHCOUNT1/mpi_size;
+
+ ret = H5Sselect_hyperslab(fspaceid1, H5S_SELECT_SET, start, stride, count, block);
+ VRFY((ret >= 0),"hyperslab selection succeeded");
+
+
+ start[0] = RFSHSTART0;
+ start[1] = RFSHSTART1+RFSHCOUNT1*mpi_rank/mpi_size;
+ block[0] = RFSHBLOCK0;
+ block[1] = RFSHBLOCK1;
+ stride[0] = RFSHSTRIDE0;
+ stride[1] = RFSHSTRIDE0;
+ count[0] = RFSHCOUNT0;
+ count[1] = RFSHCOUNT1/mpi_size;
+
+ ret = H5Sselect_hyperslab(fspaceid1, H5S_SELECT_OR, start, stride, count, block);
+ VRFY((ret >= 0),"hyperslab selection succeeded");
+
+
+ /*
+ * Create memory dataspace.
+ */
+ mspaceid = H5Screate_simple(MSPACE_RANK, mdim, NULL);
+
+ /*
+ * Select two hyperslabs in memory. Hyperslabs has the same
+ * size and shape as the selected hyperslabs for the file dataspace.
+ */
+
+ start[0] = RMFHSTART0;
+ start[1] = RMFHSTART1+mpi_rank*RMFHCOUNT1/mpi_size;
+ block[0] = RMFHBLOCK0;
+ block[1] = RMFHBLOCK1;
+ stride[0] = RMFHSTRIDE0;
+ stride[1] = RMFHSTRIDE1;
+ count[0] = RMFHCOUNT0;
+ count[1] = RMFHCOUNT1/mpi_size;
+ ret = H5Sselect_hyperslab(mspaceid, H5S_SELECT_SET, start, stride, count, block);
+ VRFY((ret >= 0),"hyperslab selection succeeded");
+
+ start[0] = RMSHSTART0;
+ start[1] = RMSHSTART1+mpi_rank*RMSHCOUNT1/mpi_size;
+ block[0] = RMSHBLOCK0;
+ block[1] = RMSHBLOCK1;
+ stride[0] = RMSHSTRIDE0;
+ stride[1] = RMSHSTRIDE1;
+ count[0] = RMSHCOUNT0;
+ count[1] = RMSHCOUNT1/mpi_size;
+ ret = H5Sselect_hyperslab(mspaceid, H5S_SELECT_OR, start, stride, count, block);
+ VRFY((ret >= 0),"hyperslab selection succeeded");
+
+ /*
+ * Initialize data buffer.
+ */
+ for (i = 0; i < MSPACE_DIM1; i++) {
+ for (j = 0; j < MSPACE_DIM2; j++)
+ matrix_out[i][j] = 0;
+ }
+
+ /*
+ * Read data back to the buffer matrix_out.
+ */
+
+ xfer_plist = H5Pcreate(H5P_DATASET_XFER);
+ VRFY((xfer_plist >= 0),"");
+
+ ret = H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
+ VRFY((ret >= 0),"MPIO data transfer property list succeed");
+
+ ret = H5Dread(dataseti, H5T_NATIVE_INT, mspaceid, fspaceid1,
+ xfer_plist, matrix_out);
+ VRFY((ret >= 0),"H5D collecive read succeed");
+
+ ret = H5Pclose(xfer_plist);
+ VRFY((ret >= 0),"");
+
+ for (i = 0; i < MSPACE_DIM1; i++) {
+ for (j = 0; j < MSPACE_DIM2; j++)
+ matrix_out1[i][j] = 0;
+ }
+ ret = H5Dread(dataseti, H5T_NATIVE_INT, mspaceid, fspaceid1,
+ H5P_DEFAULT, matrix_out1);
+
+ VRFY((ret >= 0),"H5D independent read succeed");
+ ret = 0;
+ for (i = 0; i < MSPACE_DIM1; i++){
+ for (j = 0; j < MSPACE_DIM2; j++){
+ if(matrix_out[i][j]!=matrix_out1[i][j])ret = -1;
+ if(ret < 0) break;
+ }
+ }
+ VRFY((ret >= 0),"H5D contiguous irregular collective read succeed");
+
+ /*
+ * Close memory file and memory dataspaces.
+ */
+ ret = H5Sclose(mspaceid);
+ VRFY((ret >= 0),"");
+ ret = H5Sclose(fspaceid1);
+ VRFY((ret >= 0),"");
- /*
- * Close dataset.
- */
- ret = H5Dclose(dataset);
-
- /*
- * Close property list
- */
- ret = H5Pclose(plist);
- ret = H5Pclose(acc_plist);
-
- ret = H5Pclose(xfer_plist);
+ /*
+ * Close dataset.
+ */
+ ret = H5Dclose(dataseti);
+ VRFY((ret >= 0),"");
+ /*
+ * Close property list
+ */
+ ret = H5Pclose(acc_plist);
+ VRFY((ret >= 0),"");
+
- /*
- * Close the file.
- */
- ret = H5Fclose(file);
-#endif
- return ;
+ /*
+ * Close the file.
+ */
+ ret = H5Fclose(file);
+ VRFY((ret >= 0),"");
+
+ return ;
}
diff --git a/testpar/testphdf5.c b/testpar/testphdf5.c
index 01e7ef9..d6cc6a7 100644
--- a/testpar/testphdf5.c
+++ b/testpar/testphdf5.c
@@ -352,7 +352,6 @@ int main(int argc, char **argv)
TestInit(argv[0], usage, parse_options);
/* Tests are generally arranged from least to most complexity... */
-
AddTest("mpiodup", test_fapl_mpio_dup, NULL,
"fapl_mpio duplicate", NULL);
AddTest("posixdup", test_fapl_mpiposix_dup, NULL,
@@ -434,11 +433,14 @@ int main(int argc, char **argv)
AddTest("cchunk4", coll_chunk4,NULL,
"collective to independent chunk io",PARATESTFILE);
}
-
-#ifdef KYANG
- AddTest("span_tree",t_span_tree,NULL,
- "derived datatype test",PARATESTFILE);
+ /*#ifdef KYANG*/
+#ifdef KYANG
+ AddTest("ccontw",coll_irregular_cont_write,NULL,
+ "collective irregular contiguous write",PARATESTFILE);
+ AddTest("ccontr",coll_irregular_cont_read,NULL,
+ "collective irregular contiguous read",PARATESTFILE);
#endif
+
AddTest("null", null_dataset, NULL,
"null dataset test", PARATESTFILE);
@@ -448,7 +450,6 @@ int main(int argc, char **argv)
AddTest("I/Omodeconf", io_mode_confusion, NULL,
"I/O mode confusion test -- hangs quickly on failure",
&io_mode_confusion_params);
-
/* Display testing information */
TestInfo(argv[0]);
diff --git a/testpar/testphdf5.h b/testpar/testphdf5.h
index 788a02a..cc16719 100644
--- a/testpar/testphdf5.h
+++ b/testpar/testphdf5.h
@@ -123,17 +123,96 @@
/*Constants for MPI derived data type generated from span tree */
#define MSPACE1_RANK 1 /* Rank of the first dataset in memory */
-#define MSPACE1_DIM 50 /* Dataset size in memory */
-#define MSPACE2_RANK 1 /* Rank of the second dataset in memory */
-#define MSPACE2_DIM 4 /* Dataset size in memory */
-#define FSPACE_RANK 2 /* Dataset rank as it is stored in the file */
-#define FSPACE_DIM1 8 /* Dimension sizes of the dataset as it is stored in the file */
-#define FSPACE_DIM2 12 /* We will read dataset back from the file to the dataset in memory with these dataspace parameters. */
+#define MSPACE1_DIM 19000 /* Dataset size in memory */
+#define FSPACE_RANK 2 /* Dataset rank as it is stored in the file */
+#define FSPACE_DIM1 9 /* Dimension sizes of the dataset as it is stored in the file */
+#define FSPACE_DIM2 2400 /* We will read dataset back from the file to the dataset in memory with these dataspace parameters. */
+#define MSPACE_RANK 2
+#define MSPACE_DIM1 9
+#define MSPACE_DIM2 2400
+#define FHCOUNT0 1 /* Count of the first dimension of the first hyperslab selection*/
+#define FHCOUNT1 512 /* Count of the second dimension of the first hyperslab selection*/
+#define FHSTRIDE0 4 /* Stride of the first dimension of the first hyperslab selection*/
+#define FHSTRIDE1 3 /* Stride of the second dimension of the first hyperslab selection*/
+#define FHBLOCK0 3 /* Block of the first dimension of the first hyperslab selection*/
+#define FHBLOCK1 2 /* Block of the second dimension of the first hyperslab selection*/
+#define FHSTART0 0 /* start of the first dimension of the first hyperslab selection*/
+#define FHSTART1 1 /* start of the second dimension of the first hyperslab selection*/
+
+#define SHCOUNT0 1 /* Count of the first dimension of the first hyperslab selection*/
+#define SHCOUNT1 1 /* Count of the second dimension of the first hyperslab selection*/
+#define SHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/
+#define SHSTRIDE1 1 /* Stride of the second dimension of the first hyperslab selection*/
+#define SHBLOCK0 3 /* Block of the first dimension of the first hyperslab selection*/
+#define SHBLOCK1 512 /* Block of the second dimension of the first hyperslab selection*/
+#define SHSTART0 4 /* start of the first dimension of the first hyperslab selection*/
+#define SHSTART1 0 /* start of the second dimension of the first hyperslab selection*/
+
+#define MHCOUNT0 4608 /* Count of the first dimension of the first hyperslab selection*/
+#define MHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/
+#define MHBLOCK0 1 /* Block of the first dimension of the first hyperslab selection*/
+#define MHSTART0 1 /* start of the first dimension of the first hyperslab selection*/
+
+
+
+#define RFFHCOUNT0 3 /* Count of the first dimension of the first hyperslab selection*/
+#define RFFHCOUNT1 512 /* Count of the second dimension of the first hyperslab selection*/
+#define RFFHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/
+#define RFFHSTRIDE1 1 /* Stride of the second dimension of the first hyperslab selection*/
+#define RFFHBLOCK0 1 /* Block of the first dimension of the first hyperslab selection*/
+#define RFFHBLOCK1 1 /* Block of the second dimension of the first hyperslab selection*/
+#define RFFHSTART0 1 /* start of the first dimension of the first hyperslab selection*/
+#define RFFHSTART1 2 /* start of the second dimension of the first hyperslab selection*/
+
+
+#define RFSHCOUNT0 3 /* Count of the first dimension of the first hyperslab selection*/
+#define RFSHCOUNT1 1024 /* Count of the second dimension of the first hyperslab selection*/
+#define RFSHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/
+#define RFSHSTRIDE1 1 /* Stride of the second dimension of the first hyperslab selection*/
+#define RFSHBLOCK0 1 /* Block of the first dimension of the first hyperslab selection*/
+#define RFSHBLOCK1 1 /* Block of the second dimension of the first hyperslab selection*/
+#define RFSHSTART0 2 /* start of the first dimension of the first hyperslab selection*/
+#define RFSHSTART1 4 /* start of the second dimension of the first hyperslab selection*/
+
+
+#define RMFHCOUNT0 3 /* Count of the first dimension of the first hyperslab selection*/
+#define RMFHCOUNT1 512 /* Count of the second dimension of the first hyperslab selection*/
+#define RMFHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/
+#define RMFHSTRIDE1 1 /* Stride of the second dimension of the first hyperslab selection*/
+#define RMFHBLOCK0 1 /* Block of the first dimension of the first hyperslab selection*/
+#define RMFHBLOCK1 1 /* Block of the second dimension of the first hyperslab selection*/
+#define RMFHSTART0 0 /* start of the first dimension of the first hyperslab selection*/
+#define RMFHSTART1 0 /* start of the second dimension of the first hyperslab selection*/
+
+#define RMSHCOUNT0 3 /* Count of the first dimension of the first hyperslab selection*/
+#define RMSHCOUNT1 1024 /* Count of the second dimension of the first hyperslab selection*/
+#define RMSHSTRIDE0 1 /* Stride of the first dimension of the first hyperslab selection*/
+#define RMSHSTRIDE1 1 /* Stride of the second dimension of the first hyperslab selection*/
+#define RMSHBLOCK0 1 /* Block of the first dimension of the first hyperslab selection*/
+#define RMSHBLOCK1 1 /* Block of the second dimension of the first hyperslab selection*/
+#define RMSHSTART0 1 /* start of the first dimension of the first hyperslab selection*/
+#define RMSHSTART1 2 /* start of the second dimension of the first hyperslab selection*/
+
+
+#define NPOINTS 4 /* Number of points that will be selected
+ and overwritten */
+
+/* Don't erase these lines, they are put here for debugging purposes */
+/*
+#define MSPACE1_RANK 1
+#define MSPACE1_DIM 50
+#define MSPACE2_RANK 1
+#define MSPACE2_DIM 4
+#define FSPACE_RANK 2
+#define FSPACE_DIM1 8
+#define FSPACE_DIM2 12
#define MSPACE_RANK 2
#define MSPACE_DIM1 8
#define MSPACE_DIM2 9
-#define NPOINTS 4 /* Number of points that will be selected and overwritten */
+#define NPOINTS 4
+
+*/ /* end of debugging macro */
/* type definitions */
typedef struct H5Ptest_param_t /* holds extra test parameters */
{
@@ -178,7 +257,8 @@ void coll_chunk1(void);
void coll_chunk2(void);
void coll_chunk3(void);
void coll_chunk4(void);
-void t_span_tree(void);
+void coll_irregular_cont_read(void);
+void coll_irregular_cont_write(void);
void io_mode_confusion(void);
#ifdef H5_HAVE_FILTER_DEFLATE
void compress_readAll(void);