summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-05-08 19:09:50 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-05-08 19:09:50 (GMT)
commit0f805b3aa507d557fbab6cc8ccec81b50daf6dd8 (patch)
tree10f5d92e41a140dd11711f7af0d845079601e87d /src
parent583bdf994cb40b4568a09657a0961392660ebdff (diff)
downloadhdf5-0f805b3aa507d557fbab6cc8ccec81b50daf6dd8.zip
hdf5-0f805b3aa507d557fbab6cc8ccec81b50daf6dd8.tar.gz
hdf5-0f805b3aa507d557fbab6cc8ccec81b50daf6dd8.tar.bz2
[svn-r8496] Purpose:
Code optimization Description: Further reduce the number of copies we make of a hyperslab selection for chunked I/O, especially when we are only going to throw the old selection away for a new one. Platforms tested: Solaris 2.7 (arabica) FreeBSD 4.9 (sleipnir) w/parallel
Diffstat (limited to 'src')
-rw-r--r--src/H5A.c6
-rw-r--r--src/H5D.c4
-rw-r--r--src/H5Dio.c12
-rw-r--r--src/H5S.c12
-rw-r--r--src/H5Shyper.c17
-rw-r--r--src/H5Spkg.h2
-rw-r--r--src/H5Sprivate.h4
-rw-r--r--src/H5Sselect.c11
8 files changed, 44 insertions, 24 deletions
diff --git a/src/H5A.c b/src/H5A.c
index 00269db..bc065cf 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -241,7 +241,7 @@ H5A_create(const H5G_entry_t *ent, const char *name, const H5T_t *type,
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
/* Copy the dataspace for the attribute */
- attr->ds=H5S_copy(space);
+ attr->ds=H5S_copy(space, FALSE);
/* Mark it initially set to initialized */
attr->initialized = TRUE; /*for now, set to false later*/
@@ -872,7 +872,7 @@ H5Aget_space(hid_t attr_id)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
/* Copy the attribute's dataspace */
- if (NULL==(dst=H5S_copy (attr->ds)))
+ if (NULL==(dst=H5S_copy (attr->ds, FALSE)))
HGOTO_ERROR (H5E_ATTR, H5E_CANTINIT, FAIL, "unable to copy dataspace")
/* Atomize */
@@ -1513,7 +1513,7 @@ H5A_copy(const H5A_t *old_attr)
/* Copy the guts of the attribute */
new_attr->name=HDstrdup(old_attr->name);
new_attr->dt=H5T_copy(old_attr->dt, H5T_COPY_ALL);
- new_attr->ds=H5S_copy(old_attr->ds);
+ new_attr->ds=H5S_copy(old_attr->ds, FALSE);
if(old_attr->data) {
if (NULL==(new_attr->data=H5MM_malloc(old_attr->data_size)))
HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
diff --git a/src/H5D.c b/src/H5D.c
index c17dd11..4057cb4 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -1351,7 +1351,7 @@ H5Dget_space(hid_t dset_id)
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
/* Read the data space message and return a data space object */
- if (NULL==(space=H5S_copy (dset->space)))
+ if (NULL==(space=H5S_copy (dset->space, FALSE)))
HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get data space")
/* Create an atom */
@@ -2086,7 +2086,7 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location")
/* Copy dataspace for dataset */
- if((new_dset->space = H5S_copy(space))==NULL)
+ if((new_dset->space = H5S_copy(space, FALSE))==NULL)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy dataspace")
/* Set the dataset's dataspace to 'all' selection */
diff --git a/src/H5Dio.c b/src/H5Dio.c
index 4bcc9aa..068782c 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -2455,7 +2455,7 @@ H5D_create_chunk_map(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *file_sp
size_t elmt_size; /* Memory datatype size */
/* Make a copy of equivalent memory space */
- if((tmp_mspace = H5S_copy(equiv_mspace))==NULL)
+ if((tmp_mspace = H5S_copy(equiv_mspace,TRUE))==NULL)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space")
/* De-select the mem space copy */
@@ -2695,7 +2695,7 @@ H5D_create_chunk_file_map_hyper(const fm_map *fm)
hssize_t schunk_points; /* Number of elements in chunk selection */
/* Create "temporary" chunk for selection operations (copy file space) */
- if((tmp_fchunk = H5S_copy(fm->file_space))==NULL)
+ if((tmp_fchunk = H5S_copy(fm->file_space,TRUE))==NULL)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space")
/* Make certain selections are stored in span tree form (not "optimized hyperslab" or "all") */
@@ -2866,7 +2866,7 @@ H5D_create_chunk_mem_map_hyper(const fm_map *fm)
/* 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)
+ if((chunk_info->mspace = H5S_copy(fm->mem_space,FALSE))==NULL)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space")
} /* end if */
else {
@@ -2919,7 +2919,7 @@ H5D_create_chunk_mem_map_hyper(const fm_map *fm)
/* Copy the information */
/* Copy the memory dataspace */
- if((chunk_info->mspace = H5S_copy(fm->mem_space))==NULL)
+ if((chunk_info->mspace = H5S_copy(fm->mem_space,TRUE))==NULL)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy memory space")
/* Release the current selection */
@@ -2927,7 +2927,7 @@ H5D_create_chunk_mem_map_hyper(const fm_map *fm)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release selection")
/* Copy the file chunk's selection */
- if(H5S_select_copy(chunk_info->mspace,chunk_info->fspace)<0)
+ if(H5S_select_copy(chunk_info->mspace,chunk_info->fspace,FALSE)<0)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy selection")
/* Compensate for the chunk offset */
@@ -3166,7 +3166,7 @@ H5D_chunk_mem_cb(void UNUSED *elem, hid_t UNUSED type_id, hsize_t ndims, hssize_
/* Check if the chunk already has a memory space */
if(chunk_info->mspace==NULL) {
/* Copy the template memory chunk dataspace */
- if((chunk_info->mspace = H5S_copy(fm->mchunk_tmpl))==NULL)
+ if((chunk_info->mspace = H5S_copy(fm->mchunk_tmpl,FALSE))==NULL)
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTCOPY, FAIL, "unable to copy file space")
} /* end else */
diff --git a/src/H5S.c b/src/H5S.c
index f326860..a7ede59 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -566,7 +566,7 @@ H5Scopy(hid_t space_id)
HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
/* Copy */
- if (NULL==(dst=H5S_copy (src)))
+ if (NULL==(dst=H5S_copy (src, FALSE)))
HGOTO_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to copy data space");
/* Atomize */
@@ -691,7 +691,11 @@ done:
* Function: H5S_copy
*
* Purpose: Copies a data space, by copying the extent and selection through
- * H5S_extent_copy and H5S_select_copy
+ * H5S_extent_copy and H5S_select_copy. If the SHARE_SELECTION flag
+ * is set, then the selection can be shared between the source and
+ * destination dataspaces. (This should only occur in situations
+ * where the destination dataspace will immediately change to a new
+ * selection)
*
* Return: Success: A pointer to a new copy of SRC
*
@@ -705,7 +709,7 @@ done:
*-------------------------------------------------------------------------
*/
H5S_t *
-H5S_copy(const H5S_t *src)
+H5S_copy(const H5S_t *src, hbool_t share_selection)
{
H5S_t *dst = NULL;
H5S_t *ret_value; /* Return value */
@@ -725,7 +729,7 @@ H5S_copy(const H5S_t *src)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy extent");
/* Copy the source dataspace's selection */
- if (H5S_select_copy(dst,src)<0)
+ if (H5S_select_copy(dst,src,share_selection)<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, NULL, "can't copy select");
/* Set the return value */
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 22c1541..169d58a 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -1557,13 +1557,18 @@ done:
DESCRIPTION
Copies all the hyperslab selection information from the source
dataspace to the destination dataspace.
+
+ If the SHARE_SELECTION flag is set, then the selection can be shared
+ between the source and destination dataspaces. (This should only occur in
+ situations where the destination dataspace will immediately change to a new
+ selection)
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_hyper_copy (H5S_t *dst, const H5S_t *src)
+H5S_hyper_copy (H5S_t *dst, const H5S_t *src, hbool_t share_selection)
{
herr_t ret_value=SUCCEED; /* return value */
@@ -1575,8 +1580,14 @@ H5S_hyper_copy (H5S_t *dst, const H5S_t *src)
/* Check if there is hyperslab span information to copy */
/* (Regular hyperslab information is copied with the selection structure) */
if(src->select.sel_info.hslab.span_lst!=NULL) {
- /* Copy the hyperslab span information */
- dst->select.sel_info.hslab.span_lst=H5S_hyper_copy_span(src->select.sel_info.hslab.span_lst);
+ if(share_selection) {
+ /* Share the source's span tree by incrementing the reference count on it */
+ dst->select.sel_info.hslab.span_lst=src->select.sel_info.hslab.span_lst;
+ dst->select.sel_info.hslab.span_lst->count++;
+ } /* end if */
+ else
+ /* Copy the hyperslab span information */
+ dst->select.sel_info.hslab.span_lst=H5S_hyper_copy_span(src->select.sel_info.hslab.span_lst);
} /* end if */
done:
diff --git a/src/H5Spkg.h b/src/H5Spkg.h
index dbc7048..d34f834 100644
--- a/src/H5Spkg.h
+++ b/src/H5Spkg.h
@@ -217,7 +217,7 @@ H5_DLL herr_t H5S_hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space);
/* Hyperslab selection functions */
H5_DLL herr_t H5S_hyper_release(H5S_t *space);
H5_DLL hsize_t H5S_hyper_npoints(const H5S_t *space);
-H5_DLL herr_t H5S_hyper_copy(H5S_t *dst, const H5S_t *src);
+H5_DLL herr_t H5S_hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection);
H5_DLL htri_t H5S_hyper_is_valid(const H5S_t *space);
H5_DLL hssize_t H5S_hyper_serial_size(const H5S_t *space);
H5_DLL herr_t H5S_hyper_serialize(const H5S_t *space, uint8_t *buf);
diff --git a/src/H5Sprivate.h b/src/H5Sprivate.h
index 343fa2a..947c34b 100644
--- a/src/H5Sprivate.h
+++ b/src/H5Sprivate.h
@@ -173,7 +173,7 @@ typedef struct H5S_conv_t {
} H5S_conv_t;
/* Operations on dataspaces */
-H5_DLL H5S_t *H5S_copy(const H5S_t *src);
+H5_DLL H5S_t *H5S_copy(const H5S_t *src, hbool_t share_selection);
H5_DLL herr_t H5S_close(H5S_t *ds);
H5_DLL H5S_conv_t *H5S_find(const H5S_t *mem_space, const H5S_t *file_space,
unsigned flags, hbool_t *use_par_opt_io);
@@ -228,7 +228,7 @@ H5_DLL htri_t H5S_select_valid(const H5S_t *space);
H5_DLL hssize_t H5S_get_select_npoints(const H5S_t *space);
H5_DLL herr_t H5S_get_select_bounds(const H5S_t *space, hssize_t *start, hssize_t *end);
H5_DLL herr_t H5S_select_offset(H5S_t *space, const hssize_t *offset);
-H5_DLL herr_t H5S_select_copy(H5S_t *dst, const H5S_t *src);
+H5_DLL herr_t H5S_select_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection);
H5_DLL htri_t H5S_select_shape_same(const H5S_t *space1, const H5S_t *space2);
H5_DLL herr_t H5S_select_release(H5S_t *ds);
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index d232cdf..1e79410 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -113,13 +113,18 @@ done:
DESCRIPTION
Copies all the selection information (include offset) from the source
dataspace to the destination dataspace.
+
+ If the SHARE_SELECTION flag is set, then the selection can be shared
+ between the source and destination dataspaces. (This should only occur in
+ situations where the destination dataspace will immediately change to a new
+ selection)
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5S_select_copy (H5S_t *dst, const H5S_t *src)
+H5S_select_copy (H5S_t *dst, const H5S_t *src, hbool_t share_selection)
{
herr_t ret_value=SUCCEED; /* return value */
@@ -132,7 +137,7 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src)
/* Copy regular fields */
HDmemcpy(&dst->select,&src->select,sizeof(H5S_select_t));
-/* Need to copy order information still */
+/* Need to copy permutation order information still */
/* Copy offset information */
if(src->extent.u.simple.rank>0) {
@@ -166,7 +171,7 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src)
break;
case H5S_SEL_HYPERSLABS:
- ret_value=H5S_hyper_copy(dst,src);
+ ret_value=H5S_hyper_copy(dst,src,share_selection);
break;
default: