summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2009-07-21 19:28:34 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2009-07-21 19:28:34 (GMT)
commitf383c2a622990b3164c45ac09dc9e8f2f64fe7dd (patch)
tree97852c46af801e5f0f3d97b119bbb4791413b67e
parente117aee161db792d2dd9ee9f235f95803feb9178 (diff)
downloadhdf5-f383c2a622990b3164c45ac09dc9e8f2f64fe7dd.zip
hdf5-f383c2a622990b3164c45ac09dc9e8f2f64fe7dd.tar.gz
hdf5-f383c2a622990b3164c45ac09dc9e8f2f64fe7dd.tar.bz2
[svn-r17209] Description:
Intermediate checkin for getting extensible array code working with 2+ dimension datasets that have only 1 unlimited dimension. This code is working with n-dimension cases, but only when the slowest changing dimension is unlimited. Generalization to n-dimension with any [single] dimension being unlimited is forthcoming. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (smirom) w/Intel compilers w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode Mac OS X/32 10.5.7 (amazon) in debug mode Mac OS X/32 10.5.7 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
-rw-r--r--src/H5Dearray.c27
-rw-r--r--src/H5Olayout.c5
-rw-r--r--src/H5V.c69
-rw-r--r--src/H5Vprivate.h2
-rw-r--r--test/dsets.c365
5 files changed, 284 insertions, 184 deletions
diff --git a/src/H5Dearray.c b/src/H5Dearray.c
index a03f624..9379a87 100644
--- a/src/H5Dearray.c
+++ b/src/H5Dearray.c
@@ -931,7 +931,6 @@ H5D_earray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata)
HDassert(idx_info->f);
HDassert(idx_info->pline);
HDassert(idx_info->layout);
- HDassert(idx_info->layout->u.chunk.ndims == 2); /* (for now) */
HDassert(H5F_addr_defined(idx_info->layout->u.chunk.u.earray.addr));
HDassert(udata);
@@ -945,8 +944,9 @@ H5D_earray_idx_insert(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udata)
/* Set convenience pointer to extensible array structure */
ea = idx_info->layout->u.chunk.u.earray.ea;
- /* Compute array index for chunk offset */
- idx = udata->common.offset[0] / idx_info->layout->u.chunk.dim[0];
+ /* Calculate the index of this chunk */
+ if(H5V_chunk_index((idx_info->layout->u.chunk.ndims - 1), udata->common.offset, idx_info->layout->u.chunk.dim, idx_info->layout->u.chunk.down_chunks, &idx) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index")
/* Check for filters on chunks */
if(idx_info->pline->nused > 0) {
@@ -1076,7 +1076,6 @@ H5D_earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udat
HDassert(idx_info->f);
HDassert(idx_info->pline);
HDassert(idx_info->layout);
- HDassert(idx_info->layout->u.chunk.ndims == 2); /* (for now) */
HDassert(H5F_addr_defined(idx_info->layout->u.chunk.u.earray.addr));
HDassert(udata);
@@ -1090,8 +1089,9 @@ H5D_earray_idx_get_addr(const H5D_chk_idx_info_t *idx_info, H5D_chunk_ud_t *udat
/* Set convenience pointer to extensible array structure */
ea = idx_info->layout->u.chunk.u.earray.ea;
- /* Compute array index for chunk offset */
- idx = udata->common.offset[0] / idx_info->layout->u.chunk.dim[0];
+ /* Calculate the index of this chunk */
+ if(H5V_chunk_index((idx_info->layout->u.chunk.ndims - 1), udata->common.offset, idx_info->layout->u.chunk.dim, idx_info->layout->u.chunk.down_chunks, &idx) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index")
/* Check for filters on chunks */
if(idx_info->pline->nused > 0) {
@@ -1273,8 +1273,9 @@ H5D_earray_idx_remove(const H5D_chk_idx_info_t *idx_info, H5D_chunk_common_ud_t
/* Set convenience pointer to extensible array structure */
ea = idx_info->layout->u.chunk.u.earray.ea;
- /* Compute array index for chunk offset */
- idx = udata->offset[0] / idx_info->layout->u.chunk.dim[0];
+ /* Calculate the index of this chunk */
+ if(H5V_chunk_index((idx_info->layout->u.chunk.ndims - 1), udata->offset, idx_info->layout->u.chunk.dim, idx_info->layout->u.chunk.down_chunks, &idx) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index")
/* Check for filters on chunks */
if(idx_info->pline->nused > 0) {
@@ -1636,8 +1637,9 @@ H5D_earray_idx_support(const H5D_chk_idx_info_t *idx_info,
/* Set convenience pointer to extensible array structure */
ea = idx_info->layout->u.chunk.u.earray.ea;
- /* Compute array index for chunk offset */
- idx = udata->offset[0] / idx_info->layout->u.chunk.dim[0];
+ /* Calculate the index of this chunk */
+ if(H5V_chunk_index((idx_info->layout->u.chunk.ndims - 1), udata->offset, idx_info->layout->u.chunk.dim, idx_info->layout->u.chunk.down_chunks, &idx) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index")
/* Create flush dependency between the child_entry and the piece of metadata
* in the extensible array that contains the entry for this chunk.
@@ -1688,8 +1690,9 @@ H5D_earray_idx_unsupport(const H5D_chk_idx_info_t *idx_info,
/* Set convenience pointer to extensible array structure */
ea = idx_info->layout->u.chunk.u.earray.ea;
- /* Compute array index for chunk offset */
- idx = udata->offset[0] / idx_info->layout->u.chunk.dim[0];
+ /* Calculate the index of this chunk */
+ if(H5V_chunk_index((idx_info->layout->u.chunk.ndims - 1), udata->offset, idx_info->layout->u.chunk.dim, idx_info->layout->u.chunk.down_chunks, &idx) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "can't get chunk index")
/* Remove flush dependency between the child_entry and the piece of metadata
* in the extensible array that contains the entry for this chunk.
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 83b8469..9807488 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -1048,8 +1048,9 @@ H5O_layout_set_latest_version(H5O_layout_t *layout, const H5S_t *space)
/* If we have only 1 unlimited dimension, we can use extensible array index */
if(1 == unlim_count) {
- /* Check for rank == 1 (>1 unsupported currently) */
- if(1 == ndims) {
+ /* Check for slowest changing dimension being unlimited */
+ /* (non-slowest-changing dim. not supported yet) */
+ if(max_dims[0] == H5S_UNLIMITED) {
/* Set the chunk index type */
layout->u.chunk.idx_type = H5D_CHUNK_IDX_EARRAY;
} /* end if */
diff --git a/src/H5V.c b/src/H5V.c
index 34cf714..48fa9ab 100644
--- a/src/H5V.c
+++ b/src/H5V.c
@@ -1132,6 +1132,47 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5V_array_calc_pre
+ *
+ * Purpose: Given a linear offset in an array, the dimensions of that
+ * array and the pre-computed 'down' (accumulator) sizes, this
+ * function computes the coordinates of that offset in the array.
+ *
+ * The dimensionality of the whole array, and the coordinates is N.
+ * The array dimensions are TOTAL_SIZE and the coordinates
+ * are returned in COORD. The linear offset is in OFFSET.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * Thursday, July 16, 2009
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5V_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *total_size,
+ const hsize_t *down, hsize_t *coords)
+{
+ unsigned u; /* Local index variable */
+
+ FUNC_ENTER_NOAPI_NOFUNC(H5V_array_calc_pre)
+
+ /* Sanity check */
+ HDassert(n <= H5V_HYPER_NDIMS);
+ HDassert(total_size);
+ HDassert(coords);
+
+ /* Compute the coordinates from the offset */
+ for(u = 0; u < n; u++) {
+ coords[u] = offset / down[u];
+ offset %= down[u];
+ } /* end for */
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5V_array_calc_pre() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5V_array_calc
*
* Purpose: Given a linear offset in an array and the dimensions of that
@@ -1155,31 +1196,25 @@ herr_t
H5V_array_calc(hsize_t offset, unsigned n, const hsize_t *total_size, hsize_t *coords)
{
hsize_t idx[H5V_HYPER_NDIMS]; /* Size of each dimension in bytes */
- hsize_t acc; /* Size accumulator */
- unsigned u; /* Local index variable */
- int i; /* Local index variable */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOFUNC(H5V_array_calc)
+ FUNC_ENTER_NOAPI(H5V_array_calc, FAIL)
/* Sanity check */
- assert(n <= H5V_HYPER_NDIMS);
- assert(total_size);
- assert(coords);
+ HDassert(n <= H5V_HYPER_NDIMS);
+ HDassert(total_size);
+ HDassert(coords);
/* Build the sizes of each dimension in the array */
- /* (From fastest to slowest) */
- for(i=(int)(n-1),acc=1; i>=0; i--) {
- idx[i]=acc;
- acc *= total_size[i];
- } /* end for */
+ if(H5V_array_down(n, total_size, idx) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute down sizes")
/* Compute the coordinates from the offset */
- for(u=0; u<n; u++) {
- coords[u]=offset/idx[u];
- offset %= idx[u];
- } /* end for */
+ if(H5V_array_calc_pre(offset, n, total_size, idx, coords) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_BADVALUE, FAIL, "can't compute coordinates")
- FUNC_LEAVE_NOAPI(SUCCEED)
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* end H5V_array_calc() */
diff --git a/src/H5Vprivate.h b/src/H5Vprivate.h
index 1dec0c0..e351f86 100644
--- a/src/H5Vprivate.h
+++ b/src/H5Vprivate.h
@@ -83,6 +83,8 @@ H5_DLL hsize_t H5V_array_offset_pre(unsigned n,
const hsize_t *acc, const hsize_t *offset);
H5_DLL hsize_t H5V_array_offset(unsigned n, const hsize_t *total_size,
const hsize_t *offset);
+H5_DLL herr_t H5V_array_calc_pre(hsize_t offset, unsigned n, const hsize_t *total_size,
+ const hsize_t *down, hsize_t *coords);
H5_DLL herr_t H5V_array_calc(hsize_t offset, unsigned n,
const hsize_t *total_size, hsize_t *coords);
H5_DLL herr_t H5V_chunk_index(unsigned ndims, const hsize_t *coord,
diff --git a/test/dsets.c b/test/dsets.c
index 185af72..454d4a2 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -24,6 +24,7 @@
#include <time.h>
#include "h5test.h"
+#include "H5Vprivate.h"
#ifdef H5_HAVE_SZLIB_H
# include "szlib.h"
#endif
@@ -193,6 +194,13 @@ const char *FILENAME[] = {
#define BYPASS_DIM 1000
#define BYPASS_CHUNK_DIM 500
#define BYPASS_FILL_VALUE 7
+
+/* Parameters for testing extensible array chunk indices */
+#define EARRAY_MAX_RANK 3
+#define EARRAY_DSET_DIM 30
+#define EARRAY_CHUNK_DIM 3
+#define EARRAY_EXTEND_INCR 30
+#define EARRAY_MAX_EXTEND 150
/* Shared global arrays */
#define DSET_DIM1 100
@@ -6936,22 +6944,8 @@ test_chunk_fast(hid_t fapl)
hid_t sid = -1; /* Dataspace ID */
hid_t scalar_sid = -1;/* Scalar dataspace ID */
hid_t dsid = -1; /* Dataset ID */
- hsize_t dim, max_dim, chunk_dim; /* Dataset and chunk dimensions */
- H5D_chunk_index_t idx_type; /* Dataset chunk index type */
- H5F_libver_t low, high; /* File format bounds */
- hsize_t hs_offset; /* Hyperslab offset */
- hsize_t hs_size; /* Hyperslab size */
- H5D_alloc_time_t alloc_time; /* Storage allocation time */
+ H5F_libver_t low; /* File format low bound */
hbool_t swmr; /* Whether file should be written with SWMR access enabled */
-#ifdef H5_HAVE_FILTER_DEFLATE
- hbool_t compress; /* Whether chunks should be compressed */
-#endif /* H5_HAVE_FILTER_DEFLATE */
- unsigned write_elem, read_elem; /* Element written/read */
- int mdc_nelmts; /* # of elements in metadata cache */
- size_t rdcc_nelmts; /* # of chunks in chunk cache */
- size_t rdcc_nbytes; /* # of bytes in chunk cache */
- double rdcc_w0; /* write-ratio for chunk cache */
- unsigned u; /* Local index variable */
TESTING("datasets w/extensible array as chunk index");
@@ -6961,201 +6955,266 @@ test_chunk_fast(hid_t fapl)
if((my_fapl = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR
/* Turn on the chunk cache again */
- if(H5Pget_cache(my_fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) FAIL_STACK_ERROR
- rdcc_nbytes = 1048576;
- if(H5Pset_cache(my_fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) FAIL_STACK_ERROR
+ {
+ int mdc_nelmts; /* # of elements in metadata cache */
+ size_t rdcc_nelmts; /* # of chunks in chunk cache */
+ size_t rdcc_nbytes; /* # of bytes in chunk cache */
+ double rdcc_w0; /* write-ratio for chunk cache */
+
+ if(H5Pget_cache(my_fapl, &mdc_nelmts, &rdcc_nelmts, &rdcc_nbytes, &rdcc_w0) < 0) FAIL_STACK_ERROR
+ rdcc_nbytes = 1048576;
+ if(H5Pset_cache(my_fapl, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, rdcc_w0) < 0) FAIL_STACK_ERROR
+ } /* end block */
/* Check if we are using the latest version of the format */
- if(H5Pget_libver_bounds(my_fapl, &low, &high) < 0) FAIL_STACK_ERROR
+ if(H5Pget_libver_bounds(my_fapl, &low, NULL) < 0) FAIL_STACK_ERROR
+
+ /* Create scalar dataspace */
+ if((scalar_sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR
/* Loop over using SWMR access to write */
for(swmr = FALSE; swmr <= TRUE; swmr++) {
#ifdef H5_HAVE_FILTER_DEFLATE
+ hbool_t compress; /* Whether chunks should be compressed */
+
/* Loop over compressing chunks */
for(compress = FALSE; compress <= TRUE; compress++) {
#endif /* H5_HAVE_FILTER_DEFLATE */
+ H5D_alloc_time_t alloc_time; /* Storage allocation time */
+
/* Loop over storage allocation time */
for(alloc_time = H5D_ALLOC_TIME_EARLY; alloc_time <= H5D_ALLOC_TIME_INCR; alloc_time++) {
- /* Create file */
- if((fid = H5Fcreate(filename, H5F_ACC_TRUNC | (swmr ? H5F_ACC_SWMR_WRITE : 0), H5P_DEFAULT, my_fapl)) < 0) FAIL_STACK_ERROR
-
- /* Create dataset creation property list */
- if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR
-
- /* Set chunking */
- chunk_dim = 10;
- if(H5Pset_chunk(dcpl, 1, &chunk_dim) < 0) FAIL_STACK_ERROR
+ unsigned ndims; /* Current # of dims to test */
+
+ /* Loop over dataspace ranks to test */
+ for(ndims = 1; ndims < (EARRAY_MAX_RANK + 1); ndims++) {
+ H5D_chunk_index_t idx_type; /* Dataset chunk index type */
+ hsize_t fill; /* Temporary value, for filling arrays */
+ hsize_t chunk_dim[EARRAY_MAX_RANK]; /* Chunk dimensions */
+ hsize_t dim[EARRAY_MAX_RANK], max_dim[EARRAY_MAX_RANK]; /* Dataset dimensions */
+ hsize_t down[EARRAY_MAX_RANK]; /* 'down' sizes, for computing array index */
+ hsize_t hs_offset[EARRAY_MAX_RANK]; /* Hyperslab offset */
+ hsize_t hs_size[EARRAY_MAX_RANK]; /* Hyperslab size */
+ hssize_t snpoints; /* # of points in dataspace extent (signed) */
+ hsize_t npoints; /* # of points in dataspace extent */
+ unsigned write_elem, read_elem; /* Element written/read */
+ hsize_t u; /* Local index variable */
+
+ /* Create file */
+ if((fid = H5Fcreate(filename, H5F_ACC_TRUNC | (swmr ? H5F_ACC_SWMR_WRITE : 0), H5P_DEFAULT, my_fapl)) < 0) FAIL_STACK_ERROR
+
+ /* Create dataset creation property list */
+ if((dcpl = H5Pcreate(H5P_DATASET_CREATE)) < 0) FAIL_STACK_ERROR
+
+ /* Set chunking & chunk dims */
+ fill = EARRAY_CHUNK_DIM;
+ H5V_array_fill(chunk_dim, &fill, sizeof(fill), EARRAY_MAX_RANK);
+ if(H5Pset_chunk(dcpl, (int)ndims, chunk_dim) < 0) FAIL_STACK_ERROR
#ifdef H5_HAVE_FILTER_DEFLATE
- /* Check if we should compress the chunks */
- if(compress)
- if(H5Pset_deflate(dcpl, 9) < 0) FAIL_STACK_ERROR
+ /* Check if we should compress the chunks */
+ if(compress)
+ if(H5Pset_deflate(dcpl, 9) < 0) FAIL_STACK_ERROR
#endif /* H5_HAVE_FILTER_DEFLATE */
- /* Set fill time */
- if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) FAIL_STACK_ERROR
+ /* Set fill time */
+ if(H5Pset_fill_time(dcpl, H5D_FILL_TIME_ALLOC) < 0) FAIL_STACK_ERROR
+
+ /* Set allocation time */
+ if(H5Pset_alloc_time(dcpl, alloc_time) < 0) FAIL_STACK_ERROR
+
+ /* Create n-D dataspace */
+ fill = EARRAY_DSET_DIM;
+ H5V_array_fill(dim, &fill, sizeof(fill), EARRAY_MAX_RANK);
+ fill = EARRAY_DSET_DIM;
+ H5V_array_fill(max_dim, &fill, sizeof(fill), EARRAY_MAX_RANK);
+ max_dim[0] = H5S_UNLIMITED;
+ if((sid = H5Screate_simple((int)ndims, dim, max_dim)) < 0) FAIL_STACK_ERROR
+
+ /* Get the number of points in the dataspace */
+ if((snpoints = H5Sget_simple_extent_npoints(sid)) < 0) FAIL_STACK_ERROR
+ npoints = (hsize_t)snpoints;
+
+ /* Compute the "down" dimension values */
+ if(H5V_array_down(ndims, dim, down) < 0) FAIL_STACK_ERROR
+
+ /* Create chunked dataset */
+ if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
+ FAIL_STACK_ERROR
+
+ /* Get the chunk index type */
+ if(H5D_layout_idx_type_test(dsid, &idx_type) < 0) FAIL_STACK_ERROR
+
+ /* Chunk index tyepe expected depends on whether we are using the latest version of the format */
+ if(low == H5F_LIBVER_LATEST) {
+ /* Verify index type */
+ if(idx_type != H5D_CHUNK_IDX_EARRAY) FAIL_PUTS_ERROR("should be using extensible array as index");
+ } /* end if */
+ else {
+ /* Verify index type */
+ if(idx_type != H5D_CHUNK_IDX_BTREE) FAIL_PUTS_ERROR("should be using v1 B-tree as index");
+ } /* end else */
+
+ /* Fill existing elements */
+ fill = 1;
+ H5V_array_fill(hs_size, &fill, sizeof(fill), EARRAY_MAX_RANK);
+ for(u = 0; u < npoints; u++) {
+ /* Compute the coordinate from the linear offset */
+ if(H5V_array_calc_pre(u, ndims, dim, down, hs_offset) < 0) FAIL_STACK_ERROR
- /* Set allocation time */
- if(H5Pset_alloc_time(dcpl, alloc_time) < 0) FAIL_STACK_ERROR
+ /* Select a single element in the dataset */
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) FAIL_STACK_ERROR
- /* Create scalar dataspace */
- if((scalar_sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR
+ /* Read (unwritten) element from dataset */
+ read_elem = 1;
+ if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR
- /* Create 1-D dataspace */
- dim = 100;
- max_dim = H5S_UNLIMITED;
- if((sid = H5Screate_simple(1, &dim, &max_dim)) < 0) FAIL_STACK_ERROR
+ /* Verify unwritten element is fill value (0) */
+ if(read_elem != 0) FAIL_PUTS_ERROR("invalid unwritten element read");
- /* Create chunked dataset */
- if((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_UINT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0)
- FAIL_STACK_ERROR
+ /* Write element to dataset */
+ write_elem = (unsigned)u;
+ if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) FAIL_STACK_ERROR
- /* Get the chunk index type */
- if(H5D_layout_idx_type_test(dsid, &idx_type) < 0) FAIL_STACK_ERROR
+ /* Read element from dataset */
+ read_elem = write_elem + 1;
+ if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR
- /* Chunk index tyepe expected depends on whether we are using the latest version of the format */
- if(low == H5F_LIBVER_LATEST) {
- /* Verify index type */
- if(idx_type != H5D_CHUNK_IDX_EARRAY) FAIL_PUTS_ERROR("should be using extensible array as index");
- } /* end if */
- else {
- /* Verify index type */
- if(idx_type != H5D_CHUNK_IDX_BTREE) FAIL_PUTS_ERROR("should be using v1 B-tree as index");
- } /* end else */
+ /* Verify written element is read in */
+ if(read_elem != write_elem) FAIL_PUTS_ERROR("invalid written element read");
+ } /* end for */
- /* Fill existing elements */
- hs_size = 1;
- for(u = 0; u < 100; u++) {
- /* Select a single element in the dataset */
- hs_offset = u;
- if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) FAIL_STACK_ERROR
+ /* Incrementally extend dataset and verify write/reads */
+ while(dim[0] < EARRAY_MAX_EXTEND) {
+ hssize_t snew_npoints; /* # of points in dataspace extent (signed) */
+ hsize_t new_npoints; /* # of points in dataspace extent */
- /* Read (unwritten) element from dataset */
- read_elem = 1;
- if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR
+ /* Extend dataset */
+ dim[0] += EARRAY_EXTEND_INCR;
+ if(H5Dset_extent(dsid, dim) < 0) FAIL_STACK_ERROR
- /* Verify unwritten element is fill value (0) */
- if(read_elem != 0) FAIL_PUTS_ERROR("invalid unwritten element read");
+ /* Close old dataspace */
+ if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
- /* Write element to dataset */
- write_elem = u;
- if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) FAIL_STACK_ERROR
+ /* Get dataspace for dataset now */
+ if((sid = H5Dget_space(dsid)) < 0) FAIL_STACK_ERROR
- /* Read element from dataset */
- read_elem = write_elem + 1;
- if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR
+ /* Get the new number of points in the dataspace */
+ if((snew_npoints = H5Sget_simple_extent_npoints(sid)) < 0) FAIL_STACK_ERROR
+ new_npoints = (hsize_t)snew_npoints;
- /* Verify written element is read in */
- if(read_elem != write_elem) FAIL_PUTS_ERROR("invalid written element read");
- } /* end for */
+ /* Fill new elements */
+ for(u = npoints; u < new_npoints; u++) {
+ /* Compute the coordinate from the linear offset */
+ if(H5V_array_calc(u, ndims, dim, hs_offset) < 0) FAIL_STACK_ERROR
- /* Incrementally extend dataset and verify write/reads */
- while(dim < 1000) {
- /* Extend dataset */
- dim += 100;
- if(H5Dset_extent(dsid, &dim) < 0) FAIL_STACK_ERROR
+ /* Select a single element in the dataset */
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) FAIL_STACK_ERROR
- /* Close old dataspace */
- if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
+ /* Read (unwritten) element from dataset */
+ read_elem = 1;
+ if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR
- /* Get dataspace for dataset now */
- if((sid = H5Dget_space(dsid)) < 0) FAIL_STACK_ERROR
+ /* Verify unwritten element is fill value (0) */
+ if(read_elem != 0) FAIL_PUTS_ERROR("invalid unwritten element read");
- /* Fill new elements */
- hs_size = 1;
- for(u = 0; u < 100; u++) {
- /* Select a single element in the dataset */
- hs_offset = (dim + u) - 100;
- if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) FAIL_STACK_ERROR
+ /* Write element to dataset */
+ write_elem = (unsigned)u;
+ if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) FAIL_STACK_ERROR
- /* Read (unwritten) element from dataset */
- read_elem = 1;
- if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR
+ /* Read element from dataset */
+ read_elem = write_elem + 1;
+ if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR
- /* Verify unwritten element is fill value (0) */
- if(read_elem != 0) FAIL_PUTS_ERROR("invalid unwritten element read");
+ /* Verify written element is read in */
+ if(read_elem != write_elem) FAIL_PUTS_ERROR("invalid written element read");
+ } /* end for */
- /* Write element to dataset */
- write_elem = u;
- if(H5Dwrite(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &write_elem) < 0) FAIL_STACK_ERROR
+ /* Update the number of points in the dataspace */
+ npoints = new_npoints;
+ } /* end while */
- /* Read element from dataset */
- read_elem = write_elem + 1;
- if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR
+ /* Close everything */
+ if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR
+ if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
- /* Verify written element is read in */
- if(read_elem != write_elem) FAIL_PUTS_ERROR("invalid written element read");
- } /* end for */
- } /* end while */
- /* Close everything */
- if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR
- if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
- if(H5Sclose(scalar_sid) < 0) FAIL_STACK_ERROR
- if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
- if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+ /* Re-open file & dataset */
+ if((fid = H5Fopen(filename, H5F_ACC_RDONLY | (swmr ? H5F_ACC_SWMR_READ : 0), my_fapl)) < 0) FAIL_STACK_ERROR
- /* Re-open file & dataset */
- if((fid = H5Fopen(filename, H5F_ACC_RDONLY, my_fapl)) < 0) FAIL_STACK_ERROR
+ /* Open dataset */
+ if((dsid = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
- /* Open dataset */
- if((dsid = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR
+ /* Get the chunk index type */
+ if(H5D_layout_idx_type_test(dsid, &idx_type) < 0) FAIL_STACK_ERROR
- /* Get the chunk index type */
- if(H5D_layout_idx_type_test(dsid, &idx_type) < 0) FAIL_STACK_ERROR
+ /* Chunk index tyepe expected depends on whether we are using the latest version of the format */
+ if(low == H5F_LIBVER_LATEST) {
+ /* Verify index type */
+ if(idx_type != H5D_CHUNK_IDX_EARRAY) FAIL_PUTS_ERROR("should be using extensible array as index");
+ } /* end if */
+ else {
+ /* Verify index type */
+ if(idx_type != H5D_CHUNK_IDX_BTREE) FAIL_PUTS_ERROR("should be using v1 B-tree as index");
+ } /* end else */
- /* Chunk index tyepe expected depends on whether we are using the latest version of the format */
- if(low == H5F_LIBVER_LATEST) {
- /* Verify index type */
- if(idx_type != H5D_CHUNK_IDX_EARRAY) FAIL_PUTS_ERROR("should be using extensible array as index");
- } /* end if */
- else {
- /* Verify index type */
- if(idx_type != H5D_CHUNK_IDX_BTREE) FAIL_PUTS_ERROR("should be using v1 B-tree as index");
- } /* end else */
+ /* Get dataspace for dataset now */
+ if((sid = H5Dget_space(dsid)) < 0) FAIL_STACK_ERROR
- /* Create scalar dataspace */
- if((scalar_sid = H5Screate(H5S_SCALAR)) < 0) FAIL_STACK_ERROR
+ /* Get the number of points in the dataspace */
+ if((snpoints = H5Sget_simple_extent_npoints(sid)) < 0) FAIL_STACK_ERROR
+ npoints = (hsize_t)snpoints;
- /* Get dataspace for dataset now */
- if((sid = H5Dget_space(dsid)) < 0) FAIL_STACK_ERROR
+ /* Get the current dimensions */
+ if(H5Sget_simple_extent_dims(sid, dim, NULL) < 0) FAIL_STACK_ERROR
- /* Read elements */
- hs_size = 1;
- for(u = 0; u < 1000; u++) {
- /* Select a single element in the dataset */
- hs_offset = u;
- if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, &hs_offset, NULL, &hs_size, NULL) < 0) FAIL_STACK_ERROR
+ /* Compute the "down" dimension values */
+ if(H5V_array_down(ndims, dim, down) < 0) FAIL_STACK_ERROR
- /* Read (unwritten) element from dataset */
- read_elem = u + 1;
- if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR
+ /* Read elements */
+ for(u = 0; u < npoints; u++) {
+ /* Compute the coordinate from the linear offset */
+ if(H5V_array_calc_pre(u, ndims, dim, down, hs_offset) < 0) FAIL_STACK_ERROR
- /* Verify unwritten element is fill value (0) */
- if(read_elem != (u % 100)) FAIL_PUTS_ERROR("invalid element read");
- } /* end for */
+ /* Select a single element in the dataset */
+ if(H5Sselect_hyperslab(sid, H5S_SELECT_SET, hs_offset, NULL, hs_size, NULL) < 0) FAIL_STACK_ERROR
- /* Close everything */
- if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR
- if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
- if(H5Sclose(scalar_sid) < 0) FAIL_STACK_ERROR
- if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+ /* Read written element from dataset */
+ read_elem = (unsigned)(u + 1);
+ if(H5Dread(dsid, H5T_NATIVE_UINT, scalar_sid, sid, H5P_DEFAULT, &read_elem) < 0) FAIL_STACK_ERROR
- /* Re-open file */
- if((fid = H5Fopen(filename, H5F_ACC_RDWR, my_fapl)) < 0) FAIL_STACK_ERROR
+ /* Verify written element is correct */
+ if(read_elem != u) FAIL_PUTS_ERROR("invalid element read");
+ } /* end for */
- /* Delete dataset */
- if(H5Ldelete(fid, "dset", H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+ /* Close everything */
+ if(H5Dclose(dsid) < 0) FAIL_STACK_ERROR
+ if(H5Sclose(sid) < 0) FAIL_STACK_ERROR
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+
+ /* Re-open file */
+ if((fid = H5Fopen(filename, H5F_ACC_RDWR, my_fapl)) < 0) FAIL_STACK_ERROR
+
+ /* Delete dataset */
+ if(H5Ldelete(fid, "dset", H5P_DEFAULT) < 0) FAIL_STACK_ERROR
+
+ /* Close everything */
+ if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+
+ } /* end for */
/* Close everything */
- if(H5Fclose(fid) < 0) FAIL_STACK_ERROR
+ if(H5Pclose(dcpl) < 0) FAIL_STACK_ERROR
} /* end for */
#ifdef H5_HAVE_FILTER_DEFLATE
} /* end for */
#endif /* H5_HAVE_FILTER_DEFLATE */
} /* end for */
- /* Close FAPL copy */
+ /* Close everything */
+ if(H5Sclose(scalar_sid) < 0) FAIL_STACK_ERROR
if(H5Pclose(my_fapl) < 0) FAIL_STACK_ERROR
PASSED();