summaryrefslogtreecommitdiffstats
path: root/src/H5Shyper.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@koziol.gov>2019-07-30 20:34:53 (GMT)
committerQuincey Koziol <koziol@koziol.gov>2019-07-30 20:34:53 (GMT)
commit605889fde8a92ed902bb4c5207912d1d687f7a99 (patch)
tree40aa43620205049ea3c3473ee32a588bf42539ec /src/H5Shyper.c
parentd3fdcd8a680ad0f8b21304b35e8564b774a88ef0 (diff)
downloadhdf5-605889fde8a92ed902bb4c5207912d1d687f7a99.zip
hdf5-605889fde8a92ed902bb4c5207912d1d687f7a99.tar.gz
hdf5-605889fde8a92ed902bb4c5207912d1d687f7a99.tar.bz2
Add H5Sselect_shape_same and H5Sselect_intersect_block API routines, along
with tests and minor cleanups and refactorings.
Diffstat (limited to 'src/H5Shyper.c')
-rw-r--r--src/H5Shyper.c114
1 files changed, 50 insertions, 64 deletions
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 2acc135..492cd9e 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -28,30 +28,20 @@
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5CXprivate.h" /* API Contexts */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5FLprivate.h" /* Free Lists */
-#include "H5Iprivate.h" /* ID Functions */
-#include "H5MMprivate.h" /* Memory management */
-#include "H5Spkg.h" /* Dataspace functions */
-#include "H5VMprivate.h" /* Vector functions */
+#include "H5private.h" /* Generic Functions */
+#include "H5CXprivate.h" /* API Contexts */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5Iprivate.h" /* ID Functions */
+#include "H5MMprivate.h" /* Memory management */
+#include "H5Spkg.h" /* Dataspace functions */
+#include "H5VMprivate.h" /* Vector functions */
/****************/
/* Local Macros */
/****************/
-/* Macro for checking if two ranges overlap one another */
-/*
- * Check for the inverse of whether the ranges are disjoint. If they are
- * disjoint, then the low bound of one of the ranges must be greater than the
- * high bound of the other.
- */
-/* (Assumes that low & high bounds are _inclusive_) */
-#define H5S_RANGE_OVERLAP(L1, H1, L2, H2) \
- (!((L1) > (H2) || (L2) > (H1)))
-
/* Flags for which hyperslab fragments to compute */
#define H5S_HYPER_COMPUTE_B_NOT_A 0x01
#define H5S_HYPER_COMPUTE_A_AND_B 0x02
@@ -197,6 +187,8 @@ static htri_t H5S__hyper_is_contiguous(const H5S_t *space);
static htri_t H5S__hyper_is_single(const H5S_t *space);
static htri_t H5S__hyper_is_regular(const H5S_t *space);
static htri_t H5S__hyper_shape_same(const H5S_t *space1, const H5S_t *space2);
+static htri_t H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start,
+ const hsize_t *end);
static herr_t H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset);
static herr_t H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset);
static herr_t H5S__hyper_project_simple(const H5S_t *space, H5S_t *new_space, hsize_t *offset);
@@ -242,6 +234,7 @@ const H5S_select_class_t H5S_sel_hyper[1] = {{
H5S__hyper_is_single,
H5S__hyper_is_regular,
H5S__hyper_shape_same,
+ H5S__hyper_intersect_block,
H5S__hyper_adjust_u,
H5S__hyper_project_scalar,
H5S__hyper_project_simple,
@@ -4829,7 +4822,6 @@ static herr_t
H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
{
const hsize_t *low_bounds, *high_bounds; /* Pointers to the correct pair of low & high bounds */
- unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -4849,22 +4841,32 @@ H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
high_bounds = space->select.sel_info.hslab->span_lst->high_bounds;
} /* end else */
- /* Loop over dimensions */
- for(u = 0; u < space->extent.rank; u++) {
- /* Sanity check */
- HDassert(low_bounds[u] <= high_bounds[u]);
+ /* Check for offset set */
+ if(space->select.offset_changed) {
+ unsigned u; /* Local index variable */
- /* Check for offset moving selection negative */
- if(((hssize_t)low_bounds[u] + space->select.offset[u]) < 0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds")
+ /* Loop over dimensions */
+ for(u = 0; u < space->extent.rank; u++) {
+ /* Sanity check */
+ HDassert(low_bounds[u] <= high_bounds[u]);
- /* Set the low & high bounds in this dimension */
- start[u] = (hsize_t)((hssize_t)low_bounds[u] + space->select.offset[u]);
- if((int)u == space->select.sel_info.hslab->unlim_dim)
- end[u] = H5S_UNLIMITED;
- else
- end[u] = (hsize_t)((hssize_t)high_bounds[u] + space->select.offset[u]);
- } /* end for */
+ /* Check for offset moving selection negative */
+ if(((hssize_t)low_bounds[u] + space->select.offset[u]) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "offset moves selection out of bounds")
+
+ /* Set the low & high bounds in this dimension */
+ start[u] = (hsize_t)((hssize_t)low_bounds[u] + space->select.offset[u]);
+ if((int)u == space->select.sel_info.hslab->unlim_dim)
+ end[u] = H5S_UNLIMITED;
+ else
+ end[u] = (hsize_t)((hssize_t)high_bounds[u] + space->select.offset[u]);
+ } /* end for */
+ } /* end if */
+ else {
+ /* Offset vector is still zeros, just copy low & high bounds */
+ H5MM_memcpy(start, low_bounds, sizeof(hsize_t) * space->extent.rank);
+ H5MM_memcpy(end, high_bounds, sizeof(hsize_t) * space->extent.rank);
+ } /* end else */
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -6240,32 +6242,31 @@ done:
/*--------------------------------------------------------------------------
NAME
- H5S_hyper_intersect_block
+ H5S__hyper_intersect_block
PURPOSE
- Detect intersections in span trees
+ Detect intersections of selection with block
USAGE
- htri_t H5S_hyper_intersect_block(space, start, end)
- H5S_t *space; IN: First dataspace to operate on span tree
- hssize_t *start; IN: Starting coordinate for block
- hssize_t *end; IN: Ending coordinate for block
+ htri_t H5S__hyper_intersect_block(space, start, end)
+ const H5S_t *space; IN: Dataspace with selection to use
+ const hsize_t *start; IN: Starting coordinate for block
+ const hsize_t *end; IN: Ending coordinate for block
RETURNS
- Non-negative on success, negative on failure
+ Non-negative TRUE / FALSE on success, negative on failure
DESCRIPTION
- Quickly detect intersections between span tree and block
+ Quickly detect intersections between both regular hyperslabs and span trees
+ with a block
GLOBAL VARIABLES
COMMENTS, BUGS, ASSUMPTIONS
Does not use selection offset.
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-htri_t
-H5S_hyper_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end)
+static htri_t
+H5S__hyper_intersect_block(const H5S_t *space, const hsize_t *start, const hsize_t *end)
{
- const hsize_t *low_bounds, *high_bounds; /* Pointers to the correct pair of low & high bounds */
- unsigned u; /* Local index variable */
htri_t ret_value = FAIL; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_STATIC
/* Sanity check */
HDassert(space);
@@ -6277,27 +6278,12 @@ H5S_hyper_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end
* to be impossible.
*/
if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_NO)
- H5S__hyper_rebuild(space);
-
- /* Check which set of low & high bounds we should be using */
- if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
- low_bounds = space->select.sel_info.hslab->diminfo.low_bounds;
- high_bounds = space->select.sel_info.hslab->diminfo.high_bounds;
- } /* end if */
- else {
- low_bounds = space->select.sel_info.hslab->span_lst->low_bounds;
- high_bounds = space->select.sel_info.hslab->span_lst->high_bounds;
- } /* end else */
-
- /* Loop over selection bounds and block, checking for overlap */
- for(u = 0; u < space->extent.rank; u++)
- /* If selection bounds & block don't overlap, can leave now */
- if(!H5S_RANGE_OVERLAP(low_bounds[u], high_bounds[u], start[u], end[u]))
- HGOTO_DONE(FALSE)
+ H5S__hyper_rebuild((H5S_t *)space); /* Casting away const OK -QAK */
/* Check for regular hyperslab intersection */
if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
hbool_t single_block; /* Whether the regular selection is a single block */
+ unsigned u; /* Local index variable */
/* Check for a single block */
/* For a regular hyperslab to be single, it must have only one block
@@ -6381,7 +6367,7 @@ H5S_hyper_intersect_block(H5S_t *space, const hsize_t *start, const hsize_t *end
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5S_hyper_intersect_block() */
+} /* end H5S__hyper_intersect_block() */
/*--------------------------------------------------------------------------