summaryrefslogtreecommitdiffstats
path: root/src/H5Pfapl.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2017-01-29 07:19:37 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2017-01-29 07:19:37 (GMT)
commit1949d5756d424be0b23fc127fc99140374a7dd13 (patch)
treee7d368b8bbcb589e48e88c1b781b08e16655a832 /src/H5Pfapl.c
parent5a776edb8156c36d3a7e2f9e23c6fb349eaa90e0 (diff)
downloadhdf5-1949d5756d424be0b23fc127fc99140374a7dd13.zip
hdf5-1949d5756d424be0b23fc127fc99140374a7dd13.tar.gz
hdf5-1949d5756d424be0b23fc127fc99140374a7dd13.tar.bz2
Cache image feature and testing
Diffstat (limited to 'src/H5Pfapl.c')
-rw-r--r--src/H5Pfapl.c255
1 files changed, 255 insertions, 0 deletions
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index 91a0e03..7ea0fe0 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -225,6 +225,13 @@
#define H5F_ACS_COLL_MD_WRITE_FLAG_ENC H5P__encode_hbool_t
#define H5F_ACS_COLL_MD_WRITE_FLAG_DEC H5P__decode_hbool_t
#endif /* H5_HAVE_PARALLEL */
+/* Definitions for the initial metadata cache image configuration */
+#define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_SIZE sizeof(H5AC_cache_image_config_t)
+#define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEF H5AC__DEFAULT_CACHE_IMAGE_CONFIG
+#define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_ENC H5P__facc_cache_image_config_enc
+#define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEC H5P__facc_cache_image_config_dec
+#define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_CMP H5P__facc_cache_image_config_cmp
+
/******************/
/* Local Typedefs */
@@ -279,6 +286,11 @@ static herr_t H5P_facc_mdc_log_location_copy(const char *name, size_t size, void
static int H5P_facc_mdc_log_location_cmp(const void *value1, const void *value2, size_t size);
static herr_t H5P_facc_mdc_log_location_close(const char *name, size_t size, void *value);
+/* Metadata cache image property callbacks */
+static int H5P__facc_cache_image_config_cmp(const void *_config1, const void *_config2, size_t H5_ATTR_UNUSED size);
+static herr_t H5P__facc_cache_image_config_enc(const void *value, void **_pp, size_t *size);
+static herr_t H5P__facc_cache_image_config_dec(const void **_pp, void *_value);
+
/*********************/
/* Package Variables */
@@ -346,6 +358,7 @@ static const hbool_t H5F_def_evict_on_close_flag_g = H5F_ACS_EVICT_ON_CLOSE_FLAG
static const H5P_coll_md_read_flag_t H5F_def_coll_md_read_flag_g = H5F_ACS_COLL_MD_READ_FLAG_DEF; /* Default setting for the collective metedata read flag */
static const hbool_t H5F_def_coll_md_write_flag_g = H5F_ACS_COLL_MD_WRITE_FLAG_DEF; /* Default setting for the collective metedata write flag */
#endif /* H5_HAVE_PARALLEL */
+static const H5AC_cache_image_config_t H5F_def_mdc_initCacheImageCfg_g = H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEF; /* Default metadata cache image settings */
/*-------------------------------------------------------------------------
@@ -555,6 +568,12 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
#endif /* H5_HAVE_PARALLEL */
+ /* Register the initial metadata cache image configuration */
+ if(H5P_register_real(pclass, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_SIZE, &H5F_def_mdc_initCacheImageCfg_g,
+ NULL, NULL, NULL, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_ENC, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_DEC,
+ NULL, NULL, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_CMP, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P__facc_reg_prop() */
@@ -1543,6 +1562,101 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5Pset_mdc_image_config
+ *
+ * Purpose: Set the initial metadata cache image configuration in the
+ * target FAPL.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: J. Mainzer
+ * Thursday, June 25, 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pset_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr)
+{
+ H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "i*x", plist_id, config_ptr);
+
+ /* Get the plist structure */
+ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+
+ /* validate the new configuration */
+ if(H5AC_validate_cache_image_config(config_ptr) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid metadata cache image configuration")
+
+ /* set the modified metadata cache image config */
+
+ /* If we ever support multiple versions of H5AC_cache_image_config_t, we
+ * will have to test the version and do translation here.
+ */
+
+ if(H5P_set(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, config_ptr) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set metadata cache image initial config")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Pset_mdc_image_config() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pget_mdc_image_config
+ *
+ * Purpose: Retrieve the metadata cache initial image configuration
+ * from the target FAPL.
+ *
+ * Observe that the function will fail if config_ptr is
+ * NULL, or if config_ptr->version specifies an unknown
+ * version of H5AC_cache_image_config_t.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: J. Mainzer
+ * Friday, June 26, 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr)
+{
+ H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value = SUCCEED; /* return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "i*x", plist_id, config_ptr);
+
+ /* Get the plist structure */
+ if(NULL == (plist = H5P_object_verify(plist_id,H5P_FILE_ACCESS)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+
+ /* validate the config_ptr */
+ if(config_ptr == NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL config_ptr on entry.")
+
+ if(config_ptr->version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Unknown image config version.")
+
+ /* If we ever support multiple versions of H5AC_cache_config_t, we
+ * will have to get the cannonical version here, and then translate
+ * to the version of the structure supplied.
+ */
+
+ /* Get the current initial metadata cache resize configuration */
+ if(H5P_get(plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, config_ptr) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,FAIL, "can't get metadata cache initial image config")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* H5Pget_mdc_image_config() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5Pset_mdc_config
*
* Purpose: Set the initial metadata cache resize configuration in the
@@ -2754,6 +2868,147 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5P__facc_cache_image_config_cmp
+ *
+ * Purpose: Compare two cache image configurations.
+ *
+ * Return: positive if VALUE1 is greater than VALUE2, negative if VALUE2 is
+ * greater than VALUE1 and zero if VALUE1 and VALUE2 are equal.
+ *
+ * Programmer: John Mainzer
+ * June 26, 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+H5P__facc_cache_image_config_cmp(const void *_config1, const void *_config2, size_t H5_ATTR_UNUSED size)
+{
+ const H5AC_cache_image_config_t *config1 = (const H5AC_cache_image_config_t *)_config1; /* Create local aliases for values */
+ const H5AC_cache_image_config_t *config2 = (const H5AC_cache_image_config_t *)_config2; /* Create local aliases for values */
+ int ret_value = 0; /* Return value */
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Check for a property being set */
+ if(config1 == NULL && config2 != NULL) HGOTO_DONE(-1);
+ if(config1 != NULL && config2 == NULL) HGOTO_DONE(1);
+
+ if(config1->version < config2->version) HGOTO_DONE(-1);
+ if(config1->version > config2->version) HGOTO_DONE(1);
+
+ if(config1->generate_image < config2->generate_image) HGOTO_DONE(-1);
+ if(config1->generate_image > config2->generate_image) HGOTO_DONE(1);
+
+ if(config1->save_resize_status < config2->save_resize_status) HGOTO_DONE(-1);
+ if(config1->save_resize_status > config2->save_resize_status) HGOTO_DONE(1);
+
+ if(config1->entry_ageout < config2->entry_ageout) HGOTO_DONE(-1);
+ if(config1->entry_ageout > config2->entry_ageout) HGOTO_DONE(1);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5P__facc_cache_image_config_cmp() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P__facc_cache_image_config_enc
+ *
+ * Purpose: Callback routine which is called whenever the default
+ * cache image config property in the file creation
+ * property list is encoded.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: John Mainzer
+ * June 26, 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5P__facc_cache_image_config_enc(const void *value, void **_pp, size_t *size)
+{
+ const H5AC_cache_image_config_t *config = (const H5AC_cache_image_config_t *)value; /* Create local aliases for value */
+ uint8_t **pp = (uint8_t **)_pp;
+
+ FUNC_ENTER_STATIC_NOERR
+
+ /* Sanity check */
+ HDassert(value);
+
+ if(NULL != *pp) {
+ /* Encode type sizes (as a safety check) */
+ *(*pp)++ = (uint8_t)sizeof(unsigned);
+
+ INT32ENCODE(*pp, (int32_t)config->version);
+
+ H5_ENCODE_UNSIGNED(*pp, config->generate_image);
+
+ H5_ENCODE_UNSIGNED(*pp, config->save_resize_status);
+
+ INT32ENCODE(*pp, (int32_t)config->entry_ageout);
+ } /* end if */
+
+ /* Compute encoded size of fixed-size values */
+ *size += (1 + (2 * sizeof(unsigned)) + (2 * sizeof(int32_t)));
+
+ FUNC_LEAVE_NOAPI(SUCCEED)
+} /* end H5P__facc_cache_image_config_enc() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P__facc_cache_image_config_dec
+ *
+ * Purpose: Callback routine which is called whenever the default
+ * cache image config property in the file creation property
+ * list is decoded.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: John Mainzer
+ * June 26, 2015
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5P__facc_cache_image_config_dec(const void **_pp, void *_value)
+{
+ H5AC_cache_image_config_t *config = (H5AC_cache_image_config_t *)_value;
+ const uint8_t **pp = (const uint8_t **)_pp;
+ unsigned enc_size;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_STATIC
+
+ /* Sanity checks */
+ HDassert(pp);
+ HDassert(*pp);
+ HDassert(config);
+ HDcompile_assert(sizeof(size_t) <= sizeof(uint64_t));
+
+ /* Set property to default value */
+ HDmemcpy(config, &H5F_def_mdc_initCacheImageCfg_g, sizeof(H5AC_cache_image_config_t));
+
+ /* Decode type sizes */
+ enc_size = *(*pp)++;
+ if(enc_size != sizeof(unsigned))
+ HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "unsigned value can't be decoded")
+
+ INT32DECODE(*pp, config->version);
+
+ H5_DECODE_UNSIGNED(*pp, config->generate_image);
+
+ H5_DECODE_UNSIGNED(*pp, config->save_resize_status);
+
+ INT32DECODE(*pp, config->entry_ageout);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5P__facc_cache_image_config_dec() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5P__facc_file_image_info_set
*
* Purpose: Copies a file image property when it's set for a property list