diff options
-rw-r--r-- | src/H5D.c | 99 | ||||
-rw-r--r-- | src/H5Distore.c | 34 | ||||
-rw-r--r-- | src/H5Fistore.c | 34 | ||||
-rw-r--r-- | src/H5Fprivate.h | 10 |
4 files changed, 114 insertions, 63 deletions
@@ -88,6 +88,9 @@ static hbool_t interface_initialize_g = FALSE; #define INTERFACE_INIT H5D_init_interface static herr_t H5D_init_interface(void); static void H5D_term_interface(void); +#ifdef HAVE_PARALLEL +static herr_t H5D_allocate (H5D_t *dataset); +#endif /*-------------------------------------------------------------------------- @@ -944,11 +947,9 @@ H5D_create(H5G_t *loc, const char *name, const H5T_t *type, const H5S_t *space, * If the dataset uses chunk storage and is accessed via * parallel I/O, allocate file space for all chunks now. */ - if (/*new_dset->ent.file->shared->access_parms->driver == H5F_LOW_MPIO &&*/ + if (new_dset->ent.file->shared->access_parms->driver == H5F_LOW_MPIO && new_dset->layout.type == H5D_CHUNKED){ - if (H5F_istore_allocate(new_dset, new_dset->ent.file, - &(new_dset->layout), space, - &(new_dset->create_parms->compress))==FAIL){ + if (H5D_allocate(new_dset)==FAIL){ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "fail in file space allocation for chunks"); } @@ -1100,11 +1101,9 @@ H5D_open(H5G_t *loc, const char *name) * If the dataset uses chunk storage and is accessed via * parallel I/O, allocate file space for all chunks now. */ - if (/*dataset->ent.file->shared->access_parms->driver == H5F_LOW_MPIO &&*/ + if (dataset->ent.file->shared->access_parms->driver == H5F_LOW_MPIO && dataset->layout.type == H5D_CHUNKED){ - if (H5F_istore_allocate(dataset, dataset->ent.file, - &(dataset->layout), space, - &(dataset->create_parms->compress))==FAIL){ + if (H5D_allocate(dataset)==FAIL){ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "fail in file space allocation for chunks"); } @@ -1906,9 +1905,7 @@ H5D_extend (H5D_t *dataset, const hsize_t *size) */ if (/*dataset->ent.file->shared->access_parms->driver == H5F_LOW_MPIO &&*/ dataset->layout.type == H5D_CHUNKED){ - if (H5F_istore_allocate(dataset, dataset->ent.file, - &(dataset->layout), space, - &(dataset->create_parms->compress))==FAIL){ + if (H5D_allocate(dataset)==FAIL){ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "fail in file space allocation for chunks"); } @@ -1972,3 +1969,83 @@ H5D_typeof (H5D_t *dset) FUNC_LEAVE (dset->type); } + +#ifdef HAVE_PARALLEL +/*------------------------------------------------------------------------- + * Function: H5D_allocate + * + * Purpose: Allocate file space for the data storage of the dataset. + * Return SUCCEED if all needed allocation succeed, otherwise + * FAIL. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Note: Current implementation allocates chunked dataset only. + * + * Programmer: Albert Cheng + * July 9, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5D_allocate (H5D_t *dataset) +{ + H5S_t *space = NULL; + herr_t ret_value = SUCCEED; + hsize_t space_dim[H5O_LAYOUT_NDIMS]; + intn space_ndims; + H5O_layout_t *layout; + + FUNC_ENTER(H5D_allocate, FAIL); +#ifdef AKC +printf("Enter %s:\n", FUNC); +#endif + + /* Check args */ + assert(dataset); + assert(&(dataset->layout)); + layout = &(dataset->layout); + assert(layout->ndims>0 && layout->ndims<=H5O_LAYOUT_NDIMS); + assert(H5F_addr_defined(&(layout->addr))); + + + switch (layout->type) { + case H5D_CONTIGUOUS: + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "not implemented yet"); + + case H5D_CHUNKED: + if (NULL==(space=H5S_read (&(dataset->ent)))) { + HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to read data space info from dataset header"); + } + /* get current dims of dataset */ + if ((space_ndims=H5S_get_dims(space, space_dim, NULL)) <= 0 || + space_ndims+1 != layout->ndims){ + HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, + "unable to allocate chunk storage"); + } + /* copy the element size over */ + space_dim[space_ndims] = layout->dim[space_ndims]; + + if (H5F_istore_allocate(dataset->ent.file, + (layout), space_dim, + &(dataset->create_parms->compress))==FAIL){ + HRETURN(FAIL); + } + break; + + default: + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "not implemented yet"); + } + + done: + if (space) + H5S_close(space); + + FUNC_LEAVE(ret_value); +} +#endif diff --git a/src/H5Distore.c b/src/H5Distore.c index c78e44e..8c9d22e 100644 --- a/src/H5Distore.c +++ b/src/H5Distore.c @@ -63,6 +63,10 @@ static herr_t H5F_istore_encode_key(H5F_t *f, H5B_t *bt, uint8 *raw, void *_key); static herr_t H5F_istore_debug_key (FILE *stream, intn indent, intn fwidth, const void *key, const void *udata); +#ifdef HAVE_PARALLEL +static herr_t H5F_istore_get_addr (H5F_t *f, const H5O_layout_t *layout, + const hssize_t offset[], void *_udata/*out*/); +#endif /* * B-tree key. A key contains the minimum logical N-dimensional address and @@ -1753,10 +1757,11 @@ H5F_istore_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent, * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5F_istore_get_addr (H5F_t *f, const H5O_layout_t *layout, - const hssize_t offset[], H5F_istore_ud1_t *udata/*out*/) + const hssize_t offset[], void *_udata/*out*/) { + H5F_istore_ud1_t *udata = _udata; intn i; herr_t status; /*func return status */ @@ -1807,11 +1812,9 @@ H5F_istore_get_addr (H5F_t *f, const H5O_layout_t *layout, *------------------------------------------------------------------------- */ herr_t -H5F_istore_allocate (H5D_t *dataset, H5F_t *f, const H5O_layout_t *layout, - const H5S_t *space, const H5O_compress_t *comp) +H5F_istore_allocate (H5F_t *f, const H5O_layout_t *layout, + const hsize_t *space_dim, const H5O_compress_t *comp) { - hsize_t space_dim[H5O_LAYOUT_NDIMS]; - intn space_ndims; intn i, carry; hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; @@ -1826,26 +1829,13 @@ H5F_istore_allocate (H5D_t *dataset, H5F_t *f, const H5O_layout_t *layout, #endif /* Check args */ - assert(dataset); - assert(layout); assert(f); - assert(space); - - if (layout->type != H5D_CHUNKED) - HRETURN(SUCCEED); /*nothing to do or should we FAIL? */ - + assert(space_dim); + assert(comp); + assert(layout && H5D_CHUNKED==layout->type); assert(layout->ndims>0 && layout->ndims<=H5O_LAYOUT_NDIMS); assert(H5F_addr_defined(&(layout->addr))); - /* get current dims of dataset */ - if ((space_ndims=H5S_get_dims(space, space_dim, NULL)) <= 0 || - space_ndims+1 != layout->ndims){ - HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to allocate chunk storage"); - } - /* copy the element size over */ - space_dim[space_ndims] = layout->dim[space_ndims]; - /* * Setup indice to go through all chunks. (Future improvement * should allocate only chunks that have no file space assigned yet. diff --git a/src/H5Fistore.c b/src/H5Fistore.c index c78e44e..8c9d22e 100644 --- a/src/H5Fistore.c +++ b/src/H5Fistore.c @@ -63,6 +63,10 @@ static herr_t H5F_istore_encode_key(H5F_t *f, H5B_t *bt, uint8 *raw, void *_key); static herr_t H5F_istore_debug_key (FILE *stream, intn indent, intn fwidth, const void *key, const void *udata); +#ifdef HAVE_PARALLEL +static herr_t H5F_istore_get_addr (H5F_t *f, const H5O_layout_t *layout, + const hssize_t offset[], void *_udata/*out*/); +#endif /* * B-tree key. A key contains the minimum logical N-dimensional address and @@ -1753,10 +1757,11 @@ H5F_istore_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent, * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5F_istore_get_addr (H5F_t *f, const H5O_layout_t *layout, - const hssize_t offset[], H5F_istore_ud1_t *udata/*out*/) + const hssize_t offset[], void *_udata/*out*/) { + H5F_istore_ud1_t *udata = _udata; intn i; herr_t status; /*func return status */ @@ -1807,11 +1812,9 @@ H5F_istore_get_addr (H5F_t *f, const H5O_layout_t *layout, *------------------------------------------------------------------------- */ herr_t -H5F_istore_allocate (H5D_t *dataset, H5F_t *f, const H5O_layout_t *layout, - const H5S_t *space, const H5O_compress_t *comp) +H5F_istore_allocate (H5F_t *f, const H5O_layout_t *layout, + const hsize_t *space_dim, const H5O_compress_t *comp) { - hsize_t space_dim[H5O_LAYOUT_NDIMS]; - intn space_ndims; intn i, carry; hssize_t chunk_offset[H5O_LAYOUT_NDIMS]; @@ -1826,26 +1829,13 @@ H5F_istore_allocate (H5D_t *dataset, H5F_t *f, const H5O_layout_t *layout, #endif /* Check args */ - assert(dataset); - assert(layout); assert(f); - assert(space); - - if (layout->type != H5D_CHUNKED) - HRETURN(SUCCEED); /*nothing to do or should we FAIL? */ - + assert(space_dim); + assert(comp); + assert(layout && H5D_CHUNKED==layout->type); assert(layout->ndims>0 && layout->ndims<=H5O_LAYOUT_NDIMS); assert(H5F_addr_defined(&(layout->addr))); - /* get current dims of dataset */ - if ((space_ndims=H5S_get_dims(space, space_dim, NULL)) <= 0 || - space_ndims+1 != layout->ndims){ - HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, - "unable to allocate chunk storage"); - } - /* copy the element size over */ - space_dim[space_ndims] = layout->dim[space_ndims]; - /* * Setup indice to go through all chunks. (Future improvement * should allocate only chunks that have no file space assigned yet. diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 0245bd9..dd2b5a8 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -494,9 +494,6 @@ typedef struct H5F_t { struct H5O_layout_t; /*forward decl for prototype arguments */ struct H5O_efl_t; /*forward decl for prototype arguments */ struct H5O_compress_t; /*forward decl for prototype arguments */ -struct H5F_istore_ud1_t; /*forward decl for prototype arguments */ -struct H5S_t; /*forward decl for prototype arguments */ -struct H5D_t; /*forward decl for prototype arguments */ /* library variables */ extern const H5F_create_t H5F_create_dflt; @@ -543,12 +540,9 @@ herr_t H5F_istore_write(H5F_t *f, const struct H5O_layout_t *layout, const struct H5O_compress_t *comp, const hssize_t offset[], const hsize_t size[], const void *buf); -herr_t H5F_istore_get_addr (H5F_t *f, const struct H5O_layout_t *layout, - const hssize_t offset[], - struct H5F_istore_ud1_t *udata/*out*/); -herr_t H5F_istore_allocate (struct H5D_t *dataset, H5F_t *f, +herr_t H5F_istore_allocate (H5F_t *f, const struct H5O_layout_t *layout, - const struct H5S_t *space, + const hsize_t *space_dim, const struct H5O_compress_t *comp); /* Functions that operate on contiguous storage wrt boot block */ |