summaryrefslogtreecommitdiffstats
path: root/src/H5Dio.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-05-01 00:13:04 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-05-01 00:13:04 (GMT)
commitfbc0aaa0f7de33f841c334f3ea8a8f0359891f20 (patch)
treef08fa6c626df6154f6c8ba94ce000ca589d76782 /src/H5Dio.c
parent1eabcda33975851a8aee056a4162b1fdbaf704e2 (diff)
downloadhdf5-fbc0aaa0f7de33f841c334f3ea8a8f0359891f20.zip
hdf5-fbc0aaa0f7de33f841c334f3ea8a8f0359891f20.tar.gz
hdf5-fbc0aaa0f7de33f841c334f3ea8a8f0359891f20.tar.bz2
[svn-r8445] Purpose:
Code optimization Description: Avoid dividing the chunk coordinates at the top levels of the chunk I/O routines, only to multiply them at the bottom of the routines. Platforms tested: Solaris 2.7 (arabica) FreeBSD 4.9 (sleipnir) too minor to require h5committest
Diffstat (limited to 'src/H5Dio.c')
-rw-r--r--src/H5Dio.c58
1 files changed, 9 insertions, 49 deletions
diff --git a/src/H5Dio.c b/src/H5Dio.c
index 452663a..5b2c44b 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -110,8 +110,6 @@ static herr_t H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type,
const H5S_t *file_space, const H5S_t *mem_space, fm_map *fm);
static herr_t H5D_destroy_chunk_map(fm_map *fm);
static void H5D_free_chunk_info(void *chunk_info);
-static herr_t H5D_chunk_coords_assist(hssize_t *coords, size_t ndims,
- const hsize_t chunks[], hsize_t chunk_idx);
static herr_t H5D_create_chunk_file_map_hyper(const fm_map *fm);
static herr_t H5D_create_chunk_mem_map_hyper(const fm_map *fm);
static herr_t H5D_chunk_file_cb(void *elem, hid_t type_id, hsize_t ndims,
@@ -2235,44 +2233,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5D_chunk_coords_assist
- *
- * Purpose: Compute the coords for a particular chunk (in CHUNK_IDX),
- * based on the size of the dataset's dataspace (given in
- * NDIMS and CHUNKS), putting the resulting chunk's coordinate
- * offsets in the COORDS array.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Raymond Lu
- * Thursday, April 10, 2003
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5D_chunk_coords_assist(hssize_t *coords, size_t ndims, const hsize_t chunks[], hsize_t chunk_idx)
-{
- hsize_t tmp; /* Size of "down elements" in each dimension */
- size_t i, j; /* Local index variables */
-
- FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_chunk_coords_assist);
-
- for(i=0; i<ndims; i++) {
- tmp=1;
- for(j=i+1; j<ndims; j++)
- tmp *= chunks[j];
- coords[i] = (hssize_t)(chunk_idx / tmp);
- chunk_idx = chunk_idx % tmp;
- }
- coords[ndims] = 0;
-
- FUNC_LEAVE_NOAPI(SUCCEED);
-}
-
-
-/*-------------------------------------------------------------------------
* Function: H5D_create_chunk_map
*
* Purpose: Creates the mapping between elements selected in each chunk
@@ -2752,10 +2712,8 @@ H5D_create_chunk_file_map_hyper(const fm_map *fm)
new_chunk_info->mspace_shared=0;
/* Compute the chunk's coordinates */
- if(H5D_chunk_coords_assist(new_chunk_info->coords, fm->f_ndims, fm->chunks, chunk_index)<0) {
- H5D_free_chunk_info(new_chunk_info);
- HGOTO_ERROR(H5E_DATASPACE,H5E_CANTCOUNT,FAIL,"can't compute chunk info")
- } /* end if */
+ HDmemcpy(new_chunk_info->coords,coords,fm->f_ndims*sizeof(new_chunk_info->coords[0]));
+ new_chunk_info->coords[fm->f_ndims]=0;
/* Insert the new chunk into the TBBT tree */
if(H5TB_dins(fm->fsel,new_chunk_info,new_chunk_info)==NULL) {
@@ -2941,7 +2899,7 @@ H5D_create_chunk_mem_map_hyper(const fm_map *fm)
/* Compensate for the chunk offset */
for(u=0; u<fm->f_ndims; u++) {
H5_CHECK_OVERFLOW(fm->layout->dim[u],hsize_t,hssize_t);
- chunk_adjust[u]=adjust[u]-(chunk_info->coords[u]*(hssize_t)fm->layout->dim[u]); /*lint !e771 The adjust array will always be initialized */
+ chunk_adjust[u]=adjust[u]-chunk_info->coords[u]; /*lint !e771 The adjust array will always be initialized */
} /* end for */
#ifdef QAK
{
@@ -3071,12 +3029,14 @@ H5D_chunk_file_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize
/* Set the memory chunk dataspace */
new_chunk_info->mspace=NULL;
+ new_chunk_info->mspace_shared=0;
/* Compute the chunk's coordinates */
- if(H5D_chunk_coords_assist(new_chunk_info->coords, fm->f_ndims, fm->chunks, chunk_index)<0) {
- H5D_free_chunk_info(new_chunk_info);
- HGOTO_ERROR(H5E_DATASPACE,H5E_CANTCOUNT,FAIL,"can't compute chunk info")
- } /* end if */
+ for(u=0; u<fm->f_ndims; u++) {
+ H5_CHECK_OVERFLOW(fm->layout->dim[u],hsize_t,hssize_t);
+ new_chunk_info->coords[u]=(coords[u]/(hssize_t)fm->layout->dim[u])*(hssize_t)fm->layout->dim[u];
+ } /* end for */
+ new_chunk_info->coords[fm->f_ndims]=0;
/* Insert the new chunk into the TBBT tree */
if(H5TB_dins(fm->fsel,new_chunk_info,new_chunk_info)==NULL) {