summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-05-01 16:10:17 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-05-01 16:10:17 (GMT)
commitecea60e95cd0ddd72ba975a79d5ca65805a44dd5 (patch)
tree2a8fdb9b8e8d210e67a095f0fd505ab912ff331a
parent4f0b880861c6d719ef30302ebc522abdaf84b292 (diff)
downloadhdf5-ecea60e95cd0ddd72ba975a79d5ca65805a44dd5.zip
hdf5-ecea60e95cd0ddd72ba975a79d5ca65805a44dd5.tar.gz
hdf5-ecea60e95cd0ddd72ba975a79d5ca65805a44dd5.tar.bz2
[svn-r8457] Purpose:
Code optimization Description: Stop straddling the line and always use elements instead of bytes to determine how how I/O to perform on a selection. Platforms tested: Solaris 2.7 (arabica) FreeBSD 4.9 (sleipnir) too minor to require h5committest
-rw-r--r--src/H5Sall.c22
-rw-r--r--src/H5Shyper.c66
-rw-r--r--src/H5Snone.c16
-rw-r--r--src/H5Spoint.c35
-rw-r--r--src/H5Sselect.c144
5 files changed, 134 insertions, 149 deletions
diff --git a/src/H5Sall.c b/src/H5Sall.c
index 6ab8eaf..6f5152d 100644
--- a/src/H5Sall.c
+++ b/src/H5Sall.c
@@ -709,7 +709,7 @@ H5S_select_all (H5S_t *space, unsigned rel_prev)
/* Check args */
assert(space);
-
+
/* Remove current selection first */
if(rel_prev)
if((*space->select.release)(space)<0)
@@ -786,10 +786,10 @@ done:
position of interest in selection.
size_t elem_size; IN: Size of an element
size_t maxseq; IN: Maximum number of sequences to generate
- size_t maxbytes; IN: Maximum number of bytes to include in the
+ size_t maxelem; IN: Maximum number of elements to include in the
generated sequences
size_t *nseq; OUT: Actual number of sequences generated
- size_t *nbytes; OUT: Actual number of bytes in sequences generated
+ size_t *nelem; OUT: Actual number of elements in sequences generated
hsize_t *off; OUT: Array of offsets
size_t *len; OUT: Array of lengths
RETURNS
@@ -807,10 +807,9 @@ done:
--------------------------------------------------------------------------*/
herr_t
H5S_all_get_seq_list(const H5S_t UNUSED *space, unsigned UNUSED flags, H5S_sel_iter_t *iter,
- size_t elem_size, size_t UNUSED maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes,
+ size_t elem_size, size_t UNUSED maxseq, size_t maxelem, size_t *nseq, size_t *nelem,
hsize_t *off, size_t *len)
{
- size_t max_elem; /* Maximum number of elements to use */
size_t elem_used; /* The number of elements used */
herr_t ret_value=SUCCEED; /* return value */
@@ -821,18 +820,15 @@ H5S_all_get_seq_list(const H5S_t UNUSED *space, unsigned UNUSED flags, H5S_sel_i
assert(iter);
assert(elem_size>0);
assert(maxseq>0);
- assert(maxbytes>0);
+ assert(maxelem>0);
assert(nseq);
- assert(nbytes);
+ assert(nelem);
assert(off);
assert(len);
- /* Detemine the maximum # of elements to use for this operation */
- max_elem=maxbytes/elem_size;
-
/* Determine the actual number of elements to use */
H5_CHECK_OVERFLOW(iter->elmt_left,hsize_t,size_t);
- elem_used=MIN(max_elem,(size_t)iter->elmt_left);
+ elem_used=MIN(maxelem,(size_t)iter->elmt_left);
/* Compute the offset in the dataset */
off[0]=iter->u.all.offset*elem_size;
@@ -841,8 +837,8 @@ H5S_all_get_seq_list(const H5S_t UNUSED *space, unsigned UNUSED flags, H5S_sel_i
/* Should only need one sequence for 'all' selections */
*nseq=1;
- /* Set the number of bytes used */
- *nbytes=len[0];
+ /* Set the number of elements used */
+ *nelem=elem_used;
/* Update the iterator */
iter->elmt_left-=elem_used;
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 648f359..77d18f7 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -148,7 +148,7 @@ H5S_hyper_print_diminfo(FILE *f, const H5S_t *space)
{
FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_print_diminfo);
- H5S_hyper_print_diminfo_helper(f,"diminfo",space->extent.u.simple.rank,space->select.sel_info.hslab.opt_diminfo);
+ H5S_hyper_print_diminfo_helper(f,"opt_diminfo",space->extent.u.simple.rank,space->select.sel_info.hslab.opt_diminfo);
H5S_hyper_print_diminfo_helper(f,"app_diminfo",space->extent.u.simple.rank,space->select.sel_info.hslab.app_diminfo);
FUNC_LEAVE_NOAPI(SUCCEED);
@@ -5252,7 +5252,7 @@ H5S_hyper_rebuild (H5S_t *space)
unsigned curr_dim; /* Current dimension being worked on */
herr_t ret_value=SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT(H5S_hyper_rebuild);
+ FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5S_hyper_rebuild);
/* Check args */
assert (space);
@@ -5291,7 +5291,6 @@ H5S_hyper_rebuild (H5S_t *space)
space->select.sel_info.hslab.diminfo_valid=TRUE;
} /* end if */
-done:
FUNC_LEAVE_NOAPI(ret_value);
} /* H5S_hyper_rebuild() */
@@ -6676,10 +6675,10 @@ done:
position of interest in selection.
size_t elem_size; IN: Size of an element
size_t maxseq; IN: Maximum number of sequences to generate
- size_t maxbytes; IN: Maximum number of bytes to include in the
+ size_t maxelem; IN: Maximum number of elements to include in the
generated sequences
size_t *nseq; OUT: Actual number of sequences generated
- size_t *nbytes; OUT: Actual number of bytes in sequences generated
+ size_t *nelem; OUT: Actual number of elements in sequences generated
hsize_t *off; OUT: Array of offsets
size_t *len; OUT: Array of lengths
RETURNS
@@ -6697,7 +6696,7 @@ done:
--------------------------------------------------------------------------*/
static herr_t
H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
- size_t elem_size, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes,
+ size_t elem_size, size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem,
hsize_t *off, size_t *len)
{
H5S_hyper_span_t *curr_span; /* Current hyperslab span node */
@@ -6709,9 +6708,10 @@ H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
hssize_t *abs_arr; /* Absolute hyperslab span position */
hssize_t *off_arr; /* Offset within the dataspace extent */
size_t span_size=0; /* Number of bytes in current span to actually process */
- size_t nelem; /* Number of elements left to process */
+ size_t io_left; /* Number of elements left to process */
size_t io_bytes_left; /* Number of bytes left to process */
size_t start_io_bytes_left; /* Initial number of bytes left to process */
+ size_t io_used; /* Number of elements processed */
size_t curr_seq=0; /* Number of sequence/offsets stored in the arrays */
int ndims; /* Number of dimensions of dataset */
int fast_dim; /* Rank of the fastest changing dimension for the dataspace */
@@ -6725,15 +6725,12 @@ H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
assert(iter);
assert(elem_size>0);
assert(maxseq>0);
- assert(maxbytes>0);
+ assert(maxelem>0);
assert(nseq);
- assert(nbytes);
+ assert(nelem);
assert(off);
assert(len);
- /* "round" off the maxbytes allowed to a multiple of the element size */
- maxbytes=(maxbytes/elem_size)*elem_size;
-
/* Set the rank of the fastest changing dimension */
ndims=space->extent.u.simple.rank;
fast_dim=(ndims-1);
@@ -6745,9 +6742,9 @@ H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter,
ispan=iter->u.hyp.span;
/* Set the amount of elements to perform I/O on, etc. */
- H5_CHECK_OVERFLOW( (iter->elmt_left*elem_size) ,hsize_t,size_t);
- start_io_bytes_left=io_bytes_left=MIN(maxbytes,(size_t)(iter->elmt_left*elem_size));
- nelem=io_bytes_left/elem_size;
+ H5_CHECK_OVERFLOW(iter->elmt_left,hsize_t,size_t);
+ io_left=MIN(maxelem,(size_t)iter->elmt_left);
+ start_io_bytes_left=io_bytes_left=io_left*elem_size;
/* Compute the cumulative size of dataspace dimensions */
for(i=fast_dim, acc=elem_size; i>=0; i--) {
@@ -7086,13 +7083,14 @@ partial_done: /* Yes, goto's are evil, so sue me... :-) */
} /* end while */
/* Decrement number of elements left in iterator */
- iter->elmt_left-=(nelem-(io_bytes_left/elem_size));
+ io_used=(io_left-(io_bytes_left/elem_size));
+ iter->elmt_left-=io_used;
/* Set the number of sequences generated */
*nseq=curr_seq;
- /* Set the number of bytes used */
- *nbytes=(start_io_bytes_left-io_bytes_left);
+ /* Set the number of elements used */
+ *nelem=io_used;
FUNC_LEAVE_NOAPI(SUCCEED);
} /* end H5S_hyper_get_seq_list_gen() */
@@ -7110,10 +7108,10 @@ partial_done: /* Yes, goto's are evil, so sue me... :-) */
position of interest in selection.
size_t elem_size; IN: Size of an element
size_t maxseq; IN: Maximum number of sequences to generate
- size_t maxbytes; IN: Maximum number of bytes to include in the
+ size_t maxelem; IN: Maximum number of elements to include in the
generated sequences
size_t *nseq; OUT: Actual number of sequences generated
- size_t *nbytes; OUT: Actual number of bytes in sequences generated
+ size_t *nelem; OUT: Actual number of elements in sequences generated
hsize_t *off; OUT: Array of offsets
size_t *len; OUT: Array of lengths
RETURNS
@@ -7131,7 +7129,7 @@ partial_done: /* Yes, goto's are evil, so sue me... :-) */
--------------------------------------------------------------------------*/
static herr_t
H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
- size_t elmt_size, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes,
+ size_t elmt_size, size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem,
hsize_t *off, size_t *len)
{
hsize_t *mem_size; /* Size of the source buffer */
@@ -7173,9 +7171,9 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
assert(iter);
assert(elmt_size>0);
assert(maxseq>0);
- assert(maxbytes>0);
+ assert(maxelem>0);
assert(nseq);
- assert(nbytes);
+ assert(nelem);
assert(off);
assert(len);
@@ -7212,11 +7210,9 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
acc*=mem_size[i];
} /* end for */
- /* Get the number of elements left in the selection */
- H5_ASSIGN_OVERFLOW(io_left,iter->elmt_left,hsize_t,size_t);
-
/* Calculate the number of elements to sequence through */
- start_io_left=io_left=MIN(io_left,(maxbytes/elmt_size));
+ H5_CHECK_OVERFLOW(iter->elmt_left,hsize_t,size_t);
+ start_io_left=io_left=MIN((size_t)iter->elmt_left,maxelem);
/* Check if we stopped in the middle of a sequence of elements */
if((iter->u.hyp.off[fast_dim]-tdiminfo[fast_dim].start)%tdiminfo[fast_dim].stride!=0 ||
@@ -7571,7 +7567,7 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
*nseq=curr_seq;
/* Set the number of bytes used */
- *nbytes=(start_io_left-io_left)*elmt_size;
+ *nelem=start_io_left-io_left;
FUNC_LEAVE_NOAPI(SUCCEED);
} /* end H5S_hyper_get_seq_list_opt() */
@@ -7590,10 +7586,10 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
position of interest in selection.
size_t elem_size; IN: Size of an element
size_t maxseq; IN: Maximum number of sequences to generate
- size_t maxbytes; IN: Maximum number of bytes to include in the
+ size_t maxelem; IN: Maximum number of elements to include in the
generated sequences
size_t *nseq; OUT: Actual number of sequences generated
- size_t *nbytes; OUT: Actual number of bytes in sequences generated
+ size_t *nelem; OUT: Actual number of elements in sequences generated
hsize_t *off; OUT: Array of offsets
size_t *len; OUT: Array of lengths
RETURNS
@@ -7611,7 +7607,7 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
--------------------------------------------------------------------------*/
herr_t
H5S_hyper_get_seq_list(const H5S_t *space, unsigned UNUSED flags, H5S_sel_iter_t *iter,
- size_t elem_size, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes,
+ size_t elem_size, size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem,
hsize_t *off, size_t *len)
{
herr_t ret_value; /* return value */
@@ -7623,19 +7619,19 @@ H5S_hyper_get_seq_list(const H5S_t *space, unsigned UNUSED flags, H5S_sel_iter_t
assert(iter);
assert(elem_size>0);
assert(maxseq>0);
- assert(maxbytes>0);
+ assert(maxelem>0);
assert(nseq);
- assert(nbytes);
+ assert(nelem);
assert(off);
assert(len);
/* Check for the special case of just one H5Sselect_hyperslab call made */
if(space->select.sel_info.hslab.diminfo_valid)
/* Use optimized call to generate sequence list */
- ret_value=H5S_hyper_get_seq_list_opt(space,iter,elem_size,maxseq,maxbytes,nseq,nbytes,off,len);
+ ret_value=H5S_hyper_get_seq_list_opt(space,iter,elem_size,maxseq,maxelem,nseq,nelem,off,len);
else
/* Call the general sequence generator routine */
- ret_value=H5S_hyper_get_seq_list_gen(space,iter,elem_size,maxseq,maxbytes,nseq,nbytes,off,len);
+ ret_value=H5S_hyper_get_seq_list_gen(space,iter,elem_size,maxseq,maxelem,nseq,nelem,off,len);
done:
FUNC_LEAVE_NOAPI(ret_value);
diff --git a/src/H5Snone.c b/src/H5Snone.c
index e07f5ae..28622c1 100644
--- a/src/H5Snone.c
+++ b/src/H5Snone.c
@@ -740,10 +740,10 @@ done:
position of interest in selection.
size_t elem_size; IN: Size of an element
size_t maxseq; IN: Maximum number of sequences to generate
- size_t maxbytes; IN: Maximum number of bytes to include in the
+ size_t maxelem; IN: Maximum number of elements to include in the
generated sequences
size_t *nseq; OUT: Actual number of sequences generated
- size_t *nbytes; OUT: Actual number of bytes in sequences generated
+ size_t *nelem; OUT: Actual number of elements in sequences generated
hsize_t *off; OUT: Array of offsets
size_t *len; OUT: Array of lengths
RETURNS
@@ -761,7 +761,7 @@ done:
--------------------------------------------------------------------------*/
herr_t
H5S_none_get_seq_list(const H5S_t UNUSED *space, unsigned UNUSED flags, H5S_sel_iter_t UNUSED *iter,
- size_t UNUSED elem_size, size_t UNUSED maxseq, size_t UNUSED maxbytes, size_t *nseq, size_t *nbytes,
+ size_t UNUSED elem_size, size_t UNUSED maxseq, size_t UNUSED maxelem, size_t *nseq, size_t *nelem,
hsize_t UNUSED *off, size_t UNUSED *len)
{
herr_t ret_value=SUCCEED; /* Return value */
@@ -773,17 +773,17 @@ H5S_none_get_seq_list(const H5S_t UNUSED *space, unsigned UNUSED flags, H5S_sel_
assert(iter);
assert(elem_size>0);
assert(maxseq>0);
- assert(maxbytes>0);
+ assert(maxelem>0);
assert(nseq);
- assert(nbytes);
+ assert(nelem);
assert(off);
assert(len);
- /* "none" selection don't generate sequences of bytes */
+ /* "none" selections don't generate sequences of bytes */
*nseq=0;
- /* The don't use any bytes, either */
- *nbytes=0;
+ /* They don't use any elements, either */
+ *nelem=0;
done:
FUNC_LEAVE_NOAPI(ret_value);
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index 0200a7c..b9e0b8a 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -1287,7 +1287,7 @@ H5Sselect_elements(hid_t spaceid, H5S_seloper_t op, size_t num_elem,
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_SCALAR space");
if (H5S_NULL==H5S_get_simple_extent_type(space))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_NULL space");
- if(coord==NULL || num_elem==0)
+ if(coord==NULL || num_elem==0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "elements not specified");
if(!(op==H5S_SELECT_SET || op==H5S_SELECT_APPEND || op==H5S_SELECT_PREPEND))
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "operations other than H5S_SELECT_SET not supported currently");
@@ -1314,10 +1314,10 @@ done:
position of interest in selection.
size_t elem_size; IN: Size of an element
size_t maxseq; IN: Maximum number of sequences to generate
- size_t maxbytes; IN: Maximum number of bytes to include in the
+ size_t maxelem; IN: Maximum number of elements to include in the
generated sequences
size_t *nseq; OUT: Actual number of sequences generated
- size_t *nbytes; OUT: Actual number of bytes in sequences generated
+ size_t *nelem; OUT: Actual number of elements in sequences generated
hsize_t *off; OUT: Array of offsets
size_t *len; OUT: Array of lengths
RETURNS
@@ -1335,11 +1335,11 @@ done:
--------------------------------------------------------------------------*/
herr_t
H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter,
- size_t elem_size, size_t maxseq, size_t maxbytes, size_t *nseq, size_t *nbytes,
+ size_t elem_size, size_t maxseq, size_t maxelem, size_t *nseq, size_t *nelem,
hsize_t *off, size_t *len)
{
- hsize_t bytes_left; /* The number of bytes left in the selection */
- hsize_t start_bytes_left; /* The initial number of bytes left in the selection */
+ size_t io_left; /* The number of bytes left in the selection */
+ size_t start_io_left; /* The initial number of bytes left in the selection */
H5S_pnt_node_t *node; /* Point node */
hsize_t dims[H5O_LAYOUT_NDIMS]; /* Total size of memory buf */
int ndims; /* Dimensionality of space*/
@@ -1356,17 +1356,15 @@ H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter,
assert(iter);
assert(elem_size>0);
assert(maxseq>0);
- assert(maxbytes>0);
+ assert(maxelem>0);
assert(nseq);
- assert(nbytes);
+ assert(nelem);
assert(off);
assert(len);
- /* "round" off the maxbytes allowed to a multiple of the element size */
- maxbytes=(maxbytes/elem_size)*elem_size;
-
/* Choose the minimum number of bytes to sequence through */
- start_bytes_left=bytes_left=MIN(iter->elmt_left*elem_size,maxbytes);
+ H5_CHECK_OVERFLOW(iter->elmt_left,hsize_t,size_t);
+ start_io_left=io_left=MIN(iter->elmt_left,maxelem);
/* Get the dataspace dimensions */
if ((ndims=H5S_get_simple_extent_dims (space, dims, NULL))<0)
@@ -1413,8 +1411,8 @@ H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter,
curr_seq++;
} /* end else */
- /* Decrement number of bytes left to process */
- bytes_left-=elem_size;
+ /* Decrement number of elements left to process */
+ io_left--;
/* Move the iterator */
iter->u.pnt.curr=node->next;
@@ -1424,8 +1422,8 @@ H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter,
if(curr_seq==maxseq)
break;
- /* Check if we're finished with all the bytes available */
- if(bytes_left==0)
+ /* Check if we're finished with all the elements available */
+ if(io_left==0)
break;
/* Advance to the next point */
@@ -1435,9 +1433,8 @@ H5S_point_get_seq_list(const H5S_t *space, unsigned flags, H5S_sel_iter_t *iter,
/* Set the number of sequences generated */
*nseq=curr_seq;
- /* Set the number of bytes used */
- H5_CHECK_OVERFLOW( (start_bytes_left-bytes_left) ,hsize_t,size_t);
- *nbytes=(size_t)(start_bytes_left-bytes_left);
+ /* Set the number of elements used */
+ *nelem=start_io_left-io_left;
done:
FUNC_LEAVE_NOAPI(ret_value);
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index 3904730..e48ee93 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -880,8 +880,8 @@ H5S_select_iterate(void *buf, hid_t type_id, const H5S_t *space, H5D_operator_t
size_t curr_len; /* Length of bytes left to process in sequence */
size_t nseq; /* Number of sequences generated */
size_t curr_seq; /* Current sequnce being worked on */
- size_t nbytes; /* Number of bytes used in sequences */
- size_t max_bytes; /* Maximum number of bytes allowed in sequences */
+ size_t nelem; /* Number of elements used in sequences */
+ size_t max_elem; /* Maximum number of elements allowed in sequences */
size_t elmt_size; /* Datatype size */
int ndims; /* Number of dimensions in dataspace */
int i; /* Local Index variable */
@@ -922,12 +922,12 @@ H5S_select_iterate(void *buf, hid_t type_id, const H5S_t *space, H5D_operator_t
space_size[ndims]=elmt_size;
/* Compute the maximum number of bytes required */
- H5_ASSIGN_OVERFLOW(max_bytes,nelmts*elmt_size,hsize_t,size_t);
+ H5_ASSIGN_OVERFLOW(max_elem,nelmts,hssize_t,size_t);
/* Loop, while elements left in selection */
- while(max_bytes>0 && user_ret==0) {
+ while(max_elem>0 && user_ret==0) {
/* Get the sequences of bytes */
- if((*space->select.get_seq_list)(space,0,&iter,elmt_size,H5D_XFER_HYPER_VECTOR_SIZE_DEF,max_bytes,&nseq,&nbytes,off,len)<0)
+ if((*space->select.get_seq_list)(space,0,&iter,elmt_size,H5D_XFER_HYPER_VECTOR_SIZE_DEF,max_elem,&nseq,&nelem,off,len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed");
/* Loop, while sequences left to process */
@@ -961,8 +961,7 @@ H5S_select_iterate(void *buf, hid_t type_id, const H5S_t *space, H5D_operator_t
} /* end for */
/* Decrement number of elements left to process */
- assert((nbytes%elmt_size)==0);
- max_bytes-=nbytes;
+ max_elem-=nelem;
} /* end while */
/* Set return value */
@@ -1304,8 +1303,8 @@ H5S_select_fill(void *_fill, size_t fill_size, const H5S_t *space, void *_buf)
size_t len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths */
size_t nseq; /* Number of sequences generated */
size_t curr_seq; /* Current sequnce being worked on */
- size_t nbytes; /* Number of bytes used in sequences */
- size_t max_bytes; /* Total number of bytes in selection */
+ size_t nelem; /* Number of elements used in sequences */
+ size_t max_elem; /* Total number of elements in selection */
herr_t ret_value=SUCCEED; /* return value */
FUNC_ENTER_NOAPI(H5S_select_fill, FAIL);
@@ -1331,13 +1330,12 @@ H5S_select_fill(void *_fill, size_t fill_size, const H5S_t *space, void *_buf)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't get number of elements selected");
/* Compute the number of bytes to process */
- H5_CHECK_OVERFLOW(nelmts,hssize_t,size_t);
- max_bytes=(size_t)nelmts*fill_size;
+ H5_ASSIGN_OVERFLOW(max_elem,nelmts,hssize_t,size_t);
/* Loop, while elements left in selection */
- while(max_bytes>0) {
+ while(max_elem>0) {
/* Get the sequences of bytes */
- if((*space->select.get_seq_list)(space,0,&iter,fill_size,H5D_XFER_HYPER_VECTOR_SIZE_DEF,max_bytes,&nseq,&nbytes,off,len)<0)
+ if((*space->select.get_seq_list)(space,0,&iter,fill_size,H5D_XFER_HYPER_VECTOR_SIZE_DEF,max_elem,&nseq,&nelem,off,len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed");
/* Loop over sequences */
@@ -1350,8 +1348,8 @@ H5S_select_fill(void *_fill, size_t fill_size, const H5S_t *space, void *_buf)
H5V_array_fill(buf, fill, fill_size, (len[curr_seq]/fill_size));
} /* end for */
- /* Decrement number of bytes left to process */
- max_bytes-=nbytes;
+ /* Decrement number of elements left to process */
+ max_elem-=nelem;
} /* end while */
done:
@@ -1402,10 +1400,10 @@ H5S_select_fscat (H5F_t *f, struct H5O_layout_t *layout,
size_t dset_curr_seq; /* "Current sequence" in dataset */
size_t _len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths */
size_t *len=NULL; /* Array to store sequence lengths */
- size_t mem_len; /* Length of sequence in memory */
- size_t maxbytes; /* Number of bytes in the buffer */
+ size_t orig_mem_len, mem_len; /* Length of sequence in memory */
+ size_t maxelem; /* Number of elements in the buffer */
size_t nseq; /* Number of sequences generated */
- size_t nbytes; /* Number of bytes used in sequences */
+ size_t nelem; /* Number of elements used in sequences */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5S_select_fscat, FAIL);
@@ -1434,17 +1432,17 @@ H5S_select_fscat (H5F_t *f, struct H5O_layout_t *layout,
} /* end else */
/* Compute the number of bytes available in buffer */
- H5_ASSIGN_OVERFLOW(maxbytes,nelmts*elmt_size,hsize_t,size_t);
+ H5_ASSIGN_OVERFLOW(maxelem,nelmts,hsize_t,size_t);
/* Loop until all elements are written */
- while(maxbytes>0) {
+ while(maxelem>0) {
/* Get list of sequences for selection to write */
- if((*space->select.get_seq_list)(space,H5S_GET_SEQ_LIST_SORTED,iter,elmt_size,dxpl_cache->vec_size,maxbytes,&nseq,&nbytes,off,len)<0)
+ if((*space->select.get_seq_list)(space,H5S_GET_SEQ_LIST_SORTED,iter,elmt_size,dxpl_cache->vec_size,maxelem,&nseq,&nelem,off,len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed");
/* Reset the current sequence information */
mem_curr_seq=dset_curr_seq=0;
- mem_len=nbytes;
+ orig_mem_len=mem_len=nelem*elmt_size;
mem_off=0;
/* Write sequence list out */
@@ -1452,11 +1450,10 @@ H5S_select_fscat (H5F_t *f, struct H5O_layout_t *layout,
HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error");
/* Update buffer */
- buf += nbytes;
+ buf += orig_mem_len;
/* Decrement number of elements left to process */
- assert(nbytes%elmt_size==0);
- maxbytes -= nbytes;
+ maxelem -= nelem;
} /* end while */
done:
@@ -1508,10 +1505,10 @@ H5S_select_fgath (H5F_t *f, const struct H5O_layout_t *layout,
size_t dset_curr_seq; /* "Current sequence" in dataset */
size_t _len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths */
size_t *len=NULL; /* Pointer to sequence lengths */
- size_t mem_len; /* Length of sequence in memory */
- size_t maxbytes; /* Number of bytes in the buffer */
+ size_t orig_mem_len, mem_len; /* Length of sequence in memory */
+ size_t maxelem; /* Number of elements in the buffer */
size_t nseq; /* Number of sequences generated */
- size_t nbytes; /* Number of bytes used in sequences */
+ size_t nelem; /* Number of elements used in sequences */
hsize_t ret_value=nelmts; /* Return value */
FUNC_ENTER_NOAPI(H5S_select_fgath, 0);
@@ -1538,18 +1535,18 @@ H5S_select_fgath (H5F_t *f, const struct H5O_layout_t *layout,
off=_off;
} /* end else */
- /* Compute the number of bytes available in buffer */
- H5_ASSIGN_OVERFLOW(maxbytes,nelmts*elmt_size,hsize_t,size_t);
+ /* Compute the number of elements available in buffer */
+ H5_ASSIGN_OVERFLOW(maxelem,nelmts,hsize_t,size_t);
/* Loop until all elements are written */
- while(maxbytes>0) {
+ while(maxelem>0) {
/* Get list of sequences for selection to write */
- if((*space->select.get_seq_list)(space,H5S_GET_SEQ_LIST_SORTED,iter,elmt_size,dxpl_cache->vec_size,maxbytes,&nseq,&nbytes,off,len)<0)
+ if((*space->select.get_seq_list)(space,H5S_GET_SEQ_LIST_SORTED,iter,elmt_size,dxpl_cache->vec_size,maxelem,&nseq,&nelem,off,len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed");
/* Reset the current sequence information */
mem_curr_seq=dset_curr_seq=0;
- mem_len=nbytes;
+ orig_mem_len=mem_len=nelem*elmt_size;
mem_off=0;
/* Read sequence list in */
@@ -1557,11 +1554,10 @@ H5S_select_fgath (H5F_t *f, const struct H5O_layout_t *layout,
HGOTO_ERROR(H5E_DATASPACE, H5E_READERROR, 0, "read error");
/* Update buffer */
- buf += nbytes;
+ buf += orig_mem_len;
/* Decrement number of elements left to process */
- assert(nbytes%elmt_size==0);
- maxbytes -= nbytes;
+ maxelem -= nelem;
} /* end while */
done:
@@ -1604,10 +1600,10 @@ H5S_select_mscat (const void *_tscat_buf, size_t elmt_size, const H5S_t *space,
size_t _len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths */
size_t *len=NULL; /* Pointer to sequence lengths */
size_t curr_len; /* Length of bytes left to process in sequence */
- size_t maxbytes; /* Number of bytes in the buffer */
+ size_t maxelem; /* Number of elements in the buffer */
size_t nseq; /* Number of sequences generated */
size_t curr_seq; /* Current sequence being processed */
- size_t nbytes; /* Number of bytes used in sequences */
+ size_t nelem; /* Number of elements used in sequences */
herr_t ret_value=SUCCEED; /* Number of elements scattered */
FUNC_ENTER_NOAPI(H5S_select_mscat, FAIL);
@@ -1632,13 +1628,13 @@ H5S_select_mscat (const void *_tscat_buf, size_t elmt_size, const H5S_t *space,
off=_off;
} /* end else */
- /* Compute the number of bytes available in buffer */
- H5_ASSIGN_OVERFLOW(maxbytes,nelmts*elmt_size,hsize_t,size_t);
+ /* Compute the number of elements available in buffer */
+ H5_ASSIGN_OVERFLOW(maxelem,nelmts,hsize_t,size_t);
/* Loop until all elements are written */
- while(maxbytes>0) {
+ while(maxelem>0) {
/* Get list of sequences for selection to write */
- if((*space->select.get_seq_list)(space,0,iter,elmt_size,dxpl_cache->vec_size,maxbytes,&nseq,&nbytes,off,len)<0)
+ if((*space->select.get_seq_list)(space,0,iter,elmt_size,dxpl_cache->vec_size,maxelem,&nseq,&nelem,off,len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed");
/* Loop, while sequences left to process */
@@ -1653,8 +1649,7 @@ H5S_select_mscat (const void *_tscat_buf, size_t elmt_size, const H5S_t *space,
} /* end for */
/* Decrement number of elements left to process */
- assert(nbytes%elmt_size==0);
- maxbytes -= nbytes;
+ maxelem -= nelem;
} /* end while */
done:
@@ -1699,10 +1694,10 @@ H5S_select_mgath (const void *_buf, size_t elmt_size, const H5S_t *space,
size_t _len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths */
size_t *len=NULL; /* Pointer to sequence lengths */
size_t curr_len; /* Length of bytes left to process in sequence */
- size_t maxbytes; /* Number of bytes in the buffer */
+ size_t maxelem; /* Number of elements in the buffer */
size_t nseq; /* Number of sequences generated */
size_t curr_seq; /* Current sequence being processed */
- size_t nbytes; /* Number of bytes used in sequences */
+ size_t nelem; /* Number of elements used in sequences */
hsize_t ret_value=nelmts; /* Number of elements gathered */
FUNC_ENTER_NOAPI(H5S_select_mgath, 0);
@@ -1727,13 +1722,13 @@ H5S_select_mgath (const void *_buf, size_t elmt_size, const H5S_t *space,
off=_off;
} /* end else */
- /* Compute the number of bytes available in buffer */
- H5_ASSIGN_OVERFLOW(maxbytes,nelmts*elmt_size,hsize_t,size_t);
+ /* Compute the number of elements available in buffer */
+ H5_ASSIGN_OVERFLOW(maxelem,nelmts,hsize_t,size_t);
/* Loop until all elements are written */
- while(maxbytes>0) {
+ while(maxelem>0) {
/* Get list of sequences for selection to write */
- if((*space->select.get_seq_list)(space,0,iter,elmt_size,dxpl_cache->vec_size,maxbytes,&nseq,&nbytes,off,len)<0)
+ if((*space->select.get_seq_list)(space,0,iter,elmt_size,dxpl_cache->vec_size,maxelem,&nseq,&nelem,off,len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, 0, "sequence length generation failed");
/* Loop, while sequences left to process */
@@ -1748,8 +1743,7 @@ H5S_select_mgath (const void *_buf, size_t elmt_size, const H5S_t *space,
} /* end for */
/* Decrement number of elements left to process */
- assert(nbytes%elmt_size==0);
- maxbytes -= nbytes;
+ maxelem -= nelem;
} /* end while */
done:
@@ -1795,11 +1789,11 @@ H5S_select_read(H5F_t *f, const H5O_layout_t *layout, const H5D_dcpl_cache_t *dc
size_t *mem_len=NULL; /* Pointer to sequence lengths in memory */
size_t _file_len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths in the file */
size_t *file_len=NULL; /* Pointer to sequence lengths in the file */
- size_t maxbytes; /* Number of bytes in selection */
+ size_t maxelem; /* Number of elements in selection */
size_t mem_nseq; /* Number of sequences generated in the file */
size_t file_nseq; /* Number of sequences generated in memory */
- size_t mem_nbytes; /* Number of bytes used in memory sequences */
- size_t file_nbytes; /* Number of bytes used in file sequences */
+ size_t mem_nelem; /* Number of elements used in memory sequences */
+ size_t file_nelem; /* Number of elements used in file sequences */
size_t curr_mem_seq; /* Current memory sequence to operate on */
size_t curr_file_seq; /* Current file sequence to operate on */
ssize_t tmp_file_len; /* Temporary number of bytes in file sequence */
@@ -1844,11 +1838,11 @@ H5S_select_read(H5F_t *f, const H5O_layout_t *layout, const H5D_dcpl_cache_t *dc
/* Get number of bytes in selection */
#ifndef NDEBUG
{
- hsize_t tmp_maxbytes=H5S_get_select_npoints(file_space)*elmt_size;
- H5_ASSIGN_OVERFLOW(maxbytes,tmp_maxbytes,hsize_t,size_t);
+ hsize_t tmp_maxelem=H5S_get_select_npoints(file_space);
+ H5_ASSIGN_OVERFLOW(maxelem,tmp_maxelem,hsize_t,size_t);
}
#else /* NDEBUG */
- maxbytes=(size_t)(H5S_get_select_npoints(file_space)*elmt_size);
+ maxelem=(size_t)H5S_get_select_npoints(file_space);
#endif /* NDEBUG */
/* Initialize sequence counts */
@@ -1856,11 +1850,11 @@ H5S_select_read(H5F_t *f, const H5O_layout_t *layout, const H5D_dcpl_cache_t *dc
mem_nseq=file_nseq=0;
/* Loop, until all bytes are processed */
- while(maxbytes>0) {
+ while(maxelem>0) {
/* Check if more file sequences are needed */
if(curr_file_seq>=file_nseq) {
/* Get sequences for file selection */
- if((*file_space->select.get_seq_list)(file_space,H5S_GET_SEQ_LIST_SORTED,&file_iter,elmt_size,dxpl_cache->vec_size,maxbytes,&file_nseq,&file_nbytes,file_off,file_len)<0)
+ if((*file_space->select.get_seq_list)(file_space,H5S_GET_SEQ_LIST_SORTED,&file_iter,elmt_size,dxpl_cache->vec_size,maxelem,&file_nseq,&file_nelem,file_off,file_len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed");
/* Start at the beginning of the sequences again */
@@ -1870,7 +1864,7 @@ H5S_select_read(H5F_t *f, const H5O_layout_t *layout, const H5D_dcpl_cache_t *dc
/* Check if more memory sequences are needed */
if(curr_mem_seq>=mem_nseq) {
/* Get sequences for memory selection */
- if((*mem_space->select.get_seq_list)(mem_space,0,&mem_iter,elmt_size,dxpl_cache->vec_size,maxbytes,&mem_nseq,&mem_nbytes,mem_off,mem_len)<0)
+ if((*mem_space->select.get_seq_list)(mem_space,0,&mem_iter,elmt_size,dxpl_cache->vec_size,maxelem,&mem_nseq,&mem_nelem,mem_off,mem_len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed");
/* Start at the beginning of the sequences again */
@@ -1890,8 +1884,9 @@ HDfprintf(stderr,"%s: mem_off[%Zu]=%Hu, mem_len[%Zu]=%Zu\n",FUNC,curr_mem_seq,me
buf))<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_READERROR, FAIL, "read error");
- /* Decrement number of bytes left to process */
- maxbytes-=tmp_file_len;
+ /* Decrement number of elements left to process */
+ assert((tmp_file_len%elmt_size)==0);
+ maxelem-=(tmp_file_len/elmt_size);
} /* end while */
done:
@@ -1954,11 +1949,11 @@ H5S_select_write(H5F_t *f, H5O_layout_t *layout, const H5D_dcpl_cache_t *dcpl_ca
size_t *mem_len=NULL; /* Pointer to sequence lengths in memory */
size_t _file_len[H5D_XFER_HYPER_VECTOR_SIZE_DEF]; /* Array to store sequence lengths in the file */
size_t *file_len=NULL; /* Pointer to sequence lengths in the file */
- size_t maxbytes; /* Number of bytes in selection */
+ size_t maxelem; /* Number of elements in selection */
size_t mem_nseq; /* Number of sequences generated in the file */
size_t file_nseq; /* Number of sequences generated in memory */
- size_t mem_nbytes; /* Number of bytes used in memory sequences */
- size_t file_nbytes; /* Number of bytes used in file sequences */
+ size_t mem_nelem; /* Number of elements used in memory sequences */
+ size_t file_nelem; /* Number of elements used in file sequences */
size_t curr_mem_seq; /* Current memory sequence to operate on */
size_t curr_file_seq; /* Current file sequence to operate on */
ssize_t tmp_file_len; /* Temporary number of bytes in file sequence */
@@ -2012,11 +2007,11 @@ H5S_select_write(H5F_t *f, H5O_layout_t *layout, const H5D_dcpl_cache_t *dcpl_ca
/* Get number of bytes in selection */
#ifndef NDEBUG
{
- hsize_t tmp_maxbytes=H5S_get_select_npoints(file_space)*elmt_size;
- H5_ASSIGN_OVERFLOW(maxbytes,tmp_maxbytes,hsize_t,size_t);
+ hsize_t tmp_maxelem=H5S_get_select_npoints(file_space);
+ H5_ASSIGN_OVERFLOW(maxelem,tmp_maxelem,hsize_t,size_t);
}
#else /* NDEBUG */
- maxbytes=(size_t)(H5S_get_select_npoints(file_space)*elmt_size);
+ maxelem=(size_t)H5S_get_select_npoints(file_space);
#endif /* NDEBUG */
/* Initialize sequence counts */
@@ -2024,7 +2019,7 @@ H5S_select_write(H5F_t *f, H5O_layout_t *layout, const H5D_dcpl_cache_t *dcpl_ca
mem_nseq=file_nseq=0;
/* Loop, until all bytes are processed */
- while(maxbytes>0) {
+ while(maxelem>0) {
/* Check if more file sequences are needed */
#ifdef QAK
{
@@ -2037,7 +2032,7 @@ H5S_select_write(H5F_t *f, H5O_layout_t *layout, const H5D_dcpl_cache_t *dcpl_ca
#endif /* QAK */
if(curr_file_seq>=file_nseq) {
/* Get sequences for file selection */
- if((*file_space->select.get_seq_list)(file_space,H5S_GET_SEQ_LIST_SORTED,&file_iter,elmt_size,dxpl_cache->vec_size,maxbytes,&file_nseq,&file_nbytes,file_off,file_len)<0)
+ if((*file_space->select.get_seq_list)(file_space,H5S_GET_SEQ_LIST_SORTED,&file_iter,elmt_size,dxpl_cache->vec_size,maxelem,&file_nseq,&file_nelem,file_off,file_len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed");
/* Start at the beginning of the sequences again */
@@ -2056,7 +2051,7 @@ H5S_select_write(H5F_t *f, H5O_layout_t *layout, const H5D_dcpl_cache_t *dcpl_ca
/* Check if more memory sequences are needed */
if(curr_mem_seq>=mem_nseq) {
/* Get sequences for memory selection */
- if((*mem_space->select.get_seq_list)(mem_space,0,&mem_iter,elmt_size,dxpl_cache->vec_size,maxbytes,&mem_nseq,&mem_nbytes,mem_off,mem_len)<0)
+ if((*mem_space->select.get_seq_list)(mem_space,0,&mem_iter,elmt_size,dxpl_cache->vec_size,maxelem,&mem_nseq,&mem_nelem,mem_off,mem_len)<0)
HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "sequence length generation failed");
/* Start at the beginning of the sequences again */
@@ -2091,8 +2086,9 @@ for(u=curr_mem_seq; u<mem_nseq; u++)
buf))<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_WRITEERROR, FAIL, "write error");
- /* Decrement number of bytes left to process */
- maxbytes-=tmp_file_len;
+ /* Decrement number of elements left to process */
+ assert((tmp_file_len%elmt_size)==0);
+ maxelem-=(tmp_file_len/elmt_size);
} /* end while */
done: