diff options
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | src/H5A.c | 2 | ||||
-rw-r--r-- | src/H5D.c | 83 | ||||
-rw-r--r-- | src/H5Dchunk.c | 45 | ||||
-rw-r--r-- | src/H5Dcompact.c | 4 | ||||
-rw-r--r-- | src/H5Dcontig.c | 4 | ||||
-rw-r--r-- | src/H5Ddeprec.c | 3 | ||||
-rw-r--r-- | src/H5Defl.c | 4 | ||||
-rw-r--r-- | src/H5Dint.c | 15 | ||||
-rw-r--r-- | src/H5Doh.c | 25 | ||||
-rw-r--r-- | src/H5Dpkg.h | 8 | ||||
-rw-r--r-- | src/H5Dprivate.h | 7 | ||||
-rw-r--r-- | src/H5Dpublic.h | 6 | ||||
-rw-r--r-- | src/H5F.c | 10 | ||||
-rw-r--r-- | src/H5Fpkg.h | 2 | ||||
-rw-r--r-- | src/H5Fprivate.h | 8 | ||||
-rw-r--r-- | src/H5Fquery.c | 12 | ||||
-rw-r--r-- | src/H5Goh.c | 6 | ||||
-rw-r--r-- | src/H5O.c | 13 | ||||
-rw-r--r-- | src/H5Opkg.h | 4 | ||||
-rw-r--r-- | src/H5Pdapl.c | 271 | ||||
-rw-r--r-- | src/H5Pfapl.c | 28 | ||||
-rw-r--r-- | src/H5Pint.c | 17 | ||||
-rw-r--r-- | src/H5Ppublic.h | 12 | ||||
-rw-r--r-- | src/H5R.c | 3 | ||||
-rw-r--r-- | src/H5Toh.c | 6 | ||||
-rwxr-xr-x | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/Makefile.in | 31 | ||||
-rw-r--r-- | test/dsets.c | 210 |
29 files changed, 725 insertions, 117 deletions
@@ -675,6 +675,7 @@ ./src/H5Ounknown.c ./src/H5P.c ./src/H5Pacpl.c +./src/H5Pdapl.c ./src/H5Pdcpl.c ./src/H5Pdeprec.c ./src/H5Pdxpl.c @@ -2040,7 +2040,7 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, loc_found = TRUE; /* Open the object */ - if((obj_loc_id = H5O_open_by_loc(&obj_loc, H5AC_ind_dxpl_id, TRUE)) < 0) + if((obj_loc_id = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_ind_dxpl_id, TRUE)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object") /* Build attribute operator info */ @@ -249,7 +249,7 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") /* build and open the new dataset */ - if(NULL == (dset = H5D_create(loc.oloc->file, type_id, space, dcpl_id, H5AC_dxpl_id))) + if(NULL == (dset = H5D_create(loc.oloc->file, type_id, space, dcpl_id, dapl_id, H5AC_dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") /* Register the new dataset to get an ID for it */ @@ -328,7 +328,7 @@ H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") /* Open the dataset */ - if((dset = H5D_open(&dset_loc, dxpl_id)) == NULL) + if((dset = H5D_open(&dset_loc, dapl_id, dxpl_id)) == NULL) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open dataset") /* Register an atom for the dataset */ @@ -652,6 +652,85 @@ done: /*------------------------------------------------------------------------- + * Function: H5Dget_access_plist + * + * Purpose: Returns a copy of the dataset creation property list. + * + * Description: H5Dget_access_plist returns the dataset access property + * list identifier of the specified dataset. + * + * The chunk cache parameters in the returned property lists will be + * those used by the dataset. If the properties in the file access + * property list were used to determine the dataset’s chunk cache + * configuration, then those properties will be present in the + * returned dataset access property list. If the dataset does not + * use a chunked layout, then the chunk cache properties will be set + * to the default. The chunk cache properties in the returned list + * are considered to be “set”, and any use of this list will override + * the corresponding properties in the file’s file access property + * list. + * + * All link access properties in the returned list will be set to the + * default values. + * + * Return: Success: ID for a copy of the dataset access + * property list. The template should be + * released by calling H5Pclose(). + * + * Failure: FAIL + * + * Programmer: Neil Fortner + * Wednesday, October 29, 2008 + * + *------------------------------------------------------------------------- + */ +hid_t +H5Dget_access_plist(hid_t dset_id) +{ + H5D_t *dset; /* Dataset structure */ + H5P_genplist_t *old_plist; /* Default DAPL */ + H5P_genplist_t *new_plist; /* New DAPL */ + hid_t new_dapl_id = FAIL; + hid_t ret_value; /* Return value */ + + FUNC_ENTER_API(H5Dget_access_plist, FAIL) + H5TRACE1("i", "i", dset_id); + + /* Check args */ + if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + + /* Make a copy of the default dataset access property list */ + if (NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATASET_ACCESS_g))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + if ((new_dapl_id = H5P_copy_plist(old_plist, TRUE)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "can't copy dataset access property list") + if (NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_dapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + + /* If the dataset is chunked then copy the rdcc parameters */ + if (dset->shared->layout.type == H5D_CHUNKED) { + if (H5P_set(new_plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(dset->shared->cache.chunk.nslots)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache number of slots") + if (H5P_set(new_plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(dset->shared->cache.chunk.nbytes)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache byte size") + if (H5P_set(new_plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &(dset->shared->cache.chunk.w0)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set preempt read chunks") + } /* end if */ + + /* Set the return value */ + ret_value = new_dapl_id; + +done: + if(ret_value < 0) + if(new_dapl_id >= 0) + (void)H5I_dec_ref(new_dapl_id, TRUE); + + FUNC_LEAVE_API(ret_value) +} /* end H5Dget_access_plist() */ + + +/*------------------------------------------------------------------------- * Function: H5Dget_storage_size * * Purpose: Returns the amount of storage that is required for the diff --git a/src/H5Dchunk.c b/src/H5Dchunk.c index 202da75..d8e13a5 100644 --- a/src/H5Dchunk.c +++ b/src/H5Dchunk.c @@ -154,7 +154,7 @@ typedef struct H5D_chunk_it_ud4_t { /********************/ /* Chunked layout operation callbacks */ -static herr_t H5D_chunk_new(H5F_t *f, hid_t dxpl_id, H5D_t *dset, +static herr_t H5D_chunk_new(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, const H5P_genplist_t *dc_plist); static herr_t H5D_chunk_io_init(const H5D_io_info_t *io_info, const H5D_type_info_t *type_info, hsize_t nelmts, const H5S_t *file_space, @@ -257,7 +257,7 @@ H5FL_DEFINE_STATIC(H5D_chunk_sl_ck_t); *------------------------------------------------------------------------- */ static herr_t -H5D_chunk_new(H5F_t *f, hid_t dxpl_id, H5D_t *dset, +H5D_chunk_new(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, const H5P_genplist_t *dc_plist) { const H5T_t *type = dset->shared->type; /* Convenience pointer to dataset's datatype */ @@ -326,7 +326,7 @@ H5D_chunk_new(H5F_t *f, hid_t dxpl_id, H5D_t *dset, H5_ASSIGN_OVERFLOW(dset->shared->layout.u.chunk.size, chunk_size, uint64_t, uint32_t); /* Initialize the chunk cache for the dataset */ - if(H5D_chunk_init(f, dxpl_id, dset) < 0) + if(H5D_chunk_init(f, dapl_id, dxpl_id, dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize chunk cache") done: @@ -649,7 +649,7 @@ H5D_chunk_alloc(size_t size, const H5O_pline_t *pline) { void *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5D_chunk_alloc) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5D_chunk_alloc) HDassert(size); HDassert(pline); @@ -1743,10 +1743,11 @@ done: *------------------------------------------------------------------------- */ herr_t -H5D_chunk_init(H5F_t *f, hid_t dxpl_id, const H5D_t *dset) +H5D_chunk_init(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, const H5D_t *dset) { H5D_chk_idx_info_t idx_info; /* Chunked index info */ H5D_rdcc_t *rdcc = &(dset->shared->cache.chunk); /* Convenience pointer to dataset's chunk cache */ + H5P_genplist_t *dapl; /* Data access property list object pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5D_chunk_init, FAIL) @@ -1755,16 +1756,36 @@ H5D_chunk_init(H5F_t *f, hid_t dxpl_id, const H5D_t *dset) HDassert(f); HDassert(dset); - if(H5F_RDCC_NBYTES(f) > 0 && H5F_RDCC_NELMTS(f) > 0) { + if(NULL == (dapl = (H5P_genplist_t *)H5I_object(dapl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for fapl ID"); + + /* Use the properties in dapl_id if they have been set, otherwise use the properties from the file */ + if(H5P_get(dapl, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc->nslots) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache number of slots"); + if(rdcc->nslots == H5D_CHUNK_CACHE_NSLOTS_DEFAULT) + rdcc->nslots = H5F_RDCC_NSLOTS(f); + + if(H5P_get(dapl, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc->nbytes) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache byte size"); + if(rdcc->nbytes == H5D_CHUNK_CACHE_NBYTES_DEFAULT) rdcc->nbytes = H5F_RDCC_NBYTES(f); - rdcc->nslots = H5F_RDCC_NELMTS(f); - rdcc->slot = H5FL_SEQ_CALLOC(H5D_rdcc_ent_ptr_t, rdcc->nslots); - if(NULL == rdcc->slot) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + + if(H5P_get(dapl, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc->w0) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get preempt read chunks"); + if(rdcc->w0 < 0) + rdcc->w0 = H5F_RDCC_W0(f); + + /* If nbytes or nslots is 0, set them both to 0 and avoid allocating space */ + if(!rdcc->nbytes || !rdcc->nslots) + rdcc->nbytes = rdcc->nslots = 0; + else { + rdcc->slot = H5FL_SEQ_CALLOC(H5D_rdcc_ent_ptr_t, rdcc->nslots); + if(NULL == rdcc->slot) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") /* Reset any cached chunk info for this dataset */ H5D_chunk_cinfo_cache_reset(&(rdcc->last)); - } /* end if */ + } /* end else */ /* Compose chunked index info struct */ idx_info.f = f; @@ -2252,7 +2273,7 @@ H5D_chunk_cache_prune(const H5D_t *dset, hid_t dxpl_id, * begins. The pointers participating in the list traversal are each * given a chance at preemption before any of the pointers are advanced. */ - w[0] = (int)(rdcc->nused * H5F_RDCC_W0(dset->oloc.file)); + w[0] = (int)(rdcc->nused * rdcc->w0); p[0] = rdcc->head; p[1] = NULL; diff --git a/src/H5Dcompact.c b/src/H5Dcompact.c index 8469442..c48dee4 100644 --- a/src/H5Dcompact.c +++ b/src/H5Dcompact.c @@ -57,7 +57,7 @@ /********************/ /* Layout operation callbacks */ -static herr_t H5D_compact_new(H5F_t *f, hid_t dxpl_id, H5D_t *dset, +static herr_t H5D_compact_new(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, const H5P_genplist_t *dc_plist); static herr_t H5D_compact_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, @@ -165,7 +165,7 @@ done: */ /* ARGSUSED */ static herr_t -H5D_compact_new(H5F_t *f, hid_t UNUSED dxpl_id, H5D_t *dset, +H5D_compact_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset, const H5P_genplist_t UNUSED *dc_plist) { hssize_t tmp_size; /* Temporary holder for raw data size */ diff --git a/src/H5Dcontig.c b/src/H5Dcontig.c index 01ee5e2..de79203 100644 --- a/src/H5Dcontig.c +++ b/src/H5Dcontig.c @@ -61,7 +61,7 @@ /********************/ /* Layout operation callbacks */ -static herr_t H5D_contig_new(H5F_t *f, hid_t dxpl_id, H5D_t *dset, +static herr_t H5D_contig_new(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, const H5P_genplist_t *dc_plist); static herr_t H5D_contig_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, @@ -371,7 +371,7 @@ H5D_contig_get_addr(const H5D_t *dset) */ /* ARGSUSED */ static herr_t -H5D_contig_new(H5F_t *f, hid_t UNUSED dxpl_id, H5D_t *dset, +H5D_contig_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset, const H5P_genplist_t UNUSED *dc_plist) { hssize_t tmp_size; /* Temporary holder for raw data size */ diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index b1f6586..5b0621e 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -209,6 +209,7 @@ H5Dopen1(hid_t loc_id, const char *name) H5O_loc_t oloc; /* Dataset object location */ H5O_type_t obj_type; /* Type of object at location */ hbool_t loc_found = FALSE; /* Location at 'name' found */ + hid_t dapl_id = H5P_DATASET_ACCESS_DEFAULT; /* dapl to use to open dataset */ hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datset */ hid_t ret_value; @@ -238,7 +239,7 @@ H5Dopen1(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") /* Open the dataset */ - if((dset = H5D_open(&dset_loc, dxpl_id)) == NULL) + if((dset = H5D_open(&dset_loc, dapl_id, dxpl_id)) == NULL) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open dataset") /* Register an atom for the dataset */ diff --git a/src/H5Defl.c b/src/H5Defl.c index 1fe0f37..2dcad4d 100644 --- a/src/H5Defl.c +++ b/src/H5Defl.c @@ -49,7 +49,7 @@ /********************/ /* Layout operation callbacks */ -static herr_t H5D_efl_new(H5F_t *f, hid_t dxpl_id, H5D_t *dset, +static herr_t H5D_efl_new(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, const H5P_genplist_t *dc_plist); static herr_t H5D_efl_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, @@ -107,7 +107,7 @@ const H5D_layout_ops_t H5D_LOPS_EFL[1] = {{ *------------------------------------------------------------------------- */ static herr_t -H5D_efl_new(H5F_t *f, hid_t UNUSED dxpl_id, H5D_t *dset, +H5D_efl_new(H5F_t *f, hid_t UNUSED dapl_id, hid_t UNUSED dxpl_id, H5D_t *dset, const H5P_genplist_t *dc_plist) { size_t dt_size; /* Size of datatype */ diff --git a/src/H5Dint.c b/src/H5Dint.c index aa91db5..02be08c 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -66,7 +66,7 @@ static herr_t H5D_init_type(H5F_t *file, const H5D_t *dset, hid_t type_id, static herr_t H5D_init_space(H5F_t *file, const H5D_t *dset, const H5S_t *space); static herr_t H5D_set_io_ops(H5D_t *dataset); static herr_t H5D_update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset); -static herr_t H5D_open_oid(H5D_t *dataset, hid_t dxpl_id); +static herr_t H5D_open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id); static herr_t H5D_flush_real(H5D_t *dataset, hid_t dxpl_id, unsigned flags); @@ -418,6 +418,7 @@ H5D_create_named(const H5G_loc_t *loc, const char *name, hid_t type_id, dcrt_info.type_id = type_id; dcrt_info.space = space; dcrt_info.dcpl_id = dcpl_id; + dcrt_info.dapl_id = dapl_id; /* Set up object creation information */ ocrt_info.obj_type = H5O_TYPE_DATASET; @@ -1001,7 +1002,7 @@ done: */ H5D_t * H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, - hid_t dxpl_id) + hid_t dapl_id, hid_t dxpl_id) { const H5T_t *type; /* Datatype for dataset */ H5D_t *new_dset = NULL; @@ -1128,7 +1129,7 @@ H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize I/O operations") /* Create the layout information for the new dataset */ - if((new_dset->shared->layout.ops->new)(file, dxpl_id, new_dset, dc_plist) < 0) + if((new_dset->shared->layout.ops->new)(file, dapl_id, dxpl_id, new_dset, dc_plist) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to initialize layout information") /* Indicate that the layout information was initialized */ @@ -1198,7 +1199,7 @@ done: *------------------------------------------------------------------------- */ H5D_t * -H5D_open(const H5G_loc_t *loc, hid_t dxpl_id) +H5D_open(const H5G_loc_t *loc, hid_t dapl_id, hid_t dxpl_id) { H5D_shared_t *shared_fo = NULL; H5D_t *dataset = NULL; @@ -1227,7 +1228,7 @@ H5D_open(const H5G_loc_t *loc, hid_t dxpl_id) H5E_clear_stack(NULL); /* Open the dataset object */ - if(H5D_open_oid(dataset, dxpl_id) < 0) + if(H5D_open_oid(dataset, dapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found") /* Add the dataset to the list of opened objects in the file */ @@ -1295,7 +1296,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5D_open_oid(H5D_t *dataset, hid_t dxpl_id) +H5D_open_oid(H5D_t *dataset, hid_t dapl_id, hid_t dxpl_id) { H5P_genplist_t *plist; /* Property list */ H5O_fill_t *fill_prop; /* Pointer to dataset's fill value info */ @@ -1411,7 +1412,7 @@ H5D_open_oid(H5D_t *dataset, hid_t dxpl_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set chunk size") /* Initialize the chunk cache for the dataset */ - if(H5D_chunk_init(dataset->oloc.file, dxpl_id, dataset) < 0) + if(H5D_chunk_init(dataset->oloc.file, dapl_id, dxpl_id, dataset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't initialize chunk cache") } break; diff --git a/src/H5Doh.c b/src/H5Doh.c index 5268075..88ab971 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -48,8 +48,8 @@ static void *H5O_dset_get_copy_file_udata(void); static void H5O_dset_free_copy_file_udata(void *); static htri_t H5O_dset_isa(H5O_t *loc); -static hid_t H5O_dset_open(const H5G_loc_t *obj_loc, hid_t dxpl_id, - hbool_t app_ref); +static hid_t H5O_dset_open(const H5G_loc_t *obj_loc, hid_t lapl_id, + hid_t dxpl_id, hbool_t app_ref); static void *H5O_dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id); static H5O_loc_t *H5O_dset_get_oloc(hid_t obj_id); @@ -220,17 +220,31 @@ done: *------------------------------------------------------------------------- */ static hid_t -H5O_dset_open(const H5G_loc_t *obj_loc, hid_t dxpl_id, hbool_t app_ref) +H5O_dset_open(const H5G_loc_t *obj_loc, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref) { H5D_t *dset = NULL; /* Dataset opened */ + htri_t isdapl; /* lapl_id is a dapl */ + hid_t dapl_id; /* dapl to use to open this dataset */ hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT(H5O_dset_open) HDassert(obj_loc); + /* If the lapl passed in is a dapl, use it. Otherwise, use the default dapl */ + if(lapl_id == H5P_DEFAULT) + isdapl = FALSE; + else + if((isdapl = H5P_isa_class(lapl_id, H5P_DATASET_ACCESS)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOMPARE, FAIL, "unable to compare property list classes") + + if(isdapl) + dapl_id = lapl_id; + else + dapl_id = H5P_DATASET_ACCESS_DEFAULT; + /* Open the dataset */ - if(NULL == (dset = H5D_open(obj_loc, dxpl_id))) + if(NULL == (dset = H5D_open(obj_loc, dapl_id, dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open dataset") /* Register an ID for the dataset */ @@ -274,7 +288,8 @@ H5O_dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id) HDassert(obj_loc); /* Create the the dqtaset */ - if(NULL == (dset = H5D_create(f, crt_info->type_id, crt_info->space, crt_info->dcpl_id, dxpl_id))) + if(NULL == (dset = H5D_create(f, crt_info->type_id, crt_info->space, + crt_info->dcpl_id, crt_info->dapl_id, dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") /* Set up the new dataset's location */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 09a3c2c..bbd3a42 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -100,7 +100,7 @@ struct H5D_io_info_t; struct H5D_chunk_map_t; /* Function pointers for I/O on particular types of dataset layouts */ -typedef herr_t (*H5D_layout_new_func_t)(H5F_t *f, hid_t dxpl_id, +typedef herr_t (*H5D_layout_new_func_t)(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, H5D_t *dset, const H5P_genplist_t *dc_plist); typedef herr_t (*H5D_layout_io_init_func_t)(const struct H5D_io_info_t *io_info, const H5D_type_info_t *type_info, @@ -358,6 +358,7 @@ typedef struct H5D_rdcc_t { } stats; size_t nbytes; /* Current cached raw data in bytes */ size_t nslots; /* Number of chunk slots allocated */ + double w0; /* Chunk preemption policy */ struct H5D_rdcc_ent_t *head; /* Head of doubly linked list */ struct H5D_rdcc_ent_t *tail; /* Tail of doubly linked list */ int nused; /* Number of chunk slots in use */ @@ -426,6 +427,7 @@ typedef struct { hid_t type_id; /* Datatype for dataset */ const H5S_t *space; /* Dataspace for dataset */ hid_t dcpl_id; /* Dataset creation property list */ + hid_t dapl_id; /* Dataset access property list */ } H5D_obj_create_t; /* Typedef for filling a buffer with a fill value */ @@ -502,7 +504,7 @@ H5_DLLVAR const H5D_chunk_ops_t H5D_COPS_ISTORE[1]; /******************************/ H5_DLL H5D_t *H5D_create(H5F_t *file, hid_t type_id, const H5S_t *space, - hid_t dcpl_id, hid_t dxpl_id); + hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id); H5_DLL H5D_t *H5D_create_named(const H5G_loc_t *loc, const char *name, hid_t type_id, const H5S_t *space, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id); @@ -563,7 +565,7 @@ H5_DLL herr_t H5D_contig_copy(H5F_t *f_src, const H5O_layout_t *layout_src, H5F_ H5_DLL hbool_t H5D_chunk_cacheable(const H5D_io_info_t *io_info, haddr_t caddr); H5_DLL herr_t H5D_chunk_cinfo_cache_reset(H5D_chunk_cached_t *last); H5_DLL herr_t H5D_chunk_create(H5D_t *dset /*in,out*/, hid_t dxpl_id); -H5_DLL herr_t H5D_chunk_init(H5F_t *f, hid_t dxpl_id, const H5D_t *dset); +H5_DLL herr_t H5D_chunk_init(H5F_t *f, hid_t dapl_id, hid_t dxpl_id, const H5D_t *dset); H5_DLL herr_t H5D_chunk_get_info(const H5D_t *dset, hid_t dxpl_id, const hsize_t *chunk_offset, H5D_chunk_ud_t *udata); H5_DLL void *H5D_chunk_lock(const H5D_io_info_t *io_info, diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index dcf3aa3..63aadbb 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -50,6 +50,11 @@ #define H5D_CRT_EXT_FILE_LIST_NAME "efl" /* External file list */ #define H5D_CRT_DATA_PIPELINE_NAME "pline" /* Data filter pipeline */ +/* ======== Dataset access property names ======== */ +#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 */ + /* ======== Data transfer properties ======== */ #define H5D_XFER_MAX_TEMP_BUF_NAME "max_temp_buf" /* Maximum temp buffer size */ #define H5D_XFER_TCONV_BUF_NAME "tconv_buf" /* Type conversion buffer */ @@ -143,7 +148,7 @@ typedef struct H5D_dcpl_cache_t { /******************************/ H5_DLL herr_t H5D_init(void); -H5_DLL H5D_t *H5D_open(const H5G_loc_t *loc, hid_t dxpl_id); +H5_DLL H5D_t *H5D_open(const H5G_loc_t *loc, hid_t dapl_id, hid_t dxpl_id); H5_DLL herr_t H5D_close(H5D_t *dataset); H5_DLL H5O_loc_t *H5D_oloc(H5D_t *dataset); H5_DLL H5G_name_t *H5D_nameof(H5D_t *dataset); diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index 6c589e3..636c449 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -29,6 +29,11 @@ /* Public Macros */ /*****************/ +/* Macros used to "unset" chunk cache configuration parameters */ +#define H5D_CHUNK_CACHE_NSLOTS_DEFAULT ((size_t) -1) +#define H5D_CHUNK_CACHE_NBYTES_DEFAULT ((size_t) -1) +#define H5D_CHUNK_CACHE_W0_DEFAULT -1. + /*******************/ /* Public Typedefs */ /*******************/ @@ -101,6 +106,7 @@ H5_DLL hid_t H5Dget_space(hid_t dset_id); H5_DLL herr_t H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation); H5_DLL hid_t H5Dget_type(hid_t dset_id); H5_DLL hid_t H5Dget_create_plist(hid_t dset_id); +H5_DLL hid_t H5Dget_access_plist(hid_t dset_id); H5_DLL hsize_t H5Dget_storage_size(hid_t dset_id); H5_DLL haddr_t H5Dget_offset(hid_t dset_id); H5_DLL herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, @@ -310,8 +310,8 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) /* Copy properties of the file access property list */ if(H5P_set(new_plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, &(f->shared->mdc_initCacheCfg)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set initial metadata cache resize config.") - if(H5P_set(new_plist, H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME, &(f->shared->rdcc_nelmts)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache element size") + if(H5P_set(new_plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(f->shared->rdcc_nslots)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache number of slots") if(H5P_set(new_plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set data cache byte size") if(H5P_set(new_plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0) @@ -923,10 +923,10 @@ H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not file access property list") if(H5P_get(plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, &(f->shared->mdc_initCacheCfg)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get initial metadata cache resize config") - if(H5P_get(plist, H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME, &(f->shared->rdcc_nelmts)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get data cache element size") + if(H5P_get(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(f->shared->rdcc_nslots)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get data cache number of slots") if(H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get data cache cache size") + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get data cache byte size") if(H5P_get(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get preempt read chunk") if(H5P_get(plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold)) < 0) diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 428b58d..cc74a80 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -145,7 +145,7 @@ typedef struct H5F_file_t { /* not change thereafter. */ hid_t fcpl_id; /* File creation property list ID */ H5F_close_degree_t fc_degree; /* File close behavior degree */ - size_t rdcc_nelmts; /* Size of raw data chunk cache (elmts) */ + size_t rdcc_nslots; /* Size of raw data chunk cache (slots) */ size_t rdcc_nbytes; /* Size of raw data chunk cache (bytes) */ double rdcc_w0; /* Preempt read chunks first? [0.0..1.0]*/ size_t sieve_buf_size; /* Size of the data sieve buffer allocated (in bytes) */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 7791296..338e83f 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -250,7 +250,7 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; #define H5F_SIZEOF_SIZE(F) ((F)->shared->sizeof_size) #define H5F_SYM_LEAF_K(F) ((F)->shared->sym_leaf_k) #define H5F_KVALUE(F,T) ((F)->shared->btree_k[(T)->id]) -#define H5F_RDCC_NELMTS(F) ((F)->shared->rdcc_nelmts) +#define H5F_RDCC_NSLOTS(F) ((F)->shared->rdcc_nslots) #define H5F_RDCC_NBYTES(F) ((F)->shared->rdcc_nbytes) #define H5F_RDCC_W0(F) ((F)->shared->rdcc_w0) #define H5F_BASE_ADDR(F) ((F)->shared->base_addr) @@ -271,7 +271,7 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; #define H5F_SIZEOF_SIZE(F) (H5F_sizeof_size(F)) #define H5F_SYM_LEAF_K(F) (H5F_sym_leaf_k(F)) #define H5F_KVALUE(F,T) (H5F_Kvalue(F,T)) -#define H5F_RDCC_NELMTS(F) (H5F_rdcc_nelmts(F)) +#define H5F_RDCC_NSLOTS(F) (H5F_rdcc_nslots(F)) #define H5F_RDCC_NBYTES(F) (H5F_rdcc_nbytes(F)) #define H5F_RDCC_W0(F) (H5F_rdcc_w0(F)) #define H5F_BASE_ADDR(F) (H5F_get_base_addr(F)) @@ -358,7 +358,7 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; /* ========= File Access properties ============ */ #define H5F_ACS_META_CACHE_INIT_CONFIG_NAME "mdc_initCacheCfg" /* Initial metadata cache resize configuration */ -#define H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME "rdcc_nelmts" /* Size of raw data chunk cache(elements) */ +#define H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME "rdcc_nslots" /* Size of raw data chunk cache(slots) */ #define H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME "rdcc_nbytes" /* Size of raw data chunk cache(bytes) */ #define H5F_ACS_PREEMPT_READ_CHUNKS_NAME "rdcc_w0" /* Preemption read chunks first */ #define H5F_ACS_ALIGN_THRHD_NAME "threshold" /* Threshold for alignment */ @@ -477,7 +477,7 @@ H5_DLL size_t H5F_sizeof_size(const H5F_t *f); H5_DLL unsigned H5F_sym_leaf_k(const H5F_t *f); H5_DLL unsigned H5F_Kvalue(const H5F_t *f, const struct H5B_class_t *type); H5_DLL size_t H5F_rdcc_nbytes(const H5F_t *f); -H5_DLL size_t H5F_rdcc_nelmts(const H5F_t *f); +H5_DLL size_t H5F_rdcc_nslots(const H5F_t *f); H5_DLL double H5F_rdcc_w0(const H5F_t *f); H5_DLL haddr_t H5F_get_base_addr(const H5F_t *f); H5_DLL struct H5RC_t *H5F_grp_btree_shared(const H5F_t *f); diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 3b93fb5..550a507 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -275,14 +275,14 @@ H5F_Kvalue(const H5F_t *f, const H5B_class_t *type) /*------------------------------------------------------------------------- - * Function: H5F_rdcc_nelmts + * Function: H5F_rdcc_nslots * - * Purpose: Replaced a macro to retrieve the raw data cache number of elments, + * Purpose: Replaced a macro to retrieve the raw data cache number of slots, * now that the generic properties are being used to store * the values. * * Return: Success: Non-negative, and the raw data cache number of - * of elemnts is returned. + * of slots is returned. * * Failure: Negative (should not happen) * @@ -293,15 +293,15 @@ H5F_Kvalue(const H5F_t *f, const H5B_class_t *type) *------------------------------------------------------------------------- */ size_t -H5F_rdcc_nelmts(const H5F_t *f) +H5F_rdcc_nslots(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_rdcc_nelmts) + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5F_rdcc_nslots) HDassert(f); HDassert(f->shared); - FUNC_LEAVE_NOAPI(f->shared->rdcc_nelmts) + FUNC_LEAVE_NOAPI(f->shared->rdcc_nslots) } /* end H5F_rdcc_nelmts() */ diff --git a/src/H5Goh.c b/src/H5Goh.c index 4f4b651..497badb 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -46,8 +46,8 @@ /********************/ static htri_t H5O_group_isa(H5O_t *loc); -static hid_t H5O_group_open(const H5G_loc_t *obj_loc, hid_t dxpl_id, - hbool_t app_ref); +static hid_t H5O_group_open(const H5G_loc_t *obj_loc, hid_t lapl_id, + hid_t dxpl_id, hbool_t app_ref); static void *H5O_group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id); static H5O_loc_t *H5O_group_get_oloc(hid_t obj_id); @@ -135,7 +135,7 @@ done: *------------------------------------------------------------------------- */ static hid_t -H5O_group_open(const H5G_loc_t *obj_loc, hid_t dxpl_id, hbool_t app_ref) +H5O_group_open(const H5G_loc_t *obj_loc, hid_t UNUSED lapl_id, hid_t dxpl_id, hbool_t app_ref) { H5G_t *grp = NULL; /* Group opened */ hid_t ret_value; /* Return value */ @@ -309,7 +309,7 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, loc_found = TRUE; /* Open the object */ - if((ret_value = H5O_open_by_loc(&obj_loc, H5AC_dxpl_id, TRUE)) < 0) + if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_dxpl_id, TRUE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") done: @@ -365,6 +365,7 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr) H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Location at 'name' found */ + hid_t lapl_id = H5P_LINK_ACCESS_DEFAULT; /* lapl to use to open this object */ hid_t ret_value = FAIL; FUNC_ENTER_API(H5Oopen_by_addr, FAIL) @@ -385,7 +386,7 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr) H5G_name_reset(obj_loc.path); /* objects opened through this routine don't have a path name */ /* Open the object */ - if((ret_value = H5O_open_by_loc(&obj_loc, H5AC_dxpl_id, TRUE)) < 0) + if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_dxpl_id, TRUE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") done: @@ -1286,7 +1287,7 @@ H5O_open_name(H5G_loc_t *loc, const char *name, hid_t lapl_id, hbool_t app_ref) loc_found = TRUE; /* Open the object */ - if((ret_value = H5O_open_by_loc(&obj_loc, H5AC_ind_dxpl_id, app_ref)) < 0) + if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_ind_dxpl_id, app_ref)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") done: @@ -1312,7 +1313,7 @@ done: *------------------------------------------------------------------------- */ hid_t -H5O_open_by_loc(const H5G_loc_t *obj_loc, hid_t dxpl_id, hbool_t app_ref) +H5O_open_by_loc(const H5G_loc_t *obj_loc, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref) { const H5O_obj_class_t *obj_class; /* Class of object for location */ hid_t ret_value; /* Return value */ @@ -1327,7 +1328,7 @@ H5O_open_by_loc(const H5G_loc_t *obj_loc, hid_t dxpl_id, hbool_t app_ref) /* Call the object class's 'open' routine */ HDassert(obj_class->open); - if((ret_value = obj_class->open(obj_loc, dxpl_id, app_ref)) < 0) + if((ret_value = obj_class->open(obj_loc, lapl_id, dxpl_id, app_ref)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") done: @@ -2803,7 +2804,7 @@ H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* Open the object */ /* (Takes ownership of the obj_loc information) */ - if((obj_id = H5O_open_by_loc(&obj_loc, dxpl_id, TRUE)) < 0) + if((obj_id = H5O_open_by_loc(&obj_loc, lapl_id, dxpl_id, TRUE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") /* Make callback for starting object */ diff --git a/src/H5Opkg.h b/src/H5Opkg.h index a36ef6f..f15198e 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -308,7 +308,7 @@ typedef struct H5O_obj_class_t { void *(*get_copy_file_udata)(void); /*retrieve user data for 'copy file' operation */ void (*free_copy_file_udata)(void *); /*free user data for 'copy file' operation */ htri_t (*isa)(H5O_t *); /*if a header matches an object class */ - hid_t (*open)(const H5G_loc_t *, hid_t, hbool_t ); /*open an object of this class */ + hid_t (*open)(const H5G_loc_t *, hid_t, hid_t, hbool_t ); /*open an object of this class */ void *(*create)(H5F_t *, void *, H5G_loc_t *, hid_t ); /*create an object of this class */ H5O_loc_t *(*get_oloc)(hid_t ); /*get the object header location for an object */ } H5O_obj_class_t; @@ -463,7 +463,7 @@ H5_DLLVAR const H5O_obj_class_t H5O_OBJ_DATATYPE[1]; /* Package-local function prototypes */ H5_DLL herr_t H5O_msg_flush(H5F_t *f, H5O_t *oh, H5O_mesg_t *mesg); H5_DLL herr_t H5O_flush_msgs(H5F_t *f, H5O_t *oh); -H5_DLL hid_t H5O_open_by_loc(const H5G_loc_t *obj_loc, hid_t dxpl_id, hbool_t app_ref); +H5_DLL hid_t H5O_open_by_loc(const H5G_loc_t *obj_loc, hid_t lapl_id, hid_t dxpl_id, hbool_t app_ref); H5_DLL herr_t H5O_delete_mesg(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh, H5O_mesg_t *mesg); H5_DLL const H5O_obj_class_t *H5O_obj_class_real(H5O_t *oh); diff --git a/src/H5Pdapl.c b/src/H5Pdapl.c new file mode 100644 index 0000000..eefcca6 --- /dev/null +++ b/src/H5Pdapl.c @@ -0,0 +1,271 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/*------------------------------------------------------------------------- + * + * Created: H5Pdapl.c + * October 27, 2008 + * Neil Fortner <nfortne2@hdfgroup.org> + * + * Purpose: Dataset access property list class routines + * + *------------------------------------------------------------------------- + */ + +/****************/ +/* Module Setup */ +/****************/ +#define H5P_PACKAGE /*suppress error about including H5Ppkg */ + + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ppkg.h" /* Property lists */ + + +/****************/ +/* Local Macros */ +/****************/ + +/* ========= Dataset Access properties ============ */ +/* Definitions for size of raw data chunk cache(slots) */ +#define H5D_ACS_DATA_CACHE_NUM_SLOTS_SIZE sizeof(size_t) +#define H5D_ACS_DATA_CACHE_NUM_SLOTS_DEF H5D_CHUNK_CACHE_NSLOTS_DEFAULT +/* Definition for size of raw data chunk cache(bytes) */ +#define H5D_ACS_DATA_CACHE_BYTE_SIZE_SIZE sizeof(size_t) +#define H5D_ACS_DATA_CACHE_BYTE_SIZE_DEF H5D_CHUNK_CACHE_NBYTES_DEFAULT +/* Definition for preemption read chunks first */ +#define H5D_ACS_PREEMPT_READ_CHUNKS_SIZE sizeof(double) +#define H5D_ACS_PREEMPT_READ_CHUNKS_DEF H5D_CHUNK_CACHE_W0_DEFAULT + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + +/* Property class callbacks */ +static herr_t H5P_dacc_reg_prop(H5P_genclass_t *pclass); + + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Dataset access property list class library initialization object */ +const H5P_libclass_t H5P_CLS_DACC[1] = {{ + "dataset access", /* Class name for debugging */ + &H5P_CLS_LINK_ACCESS_g, /* Parent class ID */ + &H5P_CLS_DATASET_ACCESS_g, /* Pointer to class ID */ + &H5P_LST_DATASET_ACCESS_g, /* Pointer to default property list ID */ + H5P_dacc_reg_prop, /* Default property registration routine */ + NULL, /* Class creation callback */ + NULL, /* Class creation callback info */ + NULL, /* Class copy callback */ + NULL, /* Class copy callback info */ + NULL, /* Class close callback */ + NULL /* Class close callback info */ +}}; + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*------------------------------------------------------------------------- + * Function: H5P_dacc_reg_prop + * + * Purpose: Register the dataset access property list class's + * properties + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * October 27, 2008 + *------------------------------------------------------------------------- + */ +static herr_t +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 */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5P_dacc_reg_prop) + + /* Register the size of raw data chunk cache (elements) */ + if(H5P_register(pclass, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5D_ACS_DATA_CACHE_NUM_SLOTS_SIZE, &rdcc_nslots, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register the size of raw data chunk cache(bytes) */ + if(H5P_register(pclass, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, H5D_ACS_DATA_CACHE_BYTE_SIZE_SIZE, &rdcc_nbytes, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register the preemption for reading chunks */ + if(H5P_register(pclass, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, H5D_ACS_PREEMPT_READ_CHUNKS_SIZE, &rdcc_w0, NULL, NULL, NULL, 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() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_chunk_cache + * + * Purpose: Set the number of objects in the meta data cache and the + * maximum number of chunks and bytes in the raw data chunk cache. + * Once set, these values will override the values in the file access + * property list. Each of thhese values can be individually unset + * (or not set at all) by passing the macros: + * H5D_CHUNK_CACHE_NCHUNKS_DEFAULT, + * H5D_CHUNK_CACHE_NBYTES_DEFAULT, and/or + * H5D_CHUNK_CACHE_W0_DEFAULT + * as appropriate. + * + * The RDCC_W0 value should be between 0 and 1 inclusive and + * indicates how much chunks that have been fully read or fully + * written are favored for preemption. A value of zero means + * fully read or written chunks are treated no differently than + * other chunks (the preemption is strictly LRU) while a value + * of one means fully read chunks are always preempted before + * other chunks. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * Monday, October 27, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(H5Pset_chunk_cache, FAIL); + + /* Check arguments. Note that we allow negative values - they are + * considered to "unset" the property. */ + if (rdcc_w0 > 1.0) + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "raw data cache w0 value must be between 0.0 and 1.0 inclusive, or H5D_CHUNK_CACHE_W0_DEFAULT"); + + /* Get the plist structure */ + if (NULL == (plist = H5P_object_verify(dapl_id,H5P_DATASET_ACCESS))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + + /* Set sizes */ + if (H5P_set(plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache number of chunks"); + if (H5P_set(plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache byte size"); + if (H5P_set(plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set preempt read chunks"); + +done: + FUNC_LEAVE_API(ret_value); +} + + +/*------------------------------------------------------------------------- + * Function: H5Pget_chunk_cache + * + * Purpose: Retrieves the maximum possible number of elements in the meta + * data cache and the maximum possible number of elements and + * bytes and the RDCC_W0 value in the raw data chunk cache. Any + * (or all) arguments may be null pointers in which case the + * corresponding datum is not returned. If these properties have + * not been set on this property list, the default values for a + * file access property list are returned. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * Monday, October 27, 2008 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_chunk_cache(hid_t dapl_id, size_t *rdcc_nslots, size_t *rdcc_nbytes, double *rdcc_w0) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5P_genplist_t *def_plist; /* Default file access property list */ + herr_t ret_value = SUCCEED; /* return value */ + + FUNC_ENTER_API(H5Pget_chunk_cache, FAIL); + + /* Get the plist structure */ + if (NULL == (plist = H5P_object_verify(dapl_id, H5P_DATASET_ACCESS))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + + /* Get default file access plist */ + if (NULL == (def_plist = (H5P_genplist_t *)H5I_object(H5P_FILE_ACCESS_DEFAULT))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for default fapl ID"); + + /* Get the properties. If a property is set to the default value, the value + * from the default fapl is used. */ + if (rdcc_nslots) { + if (H5P_get(plist, H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME, rdcc_nslots) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache number of slots"); + if (*rdcc_nslots == H5D_CHUNK_CACHE_NSLOTS_DEFAULT) + if (H5P_get(def_plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, rdcc_nslots) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get default data cache number of slots"); + } /* end if */ + if (rdcc_nbytes) { + if (H5P_get(plist, H5D_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache byte size"); + if (*rdcc_nbytes == H5D_CHUNK_CACHE_NBYTES_DEFAULT) + if (H5P_get(def_plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get default data cache byte size"); + } /* end if */ + if (rdcc_w0) { + if (H5P_get(plist, H5D_ACS_PREEMPT_READ_CHUNKS_NAME, rdcc_w0) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get preempt read chunks"); + if (*rdcc_w0 < 0) + if (H5P_get(def_plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, rdcc_w0) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get default preempt read chunks"); + } /* end if */ + +done: + FUNC_LEAVE_API(ret_value); +} diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 8d8177a..c51f750 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -57,9 +57,9 @@ /* Definitions for the initial metadata cache resize configuration */ #define H5F_ACS_META_CACHE_INIT_CONFIG_SIZE sizeof(H5AC_cache_config_t) #define H5F_ACS_META_CACHE_INIT_CONFIG_DEF H5AC__DEFAULT_CACHE_CONFIG -/* Definitions for size of raw data chunk cache(elements) */ -#define H5F_ACS_DATA_CACHE_ELMT_SIZE_SIZE sizeof(size_t) -#define H5F_ACS_DATA_CACHE_ELMT_SIZE_DEF 521 +/* Definitions for size of raw data chunk cache(slots) */ +#define H5F_ACS_DATA_CACHE_NUM_SLOTS_SIZE sizeof(size_t) +#define H5F_ACS_DATA_CACHE_NUM_SLOTS_DEF 521 /* Definition for size of raw data chunk cache(bytes) */ #define H5F_ACS_DATA_CACHE_BYTE_SIZE_SIZE sizeof(size_t) #define H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF (1024*1024) @@ -187,7 +187,7 @@ static herr_t H5P_facc_reg_prop(H5P_genclass_t *pclass) { H5AC_cache_config_t mdc_initCacheCfg = H5F_ACS_META_CACHE_INIT_CONFIG_DEF; /* Default metadata cache settings */ - size_t rdcc_nelmts = H5F_ACS_DATA_CACHE_ELMT_SIZE_DEF; /* Default raw data chunk cache # of elements */ + size_t rdcc_nslots = H5F_ACS_DATA_CACHE_NUM_SLOTS_DEF; /* Default raw data chunk cache # of slots */ size_t rdcc_nbytes = H5F_ACS_DATA_CACHE_BYTE_SIZE_DEF; /* Default raw data chunk cache # of bytes */ double rdcc_w0 = H5F_ACS_PREEMPT_READ_CHUNKS_DEF; /* Default raw data chunk cache dirty ratio */ hsize_t threshold = H5F_ACS_ALIGN_THRHD_DEF; /* Default allocation alignment threshold */ @@ -213,7 +213,7 @@ H5P_facc_reg_prop(H5P_genclass_t *pclass) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of raw data chunk cache (elements) */ - if(H5P_register(pclass, H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME, H5F_ACS_DATA_CACHE_ELMT_SIZE_SIZE, &rdcc_nelmts, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + if(H5P_register(pclass, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, H5F_ACS_DATA_CACHE_NUM_SLOTS_SIZE, &rdcc_nslots, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the size of raw data chunk cache(bytes) */ @@ -1213,13 +1213,13 @@ done: */ herr_t H5Pset_cache(hid_t plist_id, int UNUSED mdc_nelmts, - size_t rdcc_nelmts, size_t rdcc_nbytes, double rdcc_w0) + size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_cache, FAIL); - H5TRACE5("e", "iIszzd", plist_id, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, + H5TRACE5("e", "iIszzd", plist_id, mdc_nelmts, rdcc_nslots, rdcc_nbytes, rdcc_w0); /* Check arguments */ @@ -1231,8 +1231,8 @@ H5Pset_cache(hid_t plist_id, int UNUSED mdc_nelmts, HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set sizes */ - if(H5P_set(plist, H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME, &rdcc_nelmts) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache element size"); + if(H5P_set(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &rdcc_nslots) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache number of slots"); if(H5P_set(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &rdcc_nbytes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET,FAIL, "can't set data cache byte size"); if(H5P_set(plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &rdcc_w0) < 0) @@ -1273,13 +1273,13 @@ done: */ herr_t H5Pget_cache(hid_t plist_id, int *mdc_nelmts, - size_t *rdcc_nelmts, size_t *rdcc_nbytes, double *rdcc_w0) + size_t *rdcc_nslots, size_t *rdcc_nbytes, double *rdcc_w0) { H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ FUNC_ENTER_API(H5Pget_cache, FAIL); - H5TRACE5("e", "i*Is*z*z*d", plist_id, mdc_nelmts, rdcc_nelmts, rdcc_nbytes, + H5TRACE5("e", "i*Is*z*z*d", plist_id, mdc_nelmts, rdcc_nslots, rdcc_nbytes, rdcc_w0); /* Get the plist structure */ @@ -1292,9 +1292,9 @@ H5Pget_cache(hid_t plist_id, int *mdc_nelmts, if (mdc_nelmts) *mdc_nelmts = 0; - if (rdcc_nelmts) - if(H5P_get(plist, H5F_ACS_DATA_CACHE_ELMT_SIZE_NAME, rdcc_nelmts) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache element size"); + if (rdcc_nslots) + if(H5P_get(plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, rdcc_nslots) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache number of slots"); if (rdcc_nbytes) if(H5P_get(plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, rdcc_nbytes) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get data cache byte size"); diff --git a/src/H5Pint.c b/src/H5Pint.c index e522010..b8c7b4c 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -142,22 +142,6 @@ const H5P_libclass_t H5P_CLS_GACC[1] = {{ NULL /* Class close callback info */ }}; -/* Dataset access property list class library initialization object */ -/* (move to proper source code file when used for real) */ -const H5P_libclass_t H5P_CLS_DACC[1] = {{ - "dataset access", /* Class name for debugging */ - &H5P_CLS_LINK_ACCESS_g, /* Parent class ID */ - &H5P_CLS_DATASET_ACCESS_g, /* Pointer to class ID */ - &H5P_LST_DATASET_ACCESS_g, /* Pointer to default property list ID */ - NULL, /* Default property registration routine */ - NULL, /* Class creation callback */ - NULL, /* Class creation callback info */ - NULL, /* Class copy callback */ - NULL, /* Class copy callback info */ - NULL, /* Class close callback */ - NULL /* Class close callback info */ -}}; - /* Datatype creation property list class library initialization object */ /* (move to proper source code file when used for real) */ const H5P_libclass_t H5P_CLS_TCRT[1] = {{ @@ -200,6 +184,7 @@ H5_DLLVAR const H5P_libclass_t H5P_CLS_OCPY[1]; /* Object copy */ H5_DLLVAR const H5P_libclass_t H5P_CLS_FCRT[1]; /* File creation */ H5_DLLVAR const H5P_libclass_t H5P_CLS_FACC[1]; /* File access */ H5_DLLVAR const H5P_libclass_t H5P_CLS_DCRT[1]; /* Dataset creation */ +H5_DLLVAR const H5P_libclass_t H5P_CLS_DACC[1]; /* Dataset access */ H5_DLLVAR const H5P_libclass_t H5P_CLS_DXFR[1]; /* Data transfer */ H5_DLLVAR const H5P_libclass_t H5P_CLS_FMNT[1]; /* File mount */ H5_DLLVAR const H5P_libclass_t H5P_CLS_ACRT[1]; /* Attribute creation */ diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 0e4e8d3..498eecc 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -245,11 +245,11 @@ H5_DLL herr_t H5Pget_family_offset(hid_t fapl_id, hsize_t *offset); H5_DLL herr_t H5Pset_multi_type(hid_t fapl_id, H5FD_mem_t type); H5_DLL herr_t H5Pget_multi_type(hid_t fapl_id, H5FD_mem_t *type); H5_DLL herr_t H5Pset_cache(hid_t plist_id, int mdc_nelmts, - size_t rdcc_nelmts, size_t rdcc_nbytes, + size_t rdcc_nslots, size_t rdcc_nbytes, double rdcc_w0); H5_DLL herr_t H5Pget_cache(hid_t plist_id, int *mdc_nelmts, /* out */ - size_t *rdcc_nelmts/*out*/, + size_t *rdcc_nslots/*out*/, size_t *rdcc_nbytes/*out*/, double *rdcc_w0); H5_DLL herr_t H5Pset_mdc_config(hid_t plist_id, H5AC_cache_config_t * config_ptr); @@ -319,6 +319,14 @@ H5_DLL herr_t H5Pset_fill_time(hid_t plist_id, H5D_fill_time_t fill_time); H5_DLL herr_t H5Pget_fill_time(hid_t plist_id, H5D_fill_time_t *fill_time/*out*/); +/* Dataset access property list (DAPL) routines */ +H5_DLL herr_t H5Pset_chunk_cache(hid_t dapl_id, size_t rdcc_nslots, + size_t rdcc_nbytes, double rdcc_w0); +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*/); + /* Dataset xfer property list (DXPL) routines */ H5_DLL herr_t H5Pset_data_transform(hid_t plist_id, const char* expression); H5_DLL ssize_t H5Pget_data_transform(hid_t plist_id, char* expression /*out*/, size_t size); @@ -461,10 +461,11 @@ H5R_dereference(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_re case H5O_TYPE_DATASET: { + hid_t dapl_id = H5P_DATASET_ACCESS_DEFAULT; /* dapl to use to open dataset */ H5D_t *dset; /* Pointer to dataset to open */ /* Open the dataset */ - if(NULL == (dset = H5D_open(&loc, dxpl_id))) + if(NULL == (dset = H5D_open(&loc, dapl_id, dxpl_id))) HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") /* Create an atom for the dataset */ diff --git a/src/H5Toh.c b/src/H5Toh.c index 1ab95f2..24fc0f1 100644 --- a/src/H5Toh.c +++ b/src/H5Toh.c @@ -46,8 +46,8 @@ /********************/ static htri_t H5O_dtype_isa(H5O_t *loc); -static hid_t H5O_dtype_open(const H5G_loc_t *obj_loc, hid_t dxpl_id, - hbool_t app_ref); +static hid_t H5O_dtype_open(const H5G_loc_t *obj_loc, hid_t lapl_id, + hid_t dxpl_id, hbool_t app_ref); static void *H5O_dtype_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc, hid_t dxpl_id); static H5O_loc_t *H5O_dtype_get_oloc(hid_t obj_id); @@ -128,7 +128,7 @@ done: *------------------------------------------------------------------------- */ static hid_t -H5O_dtype_open(const H5G_loc_t *obj_loc, hid_t dxpl_id, hbool_t app_ref) +H5O_dtype_open(const H5G_loc_t *obj_loc, hid_t UNUSED lapl_id, hid_t dxpl_id, hbool_t app_ref) { H5T_t *type = NULL; /* Datatype opened */ hid_t ret_value; /* Return value */ diff --git a/src/Makefile.am b/src/Makefile.am index 3f6c1bb..ccdb189 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -81,7 +81,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Oname.c H5Onull.c H5Opline.c H5Orefcount.c \ H5Osdspace.c H5Oshared.c H5Ostab.c \ H5Oshmesg.c H5Otest.c H5Ounknown.c \ - H5P.c H5Pacpl.c H5Pdcpl.c \ + H5P.c H5Pacpl.c H5Pdapl.c H5Pdcpl.c \ H5Pdeprec.c H5Pdxpl.c H5Pfapl.c H5Pfcpl.c H5Pfmpl.c \ H5Pgcpl.c H5Pint.c \ H5Plapl.c H5Plcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c H5Ptest.c \ diff --git a/src/Makefile.in b/src/Makefile.in index 7ac3590..03c463d 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -111,20 +111,20 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5Olink.lo H5Omessage.lo H5Omtime.lo H5Oname.lo H5Onull.lo \ H5Opline.lo H5Orefcount.lo H5Osdspace.lo H5Oshared.lo \ H5Ostab.lo H5Oshmesg.lo H5Otest.lo H5Ounknown.lo H5P.lo \ - H5Pacpl.lo H5Pdcpl.lo H5Pdeprec.lo H5Pdxpl.lo H5Pfapl.lo \ - H5Pfcpl.lo H5Pfmpl.lo H5Pgcpl.lo H5Pint.lo H5Plapl.lo \ - H5Plcpl.lo H5Pocpl.lo H5Pocpypl.lo H5Pstrcpl.lo H5Ptest.lo \ - H5R.lo H5Rdeprec.lo H5RC.lo H5RS.lo H5S.lo H5Sall.lo H5Sdbg.lo \ - H5Shyper.lo H5Smpio.lo H5Snone.lo H5Spoint.lo H5Sselect.lo \ - H5Stest.lo H5SL.lo H5SM.lo H5SMbtree2.lo H5SMcache.lo \ - H5SMtest.lo H5ST.lo H5T.lo H5Tarray.lo H5Tbit.lo H5Tcommit.lo \ - H5Tcompound.lo H5Tconv.lo H5Tcset.lo H5Tdbg.lo H5Tdeprec.lo \ - H5Tenum.lo H5Tfields.lo H5Tfixed.lo H5Tfloat.lo H5Tinit.lo \ - H5Tnative.lo H5Toffset.lo H5Toh.lo H5Topaque.lo H5Torder.lo \ - H5Tpad.lo H5Tprecis.lo H5Tstrpad.lo H5Tvisit.lo H5Tvlen.lo \ - H5TS.lo H5V.lo H5WB.lo H5Z.lo H5Zdeflate.lo H5Zfletcher32.lo \ - H5Znbit.lo H5Zshuffle.lo H5Zszip.lo H5Zscaleoffset.lo \ - H5Ztrans.lo + H5Pacpl.lo H5Pdapl.lo H5Pdcpl.lo H5Pdeprec.lo H5Pdxpl.lo \ + H5Pfapl.lo H5Pfcpl.lo H5Pfmpl.lo H5Pgcpl.lo H5Pint.lo \ + H5Plapl.lo H5Plcpl.lo H5Pocpl.lo H5Pocpypl.lo H5Pstrcpl.lo \ + H5Ptest.lo H5R.lo H5Rdeprec.lo H5RC.lo H5RS.lo H5S.lo \ + H5Sall.lo H5Sdbg.lo H5Shyper.lo H5Smpio.lo H5Snone.lo \ + H5Spoint.lo H5Sselect.lo H5Stest.lo H5SL.lo H5SM.lo \ + H5SMbtree2.lo H5SMcache.lo H5SMtest.lo H5ST.lo H5T.lo \ + H5Tarray.lo H5Tbit.lo H5Tcommit.lo H5Tcompound.lo H5Tconv.lo \ + H5Tcset.lo H5Tdbg.lo H5Tdeprec.lo H5Tenum.lo H5Tfields.lo \ + H5Tfixed.lo H5Tfloat.lo H5Tinit.lo H5Tnative.lo H5Toffset.lo \ + H5Toh.lo H5Topaque.lo H5Torder.lo H5Tpad.lo H5Tprecis.lo \ + H5Tstrpad.lo H5Tvisit.lo H5Tvlen.lo H5TS.lo H5V.lo H5WB.lo \ + H5Z.lo H5Zdeflate.lo H5Zfletcher32.lo H5Znbit.lo H5Zshuffle.lo \ + H5Zszip.lo H5Zscaleoffset.lo H5Ztrans.lo libhdf5_la_OBJECTS = $(am_libhdf5_la_OBJECTS) libhdf5_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \ @@ -464,7 +464,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Oname.c H5Onull.c H5Opline.c H5Orefcount.c \ H5Osdspace.c H5Oshared.c H5Ostab.c \ H5Oshmesg.c H5Otest.c H5Ounknown.c \ - H5P.c H5Pacpl.c H5Pdcpl.c \ + H5P.c H5Pacpl.c H5Pdapl.c H5Pdcpl.c \ H5Pdeprec.c H5Pdxpl.c H5Pfapl.c H5Pfcpl.c H5Pfmpl.c \ H5Pgcpl.c H5Pint.c \ H5Plapl.c H5Plcpl.c H5Pocpl.c H5Pocpypl.c H5Pstrcpl.c H5Ptest.c \ @@ -777,6 +777,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Ounknown.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5P.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Pacpl.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Pdapl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Pdcpl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Pdeprec.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Pdxpl.Plo@am__quote@ diff --git a/test/dsets.c b/test/dsets.c index 681f6ec..e3bac54 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -43,6 +43,7 @@ const char *FILENAME[] = { "set_local", "random_chunks", "huge_chunks", + "chunk_cache", NULL }; #define FILENAME_BUF_SIZE 1024 @@ -6474,6 +6475,214 @@ error: /*------------------------------------------------------------------------- + * Function: test_chunk_cache + * + * Purpose: Tests API for setting rdcc info on a DAPL, and interaction + * with the corresponding properties in the file structure. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Neil Fortner + * Wednesday, October 29, 2008 + * + *------------------------------------------------------------------------- + */ +static herr_t +test_chunk_cache(hid_t fapl) +{ + char filename[FILENAME_BUF_SIZE]; + hid_t fid = -1; /* File ID */ + hid_t fapl_local = -1; /* Local fapl */ + hid_t fapl_def = -1; /* Default fapl */ + hid_t dcpl = -1; /* Dataset creation property list ID */ + hid_t dapl1 = -1; /* Dataset access property list ID */ + hid_t dapl2 = -1; /* Dataset access property list ID */ + hid_t sid = -1; /* Dataspace ID */ + hid_t dsid = -1; /* Dataset ID */ + hsize_t dim, chunk_dim; /* Dataset and chunk dimensions */ + size_t nslots_1, nslots_2, nslots_3, nslots_4; /* rdcc number of elements */ + size_t nbytes_1, nbytes_2, nbytes_3, nbytes_4; /* rdcc number of bytes */ + size_t nlinks; /* Number of link traversals */ + double w0_1, w0_2, w0_3, w0_4; /* rdcc preemption policy */ + + TESTING("dataset chunk cache configuration"); + + /* Create a default fapl and dapl */ + if ((fapl_def = H5Pcreate(H5P_FILE_ACCESS)) < 0) FAIL_STACK_ERROR + if ((dapl1 = H5Pcreate(H5P_DATASET_ACCESS)) < 0) FAIL_STACK_ERROR + + /* Verify that H5Pget_chunk_cache(dapl) returns the same values as are in + * the default fapl. + */ + if (H5Pget_cache(fapl_def, NULL, &nslots_1, &nbytes_1, &w0_1) < 0) FAIL_STACK_ERROR + if (H5Pget_chunk_cache(dapl1, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR + if ((nslots_1 != nslots_4) || (nbytes_1 != nbytes_4) || !DBL_ABS_EQUAL(w0_1, w0_4)) + FAIL_PUTS_ERROR(" Cache values from default dapl do not match those from fapl.") + + /* Set a lapl property on dapl1 (to verify inheritance) */ + if (H5Pset_nlinks(dapl1, 134) < 0) FAIL_STACK_ERROR + if (H5Pget_nlinks(dapl1, &nlinks) < 0) FAIL_STACK_ERROR + if (nlinks != 134) + FAIL_PUTS_ERROR(" nlinks parameter not set properly on dapl.") + + /* Copy fapl passed to this function (as we will be modifying it) */ + if ((fapl_local = H5Pcopy(fapl)) < 0) FAIL_STACK_ERROR + + /* Set new rdcc settings on fapl */ + nslots_2 = nslots_1 * 2; + nbytes_2 = nbytes_1 * 2; + w0_2 = w0_1 / 2.; + if (H5Pset_cache(fapl_local, 0, nslots_2, nbytes_2, w0_2) < 0) FAIL_STACK_ERROR + + h5_fixname(FILENAME[8], fapl, filename, sizeof filename); + + /* Create file */ + if ((fid = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_local)) < 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 + + /* Create 1-D dataspace */ + dim = 100; + if ((sid = H5Screate_simple(1, &dim, NULL)) < 0) FAIL_STACK_ERROR + + /* Create dataset with default dapl */ + if ((dsid = H5Dcreate2(fid, "dset", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, dapl1)) < 0) + FAIL_STACK_ERROR + + /* Retrieve dapl from dataset, verfiy cache values are the same as on fapl_local */ + if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR + if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR + if ((nslots_2 != nslots_4) || (nbytes_2 != nbytes_4) || !DBL_ABS_EQUAL(w0_2, w0_4)) + FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from fapl.") + if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR + + /* Set new values on dapl1. nbytes will be set to default, so the file + * property will override this setting */ + nslots_3 = nslots_2 * 2; + nbytes_3 = H5D_CHUNK_CACHE_NBYTES_DEFAULT; + w0_3 = w0_2 / 2; + if (H5Pset_chunk_cache(dapl1, nslots_3, nbytes_3, w0_3) < 0) FAIL_STACK_ERROR + + /* Close dataset, reopen with dapl1. Note the use of a dapl with H5Oopen */ + if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if ((dsid = H5Oopen(fid, "dset", dapl1)) < 0) FAIL_STACK_ERROR + + /* Retrieve dapl from dataset, verfiy cache values are the same as on dapl1 */ + /* Note we rely on the knowledge that H5Pget_chunk_cache retrieves these + * values directly from the dataset structure, and not from a copy of the + * dapl used to open the dataset (which is not preserved). + */ + if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR + if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR + if ((nslots_3 != nslots_4) || (nbytes_2 != nbytes_4) || !DBL_ABS_EQUAL(w0_3, w0_4)) + FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from dapl1.") + if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR + + /* Close dataset, reopen with H5P_DEFAULT as dapl */ + if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if ((dsid = H5Dopen2(fid, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + + /* Retrieve dapl from dataset, verfiy cache values are the same on fapl_local */ + if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR + if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR + if ((nslots_2 != nslots_4) || (nbytes_2 != nbytes_4) || !DBL_ABS_EQUAL(w0_2, w0_4)) + FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from fapl.") + if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR + + /* Similary, test use of H5Dcreate2 with H5P_DEFAULT */ + if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if ((dsid = H5Dcreate2(fid, "dset2", H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR + if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR + if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR + if ((nslots_2 != nslots_4) || (nbytes_2 != nbytes_4) || !DBL_ABS_EQUAL(w0_2, w0_4)) + FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from fapl.") + /* Don't close dapl2, we will use it in the next section */ + + /* Modify cache values on fapl_local */ + nbytes_3 = nbytes_2 * 2; + if (H5Pset_cache(fapl_local, 0, nslots_3, nbytes_3, w0_3) < 0) FAIL_STACK_ERROR + + /* Close and reopen file with new fapl_local */ + if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR + if ((fid = H5Fopen(filename, H5F_ACC_RDWR, fapl_local)) < 0) FAIL_STACK_ERROR + + /* Verify that dapl2 retrieved earlier (using values from the old fapl) + * sets its values in the new file (test use of H5Dopen2 with a dapl) + */ + if ((dsid = H5Dopen2(fid, "dset", dapl2)) < 0) FAIL_STACK_ERROR + if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR /* Close dapl2, to avoid id leak */ + if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR + if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR + if ((nslots_2 != nslots_4) || (nbytes_2 != nbytes_4) || !DBL_ABS_EQUAL(w0_2, w0_4)) + FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from dapl2.") + + /* Test H5D_CHUNK_CACHE_NSLOTS_DEFAULT and H5D_CHUNK_CACHE_W0_DEFAULT */ + nslots_2 = H5D_CHUNK_CACHE_NSLOTS_DEFAULT; + w0_2 = H5D_CHUNK_CACHE_W0_DEFAULT; + if (H5Pset_chunk_cache(dapl2, nslots_2, nbytes_2, w0_2) < 0) FAIL_STACK_ERROR + + if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if ((dsid = H5Dopen2(fid, "dset", dapl2)) < 0) FAIL_STACK_ERROR + if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR /* Close dapl2, to avoid id leak */ + if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR + if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR + if ((nslots_3 != nslots_4) || (nbytes_2 != nbytes_4) || !DBL_ABS_EQUAL(w0_3, w0_4)) + FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those expected.") + if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR + + /* Verify that the file has indeed started using the new cache values (test + * use of H5Oopen with H5P_DEFAULT) */ + if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if ((dsid = H5Oopen(fid, "dset", H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if ((dapl2 = H5Dget_access_plist(dsid)) < 0) FAIL_STACK_ERROR + if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR + if ((nslots_3 != nslots_4) || (nbytes_3 != nbytes_4) || !DBL_ABS_EQUAL(w0_3, w0_4)) + FAIL_PUTS_ERROR(" Cache values from retrieved dapl do not match those from fapl.") + if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR + + /* Verify functionality of H5Pcopy with a dapl */ + if ((dapl2 = H5Pcopy(dapl1)) < 0) FAIL_STACK_ERROR + if (H5Pget_chunk_cache(dapl2, &nslots_4, &nbytes_4, &w0_4) < 0) FAIL_STACK_ERROR + if ((nslots_3 != nslots_4) || (nbytes_1 != nbytes_4) || !DBL_ABS_EQUAL(w0_3, w0_4)) + FAIL_PUTS_ERROR(" Cache values from dapl2 do not match those from dapl1.") + + /* Close */ + if (H5Dclose(dsid) < 0) FAIL_STACK_ERROR + if (H5Sclose(sid) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl_local) < 0) FAIL_STACK_ERROR + if (H5Pclose(fapl_def) < 0) FAIL_STACK_ERROR + if (H5Pclose(dapl1) < 0) FAIL_STACK_ERROR + if (H5Pclose(dapl2) < 0) FAIL_STACK_ERROR + if (H5Pclose(dcpl) < 0) FAIL_STACK_ERROR + if (H5Fclose(fid) < 0) FAIL_STACK_ERROR + + PASSED(); + return 0; + +error: + H5E_BEGIN_TRY { + H5Pclose(fapl_local); + H5Pclose(fapl_def); + H5Pclose(dapl1); + H5Pclose(dapl2); + H5Pclose(dcpl); + H5Dclose(dsid); + H5Sclose(sid); + H5Fclose(fid); + } H5E_END_TRY; + return -1; +} /* end test_chunk_cache() */ + + +/*------------------------------------------------------------------------- * Function: main * * Purpose: Tests the dataset interface (H5D) @@ -6593,6 +6802,7 @@ main(void) nerrors += (test_deprec(file) < 0 ? 1 : 0); #endif /* H5_NO_DEPRECATED_SYMBOLS */ nerrors += (test_huge_chunks(my_fapl) < 0 ? 1 : 0); + nerrors += (test_chunk_cache(my_fapl) < 0 ? 1 : 0); if(H5Fclose(file) < 0) goto error; |