From 8fe3dfbf9410ad5acabeaeb187bfb5f7b489042e Mon Sep 17 00:00:00 2001 From: Neil Fortner Date: Tue, 5 May 2015 15:15:40 -0500 Subject: [svn-r27022] Add new functions H5Pset_virtual_dataspace_bounds and H5Pget_virtual_dataspace_bounds. Minor refactor of dataset initialization code to make this cleaner. Update h5_vds-percival-unlim-maxmin.c Other minor fixes/cleanup. Tested: ummon --- examples/h5_vds-percival-unlim-maxmin.c | 31 ++++--- src/H5Dint.c | 2 +- src/H5Dlayout.c | 126 ++++++++++--------------- src/H5Dpkg.h | 2 + src/H5Dprivate.h | 1 + src/H5Dpublic.h | 7 ++ src/H5Dvirtual.c | 69 +++++++------- src/H5Olayout.c | 2 +- src/H5Oprivate.h | 2 +- src/H5Pdapl.c | 160 +++++++++++++++++++++++++++++++- src/H5Ppublic.h | 3 + src/H5Shyper.c | 21 +---- 12 files changed, 283 insertions(+), 143 deletions(-) diff --git a/examples/h5_vds-percival-unlim-maxmin.c b/examples/h5_vds-percival-unlim-maxmin.c index c89dbac..4640b94 100644 --- a/examples/h5_vds-percival-unlim-maxmin.c +++ b/examples/h5_vds-percival-unlim-maxmin.c @@ -209,18 +209,27 @@ main (void) * min extents depending on the sizes of the underlying datasets */ dapl = H5Pcreate (H5P_DATASET_ACCESS); - //status = H5Pset_virtual_dataset_bounds (dapl, H5D_VDS_MAX); - //status = H5Pset_virtual_dataset_bounds (dapl, H5D_VDS_MIN); - vdset = H5Dopen (vfile, DATASET, dapl); - - /* Let's get space of the VDS and its dimension; we should get 32(or 17)x10x10 */ - vspace = H5Dget_space (vdset); - H5Sget_simple_extent_dims (vspace, vdsdims_out, vdsdims_max_out); - printf ("VDS dimensions: "); - for (i=0; ishared->layout.ops->construct)(file, new_dset) < 0) + if(new_dset->shared->layout.ops->construct && (new_dset->shared->layout.ops->construct)(file, new_dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to construct layout information") /* Update the dataset's object header info. */ diff --git a/src/H5Dlayout.c b/src/H5Dlayout.c index 87e1bc8..cb8b27d 100644 --- a/src/H5Dlayout.c +++ b/src/H5Dlayout.c @@ -391,85 +391,55 @@ H5D__layout_oh_read(H5D_t *dataset, hid_t dxpl_id, hid_t dapl_id, H5P_genplist_t if(H5D_CHUNKED == dataset->shared->layout.type) dataset->shared->layout.u.chunk.ndims++; - switch(dataset->shared->layout.type) { - case H5D_CONTIGUOUS: - { - hsize_t tmp_size; /* Temporary holder for raw data size */ - size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */ - - /* Compute the size of the contiguous storage for versions of the - * layout message less than version 3 because versions 1 & 2 would - * truncate the dimension sizes to 32-bits of information. - QAK 5/26/04 - */ - if(dataset->shared->layout.version < 3) { - hssize_t snelmts; /* Temporary holder for number of elements in dataspace */ - hsize_t nelmts; /* Number of elements in dataspace */ - size_t dt_size; /* Size of datatype */ - - /* Retrieve the number of elements in the dataspace */ - if((snelmts = H5S_GET_EXTENT_NPOINTS(dataset->shared->space)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace") - nelmts = (hsize_t)snelmts; - - /* Get the datatype's size */ - if(0 == (dt_size = H5T_GET_SIZE(dataset->shared->type))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype") - - /* Compute the size of the dataset's contiguous storage */ - tmp_size = nelmts * dt_size; - - /* Check for overflow during multiplication */ - if(nelmts != (tmp_size / dt_size)) - HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed") - - /* Assign the dataset's contiguous storage size */ - dataset->shared->layout.storage.u.contig.size = tmp_size; - } else - tmp_size = dataset->shared->layout.storage.u.contig.size; - - /* Get the sieve buffer size for the file */ - tmp_sieve_buf_size = H5F_SIEVE_BUF_SIZE(dataset->oloc.file); - - /* Adjust the sieve buffer size to the smaller one between the dataset size and the buffer size - * from the file access property. (SLU - 2012/3/30) */ - if(tmp_size < tmp_sieve_buf_size) - dataset->shared->cache.contig.sieve_buf_size = tmp_size; - else - dataset->shared->cache.contig.sieve_buf_size = tmp_sieve_buf_size; - } - break; - - case H5D_CHUNKED: - /* Initialize the chunk cache for the dataset */ - if(H5D__chunk_init(dataset->oloc.file, dxpl_id, dataset, dapl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize chunk cache") - break; - - case H5D_COMPACT: - break; - - case H5D_VIRTUAL: - { - size_t i; - - HDassert(dataset->shared->layout.storage.u.virt.list || (dataset->shared->layout.storage.u.virt.list_nused == 0)); - - /* Patch the virtual selection dataspaces if necessary */ - for(i = 0; i < dataset->shared->layout.storage.u.virt.list_nused; i++) { - if(dataset->shared->layout.storage.u.virt.list[i].virtual_space_status != H5O_VIRTUAL_STATUS_CORRECT) { - if(H5S_extent_copy(dataset->shared->layout.storage.u.virt.list[i].virtual_select, dataset->shared->space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy virtual dataspace extent") - dataset->shared->layout.storage.u.virt.list[i].virtual_space_status = H5O_VIRTUAL_STATUS_CORRECT; - } /* end if */ - } /* end for */ - } /* end block */ - break; + if(H5D_CONTIGUOUS == dataset->shared->layout.type) { + hsize_t tmp_size; /* Temporary holder for raw data size */ + size_t tmp_sieve_buf_size; /* Temporary holder for sieve buffer size */ + + /* Compute the size of the contiguous storage for versions of the + * layout message less than version 3 because versions 1 & 2 would + * truncate the dimension sizes to 32-bits of information. - QAK 5/26/04 + */ + if(dataset->shared->layout.version < 3) { + hssize_t snelmts; /* Temporary holder for number of elements in dataspace */ + hsize_t nelmts; /* Number of elements in dataspace */ + size_t dt_size; /* Size of datatype */ + + /* Retrieve the number of elements in the dataspace */ + if((snelmts = H5S_GET_EXTENT_NPOINTS(dataset->shared->space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve number of elements in dataspace") + nelmts = (hsize_t)snelmts; + + /* Get the datatype's size */ + if(0 == (dt_size = H5T_GET_SIZE(dataset->shared->type))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to retrieve size of datatype") + + /* Compute the size of the dataset's contiguous storage */ + tmp_size = nelmts * dt_size; + + /* Check for overflow during multiplication */ + if(nelmts != (tmp_size / dt_size)) + HGOTO_ERROR(H5E_DATASET, H5E_OVERFLOW, FAIL, "size of dataset's storage overflowed") + + /* Assign the dataset's contiguous storage size */ + dataset->shared->layout.storage.u.contig.size = tmp_size; + } /* end if */ + else + tmp_size = dataset->shared->layout.storage.u.contig.size; + + /* Get the sieve buffer size for the file */ + tmp_sieve_buf_size = H5F_SIEVE_BUF_SIZE(dataset->oloc.file); + + /* Adjust the sieve buffer size to the smaller one between the dataset size and the buffer size + * from the file access property. (SLU - 2012/3/30) */ + if(tmp_size < tmp_sieve_buf_size) + dataset->shared->cache.contig.sieve_buf_size = tmp_size; + else + dataset->shared->cache.contig.sieve_buf_size = tmp_sieve_buf_size; + } /* end if */ - case H5D_LAYOUT_ERROR: - case H5D_NLAYOUTS: - default: - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown storage method") - } /* end switch */ /*lint !e788 All appropriate cases are covered */ + /* Initialize the layout information for the new dataset */ + if(dataset->shared->layout.ops->init && (dataset->shared->layout.ops->init)(dataset->oloc.file, dxpl_id, dataset, dapl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize layout information") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 978936b..d3cea4c 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -666,6 +666,8 @@ H5_DLL herr_t H5D__virtual_copy(H5F_t *f_src, const H5O_storage_virtual_t *storage_src, H5F_t *f_dst, H5O_storage_virtual_t *storage_dst, H5T_t *dt_src, H5O_copy_t *cpy_info, hid_t dxpl_id); +H5_DLL herr_t H5D__virtual_init(H5F_t *f, hid_t dxpl_id, const H5D_t *dset, + hid_t dapl_id); H5_DLL hbool_t H5D__virtual_is_space_alloc(const H5O_storage_t *storage); /* Functions that operate on EFL (External File List)*/ diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 5f588fd..a89f937 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -52,6 +52,7 @@ #define H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME "rdcc_nslots" /* Size of raw data chunk cache(slots) */ #define H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME "rdcc_nbytes" /* Size of raw data chunk cache(bytes) */ #define H5D_ACS_PREEMPT_READ_CHUNKS_NAME "rdcc_w0" /* Preemption read chunks first */ +#define H5D_ACS_VDS_BOUNDS_NAME "vds_bounds" /* VDS bounds option */ /* ======== Data transfer properties ======== */ #define H5D_XFER_MAX_TEMP_BUF_NAME "max_temp_buf" /* Maximum temp buffer size */ diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index a08ea3d..e4b1311 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -94,6 +94,13 @@ typedef enum H5D_fill_value_t { H5D_FILL_VALUE_USER_DEFINED =2 } H5D_fill_value_t; +/* Values for VDS bounds option */ +typedef enum H5D_vds_bounds_t { + H5D_VDS_ERROR = -1, + H5D_VDS_MAX = 0, + H5D_VDS_MIN = 1 +} H5D_vds_bounds_t; + /********************/ /* Public Variables */ /********************/ diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index 40fe7ac..109078f 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -36,6 +36,7 @@ #include "H5Fprivate.h" /* Files */ #include "H5Gprivate.h" /* Groups */ #include "H5HGprivate.h" /* Global Heaps */ +#include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* Object headers */ #include "H5Sprivate.h" /* Dataspaces */ @@ -56,7 +57,6 @@ /********************/ /* Layout operation callbacks */ -static herr_t H5D__virtual_construct(H5F_t *f, H5D_t *dset); static herr_t H5D__virtual_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space, const H5S_t *mem_space, H5D_chunk_map_t *cm); @@ -79,8 +79,8 @@ static herr_t H5D__virtual_open_source_dset(const H5D_t *vdset, /* Contiguous storage layout I/O ops */ const H5D_layout_ops_t H5D_LOPS_VIRTUAL[1] = {{ - H5D__virtual_construct, NULL, + H5D__virtual_init, H5D__virtual_is_space_alloc, H5D__virtual_io_init, H5D__virtual_read, @@ -348,6 +348,7 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset, hid_t dxpl_id) HDassert(dset); storage = &dset->shared->layout.storage.u.virt; HDassert(dset->shared->layout.storage.type == H5D_VIRTUAL); + HDassert((storage->bounds == H5D_VDS_MAX) || (storage->bounds == H5D_VDS_MIN)); /* Get rank of VDS */ if((rank = H5S_GET_EXTENT_NDIMS(dset->shared->space)) < 0) @@ -383,7 +384,7 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset, hid_t dxpl_id) /* Check if we are setting extent by maximum or minimum of * mappings */ - if(storage->set_extent_max) { + if(storage->bounds == H5D_VDS_MAX) { /* Check if the source extent in the unlimited dimension * changed since the last time the VDS extent/mapping * was updated */ @@ -427,7 +428,6 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset, hid_t dxpl_id) clip_size_incl_trail = storage->list[i].clip_size_virtual_incl_trail; } //VDSINC else { - HDassert(0 && "Checking code coverage..."); //VDSINC /* Get size that virtual selection would be clipped to * to match size of source selection. Also get the clip * size including the trailing space (gap between @@ -479,7 +479,7 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset, hid_t dxpl_id) /* If we did not change the VDS dimensions and we are setting the extent by * maximum, there is nothing more to update */ - if(changed || !storage->set_extent_max) { + if(changed || (storage->bounds == H5D_VDS_MIN)) { /* Update VDS extent */ if(changed) if(H5S_set_extent(dset->shared->space, new_dims) < 0) @@ -500,15 +500,13 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset, hid_t dxpl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to modify size of data space") /* Check if we are setting extent by the minimum of mappings */ - if(!storage->set_extent_max) { + if(storage->bounds == H5D_VDS_MIN) { /* Clip virtual selection to extent (only necessary if the * extent changed, otherwise it will already be clipped to * the extent) */ - if(changed) { - HDassert(0 && "Checking code coverage..."); //VDSINC + if(changed) if(H5S_hyper_clip_to_extent(storage->list[i].virtual_select)) HGOTO_ERROR(H5E_DATASET, H5E_CANTCLIP, FAIL, "failed to clip unlimited selection") - } //VDSINC /* Check if the virtual extent in the unlimited dimension * changed since the last time the VDS extent/mapping was @@ -520,7 +518,6 @@ H5D__virtual_set_extent_unlim(const H5D_t *dset, hid_t dxpl_id) clip_size = storage->list[i].clip_size_source; } //VDSINC else { - HDassert(0 && "Checking code coverage..."); //VDSINC /* Get size that source selection will be clipped to to * match size of virtual selection */ if(H5S_hyper_get_clip_extent(storage->list[i].source_select, storage->list[i].virtual_select, &clip_size, NULL) < 0) @@ -638,38 +635,52 @@ done: /*------------------------------------------------------------------------- - * Function: H5D__virtual_construct + * Function: H5D__virtual_init * - * Purpose: Constructs new virtual layout information for dataset + * Purpose: Initialize the virtual layout information for a dataset. + * This is called when the dataset is initialized. * * Return: Non-negative on success/Negative on failure * * Programmer: Neil Fortner - * Monday, February 2, 2015 + * Thursday, April 30, 2015 * *------------------------------------------------------------------------- */ -static herr_t -H5D__virtual_construct(H5F_t UNUSED *f, H5D_t *dset) +herr_t +H5D__virtual_init(H5F_t UNUSED *f, hid_t UNUSED dxpl_id, const H5D_t *dset, + hid_t dapl_id) { - size_t i; - herr_t ret_value = SUCCEED; + H5P_genplist_t *dapl; /* Data access property list object pointer */ + size_t i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE + /* Sanity check */ + HDassert(dset); HDassert(dset->shared->layout.storage.u.virt.list || (dset->shared->layout.storage.u.virt.list_nused == 0)); /* Patch the virtual selection dataspaces */ for(i = 0; i < dset->shared->layout.storage.u.virt.list_nused; i++) { - HDassert(dset->shared->layout.storage.u.virt.list[i].virtual_space_status == H5O_VIRTUAL_STATUS_USER); - if(H5S_extent_copy(dset->shared->layout.storage.u.virt.list[i].virtual_select, dset->shared->space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy virtual dataspace extent") - dset->shared->layout.storage.u.virt.list[i].virtual_space_status = H5O_VIRTUAL_STATUS_CORRECT; + if(dset->shared->layout.storage.u.virt.list[i].virtual_space_status != H5O_VIRTUAL_STATUS_CORRECT) { + if(H5S_extent_copy(dset->shared->layout.storage.u.virt.list[i].virtual_select, dset->shared->space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy virtual dataspace extent") + dset->shared->layout.storage.u.virt.list[i].virtual_space_status = H5O_VIRTUAL_STATUS_CORRECT; + } /* end if */ } /* end for */ + /* Get dataset access property list */ + if(NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for dapl ID") + + /* Get bounds option */ + if(H5P_get(dapl, H5D_ACS_VDS_BOUNDS_NAME, &dset->shared->layout.storage.u.virt.bounds) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache number of slots") + done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__virtual_construct() */ +} /* end H5D__virtual_init() */ /*------------------------------------------------------------------------- @@ -759,11 +770,7 @@ H5D__virtual_read(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, HDassert(file_space); storage = &io_info->dset->shared->layout.storage.u.virt; - - /* Update VDS extent due to unlimited selections */ - /* Don't call if there is no unlimited selection? VDSINC */ - if(H5D__virtual_set_extent_unlim(io_info->dset, io_info->dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update virtual dataset extent") + HDassert((storage->bounds == H5D_VDS_MAX) || (storage->bounds == H5D_VDS_MIN)); /* Iterate over mappings */ for(i = 0; i < storage->list_nused; i++) { @@ -871,11 +878,7 @@ H5D__virtual_write(H5D_io_info_t *io_info, const H5D_type_info_t *type_info, HDassert(file_space); storage = &io_info->dset->shared->layout.storage.u.virt; - - /* Update VDS extent due to unlimited selections */ - /* Don't call if there is no unlimited selection? VDSINC */ - if(H5D__virtual_set_extent_unlim(io_info->dset, io_info->dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to update virtual dataset extent") + HDassert((storage->bounds == H5D_VDS_MAX) || (storage->bounds == H5D_VDS_MIN)); /* Iterate over mappings */ for(i = 0; i < storage->list_nused; i++) { diff --git a/src/H5Olayout.c b/src/H5Olayout.c index cf5b3d2..9f1afb3 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -251,7 +251,7 @@ H5O_layout_decode(H5F_t *f, hid_t dxpl_id, H5O_t UNUSED *open_oh, mesg->storage.u.virt.list_nused = 0; mesg->storage.u.virt.list = NULL; mesg->storage.u.virt.list_nalloc = 0; - mesg->storage.u.virt.set_extent_max = TRUE; + mesg->storage.u.virt.bounds = H5D_VDS_ERROR; /* Decode heap block if it exists */ if(mesg->storage.u.virt.serial_list_hobjid.addr != HADDR_UNDEF) { diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 0211093..fcb0649 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -450,7 +450,7 @@ typedef struct H5O_storage_virtual_t { /* Not stored */ size_t list_nalloc; /* Number of slots allocated */ hsize_t min_dims[H5S_MAX_RANK]; /* Minimum extent of VDS (maximum of all non-unlimited selection bounds) */ - hbool_t set_extent_max; /* Whether we set the extent by the maximum (TRUE) or minimum (FALSE) of unlimited selections */ + H5D_vds_bounds_t bounds; /* Whether we set the extent by the maximum (TRUE) or minimum (FALSE) of unlimited selections */ } H5O_storage_virtual_t; typedef struct H5O_storage_t { diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c index 93d16bb..fbd83a6 100644 --- a/src/H5Pdapl.c +++ b/src/H5Pdapl.c @@ -61,6 +61,11 @@ #define H5D_ACS_PREEMPT_READ_CHUNKS_DEF H5D_CHUNK_CACHE_W0_DEFAULT #define H5D_ACS_PREEMPT_READ_CHUNKS_ENC H5P__encode_double #define H5D_ACS_PREEMPT_READ_CHUNKS_DEC H5P__decode_double +/* Definitions for VDS bounds option */ +#define H5D_ACS_VDS_BOUNDS_SIZE sizeof(H5D_vds_bounds_t) +#define H5D_ACS_VDS_BOUNDS_DEF H5D_VDS_MAX +#define H5D_ACS_VDS_BOUNDS_ENC H5P__dacc_vds_bounds_enc +#define H5D_ACS_VDS_BOUNDS_DEC H5P__dacc_vds_bounds_dec /******************/ /* Local Typedefs */ @@ -79,6 +84,10 @@ /* Property class callbacks */ static herr_t H5P__dacc_reg_prop(H5P_genclass_t *pclass); +/* Property list callbacks */ +static herr_t H5P__dacc_vds_bounds_enc(const void *value, void **pp, size_t *size); +static herr_t H5P__dacc_vds_bounds_dec(const void **pp, void *value); + /*********************/ /* Package Variables */ @@ -133,6 +142,7 @@ H5P__dacc_reg_prop(H5P_genclass_t *pclass) size_t rdcc_nslots = H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF; /* Default raw data chunk cache # of slots */ size_t rdcc_nbytes = H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF; /* Default raw data chunk cache # of bytes */ double rdcc_w0 = H5D_ACS_PREEMPT_READ_CHUNKS_DEF; /* Default raw data chunk cache dirty ratio */ + H5D_vds_bounds_t bounds_option = H5D_ACS_VDS_BOUNDS_DEF; /* Default VDS bounds option */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -152,6 +162,12 @@ H5P__dacc_reg_prop(H5P_genclass_t *pclass) NULL, NULL, NULL, H5D_ACS_PREEMPT_READ_CHUNKS_ENC, H5D_ACS_PREEMPT_READ_CHUNKS_DEC, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the VDS bounds option */ + if(H5P_register_real(pclass, H5D_ACS_VDS_BOUNDS_NAME, H5D_ACS_VDS_BOUNDS_SIZE, &bounds_option, + NULL, NULL, NULL, H5D_ACS_VDS_BOUNDS_ENC, H5D_ACS_VDS_BOUNDS_DEC, + NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dacc_reg_prop() */ @@ -282,5 +298,147 @@ H5Pget_chunk_cache(hid_t dapl_id, size_t *rdcc_nslots, size_t *rdcc_nbytes, doub done: FUNC_LEAVE_API(ret_value) -} +} /* end H5Pget_chunk_cache() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_virtual_dataspace_bounds + * + * Purpose: VDSINC + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * May 4, 2015 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_virtual_dataspace_bounds(hid_t plist_id, H5D_vds_bounds_t bounds_option) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(FAIL) + + /* Check argument */ + if((bounds_option != H5D_VDS_MAX) && (bounds_option != H5D_VDS_MIN)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid bounds option") + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* Update property list */ + if(H5P_set(plist, H5D_ACS_VDS_BOUNDS_NAME, &bounds_option) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "unable to set value") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_virtual_dataspace_bounds() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pget_virtual_dataspace_bounds + * + * Purpose: VDSINC + * + * Return: Success: H5D_VDS_MAX or H5D_VDS_MIN + * Failure: H5D_VDS_ERROR + * + * Programmer: Neil Fortner + * May 4, 2015 + * + *------------------------------------------------------------------------- + */ +H5D_vds_bounds_t +H5Pget_virtual_dataspace_bounds(hid_t plist_id) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5D_vds_bounds_t ret_value; /* Return value */ + + FUNC_ENTER_API(H5D_VDS_ERROR) + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(plist_id, H5P_DATASET_ACCESS))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5D_VDS_ERROR, "can't find object for ID") + + /* Get value from property list */ + if(H5P_get(plist, H5D_ACS_VDS_BOUNDS_NAME, &ret_value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5D_VDS_ERROR, "unable to set value") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_virtual_dataspace_bounds() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__dacc_vds_bounds_enc + * + * Purpose: Callback routine which is called whenever the vds bounds + * property in the dataset access property list is encoded. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * Tuesday, May 5, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dacc_vds_bounds_enc(const void *value, void **_pp, size_t *size) +{ + const H5D_vds_bounds_t *bounds = (const H5D_vds_bounds_t *)value; /* Create local alias for values */ + uint8_t **pp = (uint8_t **)_pp; + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(bounds); + HDassert(size); + + if(NULL != *pp) + /* Encode EDC property */ + *(*pp)++ = (uint8_t)*bounds; + + /* Size of EDC property */ + (*size)++; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5P__dacc_vds_bounds_enc() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__dacc_vds_bounds_dec + * + * Purpose: Callback routine which is called whenever the vds bounds + * property in the dataset access property list is encoded. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Neil Fortner + * Tuesday, May 5, 2015 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__dacc_vds_bounds_dec(const void **_pp, void *_value) +{ + H5D_vds_bounds_t *bounds = (H5D_vds_bounds_t *)_value; /* EDC property */ + const uint8_t **pp = (const uint8_t **)_pp; + + FUNC_ENTER_STATIC_NOERR + + /* Sanity checks */ + HDassert(pp); + HDassert(*pp); + HDassert(bounds); + + /* Decode EDC property */ + *bounds = (H5D_vds_bounds_t)*(*pp)++; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5P__dacc_vds_bounds_dec() */ diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index c1c6f17..7932716 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -393,6 +393,9 @@ H5_DLL herr_t H5Pget_chunk_cache(hid_t dapl_id, size_t *rdcc_nslots/*out*/, size_t *rdcc_nbytes/*out*/, double *rdcc_w0/*out*/); +H5_DLL herr_t H5Pset_virtual_dataspace_bounds(hid_t plist_id, + H5D_vds_bounds_t bounds_option); +H5_DLL H5D_vds_bounds_t H5Pget_virtual_dataspace_bounds(hid_t plist_id); /* Dataset xfer property list (DXPL) routines */ H5_DLL herr_t H5Pset_data_transform(hid_t plist_id, const char* expression); diff --git a/src/H5Shyper.c b/src/H5Shyper.c index 9b854c0..5667cbd 100644 --- a/src/H5Shyper.c +++ b/src/H5Shyper.c @@ -1673,20 +1673,9 @@ H5S_hyper_copy (H5S_t *dst, const H5S_t *src, hbool_t share_selection) dst->select.sel_info.hslab->span_lst = H5S_hyper_copy_span(src->select.sel_info.hslab->span_lst); } /* end if */ - /* If there is an unlimited dimension, we must update the selection if the - * extent changed */ - if(dst_hslab->unlim_dim >= 0) { - htri_t extent_equal; - - /* Check if the extent changed */ - if((extent_equal = H5S_extent_equal(src, dst)) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOMPARE, FAIL, "dataspace comparison failed") - - if(!extent_equal) - /* Update selection due to changed extent */ - if(H5S_hyper_clip_to_extent(dst) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't update hyperslab") - } /* end if */ + /* If there is an unlimited dimension, we must update the selection */ + if(H5S_hyper_clip_to_extent(dst) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTSET, FAIL, "can't update hyperslab") done: FUNC_LEAVE_NOAPI(ret_value) @@ -9843,14 +9832,12 @@ H5S_hyper_get_clip_extent(const H5S_t *clip_space, const H5S_t *match_space, + ((count - (hsize_t)1) * clip_hslab->opt_unlim_diminfo[clip_hslab->unlim_dim].stride) + clip_hslab->opt_unlim_diminfo[clip_hslab->unlim_dim].block; - if(clip_size_incl_trail) { - HDassert(0 && "Checking code coverage..."); //VDSINC + if(clip_size_incl_trail) /* Include gap after last block */ *clip_size_incl_trail = clip_hslab->opt_unlim_diminfo[clip_hslab->unlim_dim].start + (count * clip_hslab->opt_unlim_diminfo[clip_hslab->unlim_dim].stride); - } //VDSINC } /* end else */ } /* end else */ -- cgit v0.12