diff options
author | Quincey Koziol <quincey@koziol.cc> | 2023-04-12 03:57:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-12 03:57:47 (GMT) |
commit | 82b722120858d2460a6c8dc933bbf692edb431b6 (patch) | |
tree | b953f8e852d86fe41acbb9b5b358e5be902a124f /src/H5Cimage.c | |
parent | 367e4a393361418a318269a18118da62c1c4f565 (diff) | |
download | hdf5-82b722120858d2460a6c8dc933bbf692edb431b6.zip hdf5-82b722120858d2460a6c8dc933bbf692edb431b6.tar.gz hdf5-82b722120858d2460a6c8dc933bbf692edb431b6.tar.bz2 |
Cache tidy (#2693)
* Correct concurrency bugs when running tests, along with a bugfix & small
warning cleanup.
* Committing clang-format changes
* Allow spaces (and tabs) in VOL connector info string from environment variable.
* Parse connector name from HDF5_PLUGIN_PATH environment variable better
* Correct H5VLquery_optional to use H5VL routine instead of H5I. Also add an
error message to the failure return value from not finding a plugin.
* Play nice with existing plugin paths
* Use API routine to determine if native connector is terminal.
* Committing clang-format changes
* Make string size larger, to allow for connectors with longer names.
* Be more flexible about testing external pass through connectors, especially if
they have registered new optional operations.
* Bring style closer to library's agreed coding style
* Committing clang-format changes
---------
Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: AWS ParallelCluster user <ec2-user@ip-10-0-0-65.us-east-2.compute.internal>
Co-authored-by: Koziol <qkoziol@88665a374c70.ant.amazon.com>
Diffstat (limited to 'src/H5Cimage.c')
-rw-r--r-- | src/H5Cimage.c | 95 |
1 files changed, 40 insertions, 55 deletions
diff --git a/src/H5Cimage.c b/src/H5Cimage.c index 70944be..105272c 100644 --- a/src/H5Cimage.c +++ b/src/H5Cimage.c @@ -298,8 +298,8 @@ H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr) HDassert(fake_cache_ptr->image_entries); for (u = 0; u < fake_cache_ptr->num_entries_in_image; u++) { - (fake_cache_ptr->image_entries)[u].magic = H5C_IMAGE_ENTRY_T_MAGIC; - (fake_cache_ptr->image_entries)[u].image_ptr = NULL; + fake_cache_ptr->image_entries[u].magic = H5C_IMAGE_ENTRY_T_MAGIC; + fake_cache_ptr->image_entries[u].image_ptr = NULL; /* touch up f->shared->cache to satisfy sanity checks... */ f->shared->cache = fake_cache_ptr; @@ -310,43 +310,42 @@ H5C__construct_cache_image_buffer(H5F_t *f, H5C_t *cache_ptr) f->shared->cache = cache_ptr; /* verify expected contents */ - HDassert((cache_ptr->image_entries)[u].addr == (fake_cache_ptr->image_entries)[u].addr); - HDassert((cache_ptr->image_entries)[u].size == (fake_cache_ptr->image_entries)[u].size); - HDassert((cache_ptr->image_entries)[u].type_id == (fake_cache_ptr->image_entries)[u].type_id); - HDassert((cache_ptr->image_entries)[u].lru_rank == (fake_cache_ptr->image_entries)[u].lru_rank); - HDassert((cache_ptr->image_entries)[u].is_dirty == (fake_cache_ptr->image_entries)[u].is_dirty); + HDassert(cache_ptr->image_entries[u].addr == fake_cache_ptr->image_entries[u].addr); + HDassert(cache_ptr->image_entries[u].size == fake_cache_ptr->image_entries[u].size); + HDassert(cache_ptr->image_entries[u].type_id == fake_cache_ptr->image_entries[u].type_id); + HDassert(cache_ptr->image_entries[u].lru_rank == fake_cache_ptr->image_entries[u].lru_rank); + HDassert(cache_ptr->image_entries[u].is_dirty == fake_cache_ptr->image_entries[u].is_dirty); /* don't check image_fd_height as it is not stored in * the metadata cache image block. */ - HDassert((cache_ptr->image_entries)[u].fd_child_count == - (fake_cache_ptr->image_entries)[u].fd_child_count); - HDassert((cache_ptr->image_entries)[u].fd_dirty_child_count == - (fake_cache_ptr->image_entries)[u].fd_dirty_child_count); - HDassert((cache_ptr->image_entries)[u].fd_parent_count == - (fake_cache_ptr->image_entries)[u].fd_parent_count); + HDassert(cache_ptr->image_entries[u].fd_child_count == + fake_cache_ptr->image_entries[u].fd_child_count); + HDassert(cache_ptr->image_entries[u].fd_dirty_child_count == + fake_cache_ptr->image_entries[u].fd_dirty_child_count); + HDassert(cache_ptr->image_entries[u].fd_parent_count == + fake_cache_ptr->image_entries[u].fd_parent_count); - for (v = 0; v < (cache_ptr->image_entries)[u].fd_parent_count; v++) - HDassert((cache_ptr->image_entries)[u].fd_parent_addrs[v] == - (fake_cache_ptr->image_entries)[u].fd_parent_addrs[v]); + for (v = 0; v < cache_ptr->image_entries[u].fd_parent_count; v++) + HDassert(cache_ptr->image_entries[u].fd_parent_addrs[v] == + fake_cache_ptr->image_entries[u].fd_parent_addrs[v]); /* free the fd_parent_addrs array if it exists */ - if ((fake_cache_ptr->image_entries)[u].fd_parent_addrs) { - HDassert((fake_cache_ptr->image_entries)[u].fd_parent_count > 0); - (fake_cache_ptr->image_entries)[u].fd_parent_addrs = - (haddr_t *)H5MM_xfree((fake_cache_ptr->image_entries)[u].fd_parent_addrs); - (fake_cache_ptr->image_entries)[u].fd_parent_count = 0; + if (fake_cache_ptr->image_entries[u].fd_parent_addrs) { + HDassert(fake_cache_ptr->image_entries[u].fd_parent_count > 0); + fake_cache_ptr->image_entries[u].fd_parent_addrs = + (haddr_t *)H5MM_xfree(fake_cache_ptr->image_entries[u].fd_parent_addrs); + fake_cache_ptr->image_entries[u].fd_parent_count = 0; } /* end if */ else - HDassert((fake_cache_ptr->image_entries)[u].fd_parent_count == 0); + HDassert(fake_cache_ptr->image_entries[u].fd_parent_count == 0); - HDassert((cache_ptr->image_entries)[u].image_ptr); - HDassert((fake_cache_ptr->image_entries)[u].image_ptr); - HDassert(!HDmemcmp((cache_ptr->image_entries)[u].image_ptr, - (fake_cache_ptr->image_entries)[u].image_ptr, - (cache_ptr->image_entries)[u].size)); + HDassert(cache_ptr->image_entries[u].image_ptr); + HDassert(fake_cache_ptr->image_entries[u].image_ptr); + HDassert(!HDmemcmp(cache_ptr->image_entries[u].image_ptr, + fake_cache_ptr->image_entries[u].image_ptr, cache_ptr->image_entries[u].size)); - (fake_cache_ptr->image_entries)[u].image_ptr = - H5MM_xfree((fake_cache_ptr->image_entries)[u].image_ptr); + fake_cache_ptr->image_entries[u].image_ptr = + H5MM_xfree(fake_cache_ptr->image_entries[u].image_ptr); } /* end for */ HDassert((size_t)(q - (const uint8_t *)cache_ptr->image_buffer) == @@ -692,12 +691,10 @@ H5C__deserialize_prefetched_entry(H5F_t *f, H5C_t *cache_ptr, H5C_cache_entry_t pf_entry_ptr->image_ptr = NULL; if (pf_entry_ptr->is_dirty) { - HDassert(((cache_ptr->slist_enabled) && (pf_entry_ptr->in_slist)) || ((!cache_ptr->slist_enabled) && (!pf_entry_ptr->in_slist))); flush_flags |= H5C__DEL_FROM_SLIST_ON_DESTROY_FLAG; - } /* end if */ if (H5C__flush_single_entry(f, pf_entry_ptr, flush_flags) < 0) @@ -826,7 +823,7 @@ H5C__free_image_entries_array(H5C_t *cache_ptr) H5C_image_entry_t *ie_ptr; /* Image entry to release */ /* Get pointer to image entry */ - ie_ptr = &((cache_ptr->image_entries)[u]); + ie_ptr = &(cache_ptr->image_entries[u]); /* Sanity checks */ HDassert(ie_ptr); @@ -987,7 +984,6 @@ H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr) int mpi_result; if ((NULL == aux_ptr) || (aux_ptr->mpi_rank == 0)) { - HDassert((NULL == aux_ptr) || (aux_ptr->magic == H5AC__H5AC_AUX_T_MAGIC)); #endif /* H5_HAVE_PARALLEL */ @@ -1003,21 +999,16 @@ H5C__read_cache_image(H5F_t *f, H5C_t *cache_ptr) #ifdef H5_HAVE_PARALLEL if (aux_ptr) { - /* Broadcast cache image */ if (MPI_SUCCESS != (mpi_result = MPI_Bcast(cache_ptr->image_buffer, (int)cache_ptr->image_len, MPI_BYTE, 0, aux_ptr->mpi_comm))) - HMPI_GOTO_ERROR(FAIL, "MPI_Bcast failed", mpi_result) - } /* end if */ } /* end if */ else if (aux_ptr) { - /* Retrieve the contents of the metadata cache image from process 0 */ if (MPI_SUCCESS != (mpi_result = MPI_Bcast(cache_ptr->image_buffer, (int)cache_ptr->image_len, MPI_BYTE, 0, aux_ptr->mpi_comm))) - HMPI_GOTO_ERROR(FAIL, "can't receive cache image MPI_Bcast", mpi_result) } /* end else-if */ } /* end block */ @@ -1866,7 +1857,7 @@ H5C__decode_cache_image_entry(const H5F_t *f, const H5C_t *cache_ptr, const uint HDassert(buf); HDassert(*buf); HDassert(entry_num < cache_ptr->num_entries_in_image); - ie_ptr = &((cache_ptr->image_entries)[entry_num]); + ie_ptr = &(cache_ptr->image_entries[entry_num]); HDassert(ie_ptr); HDassert(ie_ptr->magic == H5C_IMAGE_ENTRY_T_MAGIC); @@ -2217,7 +2208,7 @@ H5C__encode_cache_image_entry(H5F_t *f, H5C_t *cache_ptr, uint8_t **buf, unsigne HDassert(buf); HDassert(*buf); HDassert(entry_num < cache_ptr->num_entries_in_image); - ie_ptr = &((cache_ptr->image_entries)[entry_num]); + ie_ptr = &(cache_ptr->image_entries[entry_num]); HDassert(ie_ptr->magic == H5C_IMAGE_ENTRY_T_MAGIC); /* Get pointer to buffer to encode into */ @@ -2924,12 +2915,14 @@ H5C__prep_for_file_close__scan_entries(const H5F_t *f, H5C_t *cache_ptr) HDassert(num_entries_in_image <= num_entries_tentatively_in_image); #ifndef NDEBUG - unsigned j = 0; - for (int i = H5C_MAX_RING_IN_IMAGE + 1; i <= H5C_RING_SB; i++) - j += cache_ptr->index_ring_len[i]; + { + unsigned j = 0; + for (int i = H5C_MAX_RING_IN_IMAGE + 1; i <= H5C_RING_SB; i++) + j += cache_ptr->index_ring_len[i]; - /* This will change */ - HDassert(entries_visited == (num_entries_tentatively_in_image + j)); + /* This will change */ + HDassert(entries_visited == (num_entries_tentatively_in_image + j)); + } #endif cache_ptr->num_entries_in_image = num_entries_in_image; @@ -3127,23 +3120,17 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) i = -1; entry_ptr = cache_ptr->LRU_head_ptr; - while (entry_ptr != NULL) { - HDassert(entry_ptr->magic == H5C__H5C_CACHE_ENTRY_T_MAGIC); HDassert(entry_ptr->type != NULL); if (entry_ptr->prefetched) { - HDassert(entry_ptr->lru_rank != 0); HDassert((entry_ptr->lru_rank == -1) || (entry_ptr->lru_rank > i)); if ((entry_ptr->lru_rank > 1) && (entry_ptr->lru_rank > i + 1)) - lru_rank_holes += entry_ptr->lru_rank - (i + 1); - i = entry_ptr->lru_rank; - } /* end if */ entry_ptr = entry_ptr->next; @@ -3168,10 +3155,8 @@ H5C__reconstruct_cache_contents(H5F_t *f, H5C_t *cache_ptr) */ hbool_t write_permitted = FALSE; - if (cache_ptr->check_write_permitted != NULL) { - if ((cache_ptr->check_write_permitted)(f, &write_permitted) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "Can't get write_permitted") - } /* end if */ + if (cache_ptr->check_write_permitted && (cache_ptr->check_write_permitted)(f, &write_permitted) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTPROTECT, FAIL, "Can't get write_permitted") else write_permitted = cache_ptr->write_permitted; |