summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2002-06-12 17:01:01 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2002-06-12 17:01:01 (GMT)
commitbdefbb5cba63402c819819545c3d45e862540ee6 (patch)
treebce893e3521d102b0b428a937a0944da8a7b34e9
parent3bbc9285cf7bda368f18cc724f14edcf2828a0ea (diff)
downloadhdf5-bdefbb5cba63402c819819545c3d45e862540ee6.zip
hdf5-bdefbb5cba63402c819819545c3d45e862540ee6.tar.gz
hdf5-bdefbb5cba63402c819819545c3d45e862540ee6.tar.bz2
[svn-r5603] Purpose:
Bug fix Description: I/O on "Regular" hyperslab selections could fail to transfer correctly if the number of elements in the selection's row did now fit "evenly" into the buffer being used for the transfer. Solution: Correct the calculation of the block & count offsets within the optimized "regular" hyperslab routines. Platforms tested: FreeBSD 4.5 (sleipnir)
-rw-r--r--release_docs/RELEASE.txt9
-rw-r--r--src/H5Shyper.c40
-rw-r--r--test/tselect.c11
3 files changed, 44 insertions, 16 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index be279a8..2049ac8 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -35,6 +35,9 @@ Bug Fixes since HDF5-1.4.0
Library
-------
+ * Fixed bug where regular hyperslab selection could get incorrectly
+ transferred when the number of elements in a row did not fit evenly
+ into the buffer provided. QAK 2002/06/12
* Fixed bug (#499) which allowed an "empty" compound or enumerated datatype
(one with no members) to be used to create a dataset or committed to a
file. QAK - 2002/06/11
@@ -302,9 +305,9 @@ New Features
7 and contains the sizes of the data buffer dimensions.
- F90 subroutines h5dwrite_f, h5dread_f, h5awrite_f and h5aread_f were
overloaded with "dims" argument to be assumed size array of type
- INTEGER(HSIZE_T). We recommend to use the subroutines with the new type.
- Module subroutines that accept "dims" as INTEGER array of size 7 will be
- depricated in 1.6 release.
+ INTEGER(HSIZE_T). We recommend to use the subroutines with the new
+ type. Module subroutines that accept "dims" as INTEGER array of size
+ 7 will be deprecated in 1.6 release.
EIP - 2002/05/06
* C++ API:
- Added two new member functions: Exception::getFuncName() and
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 1d14592..bf035b4 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -968,8 +968,14 @@ H5S_hyper_fread_opt (H5F_t *f, const struct H5O_layout_t *layout,
/* Compute the current "counts" for this location */
for(i=0; i<ndims; i++) {
- tmp_count[i] = (file_iter->hyp.off[i]-file_space->select.sel_info.hslab.diminfo[i].start)%file_space->select.sel_info.hslab.diminfo[i].stride;
- tmp_block[i] = (file_iter->hyp.off[i]-file_space->select.sel_info.hslab.diminfo[i].start)/file_space->select.sel_info.hslab.diminfo[i].stride;
+ if(file_space->select.sel_info.hslab.diminfo[i].stride==1) {
+ tmp_count[i] = 0;
+ tmp_block[i] = file_iter->hyp.off[i]-file_space->select.sel_info.hslab.diminfo[i].start;
+ } /* end if */
+ else {
+ tmp_count[i] = (file_iter->hyp.off[i]-file_space->select.sel_info.hslab.diminfo[i].start)/file_space->select.sel_info.hslab.diminfo[i].stride;
+ tmp_block[i] = (file_iter->hyp.off[i]-file_space->select.sel_info.hslab.diminfo[i].start)%file_space->select.sel_info.hslab.diminfo[i].stride;
+ } /* end else */
} /* end for */
/* Compute the initial buffer offset */
@@ -1993,8 +1999,14 @@ H5S_hyper_fwrite_opt (H5F_t *f, const struct H5O_layout_t *layout,
/* Compute the current "counts" for this location */
for(i=0; i<ndims; i++) {
- tmp_count[i] = (file_iter->hyp.off[i]-file_space->select.sel_info.hslab.diminfo[i].start)%file_space->select.sel_info.hslab.diminfo[i].stride;
- tmp_block[i] = (file_iter->hyp.off[i]-file_space->select.sel_info.hslab.diminfo[i].start)/file_space->select.sel_info.hslab.diminfo[i].stride;
+ if(file_space->select.sel_info.hslab.diminfo[i].stride==1) {
+ tmp_count[i] = 0;
+ tmp_block[i] = file_iter->hyp.off[i]-file_space->select.sel_info.hslab.diminfo[i].start;
+ } /* end if */
+ else {
+ tmp_count[i] = (file_iter->hyp.off[i]-file_space->select.sel_info.hslab.diminfo[i].start)/file_space->select.sel_info.hslab.diminfo[i].stride;
+ tmp_block[i] = (file_iter->hyp.off[i]-file_space->select.sel_info.hslab.diminfo[i].start)%file_space->select.sel_info.hslab.diminfo[i].stride;
+ } /* end else */
} /* end for */
/* Compute the initial buffer offset */
@@ -2923,8 +2935,14 @@ H5S_hyper_mread_opt (const void *_buf, size_t elmt_size,
/* Compute the current "counts" for this location */
for(i=0; i<ndims; i++) {
- tmp_count[i] = (mem_iter->hyp.off[i]-mem_space->select.sel_info.hslab.diminfo[i].start)%mem_space->select.sel_info.hslab.diminfo[i].stride;
- tmp_block[i] = (mem_iter->hyp.off[i]-mem_space->select.sel_info.hslab.diminfo[i].start)/mem_space->select.sel_info.hslab.diminfo[i].stride;
+ if(mem_space->select.sel_info.hslab.diminfo[i].stride==1) {
+ tmp_count[i] = 0;
+ tmp_block[i] = mem_iter->hyp.off[i]-mem_space->select.sel_info.hslab.diminfo[i].start;
+ } /* end if */
+ else {
+ tmp_count[i] = (mem_iter->hyp.off[i]-mem_space->select.sel_info.hslab.diminfo[i].start)/mem_space->select.sel_info.hslab.diminfo[i].stride;
+ tmp_block[i] = (mem_iter->hyp.off[i]-mem_space->select.sel_info.hslab.diminfo[i].start)%mem_space->select.sel_info.hslab.diminfo[i].stride;
+ } /* end else */
} /* end for */
/* Compute the initial buffer offset */
@@ -3752,8 +3770,14 @@ H5S_hyper_mwrite_opt (const void *_tconv_buf, size_t elmt_size,
/* Compute the current "counts" for this location */
for(i=0; i<ndims; i++) {
- tmp_count[i] = (mem_iter->hyp.off[i]-mem_space->select.sel_info.hslab.diminfo[i].start)%mem_space->select.sel_info.hslab.diminfo[i].stride;
- tmp_block[i] = (mem_iter->hyp.off[i]-mem_space->select.sel_info.hslab.diminfo[i].start)/mem_space->select.sel_info.hslab.diminfo[i].stride;
+ if(mem_space->select.sel_info.hslab.diminfo[i].stride==1) {
+ tmp_count[i] = 0;
+ tmp_block[i] = mem_iter->hyp.off[i]-mem_space->select.sel_info.hslab.diminfo[i].start;
+ } /* end if */
+ else {
+ tmp_count[i] = (mem_iter->hyp.off[i]-mem_space->select.sel_info.hslab.diminfo[i].start)/mem_space->select.sel_info.hslab.diminfo[i].stride;
+ tmp_block[i] = (mem_iter->hyp.off[i]-mem_space->select.sel_info.hslab.diminfo[i].start)%mem_space->select.sel_info.hslab.diminfo[i].stride;
+ } /* end else */
} /* end for */
/* Compute the initial buffer offset */
diff --git a/test/tselect.c b/test/tselect.c
index 7358d5b..c4587cf 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -939,7 +939,7 @@ compare_size_t(const void *s1, const void *s2)
**
****************************************************************/
static void
-test_select_hyper_stride(void)
+test_select_hyper_stride(hid_t xfer_plist)
{
hid_t fid1; /* HDF5 File IDs */
hid_t dataset; /* Dataset ID */
@@ -1026,7 +1026,7 @@ test_select_hyper_stride(void)
dataset=H5Dcreate(fid1,"Dataset1",H5T_STD_U16LE,sid1,H5P_DEFAULT);
/* Write selection to disk */
- ret=H5Dwrite(dataset,H5T_NATIVE_USHORT,sid2,sid1,H5P_DEFAULT,wbuf);
+ ret=H5Dwrite(dataset,H5T_NATIVE_USHORT,sid2,sid1,xfer_plist,wbuf);
CHECK(ret, FAIL, "H5Dwrite");
/* Close memory dataspace */
@@ -1046,7 +1046,7 @@ test_select_hyper_stride(void)
CHECK(ret, FAIL, "H5Sselect_hyperslab");
/* Read selection from disk */
- ret=H5Dread(dataset,H5T_NATIVE_USHORT,sid2,sid1,H5P_DEFAULT,rbuf);
+ ret=H5Dread(dataset,H5T_NATIVE_USHORT,sid2,sid1,xfer_plist,rbuf);
CHECK(ret, FAIL, "H5Dread");
/* Sort the locations into the proper order */
@@ -4996,7 +4996,7 @@ test_select(void)
CHECK(plist_id, FAIL, "H5Pcreate");
/* test I/O with a very small buffer for reads */
- ret=H5Pset_buffer(plist_id,128,NULL,NULL);
+ ret=H5Pset_buffer(plist_id,59,NULL,NULL);
CHECK(ret, FAIL, "H5Pset_buffer");
/* These next tests use the same file */
@@ -5011,7 +5011,8 @@ test_select(void)
/* These next tests use the same file */
test_select_combo(); /* Test combined hyperslab & element selection code */
- test_select_hyper_stride(); /* Test strided hyperslab selection code */
+ test_select_hyper_stride(H5P_DEFAULT); /* Test strided hyperslab selection code */
+ test_select_hyper_stride(plist_id); /* Test strided hyperslab selection code */
test_select_hyper_contig(H5T_STD_U16LE,H5P_DEFAULT); /* Test contiguous hyperslab selection code */
test_select_hyper_contig(H5T_STD_U16LE,plist_id); /* Test contiguous hyperslab selection code */
test_select_hyper_contig(H5T_STD_U16BE,H5P_DEFAULT); /* Test contiguous hyperslab selection code */