summaryrefslogtreecommitdiffstats
path: root/src/H5AC.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5AC.c')
-rw-r--r--src/H5AC.c207
1 files changed, 140 insertions, 67 deletions
diff --git a/src/H5AC.c b/src/H5AC.c
index f5b331f..64edc87 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -32,7 +32,7 @@
/****************/
#include "H5ACmodule.h" /* This source code file is part of the H5AC module */
-#define H5F_FRIEND /*suppress error about including H5Fpkg */
+#define H5F_FRIEND /* Suppress error about including H5Fpkg */
/***********/
@@ -76,22 +76,28 @@ static herr_t H5AC__ext_config_2_int_config(H5AC_cache_config_t *ext_conf_ptr,
/* Package initialization variable */
hbool_t H5_PKG_INIT_VAR = FALSE;
-
/*****************************/
/* Library Private Variables */
/*****************************/
-/* Default dataset transfer property list for metadata I/O calls */
-/* (Collective set, "block before metadata write" set and "library internal" set) */
-/* (Global variable definition, declaration is in H5ACprivate.h also) */
-hid_t H5AC_dxpl_id = (-1);
+/* Default dataset transfer property list for metadata I/O calls (coll write, ind read) */
+hid_t H5AC_ind_read_dxpl_id = (-1);
+#ifdef H5_HAVE_PARALLEL
+/* collective metadata read property */
+hid_t H5AC_coll_read_dxpl_id = (-1);
+#endif /* H5_HAVE_PARALLEL */
-/* Dataset transfer property list for independent metadata I/O calls */
-/* (just "library internal" set - i.e. independent transfer mode) */
-/* (Global variable definition, declaration is in H5ACprivate.h also) */
-H5P_genplist_t *H5AC_ind_dxpl_g = NULL;
-hid_t H5AC_ind_dxpl_id = (-1);
+/* DXPL to be used in operations that will not result in I/O calls */
+hid_t H5AC_noio_dxpl_id = (-1);
+/* Default DXPL to be used for raw data I/O operations when one is not
+ provided by the user (fill values in H5Dcreate) */
+hid_t H5AC_rawdata_dxpl_id = (-1);
+
+#ifdef H5_HAVE_PARALLEL
+/* Environment variable for collective API sanity checks */
+hbool_t H5_coll_api_sanity_check_g = false;
+#endif /* H5_HAVE_PARALLEL */
/*******************/
/* Local Variables */
@@ -172,57 +178,101 @@ done:
herr_t
H5AC__init_package(void)
{
-#ifdef H5_HAVE_PARALLEL
H5P_genplist_t *xfer_plist; /* Dataset transfer property list object */
- unsigned coll_meta_write; /* "collective metadata write" property value */
+#ifdef H5_HAVE_PARALLEL
+ H5P_coll_md_read_flag_t coll_meta_read;
#endif /* H5_HAVE_PARALLEL */
+#ifdef H5_DEBUG_BUILD
+ H5FD_dxpl_type_t dxpl_type; /* Property indicating the type of the internal dxpl */
+#endif /* H5_DEBUG_BUILD */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_PACKAGE
#ifdef H5_HAVE_PARALLEL
- /* Sanity check */
- HDassert(H5P_CLS_DATASET_XFER_g != NULL);
+ /* check whether to enable strict collective function calling
+ sanity checks using MPI barriers */
+ {
+ const char *s; /* String for environment variables */
+
+ s = HDgetenv("H5_COLL_API_SANITY_CHECK");
+ if(s && HDisdigit(*s)) {
+ H5_coll_api_sanity_check_g = (hbool_t)HDstrtol(s, NULL, 0);
+ }
+ }
+#endif /* H5_HAVE_PARALLEL */
- /* Get an ID for the collective H5AC dxpl */
- if((H5AC_dxpl_id = H5P_create_id(H5P_CLS_DATASET_XFER_g, FALSE)) < 0)
+#if defined(H5_HAVE_PARALLEL) || defined(H5_DEBUG_BUILD)
+ /* Get an ID for the internal independent metadata dxpl */
+ if((H5AC_ind_read_dxpl_id = H5P_create_id(H5P_CLS_DATASET_XFER_g, FALSE)) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "unable to register property list")
- /* Get the property list object */
- if (NULL == (xfer_plist = (H5P_genplist_t *)H5I_object(H5AC_dxpl_id)))
- HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object")
-
- /* Insert 'collective metadata write' property */
- coll_meta_write = 1;
- if(H5P_insert(xfer_plist, H5AC_COLLECTIVE_META_WRITE_NAME, H5AC_COLLECTIVE_META_WRITE_SIZE, &coll_meta_write,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "can't insert metadata cache dxpl property")
+ /* Get an ID for the no I/O internal dxpl */
+ if((H5AC_noio_dxpl_id = H5P_create_id(H5P_CLS_DATASET_XFER_g, FALSE)) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "unable to register property list")
- /* Get an ID for the independent H5AC dxpl */
- if((H5AC_ind_dxpl_id = H5P_create_id(H5P_CLS_DATASET_XFER_g, FALSE)) < 0)
+ /* Get an ID for the raw data (H5AC) dxpl */
+ if((H5AC_rawdata_dxpl_id = H5P_create_id(H5P_CLS_DATASET_XFER_g, FALSE)) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "unable to register property list")
+ /* if this is a debug build, set the dxpl type flag on the
+ independent metadata dxpl and create the noio and raw data internal dxpls */
+#ifdef H5_DEBUG_BUILD
/* Get the property list object */
- if(NULL == (H5AC_ind_dxpl_g = (H5P_genplist_t *)H5I_object(H5AC_ind_dxpl_id)))
+ if (NULL == (xfer_plist = (H5P_genplist_t *)H5I_object(H5AC_ind_read_dxpl_id)))
HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object")
+ /* Insert the dxpl type property */
+ dxpl_type = H5FD_METADATA_DXPL;
+ if(H5P_set(xfer_plist, H5FD_DXPL_TYPE_NAME, &dxpl_type) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "can't set dxpl type property")
- /* Insert 'collective metadata write' property */
- coll_meta_write = 0;
- if(H5P_insert(H5AC_ind_dxpl_g, H5AC_COLLECTIVE_META_WRITE_NAME, H5AC_COLLECTIVE_META_WRITE_SIZE, &coll_meta_write,
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
- HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "can't insert metadata cache dxpl property")
-#else /* H5_HAVE_PARALLEL */
- /* Sanity check */
- HDassert(H5P_LST_DATASET_XFER_ID_g!=(-1));
-
- H5AC_dxpl_id = H5P_DATASET_XFER_DEFAULT;
- H5AC_ind_dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ /* Get the property list object */
+ if (NULL == (xfer_plist = (H5P_genplist_t *)H5I_object(H5AC_noio_dxpl_id)))
+ HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object")
+ /* Insert the dxpl type property */
+ dxpl_type = H5FD_NOIO_DXPL;
+ if(H5P_set(xfer_plist, H5FD_DXPL_TYPE_NAME, &dxpl_type) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "can't set dxpl type property")
- /* Get the property list objects for the IDs */
- if(NULL == (H5AC_ind_dxpl_g = (H5P_genplist_t *)H5I_object(H5AC_ind_dxpl_id)))
- HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get property list object")
+ /* Get the property list object */
+ if (NULL == (xfer_plist = (H5P_genplist_t *)H5I_object(H5AC_rawdata_dxpl_id)))
+ HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object")
+ /* Insert the dxpl type property */
+ dxpl_type = H5FD_RAWDATA_DXPL;
+ if(H5P_set(xfer_plist, H5FD_DXPL_TYPE_NAME, &dxpl_type) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "can't set dxpl type property")
+#endif /* H5_DEBUG_BUILD */
+
+ /* if this is a parallel build, create an internal dxpl for
+ collective metadata reads */
+#ifdef H5_HAVE_PARALLEL
+ /* Get an ID for H5AC_coll_read_dxpl_id */
+ if((H5AC_coll_read_dxpl_id = H5P_create_id(H5P_CLS_DATASET_XFER_g, FALSE)) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTCREATE, FAIL, "unable to register property list")
+ /* Get the property list object */
+ if (NULL == (xfer_plist = (H5P_genplist_t *)H5I_object(H5AC_coll_read_dxpl_id)))
+ HGOTO_ERROR(H5E_CACHE, H5E_BADATOM, FAIL, "can't get new property list object")
+ /* set 'collective metadata read' property */
+ coll_meta_read = H5P_USER_TRUE;
+ if(H5P_set(xfer_plist, H5_COLL_MD_READ_FLAG_NAME, &coll_meta_read) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set collective metadata read flag")
+
+ /* if we have a debug build, set the dxpl type to metadata on the
+ collective metadata dxpl */
+#ifdef H5_DEBUG_BUILD
+ /* set metadata dxpl type */
+ dxpl_type = H5FD_METADATA_DXPL;
+ if(H5P_set(xfer_plist, H5FD_DXPL_TYPE_NAME, &dxpl_type) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTSET, FAIL, "can't set dxpl type property")
+#endif /* H5_DEBUG_BUILD */
#endif /* H5_HAVE_PARALLEL */
+#else /* defined(H5_HAVE_PARALLEL) || defined(H5_DEBUG_BUILD) */
+ H5AC_ind_read_dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ H5AC_noio_dxpl_id = H5P_DATASET_XFER_DEFAULT;
+ H5AC_rawdata_dxpl_id = H5P_DATASET_XFER_DEFAULT;
+#endif /* defined(H5_HAVE_PARALLEL) || defined(H5_DEBUG_BUILD) */
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5AC__init_package() */
@@ -250,20 +300,34 @@ H5AC_term_package(void)
FUNC_ENTER_NOAPI_NOINIT_NOERR
if(H5_PKG_INIT_VAR) {
+ if(H5AC_ind_read_dxpl_id > 0 || H5AC_noio_dxpl_id > 0 || H5AC_rawdata_dxpl_id > 0
#ifdef H5_HAVE_PARALLEL
- if(H5AC_dxpl_id > 0 || H5AC_ind_dxpl_id > 0) {
+ || H5AC_coll_read_dxpl_id > 0
+#endif /* H5_HAVE_PARALLEL */
+ ) {
+#if defined(H5_HAVE_PARALLEL) || defined(H5_DEBUG_BUILD)
/* Indicate more work to do */
n = 1; /* H5I */
- /* Close H5AC dxpl */
- if(H5I_dec_ref(H5AC_dxpl_id) < 0 || H5I_dec_ref(H5AC_ind_dxpl_id) < 0)
+ /* Close H5AC dxpls */
+ if(H5I_dec_ref(H5AC_ind_read_dxpl_id) < 0 ||
+ H5I_dec_ref(H5AC_noio_dxpl_id) < 0 ||
+ H5I_dec_ref(H5AC_rawdata_dxpl_id) < 0
+#ifdef H5_HAVE_PARALLEL
+ || H5I_dec_ref(H5AC_coll_read_dxpl_id) < 0
+#endif /* H5_HAVE_PARALLEL */
+ )
H5E_clear_stack(NULL); /*ignore error*/
- } /* end if */
+#endif /* defined(H5_HAVE_PARALLEL) || defined(H5_DEBUG_BUILD) */
+
+ /* Reset static IDs */
+ H5AC_ind_read_dxpl_id = (-1);
+ H5AC_noio_dxpl_id = (-1);
+ H5AC_rawdata_dxpl_id = (-1);
+#ifdef H5_HAVE_PARALLEL
+ H5AC_coll_read_dxpl_id = (-1);
#endif /* H5_HAVE_PARALLEL */
-
- /* Reset static IDs */
- H5AC_dxpl_id = (-1);
- H5AC_ind_dxpl_id = (-1);
+ } /* end if */
/* Reset interface initialization flag */
if(0 == n)
@@ -478,7 +542,11 @@ H5AC_dest(H5F_t *f, hid_t dxpl_id)
#endif /* H5AC__TRACE_FILE_ENABLED */
#ifdef H5_HAVE_PARALLEL
- aux_ptr = H5C_get_aux_ptr(f->shared->cache);
+ /* destroying the cache, so clear all collective entries */
+ if(H5C_clear_coll_entries(f->shared->cache, 0) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_clear_coll_entries() failed.")
+
+ aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache);
if(aux_ptr)
/* Sanity check */
HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC);
@@ -616,6 +684,10 @@ H5AC_flush(H5F_t *f, hid_t dxpl_id)
#endif /* H5AC__TRACE_FILE_ENABLED */
#ifdef H5_HAVE_PARALLEL
+ /* flushing the cache, so clear all collective entries */
+ if(H5C_clear_coll_entries(f->shared->cache, 0) < 0)
+ HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "H5C_clear_coll_entries() failed.")
+
/* Attempt to flush all entries from rank 0 & Bcast clean list to other ranks */
if(H5AC__flush_entries(f, dxpl_id) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't flush.")
@@ -766,14 +838,14 @@ H5AC_insert_entry(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t add
{
H5AC_aux_t *aux_ptr;
- if(NULL != (aux_ptr = H5C_get_aux_ptr(f->shared->cache))) {
+ if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) {
/* Log the new entry */
if(H5AC__log_inserted_entry((H5AC_info_t *)thing) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTINS, FAIL, "H5AC__log_inserted_entry() failed")
/* Check if we should try to flush */
if(aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold)
- if(H5AC__run_sync_point(f, H5AC_dxpl_id, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0)
+ if(H5AC__run_sync_point(f, dxpl_id, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't run sync point.")
} /* end if */
}
@@ -832,7 +904,7 @@ H5AC_mark_entry_dirty(void *thing)
H5C_t *cache_ptr = entry_ptr->cache_ptr;
H5AC_aux_t *aux_ptr;
- aux_ptr = H5C_get_aux_ptr(cache_ptr);
+ aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr);
if((!entry_ptr->is_dirty) && (!entry_ptr->is_protected) &&
(entry_ptr->is_pinned) && (NULL != aux_ptr))
if(H5AC__log_dirtied_entry(entry_ptr) < 0)
@@ -868,7 +940,8 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_addr)
+H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr,
+ haddr_t new_addr, hid_t dxpl_id)
{
#if H5AC__TRACE_FILE_ENABLED
char trace[128] = "";
@@ -901,7 +974,7 @@ H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t ne
#ifdef H5_HAVE_PARALLEL
/* Log moving the entry */
- if(NULL != (aux_ptr = H5C_get_aux_ptr(f->shared->cache)))
+ if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache)))
if(H5AC__log_moved_entry(f, old_addr, new_addr) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "can't log moved entry")
#endif /* H5_HAVE_PARALLEL */
@@ -912,7 +985,7 @@ H5AC_move_entry(H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t ne
#ifdef H5_HAVE_PARALLEL
/* Check if we should try to flush */
if(NULL != aux_ptr && aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold)
- if(H5AC__run_sync_point(f, H5AC_dxpl_id, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0)
+ if(H5AC__run_sync_point(f, dxpl_id, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't run sync point.")
#endif /* H5_HAVE_PARALLEL */
@@ -1166,7 +1239,7 @@ H5AC_resize_entry(void *thing, size_t new_size)
H5C_t *cache_ptr = entry_ptr->cache_ptr;
H5AC_aux_t *aux_ptr;
- aux_ptr = H5C_get_aux_ptr(cache_ptr);
+ aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr);
if((!entry_ptr->is_dirty) && (NULL != aux_ptr))
if(H5AC__log_dirtied_entry(entry_ptr) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTMARKDIRTY, FAIL, "can't log dirtied entry")
@@ -1377,7 +1450,7 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr,
} /* end if */
#ifdef H5_HAVE_PARALLEL
- if(NULL != (aux_ptr = H5C_get_aux_ptr(f->shared->cache))) {
+ if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache))) {
if(dirtied && ((H5AC_info_t *)thing)->is_dirty == FALSE)
if(H5AC__log_dirtied_entry((H5AC_info_t *)thing) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTUNPROTECT, FAIL, "can't log dirtied entry")
@@ -1394,7 +1467,7 @@ H5AC_unprotect(H5F_t *f, hid_t dxpl_id, const H5AC_class_t *type, haddr_t addr,
#ifdef H5_HAVE_PARALLEL
/* Check if we should try to flush */
if((aux_ptr != NULL) && (aux_ptr->dirty_bytes >= aux_ptr->dirty_bytes_threshold))
- if(H5AC__run_sync_point(f, H5AC_dxpl_id, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0)
+ if(H5AC__run_sync_point(f, dxpl_id, H5AC_SYNC_POINT_OP__FLUSH_TO_MIN_CLEAN) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "Can't run sync point.")
#endif /* H5_HAVE_PARALLEL */
@@ -1502,7 +1575,7 @@ H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr,
{
H5AC_aux_t *aux_ptr;
- aux_ptr = H5C_get_aux_ptr(cache_ptr);
+ aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr);
if((aux_ptr != NULL) && (aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC))
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad aux_ptr on entry.")
}
@@ -1549,7 +1622,7 @@ H5AC_get_cache_auto_resize_config(const H5AC_t *cache_ptr,
{
H5AC_aux_t *aux_ptr;
- if(NULL != (aux_ptr = H5C_get_aux_ptr(cache_ptr))) {
+ if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr))) {
config_ptr->dirty_bytes_threshold = aux_ptr->dirty_bytes_threshold;
config_ptr->metadata_write_strategy = aux_ptr->metadata_write_strategy;
} /* end if */
@@ -1691,7 +1764,7 @@ H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config
{
H5AC_aux_t *aux_ptr;
- aux_ptr = H5C_get_aux_ptr(cache_ptr);
+ aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr);
if((aux_ptr != NULL) && (aux_ptr->magic != H5AC__H5AC_AUX_T_MAGIC))
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "bad aux_ptr on entry.")
}
@@ -1735,7 +1808,7 @@ H5AC_set_cache_auto_resize_config(H5AC_t *cache_ptr, H5AC_cache_config_t *config
/* Set parallel configuration values */
/* (Which are only held in the H5AC layer -QAK) */
- if(NULL != (aux_ptr = H5C_get_aux_ptr(cache_ptr))) {
+ if(NULL != (aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr))) {
aux_ptr->dirty_bytes_threshold = config_ptr->dirty_bytes_threshold;
aux_ptr->metadata_write_strategy = config_ptr->metadata_write_strategy;
} /* end if */
@@ -1950,7 +2023,7 @@ H5AC_open_trace_file(H5AC_t *cache_ptr, const char *trace_file_name)
{
H5AC_aux_t * aux_ptr;
- aux_ptr = H5C_get_aux_ptr(cache_ptr);
+ aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(cache_ptr);
if(aux_ptr == NULL)
sprintf(file_name, "%s", trace_file_name);
else {
@@ -2131,7 +2204,7 @@ H5_ATTR_UNUSED
HDassert(f != NULL);
HDassert(f->shared != NULL);
HDassert(f->shared->cache != NULL);
- aux_ptr = H5C_get_aux_ptr(f->shared->cache);
+ aux_ptr = (H5AC_aux_t *)H5C_get_aux_ptr(f->shared->cache);
if(aux_ptr != NULL) {
HDassert(aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC);