summaryrefslogtreecommitdiffstats
path: root/test/tselect.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-04-02 20:51:41 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-04-02 20:51:41 (GMT)
commitd2232a345f36988f4a60034d63ddca25c476fc08 (patch)
tree2ba460735cb162b5ee94ae98f0d46873488fa454 /test/tselect.c
parentc1e44699f0460cd5a675a71dc85296740f07063a (diff)
downloadhdf5-d2232a345f36988f4a60034d63ddca25c476fc08.zip
hdf5-d2232a345f36988f4a60034d63ddca25c476fc08.tar.gz
hdf5-d2232a345f36988f4a60034d63ddca25c476fc08.tar.bz2
[svn-r5130] Purpose:
Bug Fix & Feature Description: The selection offset was being ignored for optimized hyperslab selection I/O operations. Additionally, I've found that the restrictions on optimized selection I/O operations were too strict and found a way to allow more hyperslabs to use the optimized I/O routines. Solution: Incorporate the selection offset into the selection location when performing optimized I/O operations. Allow optimized I/O on any single hyperslab selection and also allow hyperslab operations on chunked datasets. Platforms tested: FreeBSD 4.5 (sleipnir)
Diffstat (limited to 'test/tselect.c')
-rw-r--r--test/tselect.c122
1 files changed, 120 insertions, 2 deletions
diff --git a/test/tselect.c b/test/tselect.c
index 2a32a78..d0454d6 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -1227,9 +1227,7 @@ test_select_hyper_contig2(hid_t dset_type, hid_t xfer_plist)
hid_t sid1,sid2; /* Dataspace ID */
hsize_t dims2[] = {SPACE8_DIM4, SPACE8_DIM3, SPACE8_DIM2, SPACE8_DIM1};
hssize_t start[SPACE8_RANK]; /* Starting location of hyperslab */
- hsize_t stride[SPACE8_RANK]; /* Stride of hyperslab */
hsize_t count[SPACE8_RANK]; /* Element count of hyperslab */
- hsize_t block[SPACE8_RANK]; /* Block size of hyperslab */
uint16_t *wbuf, /* buffer to write to disk */
*rbuf, /* buffer read from disk */
*tbuf; /* temporary buffer pointer */
@@ -1830,6 +1828,125 @@ test_select_hyper_offset(void)
/****************************************************************
**
+** test_select_hyper_offset2(): Test basic H5S (dataspace) selection code.
+** Tests optimized hyperslab I/O with selection offsets.
+**
+****************************************************************/
+static void
+test_select_hyper_offset2(void)
+{
+ hid_t fid1; /* HDF5 File IDs */
+ hid_t dataset; /* Dataset ID */
+ hid_t sid1,sid2; /* Dataspace ID */
+ hsize_t dims1[] = {SPACE7_DIM1, SPACE7_DIM2};
+ hsize_t dims2[] = {SPACE7_DIM1, SPACE7_DIM2};
+ hssize_t start[SPACE7_RANK]; /* Starting location of hyperslab */
+ hsize_t count[SPACE7_RANK]; /* Element count of hyperslab */
+ hssize_t offset[SPACE7_RANK]; /* Offset of selection */
+ uint8_t *wbuf, /* buffer to write to disk */
+ *rbuf, /* buffer read from disk */
+ *tbuf, /* temporary buffer pointer */
+ *tbuf2; /* temporary buffer pointer */
+ int i,j; /* Counters */
+ herr_t ret; /* Generic return value */
+ htri_t valid; /* Generic boolean return value */
+
+ /* Output message about test being performed */
+ MESSAGE(5, ("Testing More Hyperslab Selection Functions with Offsets\n"));
+
+ /* Allocate write & read buffers */
+ wbuf=malloc(sizeof(uint8_t)*SPACE7_DIM1*SPACE7_DIM2);
+ rbuf=calloc(sizeof(uint8_t),SPACE7_DIM1*SPACE7_DIM2);
+
+ /* Initialize write buffer */
+ for(i=0, tbuf=wbuf; i<SPACE7_DIM1; i++)
+ for(j=0; j<SPACE7_DIM2; j++)
+ *tbuf++=(uint8_t)((i*SPACE7_DIM2)+j);
+
+ /* Create file */
+ fid1 = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ CHECK(fid1, FAIL, "H5Fcreate");
+
+ /* Create dataspace for dataset */
+ sid1 = H5Screate_simple(SPACE7_RANK, dims1, NULL);
+ CHECK(sid1, FAIL, "H5Screate_simple");
+
+ /* Create dataspace for writing buffer */
+ sid2 = H5Screate_simple(SPACE7_RANK, dims2, NULL);
+ CHECK(sid2, FAIL, "H5Screate_simple");
+
+ /* Select 4x10 hyperslab for disk dataset */
+ start[0]=1; start[1]=0;
+ count[0]=4; count[1]=10;
+ ret = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,NULL,count,NULL);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Set offset */
+ offset[0]=1; offset[1]=0;
+ ret = H5Soffset_simple(sid1,offset);
+ CHECK(ret, FAIL, "H5Soffset_simple");
+ valid = H5Sselect_valid(sid1);
+ VERIFY(valid, TRUE, "H5Sselect_valid");
+
+ /* Select 4x10 hyperslab for memory dataset */
+ start[0]=1; start[1]=0;
+ count[0]=4; count[1]=10;
+ ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,NULL,count,NULL);
+ CHECK(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Choose a valid offset for the memory dataspace */
+ offset[0]=2; offset[1]=0;
+ ret = H5Soffset_simple(sid2,offset);
+ CHECK(ret, FAIL, "H5Soffset_simple");
+ valid = H5Sselect_valid(sid2);
+ VERIFY(valid, TRUE, "H5Sselect_valid");
+
+ /* Create a dataset */
+ dataset=H5Dcreate(fid1,"Dataset1",H5T_NATIVE_UCHAR,sid1,H5P_DEFAULT);
+
+ /* Write selection to disk */
+ ret=H5Dwrite(dataset,H5T_NATIVE_UCHAR,sid2,sid1,H5P_DEFAULT,wbuf);
+ CHECK(ret, FAIL, "H5Dwrite");
+
+ /* Read selection from disk */
+ ret=H5Dread(dataset,H5T_NATIVE_UCHAR,sid2,sid1,H5P_DEFAULT,rbuf);
+ CHECK(ret, FAIL, "H5Dread");
+
+ /* Compare data read with data written out */
+ for(i=0; i<4; i++) {
+ tbuf=wbuf+((i+3)*SPACE7_DIM2);
+ tbuf2=rbuf+((i+3)*SPACE7_DIM2);
+ for(j=0; j<SPACE7_DIM2; j++, tbuf++, tbuf2++) {
+ if(*tbuf!=*tbuf2) {
+ printf("%d: hyperslab values don't match!, i=%d, j=%d, *tbuf=%u, *tbuf2=%u\n",__LINE__,i,j,(unsigned)*tbuf,(unsigned)*tbuf2);
+ num_errs++;
+ } /* end if */
+ } /* end for */
+ } /* end for */
+
+ /* 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);
+ free(rbuf);
+} /* test_select_hyper_offset2() */
+
+/****************************************************************
+**
** test_select_point_offset(): Test basic H5S (dataspace) selection code.
** Tests element selections between dataspaces of various sizes
** and dimensionalities with selection offsets.
@@ -4345,6 +4462,7 @@ test_select(void)
test_select_hyper_copy(); /* Test hyperslab selection copying code */
test_select_point_copy(); /* Test point selection copying code */
test_select_hyper_offset(); /* Test selection offset code with hyperslabs */
+ test_select_hyper_offset2();/* Test more selection offset code with hyperslabs */
test_select_point_offset(); /* Test selection offset code with elements */
test_select_hyper_union(); /* Test hyperslab union code */
#ifdef NEW_HYPERSLAB_API