summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDana Robinson <derobins@hdfgroup.org>2020-07-10 00:00:29 (GMT)
committerDana Robinson <derobins@hdfgroup.org>2020-07-10 00:00:29 (GMT)
commit07dc34123861eed0f4d04dea29094649dec679bf (patch)
tree8718e0f2b343fdbbd89387c96f04acd84ab50fbf
parentca50f03bcafd50559d254aa76d0969edbd454688 (diff)
downloadhdf5-07dc34123861eed0f4d04dea29094649dec679bf.zip
hdf5-07dc34123861eed0f4d04dea29094649dec679bf.tar.gz
hdf5-07dc34123861eed0f4d04dea29094649dec679bf.tar.bz2
Moved hyperslab code to use the new H5S_diminfo_valid_t enum.
-rw-r--r--src/H5Shyper.c67
-rw-r--r--src/H5Spkg.h11
-rw-r--r--src/H5Stest.c5
3 files changed, 50 insertions, 33 deletions
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index eca0ed3..10fe123 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -328,7 +328,7 @@ H5S__hyper_iter_init(const H5S_t *space, H5S_sel_iter_t *iter)
tdiminfo = space->select.sel_info.hslab->opt_diminfo;
/* Check for the special case of just one H5Sselect_hyperslab call made */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
/* Initialize the information needed for regular hyperslab I/O */
const hsize_t *mem_size; /* Temporary pointer to dataspace extent's dimension sizes */
hsize_t acc; /* Accumulator for "flattened" dimension's sizes */
@@ -1668,7 +1668,7 @@ H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection)
/* Copy the hyperslab information */
dst_hslab->diminfo_valid = src_hslab->diminfo_valid;
- if(src_hslab->diminfo_valid) {
+ if(src_hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
size_t u; /* Local index variable */
for(u=0; u<src->extent.rank; u++) {
@@ -1676,7 +1676,7 @@ H5S__hyper_copy(H5S_t *dst, const H5S_t *src, hbool_t share_selection)
dst_hslab->app_diminfo[u]=src_hslab->app_diminfo[u];
} /* end for */
} /* end if */
- dst->select.sel_info.hslab->span_lst=src->select.sel_info.hslab->span_lst;
+ dst->select.sel_info.hslab->span_lst = src->select.sel_info.hslab->span_lst;
/* Check if there is hyperslab span information to copy */
/* (Regular hyperslab information is copied with the selection structure) */
@@ -1796,7 +1796,7 @@ H5S__hyper_is_valid(const H5S_t *space)
HGOTO_DONE(FALSE)
/* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ if(H5S_DIMINFO_VALID_YES == space->select.sel_info.hslab->diminfo_valid) {
const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab->opt_diminfo; /* local alias for diminfo */
hssize_t end; /* The high bound of a region in a dimension */
unsigned u; /* Counter */
@@ -1904,7 +1904,7 @@ H5S__get_select_hyper_nblocks(const H5S_t *space, hbool_t app_ref)
HDassert(space->select.sel_info.hslab->unlim_dim < 0);
/* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
unsigned u; /* Local index variable */
/* Check each dimension */
@@ -2509,7 +2509,7 @@ H5S__hyper_deserialize(H5S_t **space, const uint8_t **p)
if(!*space) {
/* Patch the rank of the allocated dataspace */
- (void)HDmemset(dims, 0, (size_t)rank * sizeof(dims[0]));
+ 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 */
@@ -2740,7 +2740,7 @@ H5S__get_select_hyper_blocklist(H5S_t *space, hbool_t internal, hsize_t startblo
HDassert(space->select.sel_info.hslab->unlim_dim < 0);
/* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
const H5S_hyper_dim_t *diminfo; /* Alias for dataspace's diminfo information */
hsize_t tmp_count[H5S_MAX_RANK]; /* Temporary hyperslab counts */
hsize_t offset[H5S_MAX_RANK]; /* Offset of element in dataspace */
@@ -3042,7 +3042,7 @@ H5S__hyper_bounds(const H5S_t *space, hsize_t *start, hsize_t *end)
} /* end for */
/* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
const H5S_hyper_dim_t *diminfo = space->select.sel_info.hslab->opt_diminfo; /* local alias for diminfo */
/* Check each dimension */
@@ -3115,7 +3115,7 @@ H5S__hyper_offset(const H5S_t *space, hsize_t *offset)
dim_size = space->extent.size;
/* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
const H5S_hyper_dim_t *diminfo = space->select.sel_info.hslab->opt_diminfo; /* Local alias for diminfo */
/* Loop through starting coordinates, calculating the linear offset */
@@ -3279,7 +3279,7 @@ H5S__hyper_is_contiguous(const H5S_t *space)
HDassert(space);
/* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
const H5S_hyper_dim_t *diminfo=space->select.sel_info.hslab->opt_diminfo; /* local alias for diminfo */
/*
@@ -3461,7 +3461,7 @@ H5S__hyper_is_single(const H5S_t *space)
HDassert(space);
/* Check for a "single" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
unsigned u; /* index variable */
/*
@@ -3534,7 +3534,7 @@ H5S__hyper_is_regular(const H5S_t *space)
HDassert(space);
/* Only simple check for regular hyperslabs for now... */
- if(space->select.sel_info.hslab->diminfo_valid)
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES)
ret_value = TRUE;
else
ret_value = FALSE;
@@ -3947,7 +3947,7 @@ H5S_hyper_add_span_element(H5S_t *space, unsigned rank, const hsize_t *coords)
space->select.type = H5S_sel_hyper;
/* Reset "regular" hyperslab flag */
- space->select.sel_info.hslab->diminfo_valid = FALSE;
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
/* Set unlim_dim */
space->select.sel_info.hslab->unlim_dim = -1;
@@ -4295,7 +4295,7 @@ H5S__hyper_adjust_u(H5S_t *space, const hsize_t *offset)
/* Only perform operation if the offset is non-zero */
if(non_zero_offset) {
/* Subtract the offset from the "regular" coordinates, if they exist */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
for(u = 0; u < space->extent.rank; u++) {
HDassert(space->select.sel_info.hslab->opt_diminfo[u].start >= offset[u]);
space->select.sel_info.hslab->opt_diminfo[u].start -= offset[u];
@@ -4340,7 +4340,7 @@ H5S__hyper_project_scalar(const H5S_t *space, hsize_t *offset)
HDassert(offset);
/* Check for a "regular" hyperslab selection */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
const H5S_hyper_dim_t *diminfo = space->select.sel_info.hslab->opt_diminfo; /* Alias for dataspace's diminfo information */
unsigned u; /* Counter */
@@ -4550,7 +4550,7 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of
new_space->select.sel_info.hslab->unlim_dim = -1;
/* Check for a "regular" hyperslab selection */
- if(base_space->select.sel_info.hslab->diminfo_valid) {
+ if(base_space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
unsigned base_space_dim; /* Current dimension in the base dataspace */
unsigned new_space_dim; /* Current dimension in the new dataspace */
@@ -4619,7 +4619,7 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of
} /* end for */
/* Indicate that the dimension information is valid */
- new_space->select.sel_info.hslab->diminfo_valid = TRUE;
+ new_space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_YES;
/* Indicate that there's no slab information */
new_space->select.sel_info.hslab->span_lst = NULL;
@@ -4665,7 +4665,7 @@ H5S__hyper_project_simple(const H5S_t *base_space, H5S_t *new_space, hsize_t *of
} /* end else */
/* Indicate that the dimension information is not valid */
- new_space->select.sel_info.hslab->diminfo_valid = FALSE;
+ new_space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
} /* end else */
/* Number of elements selected will be the same */
@@ -4778,7 +4778,7 @@ H5S_hyper_adjust_s(H5S_t *space, const hssize_t *offset)
/* Only perform operation if the offset is non-zero */
if(non_zero_offset) {
/* Subtract the offset from the "regular" coordinates, if they exist */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ if(space->select.sel_info.hslab->diminfo_valid == H5S_DIMINFO_VALID_YES) {
for(u = 0; u < space->extent.rank; u++) {
HDassert((hssize_t)space->select.sel_info.hslab->opt_diminfo[u].start >= offset[u]);
space->select.sel_info.hslab->opt_diminfo[u].start = (hsize_t)((hssize_t)space->select.sel_info.hslab->opt_diminfo[u].start - offset[u]);
@@ -6254,7 +6254,7 @@ H5S__hyper_rebuild(H5S_t *space)
} /* end for */
- space->select.sel_info.hslab->diminfo_valid = TRUE;
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_YES;
} /* end else */
done:
@@ -6826,7 +6826,7 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[],
space->select.sel_info.hslab->unlim_dim = unlim_dim;
/* Indicate that the dimension information is valid */
- space->select.sel_info.hslab->diminfo_valid = TRUE;
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_YES;
/* Indicate that there's no slab information */
space->select.sel_info.hslab->span_lst = NULL;
@@ -6890,7 +6890,7 @@ H5S_select_hyperslab(H5S_t *space, H5S_seloper_t op, const hsize_t start[],
HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree")
/* Indicate that the regular dimensions are no longer valid */
- space->select.sel_info.hslab->diminfo_valid = FALSE;
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
/* Set selection type */
/* (Could be overridden by resetting selection to 'none', below) */
@@ -7514,7 +7514,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
space->select.sel_info.hslab->unlim_dim = unlim_dim;
/* Indicate that the dimension information is valid */
- space->select.sel_info.hslab->diminfo_valid = TRUE;
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_YES;
/* Indicate that there's no slab information */
space->select.sel_info.hslab->span_lst = NULL;
@@ -7574,7 +7574,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
HGOTO_ERROR(H5E_DATASPACE, H5E_UNINITIALIZED, FAIL, "dataspace does not have span tree")
/* Indicate that the regular dimensions are no longer valid */
- space->select.sel_info.hslab->diminfo_valid = FALSE;
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
/* Add in the new hyperslab information */
if(H5S__generate_hyperslab (space, op, start, opt_stride, opt_count, opt_block)<0)
@@ -7767,8 +7767,9 @@ H5S__combine_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, NULL, "can't release selection")
/* Allocate space for the hyperslab selection information */
- if((new_space->select.sel_info.hslab=H5FL_CALLOC(H5S_hyper_sel_t))==NULL)
+ if((new_space->select.sel_info.hslab = H5FL_CALLOC(H5S_hyper_sel_t)) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate hyperslab info")
+ new_space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
/* Set unlim_dim */
new_space->select.sel_info.hslab->unlim_dim = -1;
@@ -7897,8 +7898,9 @@ H5S__modify_select(H5S_t *space1, H5S_seloper_t op, H5S_t *space2)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't release selection")
/* Allocate space for the hyperslab selection information */
- if((space1->select.sel_info.hslab=H5FL_CALLOC(H5S_hyper_sel_t))==NULL)
+ if((space1->select.sel_info.hslab = H5FL_CALLOC(H5S_hyper_sel_t)) == NULL)
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate hyperslab info")
+ space1->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
/* Set unlim_dim */
space1->select.sel_info.hslab->unlim_dim = -1;
@@ -9185,7 +9187,7 @@ H5S__hyper_get_seq_list(const H5S_t *space, unsigned H5_ATTR_UNUSED flags, H5S_s
HDassert(space->select.sel_info.hslab->unlim_dim < 0);
/* Check for the special case of just one H5Sselect_hyperslab call made */
- if(space->select.sel_info.hslab->diminfo_valid) {
+ if(H5S_DIMINFO_VALID_YES == space->select.sel_info.hslab->diminfo_valid) {
const H5S_hyper_dim_t *tdiminfo; /* Temporary pointer to diminfo information */
const hssize_t *sel_off; /* Selection offset in dataspace */
hsize_t *mem_size; /* Size of the source buffer */
@@ -9434,9 +9436,11 @@ H5S__hyper_project_intersection(const H5S_t *src_space, const H5S_t *dst_space,
goto loop_end;
/* Allocate space for the hyperslab selection information (note this sets
- * diminfo_valid to FALSE, diminfo arrays to 0, and span list to NULL) */
+ * diminfo arrays to 0, and span list to NULL)
+ */
if((proj_space->select.sel_info.hslab = H5FL_CALLOC(H5S_hyper_sel_t)) == NULL)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTALLOC, FAIL, "can't allocate hyperslab info")
+ proj_space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
/* Set selection type */
proj_space->select.type = H5S_sel_hyper;
@@ -9789,6 +9793,7 @@ H5S__hyper_subtract(H5S_t *space, H5S_t *subtract_space)
/* Allocate space for the hyperslab selection information */
if((space->select.sel_info.hslab = H5FL_CALLOC(H5S_hyper_sel_t)) == NULL)
HGOTO_ERROR(H5E_DATASPACE, H5E_NOSPACE, FAIL, "can't allocate hyperslab info")
+ space->select.sel_info.hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
/* Set unlim_dim */
space->select.sel_info.hslab->unlim_dim = -1;
@@ -9965,7 +9970,7 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size)
space->select.num_elem = diminfo->block * hslab->num_elem_non_unlim;
/* Mark that opt_diminfo is valid */
- hslab->diminfo_valid = TRUE;
+ hslab->diminfo_valid = H5S_DIMINFO_VALID_YES;
} /* end if */
else {
/* Calculate number of elements */
@@ -9998,7 +10003,7 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to generate span tree")
/* Indicate that the regular dimensions are no longer valid */
- hslab->diminfo_valid = FALSE;
+ hslab->diminfo_valid = H5S_DIMINFO_VALID_NO;
/* "And" selection with calculated block to perform clip operation */
if(H5S__generate_hyperslab(space, H5S_SELECT_AND, start, H5S_hyper_ones_g, H5S_hyper_ones_g, block) < 0)
@@ -10006,7 +10011,7 @@ H5S_hyper_clip_unlim(H5S_t *space, hsize_t clip_size)
} /* end if */
else
/* Last block is complete, simply mark that opt_diminfo is valid */
- hslab->diminfo_valid = TRUE;
+ hslab->diminfo_valid = H5S_DIMINFO_VALID_YES;
} /* end else */
done:
diff --git a/src/H5Spkg.h b/src/H5Spkg.h
index 2961ef1..9013adf 100644
--- a/src/H5Spkg.h
+++ b/src/H5Spkg.h
@@ -141,9 +141,18 @@ struct H5S_hyper_span_info_t {
struct H5S_hyper_span_t *head; /* Pointer to list of spans in next dimension down */
};
+/* Enum for diminfo_valid field in H5S_hyper_sel_t */
+typedef enum {
+ /* DER: Revert to develop order once the hyperslab optimizations are complete */
+ H5S_DIMINFO_VALID_NO, /* 1: diminfo is not valid but may or may not be possible to constuct */
+ H5S_DIMINFO_VALID_IMPOSSIBLE, /* 0: diminfo is not valid and can never be valid with the current selection */
+ H5S_DIMINFO_VALID_YES /* 2: diminfo is valid */
+} H5S_diminfo_valid_t;
+
/* Information about hyperslab selection */
typedef struct {
- hbool_t diminfo_valid; /* Whether the dataset has valid diminfo */
+ H5S_diminfo_valid_t diminfo_valid; /* Whether the dataset has valid diminfo */
+
H5S_hyper_dim_t opt_diminfo[H5S_MAX_RANK]; /* per-dim selection info */
H5S_hyper_dim_t app_diminfo[H5S_MAX_RANK]; /* per-dim selection info */
/* 'opt_diminfo' points to a [potentially] optimized version of the user's
diff --git a/src/H5Stest.c b/src/H5Stest.c
index 60c5679..4c7709b 100644
--- a/src/H5Stest.c
+++ b/src/H5Stest.c
@@ -94,7 +94,10 @@ H5S__get_rebuild_status_test(hid_t space_id)
if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
- ret_value = (htri_t)space->select.sel_info.hslab->diminfo_valid;
+ if(H5S_DIMINFO_VALID_YES == space->select.sel_info.hslab->diminfo_valid)
+ ret_value = TRUE;
+ else
+ ret_value = FALSE;
done:
FUNC_LEAVE_NOAPI(ret_value)