diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-04-10 18:02:24 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-04-10 18:02:24 (GMT) |
commit | acaf0a0107c8cea8f5ec06f5cf6bf0aa2818c031 (patch) | |
tree | 578b4c4428bd7ebe2de7be29ba69a937ca4f2091 | |
parent | 3910acb2be598cf4705973a4f128132ea934da4f (diff) | |
download | hdf5-acaf0a0107c8cea8f5ec06f5cf6bf0aa2818c031.zip hdf5-acaf0a0107c8cea8f5ec06f5cf6bf0aa2818c031.tar.gz hdf5-acaf0a0107c8cea8f5ec06f5cf6bf0aa2818c031.tar.bz2 |
[svn-r8341] Purpose:
Code optimization
Description:
Remove another dataspace copy, in certain circumstances.
Platforms tested:
Solaris 2.7 (arabica)
FreeBSD 4.9 (sleipnir)
too minor to require h5committest
-rw-r--r-- | src/H5Dio.c | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/H5Dio.c b/src/H5Dio.c index 655289f..cb49a13 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -46,6 +46,7 @@ typedef struct H5D_chunk_info_t { H5S_t *fspace; /* Dataspace describing chunk & selection in it */ hssize_t coords[H5O_LAYOUT_NDIMS]; /* Coordinates of chunk in file dataset's dataspace */ H5S_t *mspace; /* Dataspace describing selection in memory corresponding to this chunk */ + unsigned mspace_shared; /* Indicate that the memory space for a chunk is shared and shouldn't be freed */ } H5D_chunk_info_t; /* Main structure holding the mapping between file chunks and memory */ @@ -54,6 +55,7 @@ typedef struct fm_map { hsize_t last_index; /* Index of last chunk operated on */ const H5S_t *file_space; /* Pointer to the file dataspace */ const H5S_t *mem_space; /* Pointer to the memory dataspace */ + unsigned mem_space_copy; /* Flag to indicate that the memory dataspace must be copied */ hsize_t f_dims[H5O_LAYOUT_NDIMS]; /* File dataspace dimensions */ H5S_t *last_chunk; /* Pointer to last memory chunk's dataspace */ H5S_t *mchunk_tmpl; /* Dataspace template for new memory chunks */ @@ -2380,6 +2382,7 @@ H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_sp /* Point at the dataspaces */ fm->file_space=file_space; fm->mem_space=equiv_mspace; + fm->mem_space_copy=equiv_mspace_init; /* Make certain to copy memory dataspace if necessary */ /* Get type of selection on disk & in memory */ if((fsel_type=H5S_get_select_type(file_space))<0) @@ -2585,8 +2588,9 @@ H5D_free_chunk_info(void *_chunk_info) /* Close the chunk's dataspace */ H5S_close(chunk_info->fspace); - /* Close the chunk's memory dataspace */ - H5S_close(chunk_info->mspace); + /* Close the chunk's memory dataspace, if it's not shared */ + if(!chunk_info->mspace_shared) + H5S_close(chunk_info->mspace); /* Free the actual chunk info */ H5FL_FREE(H5D_chunk_info_t,chunk_info); @@ -2741,6 +2745,7 @@ H5D_create_chunk_file_map_hyper(const fm_map *fm) /* 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) { @@ -2862,9 +2867,19 @@ H5D_create_chunk_mem_map_hyper(const fm_map *fm) chunk_info=curr_node->data; assert(chunk_info); - /* Copy the memory dataspace & selection to be the chunk's dataspace & selection */ - if((chunk_info->mspace = H5S_copy(fm->mem_space))==NULL) - HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space") + /* Check if it's OK to share dataspace */ + if(fm->mem_space_copy) { + /* Copy the memory dataspace & selection to be the chunk's dataspace & selection */ + if((chunk_info->mspace = H5S_copy(fm->mem_space))==NULL) + HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space") + } /* end if */ + else { + /* Just point at the memory dataspace & selection */ + chunk_info->mspace=fm->mem_space; + + /* Indicate that the chunk's memory space is shared */ + chunk_info->mspace_shared=1; + } /* end else */ } /* end if */ else { /* Get bounding box for selection */ |