diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2005-05-31 21:20:41 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2005-05-31 21:20:41 (GMT) |
commit | 85c50a468b54143a9ab54469d0cdbaa41228d2f7 (patch) | |
tree | 9b8ce2e985273ef0e2b518c597adb43228c3d100 /src | |
parent | cb8c548529f40149eb23028356b2ccd103cf86e7 (diff) | |
download | hdf5-85c50a468b54143a9ab54469d0cdbaa41228d2f7.zip hdf5-85c50a468b54143a9ab54469d0cdbaa41228d2f7.tar.gz hdf5-85c50a468b54143a9ab54469d0cdbaa41228d2f7.tar.bz2 |
[svn-r10833] Purpose:
Bug fix
Description:
Fix problems with hyperslab operations with hyperslabs that have count == 0
or block == 0 values. (bugzilla #294)
Solution:
Detect zero sized selections and translate into appropriate action on the
current hyperslab, rather than go through the formality of generating span
trees with zero-sized spans, etc.
Platforms tested:
FreeBSD 4.11 (sleipnir) w/parallel
Too minor to require h5committest
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Shyper.c | 74 |
1 files changed, 62 insertions, 12 deletions
diff --git a/src/H5Shyper.c b/src/H5Shyper.c index b9de94d..0235b7d 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -5384,7 +5384,6 @@ H5S_hyper_rebuild (H5S_t *space) app_diminfo[curr_dim].stride = diminfo[curr_dim].stride = 1; app_diminfo[curr_dim].count = diminfo[curr_dim].count = 1; app_diminfo[curr_dim].block = diminfo[curr_dim].block = (span->high-span->low)+1; - assert(diminfo[curr_dim].block>0); /* Walk down the span tree */ if(span->down) { @@ -5478,7 +5477,6 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, H5S_hyper_span_info_t *a_not_b=NULL; /* Span tree for hyperslab spans in old span tree and not in new span tree */ H5S_hyper_span_info_t *a_and_b=NULL; /* Span tree for hyperslab spans in both old and new span trees */ H5S_hyper_span_info_t *b_not_a=NULL; /* Span tree for hyperslab spans in new span tree and not in old span tree */ - htri_t status; /* Status from internal calls */ herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5S_generate_hyperslab); @@ -5508,6 +5506,8 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, new_spans=NULL; } /* end if */ else { + hbool_t updated_spans = FALSE; /* Whether the spans in the selection were modified */ + /* Generate lists of spans which overlap and don't overlap */ if(H5S_hyper_clip_spans(space->select.sel_info.hslab->span_lst,new_spans,&a_not_b,&a_and_b,&b_not_a)<0) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCLIP, FAIL, "can't clip hyperslab information"); @@ -5521,6 +5521,9 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, /* Update the number of elements in current selection */ space->select.num_elem+=H5S_hyper_spans_nelem(b_not_a); + + /* Indicate that the spans were updated */ + updated_spans = TRUE; } /* end if */ break; @@ -5543,6 +5546,9 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, /* Indicate that the a_and_b spans are owned */ a_and_b=NULL; + + /* Indicate that the spans were updated */ + updated_spans = TRUE; } /* end if */ break; @@ -5562,6 +5568,9 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, /* Update the number of elements in current selection */ space->select.num_elem=H5S_hyper_spans_nelem(a_not_b); + + /* Indicate that the spans were updated */ + updated_spans = TRUE; } /* end if */ if(b_not_a!=NULL) { if(H5S_hyper_merge_spans(space,b_not_a,FALSE)<0) @@ -5569,6 +5578,9 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, /* Update the number of elements in current selection */ space->select.num_elem+=H5S_hyper_spans_nelem(b_not_a); + + /* Indicate that the spans were updated */ + updated_spans = TRUE; } /* end if */ break; @@ -5591,6 +5603,9 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, /* Indicate that the a_not_b are owned */ a_not_b=NULL; + + /* Indicate that the spans were updated */ + updated_spans = TRUE; } /* end if */ break; @@ -5613,6 +5628,9 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, /* Indicate that the b_not_a are owned */ b_not_a=NULL; + + /* Indicate that the spans were updated */ + updated_spans = TRUE; } /* end if */ break; @@ -5652,15 +5670,20 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op, space->select.sel_info.hslab->span_lst=spans; } /* end if */ else { - /* Check if the resulting hyperslab span tree can be used to re-build - * "optimized" start/stride/count/block information. - */ - status=H5S_hyper_can_rebuild(space); - if(status<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't check for rebuilding hyperslab info"); - if(status>0) - if(H5S_hyper_rebuild(space)<0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't rebuild hyperslab info"); + /* Check if we updated the spans */ + if(updated_spans) { + htri_t status; /* Status from internal calls */ + + /* Check if the resulting hyperslab span tree can be used to re-build + * "optimized" start/stride/count/block information. + */ + status=H5S_hyper_can_rebuild(space); + if(status<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't check for rebuilding hyperslab info"); + if(status>0) + if(H5S_hyper_rebuild(space)<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOUNT, FAIL, "can't rebuild hyperslab info"); + } /* end if */ } /* end else */ } /* end else */ @@ -5701,6 +5724,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, const hsize_t *opt_stride; /* Optimized stride information */ const hsize_t *opt_count; /* Optimized count information */ const hsize_t *opt_block; /* Optimized block information */ + hbool_t zero_hyperslab = FALSE; /* Indicate if the new hyperslab contains zero elements */ unsigned u; /* Counters */ herr_t ret_value=SUCCEED; /* Return value */ @@ -5721,11 +5745,16 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, block = _ones; /* - * Check for overlapping hyperslab blocks in new selection. + * Check new selection. */ for(u=0; u<space->extent.rank; u++) { + /* Check for overlapping hyperslab blocks in new selection. */ if(count[u]>1 && stride[u]<block[u]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab blocks overlap"); + + /* Detect zero-sized hyperslabs in new selection */ + if(count[u] == 0 || block[u] == 0) + zero_hyperslab = TRUE; } /* end for */ /* Optimize hyperslab parameters to merge contiguous blocks, etc. */ @@ -5763,6 +5792,27 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op, } /* end for */ } /* end else */ + /* Fixup zero-sized hyperslab selections */ + if(zero_hyperslab) { + switch(op) { + case H5S_SELECT_SET: /* Select "set" operation */ + case H5S_SELECT_AND: /* Binary "and" operation for hyperslabs */ + case H5S_SELECT_NOTA: /* Binary "B not A" operation for hyperslabs */ + /* Convert to "none" selection */ + if(H5S_select_none(space)<0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't convert selection"); + HGOTO_DONE(SUCCEED); + + case H5S_SELECT_OR: /* Binary "or" operation for hyperslabs */ + case H5S_SELECT_XOR: /* Binary "xor" operation for hyperslabs */ + case H5S_SELECT_NOTB: /* Binary "A not B" operation for hyperslabs */ + HGOTO_DONE(SUCCEED); /* Selection stays same */ + + default: + HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation"); + } /* end switch */ + } /* end if */ + /* Fixup operation for non-hyperslab selections */ switch(H5S_GET_SELECT_TYPE(space)) { case H5S_SEL_NONE: /* No elements selected in dataspace */ |