summaryrefslogtreecommitdiffstats
path: root/src/H5Spoint.c
diff options
context:
space:
mode:
authorLarry Knox <lrknox@hdfgroup.org>2019-12-24 21:12:08 (GMT)
committerLarry Knox <lrknox@hdfgroup.org>2019-12-24 21:12:08 (GMT)
commit5b9cf732caab9daa6ed1e00f2df4f5a792340196 (patch)
tree4c01c9bd71ba5e7d8d11b474f6896e6ffbf0416d /src/H5Spoint.c
parent646fc294078f560fc9bef784cb1c4e27cdc51f5b (diff)
parente0fa36bfe008c03365ce8ea94d705f8fdebccdf0 (diff)
downloadhdf5-5b9cf732caab9daa6ed1e00f2df4f5a792340196.zip
hdf5-5b9cf732caab9daa6ed1e00f2df4f5a792340196.tar.gz
hdf5-5b9cf732caab9daa6ed1e00f2df4f5a792340196.tar.bz2
Merge pull request #2203 in HDFFV/hdf5 from ~LRKNOX/hdf5_lrk:1.10/master to 1.10/masterhdf5-1_10_6
* commit 'e0fa36bfe008c03365ce8ea94d705f8fdebccdf0': (166 commits) Update release date strings in README.txt and release_docs/RELEASE.txt Add release note about using ompio instead of romio when collective writes fail with OpenMPI. Fixed typos, grammatical errors, etc. Expanded entry for S3 and HDFS VFDs. Moved Mac 10.11 and 10.12 from Supported Platforms to More Platforms Tested. Add qualification to RELEASE.txt regarding performance improvements Standalone doesn't use h5test implementation. Add missing note Update COPYING file with new HDF5 license. Update bin/config.guess and config.sub to current version available from git.savannah.gnu.org. Fix include to correct memory calls - big-endian issue. Revert BLDLIBDIR value in junit.sh.in. Corrections to CMake functions Update version for HDF5 1.10.6 release. Remove autom4te.cache directory that shouldn't have been added. Remove duplicate instance Fix merge issue HDFFV-10979 - fix global name clash Correct clang search and java include Latest date first in RELEASE.txt Update RELEASE.txt with performance improvements and Steven Varga's bugfix. Update version numbers for shared lib files according to api compatibility report. Created hdf5_1_10_6 branch for HDF5 1.10.6 release preparation. Set version to 1.10.6-pre1. Switched default maintainer mode to disabled and default build mode to production. Added files produced by autogen.sh to commit except for src/H5config.h.in~ and src/H5public.h~. ...
Diffstat (limited to 'src/H5Spoint.c')
-rw-r--r--src/H5Spoint.c204
1 files changed, 95 insertions, 109 deletions
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index 2363352..04d829f 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -38,10 +38,9 @@ static herr_t H5S_point_get_seq_list(const H5S_t *space, unsigned flags,
size_t *nseq, size_t *nbytes, hsize_t *off, size_t *len);
static herr_t H5S_point_release(H5S_t *space);
static htri_t H5S_point_is_valid(const H5S_t *space);
-static hssize_t H5S_point_serial_size(const H5S_t *space, H5F_t *f);
-static herr_t H5S_point_serialize(const H5S_t *space, uint8_t **p, H5F_t *f);
-static herr_t H5S_point_deserialize(H5S_t *space, uint32_t version, uint8_t flags,
- const uint8_t **p);
+static hssize_t H5S_point_serial_size(const H5S_t *space);
+static herr_t H5S_point_serialize(const H5S_t *space, uint8_t **p);
+static herr_t H5S_point_deserialize(H5S_t **space, const uint8_t **p);
static herr_t H5S_point_bounds(const H5S_t *space, hsize_t *start, hsize_t *end);
static herr_t H5S_point_offset(const H5S_t *space, hsize_t *off);
static int H5S__point_unlim_dim(const H5S_t *space);
@@ -52,13 +51,15 @@ static void H5S_point_adjust_u(H5S_t *space, const hsize_t *offset);
static herr_t H5S_point_project_scalar(const H5S_t *space, hsize_t *offset);
static herr_t H5S_point_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset);
static herr_t H5S_point_iter_init(H5S_sel_iter_t *iter, const H5S_t *space);
+static herr_t
+ H5S_point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t *enc_size);
/* Selection iteration callbacks */
static herr_t H5S_point_iter_coords(const H5S_sel_iter_t *iter, hsize_t *coords);
static herr_t H5S_point_iter_block(const H5S_sel_iter_t *iter, hsize_t *start, hsize_t *end);
static hsize_t H5S_point_iter_nelmts(const H5S_sel_iter_t *iter);
static htri_t H5S_point_iter_has_next_block(const H5S_sel_iter_t *iter);
-static herr_t H5S_point_iter_next(H5S_sel_iter_t *sel_iter, hsize_t nelem);
+static herr_t H5S_point_iter_next(H5S_sel_iter_t *sel_iter, size_t nelem);
static herr_t H5S_point_iter_next_block(H5S_sel_iter_t *sel_iter);
static herr_t H5S_point_iter_release(H5S_sel_iter_t *sel_iter);
@@ -278,7 +279,7 @@ done:
USAGE
herr_t H5S_point_iter_next(iter, nelem)
H5S_sel_iter_t *iter; IN: Pointer to selection iterator
- hsize_t nelem; IN: Number of elements to advance by
+ size_t nelem; IN: Number of elements to advance by
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
@@ -289,7 +290,7 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_point_iter_next(H5S_sel_iter_t *iter, hsize_t nelem)
+H5S_point_iter_next(H5S_sel_iter_t *iter, size_t nelem)
{
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -754,20 +755,19 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5S_point_set_version
+ H5S_point_get_version_enc_size
PURPOSE
- Determine the version to use for encoding points selection info
+ Determine the version and the size (4 bytes) to encode point selection info
USAGE
- hssize_t H5S_point_set_version(space, bounds_end, f, version)
+ hssize_t H5S_point_get_version_enc_size(space, uint32_t *version, uint8_t *enc_size
const H5S_t *space; IN: The dataspace
- hsize_t bounds_end: IN: The selection high bounds
- H5F_t *f: IN: The file pointer
uint32_t *version: OUT: The version to use for encoding
+ uint8_t *enc_size: OUT: The size to use for encoding
RETURNS
- The version to use
+ The version and the encoded size to use
DESCRIPTION
- Determine the version to use for encoding points selection info:
- For 1.10, return 1
+ Determine the version and the encoded size to use for encoding points selection info.
+ Detect whether the number of points or the high bound exceeds 2^32 -1.
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
@@ -775,15 +775,20 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_point_set_version(const H5S_t *space, hsize_t bounds_end[], H5F_t *f, uint32_t *version)
+H5S_point_get_version_enc_size(const H5S_t *space, uint32_t *version, uint8_t *enc_size)
{
hbool_t exceed = FALSE;
+ hsize_t bounds_start[H5S_MAX_RANK];
+ hsize_t bounds_end[H5S_MAX_RANK];
unsigned u;
herr_t ret_value = SUCCEED; /* return value */
FUNC_ENTER_NOAPI_NOINIT
- *version = H5S_POINT_VERSION_1;
+ /* Get bounding box for the selection */
+ HDmemset(bounds_end, 0, sizeof(bounds_end));
+ if(H5S_point_bounds(space, bounds_start, bounds_end) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds")
/* Determine whether the number of points or the high bounds in the selection exceed (2^32 - 1) */
for(u = 0; u < space->extent.rank; u++)
@@ -797,47 +802,12 @@ H5S_point_set_version(const H5S_t *space, hsize_t bounds_end[], H5F_t *f, uint32
else if(exceed)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL, "The end of bounding box in point selection exceeds 2^32")
+ *version = H5S_POINT_VERSION_1;
+ *enc_size = H5S_SELECT_INFO_ENC_SIZE_4;
+
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5S_point_set_version() */
-
-
-/*--------------------------------------------------------------------------
- NAME
- H5S_point_set_info_size
- PURPOSE
- Determine the size of point info to use for encoding selection info
- USAGE
- hssize_t H5S_point_set_info_size(space, bounds_end, version, point_size)
- const H5S_t *space: IN: Dataspace ID of selection to query
- hsize_t bounds_end[]: IN: The selection high bounds
- uint32_t version: IN: The version used for encoding
- uint8_t *point_size: OUT: The size of point info
- RETURNS
- The size of the points selection info
- DESCRIPTION
- Determine the size for encoding points selection info:
- For 1.10, return 4
-
- GLOBAL VARIABLES
- COMMENTS, BUGS, ASSUMPTIONS
- EXAMPLES
- REVISION LOG
---------------------------------------------------------------------------*/
-static herr_t
-H5S_point_set_info_size(const H5S_t *space, hsize_t H5_ATTR_UNUSED bounds_end[], uint32_t H5_ATTR_UNUSED version, uint8_t H5_ATTR_UNUSED *point_size)
-{
- hsize_t max_size = 0;
- unsigned u;
-
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- HDassert(version == H5S_POINT_VERSION_1);
-
- *point_size = H5S_INFO_SIZE_4;
-
- FUNC_LEAVE_NOAPI(SUCCEED)
-} /* H5S_point_set_info_size() */
+} /* H5S_point_get_version_enc_size() */
/*--------------------------------------------------------------------------
@@ -847,9 +817,8 @@ H5S_point_set_info_size(const H5S_t *space, hsize_t H5_ATTR_UNUSED bounds_end[],
Determine the number of bytes needed to store the serialized point selection
information.
USAGE
- hssize_t H5S_point_serial_size(space, f)
+ hssize_t H5S_point_serial_size(space)
H5S_t *space; IN: Dataspace pointer to query
- H5F_t *f; IN: File pointer
RETURNS
The number of bytes required on success, negative on an error.
DESCRIPTION
@@ -861,34 +830,23 @@ H5S_point_set_info_size(const H5S_t *space, hsize_t H5_ATTR_UNUSED bounds_end[],
REVISION LOG
--------------------------------------------------------------------------*/
static hssize_t
-H5S_point_serial_size (const H5S_t *space, H5F_t *f)
+H5S_point_serial_size (const H5S_t *space)
{
H5S_pnt_node_t *curr; /* Point information nodes */
- hsize_t bounds_start[H5S_MAX_RANK];
- hsize_t bounds_end[H5S_MAX_RANK];
uint32_t version; /* Version number */
- uint8_t point_size; /* Size of point info */
+ uint8_t enc_size; /* Size of point info */
hssize_t ret_value = -1; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
HDassert(space);
- /* Get bounding box for the selection */
- HDmemset(bounds_end, 0, sizeof(bounds_end));
- if(H5S_point_bounds(space, bounds_start, bounds_end) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds")
-
/* Determine the version */
- if(H5S_point_set_version(space, bounds_end, f, &version) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version")
-
- /* Determine the size of point info */
- if(H5S_point_set_info_size(space, bounds_end, version, &point_size) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version")
+ if(H5S_point_get_version_enc_size(space, &version, &enc_size) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine version and enc_size")
HDassert(version == H5S_POINT_VERSION_1);
- HDassert(point_size == H5S_INFO_SIZE_4);
+ HDassert(enc_size == H5S_SELECT_INFO_ENC_SIZE_4);
/* Basic number of bytes required to serialize point selection: */
/*
@@ -897,14 +855,14 @@ H5S_point_serial_size (const H5S_t *space, H5F_t *f)
*/
ret_value=20;
- /* <num points (depend on point_size)> */
- ret_value += point_size;
+ /* <num points (depend on enc_size)> */
+ ret_value += enc_size;
/* Count points in selection */
curr=space->select.sel_info.pnt_lst->head;
while(curr!=NULL) {
- /* Add <point_size> bytes times the rank for each element selected */
- ret_value += point_size * space->extent.rank;
+ /* Add <enc_size> bytes times the rank for each element selected */
+ ret_value += enc_size * space->extent.rank;
curr = curr->next;
} /* end while */
@@ -919,12 +877,11 @@ done:
PURPOSE
Serialize the current selection into a user-provided buffer.
USAGE
- herr_t H5S_point_serialize(space, p, f)
+ herr_t H5S_point_serialize(space, p)
const H5S_t *space; IN: Dataspace with selection to serialize
uint8_t **p; OUT: Pointer to buffer to put serialized
selection. Will be advanced to end of
serialized selection.
- H5F_t *f; IN: File pointer
RETURNS
Non-negative on success/Negative on failure
DESCRIPTION
@@ -936,17 +893,15 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_point_serialize (const H5S_t *space, uint8_t **p, H5F_t *f)
+H5S_point_serialize (const H5S_t *space, uint8_t **p)
{
H5S_pnt_node_t *curr; /* Point information nodes */
- uint8_t *pp = (*p); /* Local pointer for decoding */
+ uint8_t *pp; /* Local pointer for encoding */
uint8_t *lenp; /* pointer to length location for later storage */
uint32_t len=0; /* number of bytes used */
unsigned u; /* local counting variable */
uint32_t version; /* Version number */
- uint8_t point_size; /* Size of point info */
- hsize_t bounds_start[H5S_MAX_RANK];
- hsize_t bounds_end[H5S_MAX_RANK];
+ uint8_t enc_size; /* Size of point info */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -954,22 +909,14 @@ H5S_point_serialize (const H5S_t *space, uint8_t **p, H5F_t *f)
/* Check args */
HDassert(space);
HDassert(p);
+ pp = (*p);
HDassert(pp);
- /* Get bounding box for the selection */
- HDmemset(bounds_end, 0, sizeof(bounds_end));
- if(H5S_point_bounds(space, bounds_start, bounds_end) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't get selection bounds")
-
/* Determine the version */
- if(H5S_point_set_version(space, bounds_end, f, &version) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version")
-
- /* Determine the size of point info */
- if(H5S_point_set_info_size(space, bounds_end, version, &point_size) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine hyper version")
+ if(H5S_point_get_version_enc_size(space, &version, &enc_size) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTGET, FAIL, "can't determine version and enc_size")
- HDassert(point_size == H5S_INFO_SIZE_4);
+ HDassert(enc_size == H5S_SELECT_INFO_ENC_SIZE_4);
HDassert(version == H5S_POINT_VERSION_1);
/* Store the preamble information */
@@ -1019,10 +966,8 @@ done:
Deserialize the current selection from a user-provided buffer.
USAGE
herr_t H5S_point_deserialize(space, p)
- H5S_t *space; IN/OUT: Dataspace pointer to place
+ H5S_t **space; IN/OUT: Dataspace pointer to place
selection into
- uint32_t version IN: Selection version
- uint8_t flags IN: Selection flags
uint8 **p; OUT: Pointer to buffer holding serialized
selection. Will be advanced to end of
serialized selection.
@@ -1037,13 +982,15 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
static herr_t
-H5S_point_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_ATTR_UNUSED flags,
- const uint8_t **p)
+H5S_point_deserialize(H5S_t **space, const uint8_t **p)
{
- H5S_seloper_t op = H5S_SELECT_SET; /* Selection operation */
+ H5S_t *tmp_space = NULL; /* Pointer to actual dataspace to use,
+ either *space or a newly allocated one */
+ hsize_t dims[H5S_MAX_RANK]; /* Dimension sizes */
+ uint32_t version; /* Version number */
hsize_t *coord = NULL, *tcoord; /* Pointer to array of elements */
- const uint8_t *pp = (*p); /* Local pointer for decoding */
- hsize_t num_elem = 0; /* Number of elements in selection */
+ const uint8_t *pp; /* Local pointer for decoding */
+ size_t num_elem = 0; /* Number of elements in selection */
unsigned rank; /* Rank of points */
unsigned i, j; /* local counting variables */
herr_t ret_value = SUCCEED; /* Return value */
@@ -1051,13 +998,43 @@ H5S_point_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_
FUNC_ENTER_NOAPI_NOINIT
/* Check args */
- HDassert(space);
HDassert(p);
+ pp = (*p);
HDassert(pp);
+ /* As part of the efforts to push all selection-type specific coding
+ to the callbacks, the coding for the allocation of a null dataspace
+ is moved from H5S_select_deserialize() in H5Sselect.c to here.
+ This is needed for decoding virtual layout in H5O__layout_decode() */
+ /* Allocate space if not provided */
+ if(!*space) {
+ if(NULL == (tmp_space = H5S_create(H5S_SIMPLE)))
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace")
+ } /* end if */
+ else
+ tmp_space = *space;
+
+ /* Decode version */
+ UINT32DECODE(pp, version);
+
+ /* Skip over the remainder of the header */
+ pp += 8;
+
+ /* Decode the rank of the point selection */
+ UINT32DECODE(pp,rank);
+
+ if(!*space) {
+ /* Patch the rank of the allocated dataspace */
+ (void)HDmemset(dims, 0, (size_t)rank * sizeof(dims[0]));
+ if(H5S_set_extent_simple(tmp_space, rank, dims, NULL) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "can't set dimensions")
+ } /* end if */
+ else
+ /* Verify the rank of the provided dataspace */
+ if(rank != tmp_space->extent.rank)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "rank of serialized selection does not match dataspace")
+
/* Deserialize points to select */
- /* (The header and rank have already beed decoded) */
- rank = space->extent.rank; /* Retrieve rank from space */
UINT32DECODE(pp, num_elem); /* decode the number of points */
/* Allocate space for the coordinates */
@@ -1070,13 +1047,22 @@ H5S_point_deserialize(H5S_t *space, uint32_t H5_ATTR_UNUSED version, uint8_t H5_
UINT32DECODE(pp, *tcoord);
/* Select points */
- if(H5S_select_elements(space, op, num_elem, (const hsize_t *)coord) < 0)
+ if(H5S_select_elements(tmp_space, H5S_SELECT_SET, num_elem, (const hsize_t *)coord) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection")
/* Update decoding pointer */
*p = pp;
+ /* Return space to the caller if allocated */
+ if(!*space)
+ *space = tmp_space;
+
done:
+ /* Free temporary space if not passed to caller (only happens on error) */
+ if(!*space && tmp_space)
+ if(H5S_close(tmp_space) < 0)
+ HDONE_ERROR(H5E_DATASPACE, H5E_CANTFREE, FAIL, "can't close dataspace")
+
/* Free the coordinate array if necessary */
if(coord != NULL)
H5MM_xfree(coord);