From d08090ff29eaef0c315a1abce7df94bcc902c2fc Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Sat, 17 Apr 2004 14:22:15 -0500 Subject: [svn-r8374] Purpose: Code optimization Description: Instead of re-initializing the default stride & block arrays to have values of '1' in each position each time we perform a hyperslab selection, create static constant arrays with '1's in them. Platforms tested: Solaris 2.7 (arabica) FreeBSD 4.9 (sleipnir) too minor to require h5committest --- src/H5Shyper.c | 100 ++++++++++++++++++++++++++------------------------------- 1 file changed, 46 insertions(+), 54 deletions(-) diff --git a/src/H5Shyper.c b/src/H5Shyper.c index dd097be..60d1269 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -56,6 +56,18 @@ static herr_t H5S_hyper_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem); static herr_t H5S_hyper_iter_next_block(H5S_sel_iter_t *sel_iter); static herr_t H5S_hyper_iter_release(H5S_sel_iter_t *sel_iter); +/* 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 */ + 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}; + /* Declare a free list to manage the H5S_hyper_span_t struct */ H5FL_DEFINE_STATIC(H5S_hyper_span_t); @@ -5431,9 +5443,9 @@ done: static herr_t H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, const hssize_t start[], - const hsize_t _stride[], - const hsize_t _count[], - const hsize_t _block[]) + const hsize_t t_stride[], + const hsize_t t_count[], + const hsize_t t_block[]) { hsize_t stride[H5O_LAYOUT_NDIMS]; /* Optimized stride information */ hsize_t count[H5O_LAYOUT_NDIMS]; /* Optimized count information */ @@ -5453,27 +5465,27 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, assert(space); assert(op>H5S_SELECT_NOOP && opextent.u.simple.rank; u++) { /* contiguous hyperslabs have the block size equal to the stride */ - if(_stride[u]==_block[u]) { + if(t_stride[u]==t_block[u]) { count[u]=1; stride[u]=1; - block[u]=_block[u]*_count[u]; + block[u]=t_block[u]*t_count[u]; } else { - if(_count[u]==1) + if(t_count[u]==1) stride[u]=1; else { - assert(_stride[u]>_block[u]); - stride[u]=_stride[u]; + assert(t_stride[u]>t_block[u]); + stride[u]=t_stride[u]; } /* end else */ - count[u]=_count[u]; - block[u]=_block[u]; + count[u]=t_count[u]; + block[u]=t_block[u]; } /* end if */ } /* end for */ @@ -5695,8 +5707,6 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, const hsize_t count[], const hsize_t *block) { - hsize_t _stride[H5O_LAYOUT_NDIMS]; /* Stride array */ - hsize_t _block[H5O_LAYOUT_NDIMS]; /* Block size array */ unsigned u; /* Counters */ H5S_hyper_dim_t *diminfo; /* per-dimension info for the selection */ herr_t ret_value=SUCCEED; /* Return value */ @@ -5709,21 +5719,13 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, assert(count); assert(op>H5S_SELECT_NOOP && opextent.u.simple.rank); + /* Point to the correct stride values */ + if(stride==NULL) stride = _stride; - } - /* Fill in the correct block values */ - if(block==NULL) { - hsize_t fill=1; - - H5V_array_fill(_block,&fill,sizeof(hssize_t),space->extent.u.simple.rank); + /* Point to the correct block values */ + if(block==NULL) block = _block; - } /* Fixup operation for non-hyperslab selections */ switch(space->select.type) { @@ -6221,9 +6223,9 @@ done: static herr_t H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, const hssize_t start[], - const hsize_t _stride[], - const hsize_t _count[], - const hsize_t _block[]) + const hsize_t t_stride[], + const hsize_t t_count[], + const hsize_t t_block[]) { hsize_t stride[H5O_LAYOUT_NDIMS]; /* Optimized stride information */ hsize_t count[H5O_LAYOUT_NDIMS]; /* Optimized count information */ @@ -6240,27 +6242,27 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, assert(space); assert(op>H5S_SELECT_NOOP && opextent.u.simple.rank; u++) { /* contiguous hyperslabs have the block size equal to the stride */ - if(_stride[u]==_block[u]) { + if(t_stride[u]==t_block[u]) { count[u]=1; stride[u]=1; - block[u]=_block[u]*_count[u]; + block[u]=t_block[u]*t_count[u]; } else { - if(_count[u]==1) + if(t_count[u]==1) stride[u]=1; else { - assert(_stride[u]>_block[u]); - stride[u]=_stride[u]; + assert(t_stride[u]>t_block[u]); + stride[u]=t_stride[u]; } /* end else */ - count[u]=_count[u]; - block[u]=_block[u]; + count[u]=t_count[u]; + block[u]=t_block[u]; } /* end if */ } /* end for */ @@ -6311,8 +6313,6 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, const hsize_t count[], const hsize_t *block) { - hsize_t _stride[H5O_LAYOUT_NDIMS]; /* Stride array */ - hsize_t _block[H5O_LAYOUT_NDIMS]; /* Block size array */ unsigned u; /* Counters */ H5S_hyper_dim_t *diminfo; /* per-dimension info for the selection */ herr_t ret_value=SUCCEED; /* Return value */ @@ -6325,21 +6325,13 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, assert(count); assert(op>H5S_SELECT_NOOP && opextent.u.simple.rank); + /* Point to the correct stride values */ + if(stride==NULL) stride = _stride; - } /* end if */ - - /* Fill in the correct block values */ - if(block==NULL) { - hsize_t fill=1; - H5V_array_fill(_block,&fill,sizeof(hssize_t),space->extent.u.simple.rank); + /* Point to the correct block values */ + if(block==NULL) block = _block; - } /* end if */ /* Fixup operation for non-hyperslab selections */ switch(space->select.type) { -- cgit v0.12