summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeil Fortner <nfortne2@hdfgroup.org>2015-08-07 20:06:56 (GMT)
committerNeil Fortner <nfortne2@hdfgroup.org>2015-08-07 20:06:56 (GMT)
commit0c4ec00cba82a900d22c3ba9bb0403a6b4cf8208 (patch)
tree8bcff59908f166b3a138ea6ae56ae841c28bcdec
parent98f947ceaedbae472efbebad505680d2ca62b403 (diff)
downloadhdf5-0c4ec00cba82a900d22c3ba9bb0403a6b4cf8208.zip
hdf5-0c4ec00cba82a900d22c3ba9bb0403a6b4cf8208.tar.gz
hdf5-0c4ec00cba82a900d22c3ba9bb0403a6b4cf8208.tar.bz2
[svn-r27481] Add support for offset selections passed to H5Pset_virtual.
Add test for this. Tested: ummon
-rw-r--r--src/H5Dvirtual.c16
-rw-r--r--test/vds.c197
2 files changed, 207 insertions, 6 deletions
diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c
index db45ceb..04f42c9 100644
--- a/src/H5Dvirtual.c
+++ b/src/H5Dvirtual.c
@@ -1552,6 +1552,7 @@ H5D__virtual_init(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, const H5D_t *dset,
{
H5O_storage_virtual_t *storage; /* Convenience pointer */
H5P_genplist_t *dapl; /* Data access property list object pointer */
+ hssize_t old_offset[H5O_LAYOUT_NDIMS]; /* Old selection offset (unused) */
size_t i; /* Local index variables */
herr_t ret_value = SUCCEED; /* Return value */
@@ -1566,12 +1567,23 @@ H5D__virtual_init(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, const H5D_t *dset,
* status because this layout could be from an old version held in the
* object header message code. We cannot update that held message because
* the layout message is constant, so just overwrite the values here (and
- * invalidate other fields by setting storage->init to FALSE below). */
+ * invalidate other fields by setting storage->init to FALSE below). Also
+ * remove offset from selections. We only have to update
+ * source_space_status and virtual_space_status because others will be based
+ * on these and should therefore already have been normalized. */
for(i = 0; i < storage->list_nused; i++) {
+ HDassert(storage->list[i].sub_dset_nalloc == 0);
+
+ /* Patch extent */
if(H5S_extent_copy(storage->list[i].source_dset.virtual_select, dset->shared->space) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy virtual dataspace extent")
storage->list[i].virtual_space_status = H5O_VIRTUAL_STATUS_CORRECT;
- HDassert(storage->list[i].sub_dset_nalloc == 0);
+
+ /* Normalize offsets, toss out old offset values */
+ if(H5S_hyper_normalize_offset(storage->list[i].source_dset.virtual_select, old_offset) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to normalize dataspace by offset")
+ if(H5S_hyper_normalize_offset(storage->list[i].source_select, old_offset) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_BADSELECT, FAIL, "unable to normalize dataspace by offset")
} /* end for */
/* Get dataset access property list */
diff --git a/test/vds.c b/test/vds.c
index 547f775..64a72f5 100644
--- a/test/vds.c
+++ b/test/vds.c
@@ -1104,6 +1104,7 @@ test_basic_io(unsigned config, hid_t fapl)
hsize_t stride[4]; /* Hyperslab stride */
hsize_t count[4]; /* Hyperslab count */
hsize_t block[4]; /* Hyperslab block */
+ hssize_t offset[2] = {0, 0}; /* Selection offset */
int buf[10][26]; /* Write and expected read buffer */
int rbuf[10][26]; /* Read buffer */
int rbuf99[9][9]; /* 9x9 Read buffer */
@@ -1606,7 +1607,195 @@ test_basic_io(unsigned config, hid_t fapl)
/*
- * Test 3: 2 Source datasets, hyperslab virtual mappings on one mapping at a
+ * Test 3: 2 Source datasets, hyperslab virtual mappings with offsets
+ */
+ /* Clear virtual layout in DCPL */
+ if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0)
+ TEST_ERROR
+
+ /* Create virtual dataspaces */
+ if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0)
+ TEST_ERROR
+
+ /* Create source dataspace */
+ dims[1] = 13;
+ if((srcspace[0] = H5Screate_simple(2, dims, NULL)) < 0)
+ TEST_ERROR
+
+ /* Select all in source space (should not be necessary, but just to be sure)
+ */
+ if(H5Sselect_all(srcspace[0]) < 0)
+ TEST_ERROR
+
+ /* Select hyperslabs in virtual spaces */
+ start[0] = 0;
+ start[1] = 3;
+ if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, dims, NULL) < 0)
+ TEST_ERROR
+
+ /* Add virtual layout mappings */
+ offset[1] = -3;
+ if(H5Soffset_simple(vspace[0], offset) < 0)
+ TEST_ERROR
+ if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "%%src_dset1", srcspace[0]) < 0)
+ TEST_ERROR
+ offset[1] = 10;
+ if(H5Soffset_simple(vspace[0], offset) < 0)
+ TEST_ERROR
+ if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2%%", srcspace[0]) < 0)
+ TEST_ERROR
+
+ /* Reset dims */
+ dims[1] = 26;
+
+ /* Create virtual file */
+ if((vfile = H5Fcreate(vfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+
+ /* Create source file if requested */
+ if(config & TEST_IO_DIFFERENT_FILE) {
+ if((srcfile[0] = H5Fcreate(srcfilename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
+ TEST_ERROR
+ } /* end if */
+ else {
+ srcfile[0] = vfile;
+ if(H5Iinc_ref(srcfile[0]) < 0)
+ TEST_ERROR
+ } /* end if */
+
+ /* Create source datasets */
+ if((srcdset[0] = H5Dcreate2(srcfile[0], "%src_dset1", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if((srcdset[1] = H5Dcreate2(srcfile[0], "src_dset2%", H5T_NATIVE_INT, srcspace[0], H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Create virtual dataset */
+ if((vdset = H5Dcreate2(vfile, "v_dset", H5T_NATIVE_INT, vspace[0], H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ TEST_ERROR
+
+ /* Populate write buffer */
+ for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++)
+ for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++)
+ buf[i][j] = (i * (int)(sizeof(buf[0]) / sizeof(buf[0][0]))) + j;
+
+ /* Write data directly to source datasets */
+ offset[1] = -3;
+ if(H5Soffset_simple(vspace[0], offset) < 0)
+ TEST_ERROR
+ if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, buf[0]) < 0)
+ TEST_ERROR
+ offset[1] = 10;
+ if(H5Soffset_simple(vspace[0], offset) < 0)
+ TEST_ERROR
+ if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, buf[0]) < 0)
+ TEST_ERROR
+
+ /* Close srcdsets and srcfile if config option specified */
+ if(config & TEST_IO_CLOSE_SRC) {
+ if(H5Dclose(srcdset[0]) < 0)
+ TEST_ERROR
+ srcdset[0] = -1;
+ if(H5Dclose(srcdset[1]) < 0)
+ TEST_ERROR
+ srcdset[1] = -1;
+
+ if(config & TEST_IO_DIFFERENT_FILE) {
+ if(H5Fclose(srcfile[0]) < 0)
+ TEST_ERROR
+ srcfile[0] = -1;
+ } /* end if */
+ } /* end if */
+
+ /* Reopen virtual dataset and file if config option specified */
+ if(config & TEST_IO_REOPEN_VIRT) {
+ if(H5Dclose(vdset) < 0)
+ TEST_ERROR
+ vdset = -1;
+ if(H5Fclose(vfile) < 0)
+ TEST_ERROR
+ vfile = -1;
+ if((vfile = H5Fopen(vfilename, H5F_ACC_RDWR, fapl)) < 0)
+ TEST_ERROR
+ if((vdset = H5Dopen2(vfile, "v_dset", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ } /* end if */
+
+ /* Read data through virtual dataset */
+ HDmemset(rbuf[0], 0, sizeof(rbuf));
+ if(H5Dread(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0)
+ TEST_ERROR
+
+ /* Verify read data */
+ for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++)
+ for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++)
+ if(rbuf[i][j] != buf[i][j])
+ TEST_ERROR
+
+ /* Adjust write buffer */
+ for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++)
+ for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++)
+ buf[i][j] += (int)(sizeof(buf) / sizeof(buf[0][0]));
+
+ /* Write data through virtual dataset */
+ if(H5Dwrite(vdset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf[0]) < 0)
+ TEST_ERROR
+
+ /* Reopen srcdsets and srcfile if config option specified */
+ if(config & TEST_IO_CLOSE_SRC) {
+ if(config & TEST_IO_DIFFERENT_FILE)
+ if((srcfile[0] = H5Fopen(srcfilename, H5F_ACC_RDONLY, fapl)) < 0)
+ TEST_ERROR
+ if((srcdset[0] = H5Dopen2(srcfile[0], "%src_dset1", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ if((srcdset[1] = H5Dopen2(srcfile[0], "src_dset2%", H5P_DEFAULT)) < 0)
+ TEST_ERROR
+ } /* end if */
+
+ /* Read data directly from source datasets */
+ HDmemset(rbuf[0], 0, sizeof(rbuf));
+ offset[1] = -3;
+ if(H5Soffset_simple(vspace[0], offset) < 0)
+ TEST_ERROR
+ if(H5Dread(srcdset[0], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0)
+ TEST_ERROR
+ offset[1] = 10;
+ if(H5Soffset_simple(vspace[0], offset) < 0)
+ TEST_ERROR
+ if(H5Dread(srcdset[1], H5T_NATIVE_INT, vspace[0], H5S_ALL, H5P_DEFAULT, rbuf[0]) < 0)
+ TEST_ERROR
+
+ /* Verify read data */
+ for(i = 0; i < (int)(sizeof(buf) / sizeof(buf[0])); i++)
+ for(j = 0; j < (int)(sizeof(buf[0]) / sizeof(buf[0][0])); j++)
+ if(rbuf[i][j] != buf[i][j])
+ TEST_ERROR
+
+ /* Close */
+ if(H5Dclose(srcdset[0]) < 0)
+ TEST_ERROR
+ srcdset[0] = -1;
+ if(H5Dclose(srcdset[1]) < 0)
+ TEST_ERROR
+ srcdset[1] = -1;
+ if(H5Dclose(vdset) < 0)
+ TEST_ERROR
+ vdset = -1;
+ if(H5Fclose(srcfile[0]) < 0)
+ TEST_ERROR
+ srcfile[0] = -1;
+ if(H5Fclose(vfile) < 0)
+ TEST_ERROR
+ vfile = -1;
+ if(H5Sclose(srcspace[0]) < 0)
+ TEST_ERROR
+ srcspace[0] = -1;
+ if(H5Sclose(vspace[0]) < 0)
+ TEST_ERROR
+ vspace[0] = -1;
+
+
+ /*
+ * Test 4: 2 Source datasets, hyperslab virtual mappings on one mapping at a
* time, '%' in source file name
*/
/* Clear virtual layout in DCPL */
@@ -1809,7 +1998,7 @@ test_basic_io(unsigned config, hid_t fapl)
/*
- * Test 4: 2 Source datasets, hyperslab virtual mappings and selections
+ * Test 5: 2 Source datasets, hyperslab virtual mappings and selections
*/
/* Clear virtual layout in DCPL */
if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0)
@@ -2090,7 +2279,7 @@ test_basic_io(unsigned config, hid_t fapl)
/*
- * Test 5: 2 Source datasets, checkerboard/stripe pattern to trigger
+ * Test 6: 2 Source datasets, checkerboard/stripe pattern to trigger
* sequence list refresh internally
*/
/* Clear virtual layout in DCPL */
@@ -2383,7 +2572,7 @@ test_basic_io(unsigned config, hid_t fapl)
/*
- * Test 6: 1 Source dataset, two mappings, 4 dimensional virtual dataset
+ * Test 7: 1 Source dataset, two mappings, 4 dimensional virtual dataset
* and 3 dimensional source dataset
*/
/* Clear virtual layout in DCPL */