summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-11-05 16:31:02 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-11-05 16:31:02 (GMT)
commit22f38d627e0f75ca92731ef8df75b2df3ad8aa85 (patch)
tree253fcf1b8a5675ce8ef45def44af17c7840e79e3
parent3ed57b880ab78490678eb1824b623beb1930eeb5 (diff)
downloadhdf5-22f38d627e0f75ca92731ef8df75b2df3ad8aa85.zip
hdf5-22f38d627e0f75ca92731ef8df75b2df3ad8aa85.tar.gz
hdf5-22f38d627e0f75ca92731ef8df75b2df3ad8aa85.tar.bz2
[svn-r6055] Purpose:
New feature Description: Add support for scalar dataspaces in parallel I/O. Platforms tested: Tested h5committest {arabica (fortran), eirene (fortran, C++) modi4 (parallel, fortran)} Also, FreeBSD 4.7 (sleipnir) serial & parallel Misc. update: Update release_docs/RELEASE for bug fixes, new features, etc.
-rw-r--r--release_docs/RELEASE.txt1
-rw-r--r--src/H5A.c4
-rw-r--r--src/H5Smpio.c9
-rw-r--r--test/tselect.c169
-rw-r--r--testpar/t_dset.c85
-rw-r--r--testpar/testphdf5.h1
6 files changed, 251 insertions, 18 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index ceb7a58..3e3df14 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -35,6 +35,7 @@ Bug Fixes since HDF5-1.4.0
Library
-------
+ * Allow scalar dataspaces to be used for parallel I/O. QAK - 2002/11/05
* Fixed error condition where "none" selections were not being handled
correctly in parallel. QAK - 2002/10/29
* New functions H5Gget_comment(modification), H5Aget_storage_size,
diff --git a/src/H5A.c b/src/H5A.c
index 24efd72..443f800 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -1181,7 +1181,7 @@ H5A_rename(H5G_entry_t *ent, char *old_name, char *new_name)
{
int seq, idx=FAIL; /* Index of attribute being querried */
H5A_t *found_attr; /* Attribute with OLD_NAME */
- herr_t ret_value; /* Return value */
+ herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5A_rename, FAIL);
@@ -1227,7 +1227,7 @@ H5A_rename(H5G_entry_t *ent, char *old_name, char *new_name)
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to update attribute header messages");
/* Close the attribute */
- if(found_attr) H5A_close(found_attr);
+ H5A_close(found_attr);
done:
FUNC_LEAVE(ret_value);
diff --git a/src/H5Smpio.c b/src/H5Smpio.c
index c4996a4..9b3f132 100644
--- a/src/H5Smpio.c
+++ b/src/H5Smpio.c
@@ -721,10 +721,6 @@ H5S_mpio_space_type( const H5S_t *space, size_t elmt_size, hbool_t prefer_derive
/* Creat MPI type based on the kind of selection */
switch (space->extent.type) {
case H5S_SCALAR:
- /* not yet implemented */
- ret_value = FAIL;
- break;
-
case H5S_SIMPLE:
switch(space->select.type) {
case H5S_SEL_NONE:
@@ -1039,8 +1035,9 @@ H5S_mpio_opt_possible( const H5S_t *mem_space, const H5S_t *file_space, const un
assert(mem_space);
assert(file_space);
- /* Check whether these are both simple dataspaces */
- if (H5S_SIMPLE!=mem_space->extent.type || H5S_SIMPLE!=file_space->extent.type)
+ /* Check whether these are both simple or scalar dataspaces */
+ if (!((H5S_SIMPLE==mem_space->extent.type || H5S_SCALAR==mem_space->extent.type)
+ && (H5S_SIMPLE==file_space->extent.type || H5S_SCALAR==file_space->extent.type)))
HGOTO_DONE(FALSE);
/* Check whether both selections are "regular" */
diff --git a/test/tselect.c b/test/tselect.c
index 2cbfa6a..47dcc4e 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -4969,12 +4969,12 @@ test_select_fill_hyper_irregular(hssize_t *offset)
/****************************************************************
**
-** test_zero_none(): Test basic H5S (dataspace) selection code.
+** test_select_none(): Test basic H5S (dataspace) selection code.
** Tests I/O on 0-sized point selections
**
****************************************************************/
static void
-test_zero_none(void)
+test_select_none(void)
{
hid_t fid1; /* HDF5 File IDs */
hid_t dataset; /* Dataset ID */
@@ -5046,7 +5046,165 @@ test_zero_none(void)
/* Free memory buffers */
free(wbuf);
-} /* test_zero_none() */
+} /* test_select_none() */
+
+/****************************************************************
+**
+** test_scalar_select(): Test basic H5S (dataspace) selection code.
+** Tests selections on scalar dataspaces
+**
+****************************************************************/
+static void
+test_scalar_select(void)
+{
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid1,sid2; /* Dataspace ID */
+ hsize_t dims2[] = {SPACE7_DIM1, SPACE7_DIM2};
+ hssize_t coord1[SPACE7_RANK]; /* Coordinates for point selection */
+ hssize_t start[SPACE7_RANK]; /* Hyperslab start */
+ hsize_t count[SPACE7_RANK]; /* Hyperslab block count */
+ uint8_t *wbuf_uint8, /* buffer to write to disk */
+ rval_uint8, /* value read back in */
+ *tbuf_uint8; /* temporary buffer pointer */
+ unsigned short *wbuf_ushort,/* another buffer to write to disk */
+ rval_ushort, /* value read back in */
+ *tbuf_ushort; /* temporary buffer pointer */
+ int i,j; /* Counters */
+ herr_t ret; /* Generic return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing I/O on Selections in Scalar Dataspaces\n"));
+
+ /* Allocate write & read buffers */
+ wbuf_uint8=malloc(sizeof(uint8_t)*SPACE7_DIM1*SPACE7_DIM2);
+ wbuf_ushort=malloc(sizeof(unsigned short)*SPACE7_DIM1*SPACE7_DIM2);
+
+ /* Initialize write buffers */
+ for(i=0, tbuf_uint8=wbuf_uint8, tbuf_ushort=wbuf_ushort; i<SPACE7_DIM1; i++)
+ for(j=0; j<SPACE7_DIM2; j++) {
+ *tbuf_uint8++=(uint8_t)((i*SPACE7_DIM2)+j);
+ *tbuf_ushort++=(unsigned short)((j*SPACE7_DIM2)+i);
+ } /* end for */
+
+ /* Create file */
+ fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Create dataspace for dataset */
+ sid1 = H5Screate(H5S_SCALAR);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+
+ /* Create dataspace for writing buffer */
+ sid2 = H5Screate_simple(SPACE7_RANK, dims2, NULL);
+ CHECK(sid2, FAIL, "H5Screate_simple");
+
+ /* Create a dataset */
+ dataset=H5Dcreate(fid1,"Dataset1",H5T_NATIVE_UCHAR,sid1,H5P_DEFAULT);
+ CHECK(dataset, FAIL, "H5Dcreate");
+
+ /* Select one element in memory with a point selection */
+ coord1[0]=0; coord1[1]= 2;
+ ret = H5Sselect_elements(sid2,H5S_SELECT_SET,1,(const hssize_t **)&coord1);
+ CHECK(ret, FAIL, "H5Sselect_elements");
+
+ /* Write single point to disk */
+ ret=H5Dwrite(dataset,H5T_NATIVE_UCHAR,sid2,sid1,H5P_DEFAULT,wbuf_uint8);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Read scalar element from disk */
+ ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid1,sid1,H5P_DEFAULT,&rval_uint8);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Check value read back in */
+ if(rval_uint8!=*(wbuf_uint8+2)) {
+ printf("Error! rval=%u, should be: *(wbuf+2)=%u\n",(unsigned)rval_uint8,(unsigned)*(wbuf_uint8+2));
+ num_errs++;
+ } /* end if */
+
+ /* Write single point to disk (with a datatype conversion) */
+ ret=H5Dwrite(dataset,H5T_NATIVE_USHORT,sid2,sid1,H5P_DEFAULT,wbuf_ushort);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Read scalar element from disk */
+ ret=H5Dread(dataset,H5T_NATIVE_USHORT,sid1,sid1,H5P_DEFAULT,&rval_ushort);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Check value read back in */
+ if(rval_ushort!=*(wbuf_ushort+2)) {
+ printf("Error! rval=%u, should be: *(wbuf+2)=%u\n",(unsigned)rval_ushort,(unsigned)*(wbuf_ushort+2));
+ num_errs++;
+ } /* end if */
+
+ /* Select one element in memory with a hyperslab selection */
+ start[0]=4; start[1]=3;
+ count[0]=1; count[1]=1;
+ ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,NULL,count,NULL);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Write single hyperslab element to disk */
+ ret=H5Dwrite(dataset,H5T_NATIVE_UCHAR,sid2,sid1,H5P_DEFAULT,wbuf_uint8);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Read scalar element from disk */
+ ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid1,sid1,H5P_DEFAULT,&rval_uint8);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Check value read back in */
+ if(rval_uint8!=*(wbuf_uint8+(SPACE7_DIM2*4)+3)) {
+ printf("Error! rval=%u, should be: *(wbuf+(SPACE7_DIM2*4)+3)=%u\n",(unsigned)rval_uint8,(unsigned)*(wbuf_uint8+(SPACE7_DIM2*4)+3));
+ num_errs++;
+ } /* end if */
+
+ /* Write single hyperslab element to disk (with a datatype conversion) */
+ ret=H5Dwrite(dataset,H5T_NATIVE_USHORT,sid2,sid1,H5P_DEFAULT,wbuf_ushort);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Read scalar element from disk */
+ ret=H5Dread(dataset,H5T_NATIVE_USHORT,sid1,sid1,H5P_DEFAULT,&rval_ushort);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Check value read back in */
+ if(rval_ushort!=*(wbuf_ushort+(SPACE7_DIM2*4)+3)) {
+ printf("Error! rval=%u, should be: *(wbuf+(SPACE7_DIM2*4)+3)=%u\n",(unsigned)rval_ushort,(unsigned)*(wbuf_ushort+(SPACE7_DIM2*4)+3));
+ num_errs++;
+ } /* end if */
+
+ /* Select no elements in memory & file with "none" selections */
+ ret = H5Sselect_none(sid1);
+ CHECK(ret, FAIL, "H5Sselect_none");
+
+ ret = H5Sselect_none(sid2);
+ CHECK(ret, FAIL, "H5Sselect_none");
+
+ /* Write no data to disk */
+ ret=H5Dwrite(dataset,H5T_NATIVE_UCHAR,sid2,sid1,H5P_DEFAULT,wbuf_uint8);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Write no data to disk (with a datatype conversion) */
+ ret=H5Dwrite(dataset,H5T_NATIVE_USHORT,sid2,sid1,H5P_DEFAULT,wbuf_ushort);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Close memory dataspace */
+ ret = H5Sclose(sid2);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close disk dataspace */
+ ret = H5Sclose(sid1);
+ CHECK(ret, FAIL, "H5Sclose");
+
+ /* Close Dataset */
+ ret = H5Dclose(dataset);
+ CHECK(ret, FAIL, "H5Dclose");
+
+ /* Close file */
+ ret = H5Fclose(fid1);
+ CHECK(ret, FAIL, "H5Fclose");
+
+ /* Free memory buffers */
+ free(wbuf_uint8);
+ free(wbuf_ushort);
+} /* test_scalar_select() */
/****************************************************************
**
@@ -5171,7 +5329,10 @@ test_select(void)
test_select_fill_hyper_irregular(offset);
/* Test 0-sized selections */
- test_zero_none();
+ test_select_none();
+
+ /* Test selections on scalar dataspaces */
+ test_scalar_select();
} /* test_select() */
diff --git a/testpar/t_dset.c b/testpar/t_dset.c
index c65ee11..a65a3ae 100644
--- a/testpar/t_dset.c
+++ b/testpar/t_dset.c
@@ -479,7 +479,7 @@ dataset_writeAll(char *filename)
hid_t sid; /* Dataspace ID */
hid_t file_dataspace; /* File dataspace ID */
hid_t mem_dataspace; /* memory dataspace ID */
- hid_t dataset1, dataset2, dataset3; /* Dataset ID */
+ hid_t dataset1, dataset2, dataset3, dataset4; /* Dataset ID */
hid_t datatype; /* Datatype ID */
hsize_t dims[RANK]; /* dataset dim sizes */
DATATYPE *data_array1 = NULL; /* data buffer */
@@ -525,7 +525,7 @@ dataset_writeAll(char *filename)
* Define the dimensions of the overall datasets
* and create the dataset
* ------------------------- */
- /* setup dimensionality object */
+ /* setup 2-D dimensionality object */
dims[0] = dim0;
dims[1] = dim1;
sid = H5Screate_simple (RANK, dims, NULL);
@@ -546,7 +546,21 @@ dataset_writeAll(char *filename)
/* create a third dataset collectively */
dataset3 = H5Dcreate(fid, DATASETNAME3, H5T_NATIVE_INT, sid, H5P_DEFAULT);
- VRFY((dataset1 >= 0), "H5Dcreate succeeded");
+ VRFY((dataset3 >= 0), "H5Dcreate succeeded");
+
+ /* release 2-D space ID created */
+ H5Sclose(sid);
+
+ /* setup scalar dimensionality object */
+ sid = H5Screate(H5S_SCALAR);
+ VRFY((sid >= 0), "H5Screate succeeded");
+
+ /* create a fourth dataset collectively */
+ dataset4 = H5Dcreate(fid, DATASETNAME4, H5T_NATIVE_INT, sid, H5P_DEFAULT);
+ VRFY((dataset4 >= 0), "H5Dcreate succeeded");
+
+ /* release scalar space ID created */
+ H5Sclose(sid);
/*
* Set up dimensions of the slab this process accesses.
@@ -722,6 +736,66 @@ dataset_writeAll(char *filename)
VRFY((ret >= 0), "H5Dwrite dataset3 succeeded");
/* release all temporary handles. */
+ /* Could have used them for dataset4 but it is cleaner */
+ /* to create them again.*/
+ H5Sclose(file_dataspace);
+ H5Sclose(mem_dataspace);
+ H5Pclose(xfer_plist);
+
+ /* Dataset4: each process writes no data, except process zero uses "all" selection. */
+ /* Additionally, these are in a scalar dataspace */
+
+ /* create a file dataspace independently */
+ file_dataspace = H5Dget_space (dataset4);
+ VRFY((file_dataspace >= 0), "H5Dget_space succeeded");
+ if (MAINPROCESS) {
+ ret=H5Sselect_none(file_dataspace);
+ VRFY((ret >= 0), "H5Sselect_all file_dataspace succeeded");
+ } /* end if */
+ else {
+ ret=H5Sselect_all(file_dataspace);
+ VRFY((ret >= 0), "H5Sselect_none succeeded");
+ } /* end else */
+
+ /* create a memory dataspace independently */
+ mem_dataspace = H5Screate(H5S_SCALAR);
+ VRFY((mem_dataspace >= 0), "");
+ if (MAINPROCESS) {
+ ret=H5Sselect_none(mem_dataspace);
+ VRFY((ret >= 0), "H5Sselect_all mem_dataspace succeeded");
+ } /* end if */
+ else {
+ ret=H5Sselect_all(mem_dataspace);
+ VRFY((ret >= 0), "H5Sselect_none succeeded");
+ } /* end else */
+
+ /* fill the local slab with some trivial data */
+ dataset_fill(start, block, data_array1);
+ MESG("data_array initialized");
+ if (verbose) {
+ MESG("data_array created");
+ dataset_print(start, block, data_array1);
+ } /* end if */
+
+ /* set up the collective transfer properties list */
+ xfer_plist = H5Pcreate (H5P_DATASET_XFER);
+ VRFY((xfer_plist >= 0), "");
+ ret=H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE);
+ VRFY((ret >= 0), "H5Pcreate xfer succeeded");
+
+ /* write data collectively */
+ MESG("writeAll with scalar dataspace");
+ ret = H5Dwrite(dataset4, H5T_NATIVE_INT, mem_dataspace, file_dataspace,
+ xfer_plist, data_array1);
+ VRFY((ret >= 0), "H5Dwrite dataset4 succeeded");
+
+ /* write data collectively (with datatype conversion) */
+ MESG("writeAll with scalar dataspace");
+ ret = H5Dwrite(dataset4, H5T_NATIVE_UCHAR, mem_dataspace, file_dataspace,
+ xfer_plist, data_array1);
+ VRFY((ret >= 0), "H5Dwrite dataset4 succeeded");
+
+ /* release all temporary handles. */
H5Sclose(file_dataspace);
H5Sclose(mem_dataspace);
H5Pclose(xfer_plist);
@@ -735,9 +809,8 @@ dataset_writeAll(char *filename)
VRFY((ret >= 0), "H5Dclose2 succeeded");
ret=H5Dclose(dataset3);
VRFY((ret >= 0), "H5Dclose3 succeeded");
-
- /* release all IDs created */
- H5Sclose(sid);
+ ret=H5Dclose(dataset4);
+ VRFY((ret >= 0), "H5Dclose3 succeeded");
/* close the file collectively */
H5Fclose(fid);
diff --git a/testpar/testphdf5.h b/testpar/testphdf5.h
index 1e0e47a..57d6112 100644
--- a/testpar/testphdf5.h
+++ b/testpar/testphdf5.h
@@ -72,6 +72,7 @@
#define DATASETNAME1 "Data1"
#define DATASETNAME2 "Data2"
#define DATASETNAME3 "Data3"
+#define DATASETNAME4 "Data4"
/* hyperslab layout styles */
#define BYROW 1 /* divide into slabs of rows */
#define BYCOL 2 /* divide into blocks of columns */