summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2004-11-23 19:48:10 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2004-11-23 19:48:10 (GMT)
commit0535c9b048a090ae6cecf2b957e8d88e4e178d1a (patch)
tree26dc6db4613e2b574a57ab5557ff92448d0e2864 /src
parent56951d947c339184c7f9f78b2c804623a42e0678 (diff)
downloadhdf5-0535c9b048a090ae6cecf2b957e8d88e4e178d1a.zip
hdf5-0535c9b048a090ae6cecf2b957e8d88e4e178d1a.tar.gz
hdf5-0535c9b048a090ae6cecf2b957e8d88e4e178d1a.tar.bz2
[svn-r9563] 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
Diffstat (limited to 'src')
-rw-r--r--src/H5D.c41
-rw-r--r--src/H5Dprivate.h20
-rw-r--r--src/H5Pdcpl.c112
3 files changed, 134 insertions, 39 deletions
diff --git a/src/H5D.c b/src/H5D.c
index c388184..149c021 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -189,6 +189,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;
@@ -329,6 +330,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")
@@ -361,8 +366,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)
@@ -2193,25 +2196,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)
@@ -2594,6 +2581,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 */
@@ -2757,16 +2745,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 6987c40..4479c37 100644
--- a/src/H5Dprivate.h
+++ b/src/H5Dprivate.h
@@ -58,7 +58,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)
@@ -75,14 +78,6 @@
#define H5D_CRT_DATA_PIPELINE_CMP H5D_crt_data_pipeline_cmp
/* ======== Data transfer properties ======== */
-/* Definitions for data transform property */
-#define H5D_XFER_XFORM_NAME "data_transform"
-#define H5D_XFER_XFORM_SIZE sizeof(void *)
-#define H5D_XFER_XFORM_DEF NULL
-#define H5D_XFER_XFORM_DEL H5D_xfer_xform_del
-#define H5D_XFER_XFORM_COPY H5D_xfer_xform_copy
-#define H5D_XFER_XFORM_CLOSE H5D_xfer_xform_close
-
/* Definitions for maximum temp buffer size property */
#define H5D_XFER_MAX_TEMP_BUF_NAME "max_temp_buf"
#define H5D_XFER_MAX_TEMP_BUF_SIZE sizeof(size_t)
@@ -153,6 +148,13 @@
#define H5D_XFER_CONV_CB_NAME "type_conv_cb"
#define H5D_XFER_CONV_CB_SIZE sizeof(H5T_conv_cb_t)
#define H5D_XFER_CONV_CB_DEF {NULL,NULL}
+/* Definitions for data transform property */
+#define H5D_XFER_XFORM_NAME "data_transform"
+#define H5D_XFER_XFORM_SIZE sizeof(void *)
+#define H5D_XFER_XFORM_DEF NULL
+#define H5D_XFER_XFORM_DEL H5D_xfer_xform_del
+#define H5D_XFER_XFORM_COPY H5D_xfer_xform_copy
+#define H5D_XFER_XFORM_CLOSE H5D_xfer_xform_close
#ifdef H5_HAVE_INSTRUMENTED_LIBRARY
/* Definitions for collective chunk I/O property */
#define H5D_XFER_COLL_CHUNK_NAME "coll_chunk"
diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c
index 33edafc..a5e1c3a 100644
--- a/src/H5Pdcpl.c
+++ b/src/H5Pdcpl.c
@@ -30,6 +30,69 @@
/* 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() */
/*-------------------------------------------------------------------------
@@ -69,7 +132,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:
@@ -149,7 +212,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 */
@@ -178,13 +240,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);
@@ -1066,6 +1127,7 @@ done:
* Tuesday, April 1, 2003
*
* Modifications:
+ *
* Nat Furrer and James Laird
* June 30, 2004
* Now ensures that SZIP encoding is enabled
@@ -1504,6 +1566,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);
@@ -1513,9 +1576,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);