From 6a806870e9938bf0651a7513c109489687b016bb Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 13 May 2004 18:26:10 -0500 Subject: [svn-r8520] Purpose: Code optimization Description: Don't make a separate allocation for the selection offset - incorporate it into the selection structure as a fixed size array. Platforms tested: Solaris 2.7 (arabica) FreeBSD 4.9 (sleipnir) w/parallel --- src/H5S.c | 20 ++------------------ src/H5Shyper.c | 29 +++++++++++++---------------- src/H5Spkg.h | 2 +- src/H5Sselect.c | 22 ---------------------- 4 files changed, 16 insertions(+), 57 deletions(-) diff --git a/src/H5S.c b/src/H5S.c index a7ede59..c183be7 100644 --- a/src/H5S.c +++ b/src/H5S.c @@ -1205,13 +1205,6 @@ H5S_read(H5G_entry_t *ent, hid_t dxpl_id) if(H5S_select_all(ds,0)<0) HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection"); - /* Allocate space for the offset and set it to zeros */ - if(ds->extent.u.simple.rank>0) { - if (NULL==(ds->select.offset = H5FL_ARR_CALLOC(hssize_t,ds->extent.u.simple.rank))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - } else - ds->select.offset = NULL; - /* Set the value for successful return */ ret_value=ds; @@ -1389,17 +1382,8 @@ H5S_set_extent_simple (H5S_t *space, unsigned rank, const hsize_t *dims, assert(rank<=H5S_MAX_RANK); assert(0==rank || dims); - /* If there was a previous offset for the selection, release it */ - if(space->select.offset!=NULL) - space->select.offset=H5FL_ARR_FREE(hssize_t,space->select.offset); - - /* Allocate space for the offset and set it to zeros */ - if(rank>0) { - if (NULL==(space->select.offset = H5FL_ARR_CALLOC(hssize_t,rank))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - } /* end if */ - else - space->select.offset = NULL; + /* Set offset to zeros */ + HDmemset(space->select.offset,0,sizeof(hssize_t)*rank); /* shift out of the previous state to a "simple" dataspace. */ if(H5S_extent_release(&space->extent)<0) diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 7094134..acc78c9 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -4030,20 +4030,17 @@ H5S_hyper_normalize_offset(H5S_t *space) /* Check for 'all' selection, instead of a hyperslab selection */ /* (Technically, this check shouldn't be in the "hyperslab" routines...) */ if(space->select.type!=H5S_SEL_ALL) { - /* Check if there is an offset currently */ - if(space->select.offset) { - /* Invert the selection offset */ - for(u=0; uextent.u.simple.rank; u++) - space->select.offset[u] =- space->select.offset[u]; - - /* Call the existing 'adjust' routine */ - if(H5S_hyper_adjust(space, space->select.offset)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab normalization"); - - /* Zero out the selection offset */ - for(u=0; uextent.u.simple.rank; u++) - space->select.offset[u] = 0; - } /* end if */ + /* Invert the selection offset */ + for(u=0; uextent.u.simple.rank; u++) + space->select.offset[u] =- space->select.offset[u]; + + /* Call the existing 'adjust' routine */ + if(H5S_hyper_adjust(space, space->select.offset)<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADSELECT, FAIL, "can't perform hyperslab normalization"); + + /* Zero out the selection offset */ + for(u=0; uextent.u.simple.rank; u++) + space->select.offset[u] = 0; } /* end if */ done: @@ -6796,7 +6793,7 @@ H5S_hyper_get_seq_list_gen(const H5S_t *space,H5S_sel_iter_t *iter, hsize_t loc_off; /* Element offset in the dataspace */ hsize_t last_span_end=0; /* The offset of the end of the last span */ hssize_t *abs_arr; /* Absolute hyperslab span position */ - hssize_t *off_arr; /* Offset within the dataspace extent */ + const 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 io_left; /* Number of elements left to process */ size_t io_bytes_left; /* Number of bytes left to process */ @@ -7224,7 +7221,7 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter, { hsize_t *mem_size; /* Size of the source buffer */ hsize_t slab[H5O_LAYOUT_NDIMS]; /* Hyperslab size */ - hssize_t *sel_off; /* Selection offset in dataspace */ + const hssize_t *sel_off; /* Selection offset in dataspace */ hssize_t offset[H5O_LAYOUT_NDIMS]; /* Coordinate offset in dataspace */ hsize_t tmp_count[H5O_LAYOUT_NDIMS];/* Temporary block count */ hsize_t tmp_block[H5O_LAYOUT_NDIMS];/* Temporary block offset */ diff --git a/src/H5Spkg.h b/src/H5Spkg.h index d34f834..d062854 100644 --- a/src/H5Spkg.h +++ b/src/H5Spkg.h @@ -141,7 +141,7 @@ typedef herr_t (*H5S_sel_iter_init_func_t)(H5S_sel_iter_t *sel_iter, const H5S_t /* Selection information object */ typedef struct { H5S_sel_type type; /* Type of selection (list of points or hyperslabs) */ - hssize_t *offset; /* Offset within the extent (NULL means a 0 offset) */ + hssize_t offset[H5S_MAX_RANK]; /* Offset within the extent */ hsize_t *order; /* Selection order. (NULL means a specific ordering of points) */ hsize_t num_elem; /* Number of elements in selection */ union { diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 1e79410..daf40cd 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -85,12 +85,6 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset) assert(space->extent.u.simple.rank); assert(offset); - /* Allocate space for new offset */ - if(space->select.offset==NULL) { - if (NULL==(space->select.offset = H5FL_ARR_MALLOC(hssize_t,space->extent.u.simple.rank))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - } - /* Copy the offset over */ HDmemcpy(space->select.offset,offset,sizeof(hssize_t)*space->extent.u.simple.rank); @@ -139,18 +133,6 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src, hbool_t share_selection) /* Need to copy permutation order information still */ - /* Copy offset information */ - if(src->extent.u.simple.rank>0) { - if (NULL==(dst->select.offset = H5FL_ARR_MALLOC(hssize_t,src->extent.u.simple.rank))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed"); - if(src->select.offset==NULL) - HDmemset(dst->select.offset,0,(src->extent.u.simple.rank*sizeof(hssize_t))); - else - HDmemcpy(dst->select.offset,src->select.offset,(src->extent.u.simple.rank*sizeof(hssize_t))); - } /* end if */ - else - dst->select.offset=NULL; - /* Perform correct type of copy based on the type of selection */ switch (src->extent.type) { case H5S_NULL: @@ -217,10 +199,6 @@ H5S_select_release(H5S_t *ds) assert(ds); - /* If there was a previous offset for the selection, release it */ - if(ds->select.offset!=NULL) - ds->select.offset=H5FL_ARR_FREE(hssize_t,ds->select.offset); - /* Call the selection type's release function */ (*ds->select.release)(ds); -- cgit v0.12