diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2005-04-08 01:06:24 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2005-04-08 01:06:24 (GMT) |
commit | c3fa71f95ed32158a2eb9efb14145d449a8a78bb (patch) | |
tree | 7f19f56a80bf0974f87bad58c93a85e070f44c77 /src/H5Shyper.c | |
parent | c33b174d18353111f153fe869340dc0e1ecc3fe3 (diff) | |
download | hdf5-c3fa71f95ed32158a2eb9efb14145d449a8a78bb.zip hdf5-c3fa71f95ed32158a2eb9efb14145d449a8a78bb.tar.gz hdf5-c3fa71f95ed32158a2eb9efb14145d449a8a78bb.tar.bz2 |
[svn-r10579] Purpose:
Code optimization
Description:
Reduce overhead for common case of stride==NULL and block==NULL for
H5Sselect_hyperslab() calls.
Platforms tested:
FreeBSD 4.11 (sleipnir)
Solaris 2.9 (shanti)
Diffstat (limited to 'src/H5Shyper.c')
-rw-r--r-- | src/H5Shyper.c | 74 |
1 files changed, 43 insertions, 31 deletions
diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 1ea4100..b9de94d 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -100,12 +100,9 @@ static const H5S_sel_iter_class_t H5S_sel_iter_hyper[1] = {{ }}; /* Static variables */ -static const hsize_t _stride[H5O_LAYOUT_NDIMS]={ /* Default stride array */ - 1,1,1,1, 1,1,1,1, - 1,1,1,1, 1,1,1,1, - 1,1,1,1, 1,1,1,1, - 1,1,1,1, 1,1,1,1,1}; -static const hsize_t _block[H5O_LAYOUT_NDIMS]={ /* Default block size array */ + +/* Array for default stride, block, etc. */ +static const hsize_t _ones[H5O_LAYOUT_NDIMS]={ 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, 1,1,1,1, @@ -5698,10 +5695,13 @@ 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 */ + hsize_t int_stride[H5O_LAYOUT_NDIMS]; /* Internal storage for stride information */ + hsize_t int_count[H5O_LAYOUT_NDIMS]; /* Internal storage for count information */ + hsize_t int_block[H5O_LAYOUT_NDIMS]; /* Internal storage for block information */ + const hsize_t *opt_stride; /* Optimized stride information */ + const hsize_t *opt_count; /* Optimized count information */ + const hsize_t *opt_block; /* Optimized block information */ + unsigned u; /* Counters */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5S_select_hyperslab, FAIL); @@ -5714,11 +5714,11 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, /* Point to the correct stride values */ if(stride==NULL) - stride = _stride; + stride = _ones; /* Point to the correct block values */ if(block==NULL) - block = _block; + block = _ones; /* * Check for overlapping hyperslab blocks in new selection. @@ -5729,27 +5729,39 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, } /* end for */ /* Optimize hyperslab parameters to merge contiguous blocks, etc. */ - for(u=0; u<space->extent.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; + if(stride == _ones && block == _ones) { + /* Point to existing arrays */ + opt_stride = _ones; + opt_count = _ones; + opt_block = count; + } /* end if */ + else { + /* Point to local arrays */ + opt_stride = int_stride; + opt_count = int_count; + opt_block = int_block; + for(u=0; u<space->extent.rank; u++) { + /* contiguous hyperslabs have the block size equal to the stride */ + if(stride[u]==block[u]) { + int_count[u]=1; + int_stride[u]=1; + if(block[u]==1) + int_block[u]=count[u]; + else + int_block[u]=block[u]*count[u]; + } /* end if */ else { - assert(stride[u]>block[u]); - opt_stride[u]=stride[u]; + if(count[u]==1) + int_stride[u]=1; + else { + assert(stride[u]>block[u]); + int_stride[u]=stride[u]; + } /* end else */ + int_count[u]=count[u]; + int_block[u]=block[u]; } /* end else */ - opt_count[u]=count[u]; - opt_block[u]=block[u]; - } /* end if */ - } /* end for */ + } /* end for */ + } /* end else */ /* Fixup operation for non-hyperslab selections */ switch(H5S_GET_SELECT_TYPE(space)) { |