summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2016-02-06 17:45:22 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2016-02-06 17:45:22 (GMT)
commit363e419340101c984f1f7b133df81776c4e3ed4f (patch)
tree936e32bc20641546cd6d99212010d9b4bf854af4
parent65ba538f5b65d3768ecc94813948717b01ca6690 (diff)
downloadhdf5-363e419340101c984f1f7b133df81776c4e3ed4f.zip
hdf5-363e419340101c984f1f7b133df81776c4e3ed4f.tar.gz
hdf5-363e419340101c984f1f7b133df81776c4e3ed4f.tar.bz2
[svn-r29054] Description:
Correct error computing the number of bytes to encode dimensions with when using "latest format" by including the datatype's size in the computation. Tested on: Mac OSX/64 10.11.3 (amazon) w/serial & parallel (h5committest not required on this branch)
-rw-r--r--src/H5Dchunk.c17
-rw-r--r--src/H5Pdcpl.c13
2 files changed, 17 insertions, 13 deletions
diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c
index 4a7977b..612b419 100644
--- a/src/H5Dchunk.c
+++ b/src/H5Dchunk.c
@@ -570,11 +570,13 @@ herr_t
H5D__chunk_set_sizes(H5D_t *dset)
{
uint64_t chunk_size; /* Size of chunk in bytes */
+ unsigned max_enc_bytes_per_dim; /* Max. number of bytes required to encode this dimension */
unsigned u; /* Iterator */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
+ /* Sanity checks */
HDassert(dset);
/* Increment # of chunk dimensions, to account for datatype size as last element */
@@ -583,6 +585,21 @@ H5D__chunk_set_sizes(H5D_t *dset)
/* Set the last dimension of the chunk size to the size of the datatype */
dset->shared->layout.u.chunk.dim[dset->shared->layout.u.chunk.ndims - 1] = (uint32_t)H5T_GET_SIZE(dset->shared->type);
+ /* Compute number of bytes to use for encoding chunk dimensions */
+ max_enc_bytes_per_dim = 0;
+ for(u = 0; u < (unsigned)dset->shared->layout.u.chunk.ndims; u++) {
+ unsigned enc_bytes_per_dim; /* Number of bytes required to encode this dimension */
+
+ /* Get encoded size of dim, in bytes */
+ enc_bytes_per_dim = (H5VM_log2_gen(dset->shared->layout.u.chunk.dim[u]) + 8) / 8;
+
+ /* Check if this is the largest value so far */
+ if(enc_bytes_per_dim > max_enc_bytes_per_dim)
+ max_enc_bytes_per_dim = enc_bytes_per_dim;
+ } /* end for */
+ HDassert(max_enc_bytes_per_dim > 0 && max_enc_bytes_per_dim <= 8);
+ dset->shared->layout.u.chunk.enc_bytes_per_dim = max_enc_bytes_per_dim;
+
/* Compute and store the total size of a chunk */
/* (Use 64-bit value to ensure that we can detect >4GB chunks) */
for(u = 1, chunk_size = (uint64_t)dset->shared->layout.u.chunk.dim[0]; u < dset->shared->layout.u.chunk.ndims; u++)
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c
index 44872ba..5836bf0 100644
--- a/src/H5Pdcpl.c
+++ b/src/H5Pdcpl.c
@@ -1998,7 +1998,6 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/])
H5P_genplist_t *plist; /* Property list pointer */
H5O_layout_t chunk_layout; /* Layout information for setting chunk info */
uint64_t chunk_nelmts; /* Number of elements in chunk */
- unsigned max_enc_bytes_per_dim; /* Max. number of bytes required to encode this dimension */
unsigned u; /* Local index variable */
herr_t ret_value = SUCCEED; /* Return value */
@@ -2026,10 +2025,7 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/])
HDmemcpy(&chunk_layout, &H5D_def_layout_chunk_g, sizeof(H5D_def_layout_chunk_g));
HDmemset(&chunk_layout.u.chunk.dim, 0, sizeof(chunk_layout.u.chunk.dim));
chunk_nelmts = 1;
- max_enc_bytes_per_dim = 0;
for(u = 0; u < (unsigned)ndims; u++) {
- unsigned enc_bytes_per_dim; /* Number of bytes required to encode this dimension */
-
if(dim[u] == 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "all chunk dimensions must be positive")
if(dim[u] != (dim[u] & 0xffffffff))
@@ -2038,16 +2034,7 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/])
if(chunk_nelmts > (uint64_t)0xffffffff)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "number of elements in chunk must be < 4GB")
chunk_layout.u.chunk.dim[u] = (uint32_t)dim[u]; /* Store user's chunk dimensions */
-
- /* Get encoded size of dim, in bytes */
- enc_bytes_per_dim = (H5VM_log2_gen(dim[u]) + 8) / 8;
-
- /* Check if this is the largest value so far */
- if(enc_bytes_per_dim > max_enc_bytes_per_dim)
- max_enc_bytes_per_dim = enc_bytes_per_dim;
} /* end for */
- HDassert(max_enc_bytes_per_dim > 0 && max_enc_bytes_per_dim <= 8);
- chunk_layout.u.chunk.enc_bytes_per_dim = max_enc_bytes_per_dim;
/* Get the plist structure */
if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_CREATE)))