From 85c50a468b54143a9ab54469d0cdbaa41228d2f7 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Tue, 31 May 2005 16:20:41 -0500 Subject: [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 --- src/H5Shyper.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++---------- test/tselect.c | 8 +++++++ 2 files changed, 70 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; uextent.rank; u++) { + /* Check for overlapping hyperslab blocks in new selection. */ if(count[u]>1 && stride[u]