From 336bb776ea5a63517c11a70333da6102992bc301 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 12 Jun 2002 11:59:32 -0500 Subject: [svn-r5602] 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) --- release_docs/RELEASE.txt | 13 ++++++----- src/H5Shyper.c | 56 +++++++++++++++++++++++++++++++++++++++--------- test/tselect.c | 11 +++++----- 3 files changed, 60 insertions(+), 20 deletions(-) diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index 4b614bd..ec0b32c 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -60,11 +60,11 @@ New Features o APIs ------ - * 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. - EIP - 2002/05/06 + * 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 deprecated in 1.6 release. EIP - 2002/05/06 o Performance ------------- @@ -95,6 +95,9 @@ New Features Bug Fixes since HDF5-1.4.3 Release ================================== + * 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 diff --git a/src/H5Shyper.c b/src/H5Shyper.c index f5c3ad2..caac5cc 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -1116,11 +1116,22 @@ for(i=0; ihyp.pos[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.pos[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.pos[i]-file_space->select.sel_info.hslab.diminfo[i].start; + } /* end if */ + else { + tmp_count[i] = (file_iter->hyp.pos[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.pos[i]-file_space->select.sel_info.hslab.diminfo[i].start)%file_space->select.sel_info.hslab.diminfo[i].stride; + } /* end else */ } /* end for */ #ifdef QAK for(i=0; ihyp.pos[%d]=%d\n",FUNC,(int)i,(int)file_iter->hyp.pos[i]); + printf("%s: file_space->select.sel_info.hslab.diminfo[%d].start=%d\n",FUNC,(int)i,(int)file_space->select.sel_info.hslab.diminfo[i].start); + printf("%s: file_space->select.sel_info.hslab.diminfo[%d].stride=%d\n",FUNC,(int)i,(int)file_space->select.sel_info.hslab.diminfo[i].stride); + printf("%s: file_space->select.sel_info.hslab.diminfo[%d].block=%d\n",FUNC,(int)i,(int)file_space->select.sel_info.hslab.diminfo[i].block); + printf("%s: file_space->select.sel_info.hslab.diminfo[%d].count=%d\n",FUNC,(int)i,(int)file_space->select.sel_info.hslab.diminfo[i].count); printf("%s: tmp_count[%d]=%d, tmp_block[%d]=%d\n",FUNC,(int)i,(int)tmp_count[i],(int)i,(int)tmp_block[i]); printf("%s: slab[%d]=%d\n",FUNC,(int)i,(int)slab[i]); } @@ -1241,11 +1252,18 @@ for(i=0; iextent.u.simple.rank; i++) /* Increment the offset and count for the other dimensions */ temp_dim=fast_dim-1; +#ifdef QAK +printf("%s: temp_dim=%u\n",FUNC,(unsigned)temp_dim); +#endif /* QAK */ while(temp_dim>=0) { /* Move to the next row in the curent dimension */ offset[temp_dim]++; buf_off+=slab[temp_dim]; tmp_block[temp_dim]++; +#ifdef QAK +printf("%s: tmp_block[%d]=%u\n",FUNC,temp_dim,(unsigned)tmp_block[temp_dim]); +printf("%s: tdiminfo[%d].block=%u\n",FUNC,temp_dim,(unsigned)tdiminfo[temp_dim].block); +#endif /* QAK */ /* If this block is still in the range of blocks to output for the dimension, break out of loop */ if(tmp_block[temp_dim]hyp.pos[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.pos[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.pos[i]-file_space->select.sel_info.hslab.diminfo[i].start; + } /* end if */ + else { + tmp_count[i] = (file_iter->hyp.pos[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.pos[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 */ @@ -2257,8 +2281,14 @@ printf("%s: Check 2.0\n",FUNC); /* Compute the current "counts" for this location */ for(i=0; ihyp.pos[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.pos[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.pos[i]-mem_space->select.sel_info.hslab.diminfo[i].start; + } /* end if */ + else { + tmp_count[i] = (mem_iter->hyp.pos[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.pos[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 */ @@ -2664,7 +2694,7 @@ H5S_hyper_mwrite_opt (const void *_tconv_buf, size_t elmt_size, hsize_t actual_bytes; /* The actual number of bytes to copy */ hsize_t num_write=0; /* Number of elements read */ - FUNC_ENTER (H5S_hyper_fwrite_opt, 0); + FUNC_ENTER (H5S_hyper_mwrite_opt, 0); #ifdef QAK printf("%s: Called!, elmt_size=%d\n",FUNC,(int)elmt_size); @@ -2773,8 +2803,14 @@ printf("%s: Check 2.0\n",FUNC); /* Compute the current "counts" for this location */ for(i=0; ihyp.pos[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.pos[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.pos[i]-mem_space->select.sel_info.hslab.diminfo[i].start; + } /* end if */ + else { + tmp_count[i] = (mem_iter->hyp.pos[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.pos[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 */ @@ -2792,7 +2828,7 @@ printf("%s: buf_off=%u, actual_bytes=%u\n",FUNC,(unsigned)buf_off,(int)actual_by #ifdef QAK printf("%s: actual_write=%d\n",FUNC,(int)actual_write); -for(i=0; iextent.u.simple.rank; i++) +for(i=0; iextent.u.simple.rank; i++) printf("%s: diminfo: start[%d]=%d, stride[%d]=%d, block[%d]=%d, count[%d]=%d\n",FUNC, (int)i,(int)mem_space->select.sel_info.hslab.diminfo[i].start, (int)i,(int)mem_space->select.sel_info.hslab.diminfo[i].stride, diff --git a/test/tselect.c b/test/tselect.c index d735990..9120741 100644 --- a/test/tselect.c +++ b/test/tselect.c @@ -938,7 +938,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 */ @@ -1025,7 +1025,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 */ @@ -1045,7 +1045,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 */ @@ -3867,7 +3867,7 @@ test_select(void) CHECK(plist_id, FAIL, "H5Pcreate"); /* test I/O with a very small buffer for reads */ - ret=H5Pset_buffer(plist_id,(hsize_t)128,NULL,NULL); + ret=H5Pset_buffer(plist_id,(hsize_t)59,NULL,NULL); CHECK(ret, FAIL, "H5Pset_buffer"); /* These next tests use the same file */ @@ -3882,7 +3882,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 */ -- cgit v0.12