Refactor H5S__hyper_project_intersection to operate directly on span

trees, improving performance and removing the conditionn that the
extents be equal.
This commit is contained in:
Neil Fortner 2019-05-31 19:26:56 -05:00
parent 4af633d1c4
commit 35a8a549f6
5 changed files with 1458 additions and 341 deletions

View File

@ -130,6 +130,14 @@ New Features
Library:
--------
- Improved the performance of virtual dataset I/O
Refactored the internal dataspace routines used by the virtual dataset
code to improve performance, especially when one of the selections
involved is very long and non-contiguous.
(NAF - 2019/05/31, HDFFV-10693)
- Allow pre-generated H5Tinit.c and H5make_libsettings.c to be used.
Rather than always running H5detect and generating H5Tinit.c and

View File

@ -35,6 +35,13 @@
* until the virtual dataset is closed.
*/
/*
* Note: H5S_select_project_intersection has been updated to no longer require
* that the source and source intersect spaces have the same extent. This file
* should therefore be updated to remove code that ensures this condition, which
* should improve both maintainability and performance.
*/
/****************/
/* Module Setup */
/****************/

File diff suppressed because it is too large Load Diff

View File

@ -2374,10 +2374,11 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
if(H5S_select_copy(new_space, dst_space, FALSE) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy destination space selection")
} /* end if */
/* If any of the spaces are "none", the projection must also be "none" */
else if((src_intersect_space->select.type->type == H5S_SEL_NONE)
|| (src_space->select.type->type == H5S_SEL_NONE)
|| (dst_space->select.type->type == H5S_SEL_NONE)) {
/* If any of the selections contain no elements, the projection must be
* "none" */
else if((H5S_GET_SELECT_NPOINTS(src_intersect_space) == 0)
|| (H5S_GET_SELECT_NPOINTS(src_space) == 0)
|| (H5S_GET_SELECT_NPOINTS(dst_space) == 0)) {
/* Change to "none" selection */
if(H5S_select_none(new_space) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
@ -2389,6 +2390,8 @@ H5S_select_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL, "point selections not currently supported")
else {
HDassert(src_intersect_space->select.type->type == H5S_SEL_HYPERSLABS);
HDassert(src_space->select.type->type != H5S_SEL_NONE);
HDassert(dst_space->select.type->type != H5S_SEL_NONE);
/* Intersecting space is hyperslab selection. Call the hyperslab
* routine to project to another hyperslab selection. */

View File

@ -1409,7 +1409,7 @@ test_basic_io(unsigned config, hid_t fapl)
int erbuf[10][26]; /* Expected read buffer */
int fill = -1; /* Fill value */
herr_t ret; /* Generic return value */
int i, j;
int i, j, u, v;
TESTING("basic virtual dataset I/O")
@ -3498,6 +3498,724 @@ test_basic_io(unsigned config, hid_t fapl)
memspace = -1;
/*
* Test 8: For code coverage: Horizontal block virtual mappings, and file
* selection, grid memory selection
*/
/* Clear virtual layout in DCPL */
if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0)
TEST_ERROR
/* Create memory dataspace */
if((memspace = H5Screate_simple(2, dims, NULL)) < 0)
TEST_ERROR
/* Create virtual dataspaces */
dims[0] = 8;
dims[1] = 15;
if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0)
TEST_ERROR
if((vspace[1] = H5Screate_simple(2, dims, NULL)) < 0)
TEST_ERROR
/* Create source dataspace */
dims[0] = 4;
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] = 0;
if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, dims, NULL) < 0)
TEST_ERROR
start[0] = 4;
if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, dims, NULL) < 0)
TEST_ERROR
/* Add virtual layout mappings */
if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", srcspace[0]) < 0)
TEST_ERROR
if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", srcspace[0]) < 0)
TEST_ERROR
/* Reset dims */
dims[0] = 10;
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
}
else {
srcfile[0] = vfile;
if(H5Iinc_ref(srcfile[0]) < 0)
TEST_ERROR
}
/* 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
/* Reset erbuf */
HDmemset(erbuf[0], 0, sizeof(rbuf));
/* 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;
/* Select hyperslab in memory */
start[0] = 0;
start[1] = 0;
count[0] = 4;
count[1] = 15;
if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
TEST_ERROR
/* Write data directly to first source dataset */
if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0)
TEST_ERROR
/* Update erbuf */
u = 0;
v = 0;
for(i = 2; i < 4; i++)
for(j = 0; j < 15; j++) {
erbuf[u][v] = buf[i][j];
v += 2;
if(v >= 24) {
u += 2;
v = 0;
}
}
/* Select hyperslab in memory */
start[0] = 4;
if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
TEST_ERROR
/* Write data directly to second source dataset */
if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0)
TEST_ERROR
/* Update erbuf */
for(i = 4; i < 6; i++)
for(j = 0; j < 15; j++) {
erbuf[u][v] = buf[i][j];
v += 2;
if(v >= 24) {
u += 2;
v = 0;
}
}
/* 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(H5Fclose(srcfile[0]) < 0)
TEST_ERROR
srcfile[0] = -1;
}
/* 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
}
/* Select hyperslab in memory */
start[0] = 0;
start[1] = 0;
stride[0] = 2;
stride[1] = 2;
count[0] = 5;
count[1] = 12;
block[0] = 1;
block[1] = 1;
if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, stride, count, block) < 0)
TEST_ERROR
/* Select hyperslab in file */
start[0] = 2;
start[1] = 0;
count[0] = 4;
count[1] = 15;
if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0)
TEST_ERROR
/* Read data through virtual dataset */
HDmemset(rbuf[0], 0, sizeof(rbuf));
if(H5Dread(vdset, H5T_NATIVE_INT, memspace, vspace[0], 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] != erbuf[i][j])
TEST_ERROR
/* Close */
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(H5Fclose(srcfile[0]) < 0)
TEST_ERROR
srcfile[0] = -1;
}
if(H5Dclose(vdset) < 0)
TEST_ERROR
vdset = -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;
if(H5Sclose(vspace[1]) < 0)
TEST_ERROR
vspace[1] = -1;
if(H5Sclose(memspace) < 0)
TEST_ERROR
memspace = -1;
/*
* Test 9: For code coverage: Horizontal block virtual mappings, and file
* selection, grid memory selection, 3 mappings, 3D memory space
*/
/* Clear virtual layout in DCPL */
if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0)
TEST_ERROR
/* Create memory dataspace */
dims[1] = 13;
dims[2] = 2;
if((memspace = H5Screate_simple(3, dims, NULL)) < 0)
TEST_ERROR
/* Create virtual dataspaces */
dims[0] = 6;
dims[1] = 10;
if((vspace[0] = H5Screate_simple(2, dims, NULL)) < 0)
TEST_ERROR
if((vspace[1] = H5Screate_simple(2, dims, NULL)) < 0)
TEST_ERROR
if((vspace[2] = H5Screate_simple(2, dims, NULL)) < 0)
TEST_ERROR
/* Create source dataspace */
dims[0] = 2;
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] = 0;
if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, dims, NULL) < 0)
TEST_ERROR
start[0] = 2;
if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, NULL, dims, NULL) < 0)
TEST_ERROR
start[0] = 4;
if(H5Sselect_hyperslab(vspace[2], H5S_SELECT_SET, start, NULL, dims, NULL) < 0)
TEST_ERROR
/* Add virtual layout mappings */
if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", srcspace[0]) < 0)
TEST_ERROR
if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", srcspace[0]) < 0)
TEST_ERROR
if(H5Pset_virtual(dcpl, vspace[2], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset3", srcspace[0]) < 0)
TEST_ERROR
/* Reset dims */
dims[0] = 10;
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
}
else {
srcfile[0] = vfile;
if(H5Iinc_ref(srcfile[0]) < 0)
TEST_ERROR
}
/* 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
if((srcdset[2] = H5Dcreate2(srcfile[0], "src_dset3", 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
/* Reset erbuf */
HDmemset(erbuf[0], 0, sizeof(rbuf));
/* 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;
/* Select hyperslab in memory */
start[0] = 0;
start[1] = 0;
start[2] = 0;
count[0] = 2;
count[1] = 5;
count[2] = 2;
if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
TEST_ERROR
/* Write data directly to first source dataset */
if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0)
TEST_ERROR
/* Update erbuf */
u = 0;
v = 0;
for(i = 0; i < 2; i++)
for(j = 0; j < 10; j++) {
erbuf[u][v] = buf[i][j];
if(++v == 6)
v += 2;
else if(v == 14) {
u += 2;
v = 0;
}
}
/* Select hyperslab in memory */
start[0] = 2;
if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
TEST_ERROR
/* Write data directly to second source dataset */
if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0)
TEST_ERROR
/* Update erbuf */
for(i = 2; i < 4; i++)
for(j = 0; j < 10; j++) {
erbuf[u][v] = buf[i][j];
if(++v == 6)
v += 2;
else if(v == 14) {
u += 2;
v = 0;
}
}
/* Select hyperslab in memory */
start[0] = 4;
if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
TEST_ERROR
/* Write data directly to third source dataset */
if(H5Dwrite(srcdset[2], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0)
TEST_ERROR
/* Update erbuf */
for(i = 4; i < 6; i++)
for(j = 0; j < 10; j++) {
erbuf[u][v] = buf[i][j];
if(++v == 6)
v += 2;
else if(v == 14) {
u += 2;
v = 0;
}
}
/* 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(H5Dclose(srcdset[2]) < 0)
TEST_ERROR
srcdset[2] = -1;
if(H5Fclose(srcfile[0]) < 0)
TEST_ERROR
srcfile[0] = -1;
}
/* 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
}
/* Select hyperslab in memory */
start[0] = 0;
start[1] = 0;
start[2] = 0;
stride[0] = 2;
stride[1] = 4;
stride[2] = 1;
count[0] = 5;
count[1] = 2;
count[2] = 1;
block[0] = 1;
block[1] = 3;
block[2] = 2;
if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, stride, count, block) < 0)
TEST_ERROR
/* Read data through virtual dataset */
HDmemset(rbuf[0], 0, sizeof(rbuf));
if(H5Dread(vdset, H5T_NATIVE_INT, memspace, 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] != erbuf[i][j])
TEST_ERROR
/* Close */
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(H5Dclose(srcdset[2]) < 0)
TEST_ERROR
srcdset[2] = -1;
if(H5Fclose(srcfile[0]) < 0)
TEST_ERROR
srcfile[0] = -1;
}
if(H5Dclose(vdset) < 0)
TEST_ERROR
vdset = -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;
if(H5Sclose(vspace[1]) < 0)
TEST_ERROR
vspace[1] = -1;
if(H5Sclose(vspace[2]) < 0)
TEST_ERROR
vspace[2] = -1;
if(H5Sclose(memspace) < 0)
TEST_ERROR
memspace = -1;
/*
* Test 10: For code coverage: Vertical stripe virtual mappings, vertical
* block file selection, block memory selection, 3D VDS
*/
/* Clear virtual layout in DCPL */
if(H5Pset_layout(dcpl, H5D_VIRTUAL) < 0)
TEST_ERROR
/* Create memory dataspace */
if((memspace = H5Screate_simple(2, dims, NULL)) < 0)
TEST_ERROR
/* Create virtual dataspaces */
dims[0] = 10;
dims[1] = 9;
dims[2] = 6;
if((vspace[0] = H5Screate_simple(3, dims, NULL)) < 0)
TEST_ERROR
if((vspace[1] = H5Screate_simple(3, dims, NULL)) < 0)
TEST_ERROR
/* Create source dataspace */
dims[1] = 12;
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] = 0;
start[2] = 0;
count[0] = 1;
count[1] = 4;
count[2] = 3;
stride[0] = 1;
stride[1] = 2;
stride[2] = 2;
block[0] = 10;
block[1] = 1;
block[2] = 1;
if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, stride, count, block) < 0)
TEST_ERROR
start[2] = 1;
if(H5Sselect_hyperslab(vspace[1], H5S_SELECT_SET, start, stride, count, block) < 0)
TEST_ERROR
/* Add virtual layout mappings */
if(H5Pset_virtual(dcpl, vspace[0], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset1", srcspace[0]) < 0)
TEST_ERROR
if(H5Pset_virtual(dcpl, vspace[1], config & TEST_IO_DIFFERENT_FILE ? srcfilename_map : ".", "src_dset2", srcspace[0]) < 0)
TEST_ERROR
/* Reset dims */
dims[0] = 10;
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
}
else {
srcfile[0] = vfile;
if(H5Iinc_ref(srcfile[0]) < 0)
TEST_ERROR
}
/* 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
/* Initialize erbuf */
HDmemset(erbuf[0], 0, sizeof(rbuf));
for(i = 0; i < 10; i++)
for(j = 0; j < 24; j += 6) {
erbuf[i][j] = -1;
erbuf[i][j + 1] = -1;
}
/* 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;
/* Select hyperslab in memory */
start[0] = 0;
start[1] = 0;
count[0] = 10;
count[1] = 12;
if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
TEST_ERROR
/* Write data directly to first source dataset */
if(H5Dwrite(srcdset[0], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0)
TEST_ERROR
/* Update erbuf */
u = 0;
v = 0;
for(i = 0; i < 10; i++)
for(j = 0; j < 8; j++) {
if(v == 0 || v == 12)
erbuf[u][v] = buf[i][j];
v += 2;
if(!(v % 6))
v += 6;
if(v >= 28) {
u++;
v = 0;
}
}
/* Select hyperslab in memory */
start[1] = 8;
if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, NULL, count, NULL) < 0)
TEST_ERROR
/* Write data directly to second source dataset */
if(H5Dwrite(srcdset[1], H5T_NATIVE_INT, memspace, H5S_ALL, H5P_DEFAULT, buf[0]) < 0)
TEST_ERROR
/* Update erbuf */
u = 0;
v = 1;
for(i = 0; i < 10; i++)
for(j = 8; j < 16; j++) {
if(v == 1 || v == 13)
erbuf[u][v] = buf[i][j];
v += 2;
if(!((v - 1) % 6))
v += 6;
if(v >= 28) {
u++;
v = 1;
}
}
/* 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(H5Fclose(srcfile[0]) < 0)
TEST_ERROR
srcfile[0] = -1;
}
/* 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
}
/* Select hyperslab in memory */
start[0] = 0;
start[1] = 0;
stride[0] = 1;
stride[1] = 6;
count[0] = 1;
count[1] = 4;
block[0] = 10;
block[1] = 2;
if(H5Sselect_hyperslab(memspace, H5S_SELECT_SET, start, stride, count, block) < 0)
TEST_ERROR
/* Select hyperslab in file */
start[0] = 0;
start[1] = 0;
start[2] = 0;
count[0] = 10;
count[1] = 4;
count[2] = 2;
if(H5Sselect_hyperslab(vspace[0], H5S_SELECT_SET, start, NULL, count, NULL) < 0)
TEST_ERROR
/* Read data through virtual dataset */
HDmemset(rbuf[0], 0, sizeof(rbuf));
if(H5Dread(vdset, H5T_NATIVE_INT, memspace, vspace[0], 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] != erbuf[i][j])
TEST_ERROR
/* Close */
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(H5Fclose(srcfile[0]) < 0)
TEST_ERROR
srcfile[0] = -1;
}
if(H5Dclose(vdset) < 0)
TEST_ERROR
vdset = -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;
if(H5Sclose(vspace[1]) < 0)
TEST_ERROR
vspace[1] = -1;
if(H5Sclose(memspace) < 0)
TEST_ERROR
memspace = -1;
/* Close */
if(H5Pclose(dcpl) < 0)
TEST_ERROR