diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2017-01-29 07:19:37 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2017-01-29 07:19:37 (GMT) |
commit | 1949d5756d424be0b23fc127fc99140374a7dd13 (patch) | |
tree | e7d368b8bbcb589e48e88c1b781b08e16655a832 /src/H5AC.c | |
parent | 5a776edb8156c36d3a7e2f9e23c6fb349eaa90e0 (diff) | |
download | hdf5-1949d5756d424be0b23fc127fc99140374a7dd13.zip hdf5-1949d5756d424be0b23fc127fc99140374a7dd13.tar.gz hdf5-1949d5756d424be0b23fc127fc99140374a7dd13.tar.bz2 |
Cache image feature and testing
Diffstat (limited to 'src/H5AC.c')
-rw-r--r-- | src/H5AC.c | 116 |
1 files changed, 114 insertions, 2 deletions
@@ -142,7 +142,8 @@ static const H5AC_class_t *const H5AC_class_s[] = { H5AC_SUPERBLOCK, /* (25) file superblock */ H5AC_DRVRINFO, /* (26) driver info block (supplements superblock) */ H5AC_EPOCH_MARKER, /* (27) epoch marker - always internal to cache */ - H5AC_PROXY_ENTRY /* (28) cache entry proxy */ + H5AC_PROXY_ENTRY, /* (28) cache entry proxy */ + H5AC_PREFETCHED_ENTRY /* (29) prefetched entry - always internal to cache */ }; @@ -370,12 +371,13 @@ H5AC_term_package(void) *------------------------------------------------------------------------- */ herr_t -H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr) +H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr, H5AC_cache_image_config_t * image_config_ptr) { #ifdef H5_HAVE_PARALLEL char prefix[H5C__PREFIX_LEN] = ""; H5AC_aux_t * aux_ptr = NULL; #endif /* H5_HAVE_PARALLEL */ + struct H5C_cache_image_ctl_t int_ci_config = H5C__DEFAULT_CACHE_IMAGE_CTL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -384,11 +386,16 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr) HDassert(f); HDassert(NULL == f->shared->cache); HDassert(config_ptr != NULL) ; + HDassert(image_config_ptr != NULL) ; + HDassert(image_config_ptr->version == H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION); HDcompile_assert(NELMTS(H5AC_class_s) == H5AC_NTYPES); HDcompile_assert(H5C__MAX_NUM_TYPE_IDS == H5AC_NTYPES); + /* Validate configurations */ if(H5AC_validate_config(config_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache configuration") + if(H5AC_validate_cache_image_config(image_config_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Bad cache image configuration") #ifdef H5_HAVE_PARALLEL if(H5F_HAS_FEATURE(f, H5FD_FEAT_HAS_MPI)) { @@ -430,6 +437,7 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr) aux_ptr->candidate_slist_ptr = NULL; aux_ptr->write_done = NULL; aux_ptr->sync_point_done = NULL; + aux_ptr->p0_image_len = 0; sprintf(prefix, "%d:", mpi_rank); @@ -504,6 +512,20 @@ H5AC_create(const H5F_t *f, H5AC_cache_config_t *config_ptr) if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "auto resize configuration failed") + /* don't need to get the current H5C image config here since the + * cache has just been created, and thus f->shared->cache->image_ctl + * must still set to its initial value (H5C__DEFAULT_CACHE_IMAGE_CTL). + * Note that this not true as soon as control returns to the application + * program, as some test code modifies f->shared->cache->image_ctl. + */ + int_ci_config.version = image_config_ptr->version; + int_ci_config.generate_image = image_config_ptr->generate_image; + int_ci_config.save_resize_status = image_config_ptr->save_resize_status; + int_ci_config.entry_ageout = image_config_ptr->entry_ageout; + + if(H5C_set_cache_image_config(f, f->shared->cache, &int_ci_config) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTALLOC, FAIL, "auto resize configuration failed") + done: #ifdef H5_HAVE_PARALLEL /* if there is a failure, try to tidy up the auxilary structure */ @@ -982,6 +1004,41 @@ done: /*------------------------------------------------------------------------- + * Function: H5AC_load_cache_image_on_next_protect + * + * Purpose: Load the cache image block at the specified location, + * decode it, and insert its contents into the metadata + * cache. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 7/6/15 + * + *------------------------------------------------------------------------- + */ +herr_t +H5AC_load_cache_image_on_next_protect(H5F_t * f, haddr_t addr, hsize_t len, + hbool_t rw) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(f); + HDassert(f->shared); + HDassert(f->shared->cache); + + if(H5C_load_cache_image_on_next_protect(f, addr, len, rw) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTLOAD, FAIL, "call to H5C_load_cache_image_on_next_protect failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5AC_load_cache_image_on_next_protect() */ + + +/*------------------------------------------------------------------------- * Function: H5AC_mark_entry_dirty * * Purpose: Mark a pinned or protected entry as dirty. The target @@ -2395,6 +2452,61 @@ done: /*------------------------------------------------------------------------- + * Function: H5AC_validate_cache_image_config() + * + * Purpose: Run a sanity check on the contents of the supplied + * instance of H5AC_cache_image_config_t. + * + * Do nothing and return SUCCEED if no errors are detected, + * and flag an error and return FAIL otherwise. + * + * At present, this function operates by packing the data + * from the instance of H5AC_cache_image_config_t into an + * instance of H5C_cache_image_ctl_t, and then calling + * H5C_validate_cache_image_config(). If and when + * H5AC_cache_image_config_t and H5C_cache_image_ctl_t + * diverge, we may have to change this. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: John Mainzer + * 6/25/15 + * + *------------------------------------------------------------------------- + */ +herr_t +H5AC_validate_cache_image_config(H5AC_cache_image_config_t *config_ptr) +{ + H5C_cache_image_ctl_t internal_config = H5C__DEFAULT_CACHE_IMAGE_CTL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check args */ + if(config_ptr == NULL) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "NULL config_ptr on entry") + + if(config_ptr->version != H5AC__CURR_CACHE_IMAGE_CONFIG_VERSION) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "Unknown image config version") + + /* don't need to get the current H5C image config here since the + * default values of fields not in the H5AC config will always be + * valid. + */ + internal_config.version = config_ptr->version; + internal_config.generate_image = config_ptr->generate_image; + internal_config.save_resize_status = config_ptr->save_resize_status; + internal_config.entry_ageout = config_ptr->entry_ageout; + + if(H5C_validate_cache_image_config(&internal_config) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "error(s) in new cache image config") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5AC_validate_cache_image_config() */ + + +/*------------------------------------------------------------------------- * * Function: H5AC__check_if_write_permitted * |