summaryrefslogtreecommitdiffstats
path: root/src/H5Shyper.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-05-01 03:02:47 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-05-01 03:02:47 (GMT)
commitf202e3dba4171dba3e5be2f4cee34445a5239875 (patch)
treebdbeeb6ed86b252cb3ffd145215b97852d0487e8 /src/H5Shyper.c
parent61667c35e085fe64b27a7ccfd5f0593fad0f3a13 (diff)
downloadhdf5-f202e3dba4171dba3e5be2f4cee34445a5239875.zip
hdf5-f202e3dba4171dba3e5be2f4cee34445a5239875.tar.gz
hdf5-f202e3dba4171dba3e5be2f4cee34445a5239875.tar.bz2
[svn-r8453] Purpose:
Code optimization Description: Eliminate more redundant 64-bit multiplies Platforms tested: Solaris 2.7 (arabica) FreeBSD 4.9 (sleipnir) too minor to require h5committest
Diffstat (limited to 'src/H5Shyper.c')
-rw-r--r--src/H5Shyper.c116
1 files changed, 46 insertions, 70 deletions
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 6ee6fce..1a1a10c 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -5306,13 +5306,10 @@ H5S_hyper_rebuild (H5S_t *space)
static herr_t
H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op,
const hssize_t start[],
- const hsize_t t_stride[],
- const hsize_t t_count[],
- const hsize_t t_block[])
+ const hsize_t stride[],
+ const hsize_t count[],
+ const hsize_t block[])
{
- hsize_t stride[H5O_LAYOUT_NDIMS]; /* Optimized stride information */
- hsize_t count[H5O_LAYOUT_NDIMS]; /* Optimized count information */
- hsize_t block[H5O_LAYOUT_NDIMS]; /* Optimized block information */
H5S_hyper_span_info_t *new_spans=NULL; /* Span tree for new hyperslab */
H5S_hyper_span_info_t *a_not_b=NULL; /* Span tree for hyperslab spans in old span tree and not in new span tree */
H5S_hyper_span_info_t *a_and_b=NULL; /* Span tree for hyperslab spans in both old and new span trees */
@@ -5328,30 +5325,10 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op,
assert(space);
assert(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID);
assert(start);
- assert(t_stride);
- assert(t_count);
- assert(t_block);
+ assert(stride);
+ assert(count);
+ assert(block);
- /* Optimize hyperslab selection to merge contiguous blocks */
- for(u=0; u<space->extent.u.simple.rank; u++) {
- /* contiguous hyperslabs have the block size equal to the stride */
- if(t_stride[u]==t_block[u]) {
- count[u]=1;
- stride[u]=1;
- block[u]=t_block[u]*t_count[u];
- }
- else {
- if(t_count[u]==1)
- stride[u]=1;
- else {
- assert(t_stride[u]>t_block[u]);
- stride[u]=t_stride[u];
- } /* end else */
- count[u]=t_count[u];
- block[u]=t_block[u];
- } /* end if */
- } /* end for */
-
/* Generate span tree for new hyperslab information */
if((new_spans=H5S_hyper_make_spans(space->extent.u.simple.rank,start,stride,count,block))==NULL)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't create hyperslab information");
@@ -5570,8 +5547,10 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
const hsize_t count[],
const hsize_t *block)
{
+ hsize_t opt_stride[H5O_LAYOUT_NDIMS]; /* Optimized stride information */
+ hsize_t opt_count[H5O_LAYOUT_NDIMS]; /* Optimized count information */
+ hsize_t opt_block[H5O_LAYOUT_NDIMS]; /* Optimized block information */
unsigned u; /* Counters */
- H5S_hyper_dim_t *diminfo; /* per-dimension info for the selection */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(H5S_select_hyperslab, FAIL);
@@ -5590,6 +5569,37 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
if(block==NULL)
block = _block;
+ /*
+ * Check for overlapping hyperslab blocks in new selection.
+ */
+ for(u=0; u<space->extent.u.simple.rank; u++) {
+ if(count[u]>1 && stride[u]<block[u])
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab blocks overlap");
+ } /* end for */
+
+ /* Optimize hyperslab parameters to merge contiguous blocks, etc. */
+ for(u=0; u<space->extent.u.simple.rank; u++) {
+ /* contiguous hyperslabs have the block size equal to the stride */
+ if(stride[u]==block[u]) {
+ opt_count[u]=1;
+ opt_stride[u]=1;
+ if(block[u]==1)
+ opt_block[u]=count[u];
+ else
+ opt_block[u]=block[u]*count[u];
+ }
+ else {
+ if(count[u]==1)
+ opt_stride[u]=1;
+ else {
+ assert(stride[u]>block[u]);
+ opt_stride[u]=stride[u];
+ } /* end else */
+ opt_count[u]=count[u];
+ opt_block[u]=block[u];
+ } /* end if */
+ } /* end for */
+
/* Fixup operation for non-hyperslab selections */
switch(space->select.type) {
case H5S_SEL_NONE: /* No elements selected in dataspace */
@@ -5675,55 +5685,28 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
} /* end switch */
if(op==H5S_SELECT_SET) {
- /*
- * Check for overlapping hyperslab blocks in new selection.
- */
- for(u=0; u<space->extent.u.simple.rank; u++) {
- if(count[u]>1 && stride[u]<block[u])
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab blocks overlap");
- } /* end for */
-
/* If we are setting a new selection, remove current selection first */
if((*space->select.release)(space)<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release hyperslab");
/* Save the diminfo */
- diminfo=space->select.sel_info.hslab.opt_diminfo;
for(u=0; u<space->extent.u.simple.rank; u++) {
space->select.sel_info.hslab.app_diminfo[u].start = start[u];
space->select.sel_info.hslab.app_diminfo[u].stride = stride[u];
space->select.sel_info.hslab.app_diminfo[u].count = count[u];
space->select.sel_info.hslab.app_diminfo[u].block = block[u];
- /* Optimize the hyperslab selection to detect contiguously selected block/stride information */
- /* Modify the stride, block & count for contiguous hyperslab selections */
-
- /* Starting location doesn't get optimized */
- diminfo[u].start = start[u];
-
- /* contiguous hyperslabs have the block size equal to the stride */
- if(stride[u]==block[u]) {
- diminfo[u].stride=1;
- diminfo[u].count=1;
- diminfo[u].block=count[u]*block[u];
- } /* end if */
- else {
- if(count[u]==1)
- diminfo[u].stride=1;
- else {
- assert(stride[u]>block[u]);
- diminfo[u].stride=stride[u];
- } /* end else */
- diminfo[u].count=count[u];
- diminfo[u].block=block[u];
- } /* end else */
+ space->select.sel_info.hslab.opt_diminfo[u].start = start[u];
+ space->select.sel_info.hslab.opt_diminfo[u].stride = opt_stride[u];
+ space->select.sel_info.hslab.opt_diminfo[u].count = opt_count[u];
+ space->select.sel_info.hslab.opt_diminfo[u].block = opt_block[u];
} /* end for */
/* Indicate that the dimension information is valid */
space->select.sel_info.hslab.diminfo_valid=TRUE;
/* Build the hyperslab information also */
- if(H5S_generate_hyperslab (space, H5S_SELECT_SET, start, stride, count, block)<0)
+ if(H5S_generate_hyperslab (space, H5S_SELECT_SET, start, opt_stride, opt_count, opt_block)<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs");
} /* end if */
else if(op>=H5S_SELECT_OR && op<=H5S_SELECT_NOTA) {
@@ -5734,7 +5717,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
space->select.sel_info.hslab.diminfo_valid=FALSE;
/* Add in the new hyperslab information */
- if(H5S_generate_hyperslab (space, op, start, stride, count, block)<0)
+ if(H5S_generate_hyperslab (space, op, start, opt_stride, opt_count, opt_block)<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINSERT, FAIL, "can't generate hyperslabs");
} /* end if */
else
@@ -5813,13 +5796,6 @@ H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[],
if(stride[u]==0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid stride==0 value");
} /* end for */
- if(block!=NULL) {
- /* Check for strides smaller than blocks */
- for(u=0; u<space->extent.u.simple.rank; u++) {
- if(count[u]>1 && stride[u]<block[u])
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid stride<block value");
- } /* end for */
- } /* end if */
} /* end if */
if (H5S_select_hyperslab(space, op, start, stride, count, block)<0)