diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2004-11-23 19:48:15 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2004-11-23 19:48:15 (GMT) |
commit | aaf899f26c0907cb4a9628fceaecdafb0c85bb61 (patch) | |
tree | 81eff9b35507ab54cd469c1758057e58f3af0f43 | |
parent | 672d28883c738cd325f1f3020ffad787be14dbdb (diff) | |
download | hdf5-aaf899f26c0907cb4a9628fceaecdafb0c85bb61.zip hdf5-aaf899f26c0907cb4a9628fceaecdafb0c85bb61.tar.gz hdf5-aaf899f26c0907cb4a9628fceaecdafb0c85bb61.tar.bz2 |
[svn-r9564] Purpose:
Code optimization
Description:
Change how default allocation time is handled internally to the library,
to avoid some performance issues with property lists.
Platforms tested:
FreeBSD 4.10 (sleipnir) w/parallel
Solaris 2.7 (arabica)
Too minor to require h5committest
-rw-r--r-- | src/H5D.c | 41 | ||||
-rw-r--r-- | src/H5Dprivate.h | 5 | ||||
-rw-r--r-- | src/H5Pdcpl.c | 123 |
3 files changed, 132 insertions, 37 deletions
@@ -188,6 +188,7 @@ H5D_init_interface(void) size_t chunk_size[H5O_LAYOUT_NDIMS] = H5D_CRT_CHUNK_SIZE_DEF; H5O_fill_t fill = H5D_CRT_FILL_VALUE_DEF; H5D_alloc_time_t alloc_time = H5D_CRT_ALLOC_TIME_DEF; + unsigned alloc_time_state = H5D_CRT_ALLOC_TIME_STATE_DEF; H5D_fill_time_t fill_time = H5D_CRT_FILL_TIME_DEF; H5O_efl_t efl = H5D_CRT_EXT_FILE_LIST_DEF; H5O_pline_t pline = H5D_CRT_DATA_PIPELINE_DEF; @@ -330,6 +331,10 @@ H5D_init_interface(void) if(H5P_register(crt_pclass, H5D_CRT_ALLOC_TIME_NAME, H5D_CRT_ALLOC_TIME_SIZE, &alloc_time, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the space allocation time state property */ + if(H5P_register(crt_pclass, H5D_CRT_ALLOC_TIME_STATE_NAME, H5D_CRT_ALLOC_TIME_STATE_SIZE, &alloc_time_state, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the fill value writing time property */ if(H5P_register(crt_pclass, H5D_CRT_FILL_TIME_NAME, H5D_CRT_FILL_TIME_SIZE, &fill_time, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") @@ -362,8 +367,6 @@ H5D_init_interface(void) /* Set up the default allocation time information */ if(H5P_get(def_dcpl, H5D_CRT_ALLOC_TIME_NAME, &H5D_def_dset.alloc_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't retrieve space allocation time") - if(H5D_def_dset.alloc_time==H5D_ALLOC_TIME_DEFAULT) - H5D_def_dset.alloc_time=H5D_ALLOC_TIME_LATE; /* Get the default external file list information */ if(H5P_get(def_dcpl, H5D_CRT_EXT_FILE_LIST_NAME, &H5D_def_dset.efl) < 0) @@ -2081,25 +2084,9 @@ H5D_create(H5G_entry_t *loc, const char *name, hid_t type_id, const H5S_t *space if(H5P_get(dc_plist, H5D_CRT_ALLOC_TIME_NAME, &alloc_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't retrieve space allocation time") - /* Check if the alloc_time is the default and set it accordingly */ - if(alloc_time==H5D_ALLOC_TIME_DEFAULT) { - switch(dcpl_layout) { - case H5D_COMPACT: - alloc_time=H5D_ALLOC_TIME_EARLY; - break; - - case H5D_CONTIGUOUS: - alloc_time=H5D_ALLOC_TIME_LATE; - break; - - case H5D_CHUNKED: - alloc_time=H5D_ALLOC_TIME_INCR; - break; - - default: - HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet") - } /* end switch */ - } /* end if */ + /* Check if the alloc_time is the default and error out */ + if(alloc_time==H5D_ALLOC_TIME_DEFAULT) + HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL, "invalid space allocation state") /* Don't allow compact datasets to allocate space later */ if(dcpl_layout==H5D_COMPACT && alloc_time!=H5D_ALLOC_TIME_EARLY) @@ -2489,6 +2476,7 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id) { H5D_t *dataset = NULL; /*new dataset struct */ H5O_fill_new_t fill = {NULL, 0, NULL, H5D_ALLOC_TIME_LATE, H5D_CRT_FILL_TIME_DEF, TRUE}; + unsigned alloc_time_state; /* Allocation time state */ H5O_fill_t *fill_prop; /* Pointer to dataset's fill value area */ H5O_pline_t pline; /* I/O pipeline information */ H5P_genplist_t *plist; /* Property list */ @@ -2652,16 +2640,23 @@ H5D_open_oid(const H5G_entry_t *ent, hid_t dxpl_id) fill_prop->size = (size_t)-1; } } /* end else */ + alloc_time_state=0; + if( (dataset->shared->layout.type==H5D_COMPACT && fill.alloc_time==H5D_ALLOC_TIME_EARLY) + || (dataset->shared->layout.type==H5D_CONTIGUOUS && fill.alloc_time==H5D_ALLOC_TIME_LATE) + || (dataset->shared->layout.type==H5D_CHUNKED && fill.alloc_time==H5D_ALLOC_TIME_INCR)) + alloc_time_state=1; /* Set revised fill value properties */ if(H5P_set(plist, H5D_CRT_FILL_VALUE_NAME, fill_prop) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill value") dataset->shared->alloc_time=fill.alloc_time; /* Cache this for later */ if(H5P_set(plist, H5D_CRT_ALLOC_TIME_NAME, &fill.alloc_time) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill value") + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set allocation time") + if(H5P_set(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set allocation time state") dataset->shared->fill_time=fill.fill_time; /* Cache this for later */ if(H5P_set(plist, H5D_CRT_FILL_TIME_NAME, &fill.fill_time) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill value") + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set fill time") /* Get the external file list message, which might not exist. Space is * also undefined when space allocate time is H5D_ALLOC_TIME_LATE. */ diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 4c4ca09..82ba23c 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -57,7 +57,10 @@ /* Definitions for space allocation time */ #define H5D_CRT_ALLOC_TIME_NAME "alloc_time" #define H5D_CRT_ALLOC_TIME_SIZE sizeof(H5D_alloc_time_t) -#define H5D_CRT_ALLOC_TIME_DEF H5D_ALLOC_TIME_DEFAULT +#define H5D_CRT_ALLOC_TIME_DEF H5D_ALLOC_TIME_LATE +#define H5D_CRT_ALLOC_TIME_STATE_NAME "alloc_time_state" +#define H5D_CRT_ALLOC_TIME_STATE_SIZE sizeof(unsigned) +#define H5D_CRT_ALLOC_TIME_STATE_DEF 1 /* Definitions for time of fill value writing */ #define H5D_CRT_FILL_TIME_NAME "fill_time" #define H5D_CRT_FILL_TIME_SIZE sizeof(H5D_fill_time_t) diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index b3473fb..b08577f 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -14,6 +14,10 @@ #define H5P_PACKAGE /*suppress error about including H5Ppkg */ +/* Pablo information */ +/* (Put before include files to avoid problems with inline functions) */ +#define PABLO_MASK H5P_dcpl_mask + /* Private header files */ #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Datasets */ @@ -23,9 +27,6 @@ #include "H5Ppkg.h" /* Property lists */ #include "H5Zprivate.h" /* Data filters */ -/* Pablo mask */ -#define PABLO_MASK H5Pdcpl_mask - /* Interface initialization */ #define INTERFACE_INIT NULL static int interface_initialize_g = 0; @@ -33,6 +34,69 @@ static int interface_initialize_g = 0; /* Local datatypes */ /* Static function prototypes */ +static herr_t H5P_set_layout(H5P_genplist_t *plist, H5D_layout_t layout); + + +/*------------------------------------------------------------------------- + * Function: H5P_set_layout + * + * Purpose: Sets the layout of raw data in the file. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Tuesday, November 23, 2004 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P_set_layout(H5P_genplist_t *plist, H5D_layout_t layout) +{ + unsigned alloc_time_state; /* State of allocation time property */ + herr_t ret_value=SUCCEED; /* return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5P_set_layout); + + /* Get the allocation time state */ + if(H5P_get(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time"); + + /* If we still have the "default" allocation time, change it according to the new layout */ + if(alloc_time_state) { + H5D_alloc_time_t alloc_time; /* Space allocation time */ + + /* Set the default based on layout */ + switch(layout) { + case H5D_COMPACT: + alloc_time=H5D_ALLOC_TIME_EARLY; + break; + + case H5D_CONTIGUOUS: + alloc_time=H5D_ALLOC_TIME_LATE; + break; + + case H5D_CHUNKED: + alloc_time=H5D_ALLOC_TIME_INCR; + break; + + default: + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layou t type") + } /* end switch */ + + /* Set new allocation time */ + if(H5P_set(plist, H5D_CRT_ALLOC_TIME_NAME, &alloc_time) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocat ion time"); + } /* end if */ + + /* Set layout value */ + if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout"); + +done: + FUNC_LEAVE_NOAPI(ret_value); +} /* end H5P_set_layout() */ /*------------------------------------------------------------------------- @@ -72,7 +136,7 @@ H5Pset_layout(hid_t plist_id, H5D_layout_t layout) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); /* Set value */ - if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + if(H5P_set_layout (plist, layout) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout"); done: @@ -152,7 +216,6 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) { int i; size_t real_dims[H5O_LAYOUT_NDIMS]; /* Full-sized array to hold chunk dims */ - H5D_layout_t layout; H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value=SUCCEED; /* return value */ @@ -181,13 +244,12 @@ H5Pset_chunk(hid_t plist_id, int ndims, const hsize_t dim[/*ndims*/]) real_dims[i]=(size_t)dim[i]; /* Store user's chunk dimensions */ } /* end for */ - layout = H5D_CHUNKED; - if(H5P_set(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set layout"); + if(H5P_set_layout (plist, H5D_CHUNKED) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set layout"); if(H5P_set(plist, H5D_CRT_CHUNK_DIM_NAME, &ndims) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set chunk dimensionanlity"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set chunk dimensionanlity"); if(H5P_set(plist, H5D_CRT_CHUNK_SIZE_NAME, real_dims) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "can't set chunk size"); + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set chunk size"); done: FUNC_LEAVE_API(ret_value); @@ -881,7 +943,7 @@ H5Pget_filter_by_id(hid_t plist_id, H5Z_filter_t id, unsigned int *flags/*out*/, else name[0] = '\0'; } - + done: FUNC_LEAVE_API(ret_value); } /* end H5Pget_filter_by_id() */ @@ -1019,7 +1081,7 @@ H5Pset_szip(hid_t plist_id, unsigned options_mask, unsigned pixels_per_block) FUNC_ENTER_API(H5Pset_szip, FAIL); H5TRACE3("e","iIuIu",plist_id,options_mask,pixels_per_block); - + /* Check arguments */ #if !defined( H5_SZIP_CAN_ENCODE) && defined(H5_HAVE_FILTER_SZIP) HGOTO_ERROR (H5E_PLINE, H5E_NOENCODER, FAIL, "Szip filter present but encoding disabled"); @@ -1470,6 +1532,7 @@ herr_t H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time) { H5P_genplist_t *plist; /* Property list pointer */ + unsigned alloc_time_state; /* State of allocation time property */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_API(H5Pset_alloc_time, FAIL); @@ -1479,9 +1542,44 @@ H5Pset_alloc_time(hid_t plist_id, H5D_alloc_time_t alloc_time) if(NULL == (plist = H5P_object_verify(plist_id,H5P_DATASET_CREATE))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + /* Check for resetting to default for layout type */ + if(alloc_time==H5D_ALLOC_TIME_DEFAULT) { + H5D_layout_t layout; /* Type of storage layout */ + + /* Retrieve the storage layout */ + if(H5P_get(plist, H5D_CRT_LAYOUT_NAME, &layout) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get layout"); + + /* Set the default based on layout */ + switch(layout) { + case H5D_COMPACT: + alloc_time=H5D_ALLOC_TIME_EARLY; + break; + + case H5D_CONTIGUOUS: + alloc_time=H5D_ALLOC_TIME_LATE; + break; + + case H5D_CHUNKED: + alloc_time=H5D_ALLOC_TIME_INCR; + break; + + default: + HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL, "unknown layout type") + } /* end switch */ + + /* Reset the "state" of the allocation time property back to the "default" */ + alloc_time_state=1; + } /* end if */ + else + /* Set the "state" of the allocation time property to indicate the user modified it */ + alloc_time_state=0; + /* Set values */ if(H5P_set(plist, H5D_CRT_ALLOC_TIME_NAME, &alloc_time) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time"); + if(H5P_set(plist, H5D_CRT_ALLOC_TIME_STATE_NAME, &alloc_time_state) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set space allocation time"); done: FUNC_LEAVE_API(ret_value); @@ -1653,4 +1751,3 @@ H5Premove_filter(hid_t plist_id, H5Z_filter_t filter) done: FUNC_LEAVE_API(ret_value); } - |