summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5Dcontig.c2
-rw-r--r--src/H5Fcontig.c2
-rw-r--r--src/H5Shyper.c107
-rw-r--r--test/ntypes.c2
-rw-r--r--test/trefer.c2
-rw-r--r--test/tselect.c32
-rw-r--r--testpar/t_dset.c4
7 files changed, 105 insertions, 46 deletions
diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c
index 42ed109..d89b4b6 100644
--- a/src/H5Dcontig.c
+++ b/src/H5Dcontig.c
@@ -264,7 +264,7 @@ H5F_contig_fill(H5F_t *f, hid_t dxpl_id, struct H5O_layout_t *layout,
if(using_mpi) {
/* Round-robin write the chunks out from only one process */
if(mpi_round==mpi_rank) {
- if (H5F_contig_write(f, size, addr, size, dxpl_id, buf)<0)
+ if (H5F_contig_write(f, (hsize_t)size, addr, size, dxpl_id, buf)<0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to write fill value to dataset");
} /* end if */
++mpi_round;
diff --git a/src/H5Fcontig.c b/src/H5Fcontig.c
index 42ed109..d89b4b6 100644
--- a/src/H5Fcontig.c
+++ b/src/H5Fcontig.c
@@ -264,7 +264,7 @@ H5F_contig_fill(H5F_t *f, hid_t dxpl_id, struct H5O_layout_t *layout,
if(using_mpi) {
/* Round-robin write the chunks out from only one process */
if(mpi_round==mpi_rank) {
- if (H5F_contig_write(f, size, addr, size, dxpl_id, buf)<0)
+ if (H5F_contig_write(f, (hsize_t)size, addr, size, dxpl_id, buf)<0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to write fill value to dataset");
} /* end if */
++mpi_round;
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 06cb6ae..0bf7791 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -213,8 +213,8 @@ H5S_hyper_iter_init(H5S_sel_iter_t *iter, const H5S_t *space, size_t elmt_size)
else {
if((unsigned)i==(cont_dim-1)) {
iter->u.hyp.diminfo[i].start = tdiminfo[i].start*acc;
- /* Special case for stride==1 regular selections */
- if(tdiminfo[i].stride==1)
+ /* Special case for single block regular selections */
+ if(tdiminfo[i].count==1)
iter->u.hyp.diminfo[i].stride = 1;
else
iter->u.hyp.diminfo[i].stride = tdiminfo[i].stride*acc;
@@ -563,7 +563,7 @@ H5S_hyper_iter_next(H5S_sel_iter_t *iter, size_t nelem)
/* Calculate the offset and block count for each dimension */
for(i=0; i<ndims; i++) {
- if(tdiminfo[i].stride==1) {
+ if(tdiminfo[i].count==1) {
iter_offset[i]=iter->u.hyp.off[i]-tdiminfo[i].start;
iter_count[i]=0;
} /* end if */
@@ -778,7 +778,7 @@ H5S_hyper_iter_next_block(H5S_sel_iter_t *iter)
/* Calculate the offset and block count for each dimension */
for(u=0; u<ndims; u++) {
- if(tdiminfo[u].stride==1) {
+ if(tdiminfo[u].count==1) {
iter_offset[u]=iter->u.hyp.off[u]-tdiminfo[u].start;
iter_count[u]=0;
} /* end if */
@@ -2090,14 +2090,8 @@ H5S_hyper_serialize (const H5S_t *space, uint8_t *buf)
UINT32ENCODE(buf, (uint32_t)offset[i]);
/* Encode hyperslab ending location */
- for(i=0; i<ndims; i++) {
- if(diminfo[i].stride==1) {
- UINT32ENCODE(buf, (uint32_t)(offset[i]+(diminfo[i].count-1)));
- } /* end if */
- else {
- UINT32ENCODE(buf, (uint32_t)(offset[i]+(diminfo[i].block-1)));
- } /* end else */
- } /* end for */
+ for(i=0; i<ndims; i++)
+ UINT32ENCODE(buf, (uint32_t)(offset[i]+(diminfo[i].block-1)));
/* Move the offset to the next sequence to start */
offset[fast_dim]+=diminfo[fast_dim].stride;
@@ -2230,7 +2224,7 @@ H5S_hyper_deserialize (H5S_t *space, const uint8_t *buf)
/* Set the count & stride for all blocks */
for(tcount=count,tstride=stride,j=0; j<rank; j++,tstride++,tcount++) {
*tcount=1;
- *tstride=0;
+ *tstride=1;
} /* end for */
/* Retrieve the coordinates from the buffer */
@@ -2452,12 +2446,8 @@ H5S_get_select_hyper_blocklist(H5S_t *space, hsize_t startblock, hsize_t numbloc
/* Compute the ending location */
HDmemcpy(buf,offset,sizeof(hsize_t)*ndims);
- for(i=0; i<ndims; i++) {
- if(diminfo[i].stride==1)
- buf[i]+=(diminfo[i].count-1);
- else
- buf[i]+=(diminfo[i].block-1);
- } /* end for */
+ for(i=0; i<ndims; i++)
+ buf[i]+=(diminfo[i].block-1);
buf+=ndims;
/* Decrement the number of blocks to retrieve */
@@ -3539,7 +3529,7 @@ H5S_hyper_convert(H5S_t *space)
/* Fill in temporary information for the dimensions */
for(u=0; u<space->extent.u.simple.rank; u++) {
tmp_start[u]=0;
- tmp_stride[u]=0;
+ tmp_stride[u]=1;
tmp_count[u]=1;
tmp_block[u]=space->extent.u.simple.size[u];
} /* end for */
@@ -5223,7 +5213,12 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op,
block[u]=_block[u]*_count[u];
}
else {
- stride[u]=_stride[u];
+ if(_count[u]==1)
+ stride[u]=1;
+ else {
+ assert(_stride[u]>_block[u]);
+ stride[u]=_stride[u];
+ } /* end else */
count[u]=_count[u];
block[u]=_block[u];
} /* end if */
@@ -5451,7 +5446,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
/* Fill in the correct stride values */
if(stride==NULL) {
- hssize_t fill=1;
+ hsize_t fill=1;
/* Allocate temporary buffer */
if ((_stride=H5FL_ARR_MALLOC(hsize_t,space->extent.u.simple.rank))==NULL)
@@ -5462,7 +5457,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
/* Fill in the correct block values */
if(block==NULL) {
- hssize_t fill=1;
+ hsize_t fill=1;
/* Allocate temporary buffer */
if ((_block=H5FL_ARR_MALLOC(hsize_t,space->extent.u.simple.rank))==NULL)
@@ -5596,7 +5591,12 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
diminfo[u].block=count[u]*block[u];
} /* end if */
else {
- diminfo[u].stride=stride[u];
+ if(count[u]==1)
+ diminfo[u].stride=1;
+ else {
+ assert(stride[u]>block[u]);
+ diminfo[u].stride=stride[u];
+ } /* end else */
diminfo[u].count=count[u];
diminfo[u].block=block[u];
} /* end else */
@@ -5685,6 +5685,7 @@ H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[],
const hsize_t stride[], const hsize_t count[], const hsize_t block[])
{
H5S_t *space = NULL; /* Dataspace to modify selection of */
+ unsigned u; /* Local index variable */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(H5Sselect_hyperslab, FAIL);
@@ -5697,9 +5698,22 @@ H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[],
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_SCALAR space");
if(start==NULL || count==NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified");
-
if(!(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID))
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
+ if(stride!=NULL) {
+ /* Check for 0-sized strides */
+ for(u=0; u<space->extent.u.simple.rank; u++) {
+ if(stride[u]==0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid stride==0 value");
+ } /* end for */
+ if(block!=NULL) {
+ /* Check for strides smaller than blocks */
+ for(u=0; u<space->extent.u.simple.rank; u++) {
+ if(count[u]>1 && stride[u]<block[u])
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid stride<block value");
+ } /* end for */
+ } /* end if */
+ } /* end if */
if (H5S_select_hyperslab(space, op, start, stride, count, block)<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection");
@@ -5967,7 +5981,12 @@ H5S_generate_hyperslab (H5S_t *space, H5S_seloper_t op,
block[u]=_block[u]*_count[u];
}
else {
- stride[u]=_stride[u];
+ if(_count[u]==1)
+ stride[u]=1;
+ else {
+ assert(_stride[u]>_block[u]);
+ stride[u]=_stride[u];
+ } /* end else */
count[u]=_count[u];
block[u]=_block[u];
} /* end if */
@@ -6036,7 +6055,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
/* Fill in the correct stride values */
if(stride==NULL) {
- hssize_t fill=1;
+ hsize_t fill=1;
/* Allocate temporary buffer */
if ((_stride=H5FL_ARR_MALLOC(hsize_t,space->extent.u.simple.rank))==NULL)
@@ -6047,7 +6066,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
/* Fill in the correct block values */
if(block==NULL) {
- hssize_t fill=1;
+ hsize_t fill=1;
/* Allocate temporary buffer */
if ((_block=H5FL_ARR_MALLOC(hsize_t,space->extent.u.simple.rank))==NULL)
@@ -6105,7 +6124,7 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
/* Fill in temporary information for the dimensions */
for(u=0; u<space->extent.u.simple.rank; u++) {
tmp_start[u]=0;
- tmp_stride[u]=0;
+ tmp_stride[u]=1;
tmp_count[u]=1;
tmp_block[u]=space->extent.u.simple.size[u];
} /* end for */
@@ -6182,7 +6201,12 @@ H5S_select_hyperslab (H5S_t *space, H5S_seloper_t op,
diminfo[u].block=count[u]*block[u];
} /* end if */
else {
- diminfo[u].stride=stride[u];
+ if(count[u]==1)
+ diminfo[u].stride=1;
+ else {
+ assert(stride[u]>block[u]);
+ diminfo[u].stride=stride[u];
+ } /* end else */
diminfo[u].count=count[u];
diminfo[u].block=block[u];
} /* end else */
@@ -6263,11 +6287,26 @@ H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[],
/* Check args */
if (NULL == (space=H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ if (H5S_SCALAR==H5S_get_simple_extent_type(space))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_SCALAR space");
if(start==NULL || count==NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified");
-
if(!(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID))
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "invalid selection operation");
+ if(stride!=NULL) {
+ /* Check for 0-sized strides */
+ for(u=0; u<space->extent.u.simple.rank; u++) {
+ if(stride[u]==0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid stride==0 value");
+ } /* end for */
+ if(block!=NULL) {
+ /* Check for strides smaller than blocks */
+ for(u=0; u<space->extent.u.simple.rank; u++) {
+ if(count[u]>1 && stride[u]<block[u])
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid stride<block value");
+ } /* end for */
+ } /* end if */
+ } /* end if */
if (H5S_select_hyperslab(space, op, start, stride, count, block)<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL, "unable to set hyperslab selection");
@@ -7118,11 +7157,11 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
/* Check if we stopped in the middle of a sequence of elements */
if((iter->u.hyp.off[fast_dim]-tdiminfo[fast_dim].start)%tdiminfo[fast_dim].stride!=0 ||
- ((iter->u.hyp.off[fast_dim]!=tdiminfo[fast_dim].start) && tdiminfo[fast_dim].stride==1)) {
+ ((iter->u.hyp.off[fast_dim]!=tdiminfo[fast_dim].start) && tdiminfo[fast_dim].count==1)) {
size_t leftover; /* The number of elements left over from the last sequence */
/* Calculate the number of elements left in the sequence */
- if(tdiminfo[fast_dim].stride==1) {
+ if(tdiminfo[fast_dim].count==1) {
H5_ASSIGN_OVERFLOW(leftover, tdiminfo[fast_dim].block-(iter->u.hyp.off[fast_dim]-tdiminfo[fast_dim].start) ,hsize_t,size_t);
} /* end if */
else {
@@ -7172,7 +7211,7 @@ H5S_hyper_get_seq_list_opt(const H5S_t *space,H5S_sel_iter_t *iter,
/* Compute the current "counts" for this location */
for(i=0; i<ndims; i++) {
- if(tdiminfo[i].stride==1) {
+ if(tdiminfo[i].count==1) {
tmp_count[i] = 0;
tmp_block[i] = iter->u.hyp.off[i]-tdiminfo[i].start;
} /* end if */
diff --git a/test/ntypes.c b/test/ntypes.c
index 9ddcefc..53276a2 100644
--- a/test/ntypes.c
+++ b/test/ntypes.c
@@ -1624,7 +1624,7 @@ test_refer_dtype2(hid_t file)
/* Create references */
/* Select 6x6 hyperslab for first reference */
start[0]=2; start[1]=2;
- stride[0]=0; stride[1]=0;
+ stride[0]=1; stride[1]=1;
count[0]=1; count[1]=1;
block[0]=6; block[1]=6;
diff --git a/test/trefer.c b/test/trefer.c
index bb67a61..7a94d62 100644
--- a/test/trefer.c
+++ b/test/trefer.c
@@ -385,7 +385,7 @@ test_reference_region(void)
/* Select 6x6 hyperslab for first reference */
start[0]=2; start[1]=2;
- stride[0]=0; stride[1]=0;
+ stride[0]=1; stride[1]=1;
count[0]=1; count[1]=1;
block[0]=6; block[1]=6;
ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,stride,count,block);
diff --git a/test/tselect.c b/test/tselect.c
index e3b72ec..c08a611 100644
--- a/test/tselect.c
+++ b/test/tselect.c
@@ -205,6 +205,26 @@ test_select_hyper(hid_t xfer_plist)
ext_type = H5Sget_simple_extent_type(sid1);
VERIFY(ext_type, H5S_SIMPLE, "H5Sget_simple_extent_type");
+ /* Test selecting stride==0 to verify failure */
+ start[0]=1; start[1]=0; start[2]=0;
+ stride[0]=0; stride[1]=0; stride[2]=0;
+ count[0]=2; count[1]=15; count[2]=13;
+ block[0]=1; block[1]=1; block[2]=1;
+ H5E_BEGIN_TRY {
+ ret = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,stride,count,block);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Sselect_hyperslab");
+
+ /* Test selecting stride<block to verify failure */
+ start[0]=1; start[1]=0; start[2]=0;
+ stride[0]=1; stride[1]=1; stride[2]=1;
+ count[0]=2; count[1]=15; count[2]=13;
+ block[0]=2; block[1]=2; block[2]=2;
+ H5E_BEGIN_TRY {
+ ret = H5Sselect_hyperslab(sid1,H5S_SELECT_SET,start,stride,count,block);
+ } H5E_END_TRY;
+ VERIFY(ret, FAIL, "H5Sselect_hyperslab");
+
/* Select 2x15x13 hyperslab for disk dataset */
start[0]=1; start[1]=0; start[2]=0;
stride[0]=1; stride[1]=1; stride[2]=1;
@@ -4140,7 +4160,7 @@ test_select_combine(void)
/* 'AND' "all" selection with another hyperslab */
start[0]=start[1]=0;
- stride[0]=stride[1]=0;
+ stride[0]=stride[1]=1;
count[0]=count[1]=1;
block[0]=block[1]=5;
error=H5Sselect_hyperslab(space1,H5S_SELECT_AND,start,stride,count,block);
@@ -4274,7 +4294,7 @@ test_select_combine(void)
/* 'OR' "none" selection with another hyperslab */
start[0]=start[1]=0;
- stride[0]=stride[1]=0;
+ stride[0]=stride[1]=1;
count[0]=count[1]=1;
block[0]=block[1]=5;
error=H5Sselect_hyperslab(space1,H5S_SELECT_OR,start,stride,count,block);
@@ -4309,7 +4329,7 @@ test_select_combine(void)
/* 'AND' "none" selection with another hyperslab */
start[0]=start[1]=0;
- stride[0]=stride[1]=0;
+ stride[0]=stride[1]=1;
count[0]=count[1]=1;
block[0]=block[1]=5;
error=H5Sselect_hyperslab(space1,H5S_SELECT_AND,start,stride,count,block);
@@ -4329,7 +4349,7 @@ test_select_combine(void)
/* 'XOR' "none" selection with another hyperslab */
start[0]=start[1]=0;
- stride[0]=stride[1]=0;
+ stride[0]=stride[1]=1;
count[0]=count[1]=1;
block[0]=block[1]=5;
error=H5Sselect_hyperslab(space1,H5S_SELECT_XOR,start,stride,count,block);
@@ -4364,7 +4384,7 @@ test_select_combine(void)
/* 'NOTB' "none" selection with another hyperslab */
start[0]=start[1]=0;
- stride[0]=stride[1]=0;
+ stride[0]=stride[1]=1;
count[0]=count[1]=1;
block[0]=block[1]=5;
error=H5Sselect_hyperslab(space1,H5S_SELECT_NOTB,start,stride,count,block);
@@ -4384,7 +4404,7 @@ test_select_combine(void)
/* 'NOTA' "none" selection with another hyperslab */
start[0]=start[1]=0;
- stride[0]=stride[1]=0;
+ stride[0]=stride[1]=1;
count[0]=count[1]=1;
block[0]=block[1]=5;
error=H5Sselect_hyperslab(space1,H5S_SELECT_NOTA,start,stride,count,block);
diff --git a/testpar/t_dset.c b/testpar/t_dset.c
index 03fee85..a425793 100644
--- a/testpar/t_dset.c
+++ b/testpar/t_dset.c
@@ -75,7 +75,7 @@ if (verbose) printf("slab_set BYCOL\n");
/* Similar to BYROW except process 0 gets 0 row */
block[0] = (mpi_rank ? dim0/mpi_size : 0);
block[1] = dim1;
- stride[0] = block[0];
+ stride[0] = (mpi_rank ? block[0] : 1); /* avoid setting stride to 0 */
stride[1] = block[1];
count[0] = 1;
count[1] = 1;
@@ -88,7 +88,7 @@ if (verbose) printf("slab_set ZROW\n");
block[0] = dim0;
block[1] = (mpi_rank ? dim1/mpi_size : 0);
stride[0] = block[0];
- stride[1] = block[1];
+ stride[1] = (mpi_rank ? block[1] : 1); /* avoid setting stride to 0 */
count[0] = 1;
count[1] = 1;
start[0] = 0;