summaryrefslogtreecommitdiffstats
path: root/test/cache_common.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2010-07-06 19:45:35 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2010-07-06 19:45:35 (GMT)
commit98754fa9d12090f5e048fdb05cc5e9ce9111676f (patch)
tree407e611b19ee551d8153779104022dd886a467e5 /test/cache_common.c
parent29321bcafa9f1c6108bb92b5a844a9d4d9c2c8e7 (diff)
downloadhdf5-98754fa9d12090f5e048fdb05cc5e9ce9111676f.zip
hdf5-98754fa9d12090f5e048fdb05cc5e9ce9111676f.tar.gz
hdf5-98754fa9d12090f5e048fdb05cc5e9ce9111676f.tar.bz2
[svn-r19050] Description:
Bring r18704:19049 from trunk to revise_chunks branch. Tested on: FreeBSD/32 6.3 (duty) in debug mode FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64-amd64 2.6 (amani) w/Intel compilers, w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN, in production mode Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in debug mode Mac OS X/32 10.6.3 (amazon) in debug mode Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe, in production mode
Diffstat (limited to 'test/cache_common.c')
-rw-r--r--test/cache_common.c1335
1 files changed, 713 insertions, 622 deletions
diff --git a/test/cache_common.c b/test/cache_common.c
index a684e92..312de3d 100644
--- a/test/cache_common.c
+++ b/test/cache_common.c
@@ -64,20 +64,93 @@ hbool_t try_core_file_driver = FALSE;
hbool_t core_file_driver_failed = FALSE;
const char *failure_mssg = NULL;
-test_entry_t pico_entries[NUM_PICO_ENTRIES], orig_pico_entries[NUM_PICO_ENTRIES];
-test_entry_t nano_entries[NUM_NANO_ENTRIES], orig_nano_entries[NUM_NANO_ENTRIES];
-test_entry_t micro_entries[NUM_MICRO_ENTRIES], orig_micro_entries[NUM_MICRO_ENTRIES];
-test_entry_t tiny_entries[NUM_TINY_ENTRIES], orig_tiny_entries[NUM_TINY_ENTRIES];
-test_entry_t small_entries[NUM_SMALL_ENTRIES], orig_small_entries[NUM_SMALL_ENTRIES];
-test_entry_t medium_entries[NUM_MEDIUM_ENTRIES], orig_medium_entries[NUM_MEDIUM_ENTRIES];
-test_entry_t large_entries[NUM_LARGE_ENTRIES], orig_large_entries[NUM_LARGE_ENTRIES];
-test_entry_t huge_entries[NUM_HUGE_ENTRIES], orig_huge_entries[NUM_HUGE_ENTRIES];
-test_entry_t monster_entries[NUM_MONSTER_ENTRIES], orig_monster_entries[NUM_MONSTER_ENTRIES];
-test_entry_t variable_entries[NUM_VARIABLE_ENTRIES], orig_variable_entries[NUM_VARIABLE_ENTRIES];
-test_entry_t notify_entries[NUM_NOTIFY_ENTRIES], orig_notify_entries[NUM_NOTIFY_ENTRIES];
+static test_entry_t pico_entries[NUM_PICO_ENTRIES], orig_pico_entries[NUM_PICO_ENTRIES];
+static test_entry_t nano_entries[NUM_NANO_ENTRIES], orig_nano_entries[NUM_NANO_ENTRIES];
+static test_entry_t micro_entries[NUM_MICRO_ENTRIES], orig_micro_entries[NUM_MICRO_ENTRIES];
+static test_entry_t tiny_entries[NUM_TINY_ENTRIES], orig_tiny_entries[NUM_TINY_ENTRIES];
+static test_entry_t small_entries[NUM_SMALL_ENTRIES], orig_small_entries[NUM_SMALL_ENTRIES];
+static test_entry_t medium_entries[NUM_MEDIUM_ENTRIES], orig_medium_entries[NUM_MEDIUM_ENTRIES];
+static test_entry_t large_entries[NUM_LARGE_ENTRIES], orig_large_entries[NUM_LARGE_ENTRIES];
+static test_entry_t huge_entries[NUM_HUGE_ENTRIES], orig_huge_entries[NUM_HUGE_ENTRIES];
+static test_entry_t monster_entries[NUM_MONSTER_ENTRIES], orig_monster_entries[NUM_MONSTER_ENTRIES];
+static test_entry_t variable_entries[NUM_VARIABLE_ENTRIES], orig_variable_entries[NUM_VARIABLE_ENTRIES];
+static test_entry_t notify_entries[NUM_NOTIFY_ENTRIES], orig_notify_entries[NUM_NOTIFY_ENTRIES];
hbool_t orig_entry_arrays_init = FALSE;
+static herr_t pico_clear(H5F_t * f, void * thing, hbool_t dest);
+static herr_t nano_clear(H5F_t * f, void * thing, hbool_t dest);
+static herr_t micro_clear(H5F_t * f, void * thing, hbool_t dest);
+static herr_t tiny_clear(H5F_t * f, void * thing, hbool_t dest);
+static herr_t small_clear(H5F_t * f, void * thing, hbool_t dest);
+static herr_t medium_clear(H5F_t * f, void * thing, hbool_t dest);
+static herr_t large_clear(H5F_t * f, void * thing, hbool_t dest);
+static herr_t huge_clear(H5F_t * f, void * thing, hbool_t dest);
+static herr_t monster_clear(H5F_t * f, void * thing, hbool_t dest);
+static herr_t variable_clear(H5F_t * f, void * thing, hbool_t dest);
+static herr_t notify_clear(H5F_t * f, void * thing, hbool_t dest);
+
+static herr_t pico_dest(H5F_t * f, void * thing);
+static herr_t nano_dest(H5F_t * f, void * thing);
+static herr_t micro_dest(H5F_t * f, void * thing);
+static herr_t tiny_dest(H5F_t * f, void * thing);
+static herr_t small_dest(H5F_t * f, void * thing);
+static herr_t medium_dest(H5F_t * f, void * thing);
+static herr_t large_dest(H5F_t * f, void * thing);
+static herr_t huge_dest(H5F_t * f, void * thing);
+static herr_t monster_dest(H5F_t * f, void * thing);
+static herr_t variable_dest(H5F_t * f, void * thing);
+static herr_t notify_dest(H5F_t * f, void * thing);
+
+static herr_t pico_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
+ haddr_t addr, void *thing, unsigned * flags_ptr);
+static herr_t nano_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
+ haddr_t addr, void *thing, unsigned * flags_ptr);
+static herr_t micro_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
+ haddr_t addr, void *thing, unsigned * flags_ptr);
+static herr_t tiny_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
+ haddr_t addr, void *thing, unsigned * flags_ptr);
+static herr_t small_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
+ haddr_t addr, void *thing, unsigned * flags_ptr);
+static herr_t medium_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
+ haddr_t addr, void *thing, unsigned * flags_ptr);
+static herr_t large_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
+ haddr_t addr, void *thing, unsigned * flags_ptr);
+static herr_t huge_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
+ haddr_t addr, void *thing, unsigned * flags_ptr);
+static herr_t monster_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
+ haddr_t addr, void *thing, unsigned * flags_ptr);
+static herr_t variable_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
+ haddr_t addr, void *thing, unsigned * flags_ptr);
+static herr_t notify_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest,
+ haddr_t addr, void *thing, unsigned * flags_ptr);
+
+static void * pico_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
+static void * nano_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
+static void * micro_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
+static void * tiny_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
+static void * small_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
+static void * medium_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
+static void * large_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
+static void * huge_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
+static void * monster_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
+static void * variable_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
+static void * notify_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata);
+
+static herr_t pico_size(H5F_t * f, void * thing, size_t * size_ptr);
+static herr_t nano_size(H5F_t * f, void * thing, size_t * size_ptr);
+static herr_t micro_size(H5F_t * f, void * thing, size_t * size_ptr);
+static herr_t tiny_size(H5F_t * f, void * thing, size_t * size_ptr);
+static herr_t small_size(H5F_t * f, void * thing, size_t * size_ptr);
+static herr_t medium_size(H5F_t * f, void * thing, size_t * size_ptr);
+static herr_t large_size(H5F_t * f, void * thing, size_t * size_ptr);
+static herr_t huge_size(H5F_t * f, void * thing, size_t * size_ptr);
+static herr_t monster_size(H5F_t * f, void * thing, size_t * size_ptr);
+static herr_t variable_size(H5F_t * f, void * thing, size_t * size_ptr);
+static herr_t notify_size(H5F_t * f, void * thing, size_t * size_ptr);
+
+static herr_t notify_notify(H5C_notify_action_t action, void *thing);
+
test_entry_t * entries[NUMBER_OF_ENTRY_TYPES] =
{
pico_entries,
@@ -304,6 +377,7 @@ static void execute_flush_op(H5F_t *file_ptr, struct test_entry_t *entry_ptr,
/* address translation funtions: */
+
/*-------------------------------------------------------------------------
* Function: addr_to_type_and_index
*
@@ -473,10 +547,6 @@ check_write_permitted(const H5F_t UNUSED * f,
* Programmer: John Mainzer
* 6/10/04
*
- * Modifications:
- *
- * Added variable_clear. -- JRM 8/30/06
- *
*-------------------------------------------------------------------------
*/
@@ -608,16 +678,6 @@ notify_clear(H5F_t * f, void * thing, hbool_t dest)
* Programmer: John Mainzer
* 6/10/04
*
- * Modifications:
- *
- * JRM -- 4/4/06
- * Added code to decrement the pinning_ref_count s of entries
- * pinned by the target entry, and to unpin those entries
- * if the reference count drops to zero.
- *
- * JRM -- 8/30/06
- * Added variable_destroy().
- *
*-------------------------------------------------------------------------
*/
@@ -781,14 +841,6 @@ notify_dest(H5F_t * f, void * thing)
* Programmer: John Mainzer
* 6/10/04
*
- * Modifications:
- *
- * JRM -- 8/30/06
- * Added variable_flush() and flags_ptr parameter.
- *
- * JRM -- 9/1/06
- * Added support for flush operations.
- *
*-------------------------------------------------------------------------
*/
@@ -968,11 +1020,6 @@ notify_flush(H5F_t *f, hid_t dxpl_id, hbool_t dest, haddr_t addr,
* Programmer: John Mainzer
* 6/10/04
*
- * Modifications:
- *
- * JRM -- 8/30/06
- * Added variable_load().
- *
*-------------------------------------------------------------------------
*/
@@ -1103,11 +1150,6 @@ notify_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *udata)
* Programmer: John Mainzer
* 6/10/04
*
- * Modifications:
- *
- * JRM -- 8/30/06
- * Added variable_size().
- *
*-------------------------------------------------------------------------
*/
@@ -1418,8 +1460,7 @@ create_pinned_entry_dependency(H5F_t * file_ptr,
if ( pinned_entry_ptr->pinning_ref_count == 0 ) {
protect_entry(file_ptr, pinned_type, pinned_idx);
- unprotect_entry(file_ptr, pinned_type, pinned_idx, FALSE,
- H5C__PIN_ENTRY_FLAG);
+ unprotect_entry(file_ptr, pinned_type, pinned_idx, H5C__PIN_ENTRY_FLAG);
}
(pinned_entry_ptr->pinning_ref_count)++;
@@ -1439,7 +1480,7 @@ create_pinned_entry_dependency(H5F_t * file_ptr,
* If the dirty_pin parameter is true, verify that the
* target entry is in the cache and is pinned. If it
* isn't, scream and die. If it is, use the
- * H5C_mark_pinned_entry_dirty() call to dirty it.
+ * H5C_mark_entry_dirty() call to dirty it.
*
* Do nothing if pass is false on entry.
*
@@ -1492,14 +1533,14 @@ dirty_entry(H5F_t * file_ptr,
} else {
- mark_pinned_entry_dirty(type, idx, FALSE, (size_t)0);
+ mark_entry_dirty(type, idx);
}
}
} else {
protect_entry(file_ptr, type, idx);
- unprotect_entry(file_ptr, type, idx, TRUE, H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, idx, H5C__DIRTIED_FLAG);
}
}
@@ -1532,7 +1573,7 @@ execute_flush_op(H5F_t * file_ptr,
{
H5C_t * cache_ptr;
- HDassert( file_ptr ) ;
+ HDassert( file_ptr );
cache_ptr = file_ptr->shared->cache;
HDassert( cache_ptr != NULL );
HDassert( cache_ptr->magic == H5C__H5C_T_MAGIC );
@@ -1543,7 +1584,7 @@ execute_flush_op(H5F_t * file_ptr,
( entry_ptr->header.size == entry_ptr->size ) );
HDassert( op_ptr != NULL );
HDassert( ( 0 <= entry_ptr->type ) &&
- ( entry_ptr->type < NUMBER_OF_ENTRY_TYPES ) );
+ ( entry_ptr->type < NUMBER_OF_ENTRY_TYPES ) );
HDassert( ( 0 <= entry_ptr->index ) &&
( entry_ptr->index <= max_indices[entry_ptr->type] ) );
HDassert( ( 0 <= op_ptr->type ) &&
@@ -1600,8 +1641,8 @@ execute_flush_op(H5F_t * file_ptr,
}
break;
- case FLUSH_OP__RENAME:
- rename_entry(cache_ptr, op_ptr->type, op_ptr->idx,
+ case FLUSH_OP__MOVE:
+ move_entry(cache_ptr, op_ptr->type, op_ptr->idx,
op_ptr->flag);
break;
@@ -1817,24 +1858,20 @@ reset_entries(void)
/*-------------------------------------------------------------------------
- * Function: resize_entry
+ * Function: resize_entry
*
- * Purpose: Given a pointer to a cache, an entry type, an index, and
- * a size, set the size of the target entry to the size. Note
- * that at present, the type of the entry must be
- * VARIABLE_ENTRY_TYPE.
+ * Purpose: Given a pointer to a cache, an entry type, an index, and
+ * a new size, set the size of the target entry to the new size.
*
- * If the resize_pin parameter is true, verify that the
- * target entry is in the cache and is pinned. If it
- * isn't, scream and die. If it is, use the
- * H5C_mark_pinned_entry_dirty() call to resize it.
+ * Note that at present, the type of the entry must be
+ * VARIABLE_ENTRY_TYPE.
*
- * Do nothing if pass is false on entry.
+ * Do nothing if pass is false on entry.
*
- * Return: void
+ * Return: void
*
- * Programmer: John Mainzer
- * 6/10/04
+ * Programmer: John Mainzer
+ * 1/11/08
*
*-------------------------------------------------------------------------
*/
@@ -1843,11 +1880,12 @@ void
resize_entry(H5F_t * file_ptr,
int32_t type,
int32_t idx,
- size_t new_size,
- hbool_t resize_pin)
+ size_t new_size,
+ hbool_t in_cache)
{
test_entry_t * base_addr;
test_entry_t * entry_ptr;
+ herr_t result;
HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) );
HDassert( type == VARIABLE_ENTRY_TYPE );
@@ -1856,126 +1894,61 @@ resize_entry(H5F_t * file_ptr,
if ( pass ) {
- base_addr = entries[type];
- entry_ptr = &(base_addr[idx]);
-
- HDassert( entry_ptr->index == idx );
- HDassert( entry_ptr->type == type );
- HDassert( entry_ptr == entry_ptr->self );
-
- if ( resize_pin ) {
+ if ( in_cache ) {
H5C_t *cache_ptr = file_ptr->shared->cache;
HDassert( cache_ptr );
- if ( ! entry_in_cache(cache_ptr, type, idx) ) {
+ if ( ! entry_in_cache(cache_ptr, type, idx) ) {
- pass = FALSE;
+ pass = FALSE;
failure_mssg = "entry to be resized pinned is not in cache.";
- } else {
-
- if ( ! ( (entry_ptr->header).is_pinned ) ) {
-
- pass = FALSE;
- failure_mssg = "entry to be resized pinned is not pinned.";
-
- } else {
-
- mark_pinned_entry_dirty(type, idx, TRUE, new_size);
- }
- }
- } else {
-
- protect_entry(file_ptr, type, idx);
- unprotect_entry_with_size_change(file_ptr, type, idx,
- H5C__SIZE_CHANGED_FLAG, new_size);
- }
- }
-
- return;
-
-} /* resize_entry() */
-
-
-/*-------------------------------------------------------------------------
- * Function: resize_pinned_entry
- *
- * Purpose: Given a pointer to a cache, an entry type, an index, and
- * a new size, change the size of the target pinned entry
- * to match the supplied new size.
- *
- * Do nothing if pass is false on entry.
- *
- * Return: void
- *
- * Programmer: John Mainzer
- * 1/11/08
- *
- *-------------------------------------------------------------------------
- */
-
-void
-resize_pinned_entry(H5C_t * cache_ptr,
- int32_t type,
- int32_t idx,
- size_t new_size)
-{
- herr_t result;
- test_entry_t * base_addr;
- test_entry_t * entry_ptr;
-
- HDassert( cache_ptr );
- HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) );
- HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) );
- HDassert( type == VARIABLE_ENTRY_TYPE ) ;
- HDassert( ( 0 < new_size ) && ( new_size <= entry_sizes[type] ) );
-
- if ( pass ) {
-
- if ( ! entry_in_cache(cache_ptr, type, idx) ) {
-
- pass = FALSE;
- failure_mssg = "entry not in cache.";
-
- } else {
+ } else {
- base_addr = entries[type];
- entry_ptr = &(base_addr[idx]);
+ base_addr = entries[type];
+ entry_ptr = &(base_addr[idx]);
- HDassert( entry_ptr->index == idx );
- HDassert( entry_ptr->type == type );
- HDassert( entry_ptr == entry_ptr->self );
+ HDassert( entry_ptr->index == idx );
+ HDassert( entry_ptr->type == type );
+ HDassert( entry_ptr->cache_ptr == cache_ptr );
+ HDassert( entry_ptr == entry_ptr->self );
- if ( ! ( (entry_ptr->header).is_pinned ) ) {
+ if ( ! ( entry_ptr->header.is_pinned || entry_ptr->header.is_protected ) ) {
- pass = FALSE;
- failure_mssg = "entry to be resized is not pinned.";
+ pass = FALSE;
+ failure_mssg = "entry to be resized is not pinned or protected.";
- } else {
+ } else {
- entry_ptr->size = new_size;
+ entry_ptr->size = new_size;
- result = H5C_resize_pinned_entry((void *)entry_ptr,
- new_size);
+ result = H5C_resize_entry((void *)entry_ptr, new_size);
+ entry_ptr->is_dirty = TRUE;
- if ( result != SUCCEED ) {
+ if ( result != SUCCEED ) {
- pass = FALSE;
- failure_mssg = "error(s) in H5C_resize_pinned_entry().";
+ pass = FALSE;
+ failure_mssg = "error(s) in H5C_resize_entry().";
- } else {
+ } else {
- HDassert( entry_ptr->size = (entry_ptr->header).size );
+ HDassert( entry_ptr->size = (entry_ptr->header).size );
+ }
}
}
- }
+ } else {
+
+ protect_entry(file_ptr, type, idx);
+ resize_entry(file_ptr, type, idx, new_size, TRUE);
+ unprotect_entry(file_ptr, type, idx, H5C__DIRTIED_FLAG);
+ }
}
return;
-} /* resize_pinned_entry() */
+} /* resize_entry() */
/*-------------------------------------------------------------------------
@@ -2639,7 +2612,7 @@ setup_cache(size_t max_cache_size,
cache_ptr = H5C_create(max_cache_size,
min_clean_size,
(NUMBER_OF_ENTRY_TYPES - 1),
- (const char **)entry_type_names,
+ (const char **)entry_type_names,
check_write_permitted,
TRUE,
NULL,
@@ -2743,7 +2716,7 @@ setup_cache(size_t max_cache_size,
* Return: void
*
* Programmer: John Mainzer
- * 6/11/04
+ * 9/14/07
*
*-------------------------------------------------------------------------
*/
@@ -2973,12 +2946,7 @@ flush_cache(H5F_t * file_ptr,
/*-------------------------------------------------------------------------
* Function: insert_entry()
*
- * Purpose: Insert the entry indicated by the type and index. Mark
- * it clean or dirty as indicated.
- *
- * Note that I don't see much practical use for inserting
- * a clean entry, but the interface permits it so we should
- * test it.
+ * Purpose: Insert the entry indicated by the type and index.
*
* Do nothing if pass is false.
*
@@ -2994,7 +2962,6 @@ void
insert_entry(H5F_t * file_ptr,
int32_t type,
int32_t idx,
- hbool_t UNUSED dirty,
unsigned int flags)
{
H5C_t * cache_ptr;
@@ -3077,7 +3044,7 @@ insert_entry(H5F_t * file_ptr,
/*-------------------------------------------------------------------------
- * Function: mark_pinned_entry_dirty()
+ * Function: mark_entry_dirty()
*
* Purpose: Mark the specified entry as dirty.
*
@@ -3092,12 +3059,9 @@ insert_entry(H5F_t * file_ptr,
*/
void
-mark_pinned_entry_dirty(int32_t type,
- int32_t idx,
- hbool_t size_changed,
- size_t new_size)
+mark_entry_dirty(int32_t type,
+ int32_t idx)
{
- /* const char * fcn_name = "mark_pinned_entry_dirty()"; */
herr_t result;
test_entry_t * base_addr;
test_entry_t * entry_ptr;
@@ -3113,47 +3077,23 @@ mark_pinned_entry_dirty(int32_t type,
HDassert( entry_ptr->index == idx );
HDassert( entry_ptr->type == type );
HDassert( entry_ptr == entry_ptr->self );
- HDassert( ! (entry_ptr->header.is_protected) );
- HDassert( entry_ptr->header.is_pinned );
- HDassert( entry_ptr->is_pinned );
+ HDassert( entry_ptr->header.is_protected ||
+ entry_ptr->header.is_pinned );
entry_ptr->is_dirty = TRUE;
- if ( size_changed ) {
-
- /* update entry size now to keep the sanity checks happy */
- entry_ptr->size = new_size;
- }
-
- result = H5C_mark_pinned_entry_dirty((void *)entry_ptr,
- size_changed,
- new_size);
+ result = H5C_mark_entry_dirty((void *)entry_ptr);
if ( ( result < 0 ) ||
- ( ! (entry_ptr->header.is_dirty) ) ||
- ( ! (entry_ptr->header.is_pinned) ) ||
+ ( !entry_ptr->header.is_protected && !entry_ptr->header.is_pinned ) ||
+ ( entry_ptr->header.is_protected && !entry_ptr->header.dirtied ) ||
+ ( !entry_ptr->header.is_protected && !entry_ptr->header.is_dirty ) ||
( entry_ptr->header.type != &(types[type]) ) ||
( entry_ptr->size != entry_ptr->header.size ) ||
( entry_ptr->addr != entry_ptr->header.addr ) ) {
-#if 0 /* This is useful debugging code -- keep it around */
- HDfprintf(stdout, "result = %ld.\n", (long)result);
- HDfprintf(stdout, "entry_ptr->header.is_dirty = %d.\n",
- (int)(entry_ptr->header.is_dirty));
- HDfprintf(stdout, "entry_ptr->header.is_pinned = %d.\n",
- (int)(entry_ptr->header.is_pinned));
- HDfprintf(stdout,
- "(entry_ptr->header.type != &(types[type])) = %d.\n",
- (int)(entry_ptr->header.type != &(types[type])));
- HDfprintf(stdout,
- "entry_ptr->size = %ld, entry_ptr->header.size = %ld.\n",
- (long)(entry_ptr->size), (long)(entry_ptr->header.size));
- HDfprintf(stdout,
- "entry_ptr->addr = %ld, entry_ptr->header.addr = %ld.\n",
- (long)(entry_ptr->addr), (long)(entry_ptr->header.addr));
-#endif
pass = FALSE;
- failure_mssg = "error in H5C_mark_pinned_entry_dirty().";
+ failure_mssg = "error in H5C_mark_entry_dirty().";
}
@@ -3163,93 +3103,13 @@ mark_pinned_entry_dirty(int32_t type,
return;
-} /* mark_pinned_entry_dirty() */
+} /* mark_entry_dirty() */
/*-------------------------------------------------------------------------
- * Function: mark_pinned_or_protected_entry_dirty()
+ * Function: move_entry()
*
- * Purpose: Mark the specified entry as dirty.
- *
- * Do nothing if pass is FALSE on entry.
- *
- * Return: void
- *
- * Programmer: John Mainzer
- * 5/17/06
- *
- *-------------------------------------------------------------------------
- */
-
-void
-mark_pinned_or_protected_entry_dirty(int32_t type,
- int32_t idx)
-{
- /* const char * fcn_name = "mark_pinned_or_protected_entry_dirty()"; */
- herr_t result;
- test_entry_t * base_addr;
- test_entry_t * entry_ptr;
-
- if ( pass ) {
-
- HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) );
- HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) );
-
- base_addr = entries[type];
- entry_ptr = &(base_addr[idx]);
-
- HDassert( entry_ptr->index == idx );
- HDassert( entry_ptr->type == type );
- HDassert( entry_ptr == entry_ptr->self );
- HDassert( entry_ptr->header.is_protected ||
- entry_ptr->header.is_pinned );
-
- entry_ptr->is_dirty = TRUE;
-
- result = H5C_mark_pinned_or_protected_entry_dirty((void *)entry_ptr);
-
- if ( ( result < 0 )
- ||
- ( ( ! (entry_ptr->header.is_protected) )
- &&
- ( ! (entry_ptr->header.is_pinned) )
- )
- ||
- ( ( entry_ptr->header.is_protected )
- &&
- ( ! ( entry_ptr->header.dirtied ) )
- )
- ||
- ( ( ! ( entry_ptr->header.is_protected ) )
- &&
- ( ! ( entry_ptr->header.is_dirty ) )
- )
- ||
- ( entry_ptr->header.type != &(types[type]) )
- ||
- ( entry_ptr->size != entry_ptr->header.size )
- ||
- ( entry_ptr->addr != entry_ptr->header.addr ) ) {
-
- pass = FALSE;
- failure_mssg =
- "error in H5C_mark_pinned_or_protected_entry_dirty().";
-
- }
-
- HDassert( ((entry_ptr->header).type)->id == type );
-
- }
-
- return;
-
-} /* mark_pinned_or_protected_entry_dirty() */
-
-
-/*-------------------------------------------------------------------------
- * Function: rename_entry()
- *
- * Purpose: Rename the entry indicated by the type and index to its
+ * Purpose: Move the entry indicated by the type and index to its
* main or alternate address as indicated. If the entry is
* already at the desired entry, do nothing.
*
@@ -3262,7 +3122,7 @@ mark_pinned_or_protected_entry_dirty(int32_t type,
*/
void
-rename_entry(H5C_t * cache_ptr,
+move_entry(H5C_t * cache_ptr,
int32_t type,
int32_t idx,
hbool_t main_addr)
@@ -3274,74 +3134,77 @@ rename_entry(H5C_t * cache_ptr,
test_entry_t * base_addr;
test_entry_t * entry_ptr;
- HDassert( cache_ptr );
- HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) );
- HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) );
+ if ( pass ) {
- base_addr = entries[type];
- entry_ptr = &(base_addr[idx]);
+ HDassert( cache_ptr );
+ HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) );
+ HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) );
- HDassert( entry_ptr->index == idx );
- HDassert( entry_ptr->type == type );
- HDassert( entry_ptr == entry_ptr->self );
- HDassert( entry_ptr->cache_ptr == cache_ptr );
- HDassert( !(entry_ptr->is_protected) );
- HDassert( !(entry_ptr->header.is_protected) );
+ base_addr = entries[type];
+ entry_ptr = &(base_addr[idx]);
+ HDassert( entry_ptr->index == idx );
+ HDassert( entry_ptr->type == type );
+ HDassert( entry_ptr == entry_ptr->self );
+ HDassert( entry_ptr->cache_ptr == cache_ptr );
+ HDassert( !(entry_ptr->is_protected) );
+ HDassert( !(entry_ptr->header.is_protected) );
- if ( entry_ptr->at_main_addr && !main_addr ) {
- /* rename to alt addr */
+ if ( entry_ptr->at_main_addr && !main_addr ) {
- HDassert( entry_ptr->addr == entry_ptr->main_addr );
+ /* move to alt addr */
- done = FALSE;
- old_addr = entry_ptr->addr;
- new_addr = entry_ptr->alt_addr;
+ HDassert( entry_ptr->addr == entry_ptr->main_addr );
- } else if ( !(entry_ptr->at_main_addr) && main_addr ) {
+ done = FALSE;
+ old_addr = entry_ptr->addr;
+ new_addr = entry_ptr->alt_addr;
- /* rename to main addr */
+ } else if ( !(entry_ptr->at_main_addr) && main_addr ) {
- HDassert( entry_ptr->addr == entry_ptr->alt_addr );
+ /* move to main addr */
- done = FALSE;
- old_addr = entry_ptr->addr;
- new_addr = entry_ptr->main_addr;
- }
+ HDassert( entry_ptr->addr == entry_ptr->alt_addr );
- if ( ! done ) {
+ done = FALSE;
+ old_addr = entry_ptr->addr;
+ new_addr = entry_ptr->main_addr;
+ }
- entry_ptr->is_dirty = TRUE;
+ if ( ! done ) {
- result = H5C_rename_entry(cache_ptr, &(types[type]),
- old_addr, new_addr);
- }
+ entry_ptr->is_dirty = TRUE;
- if ( ! done ) {
+ result = H5C_move_entry(cache_ptr, &(types[type]),
+ old_addr, new_addr);
+ }
- if ( ( result < 0 ) ||
- ( ( ! ( entry_ptr->header.destroy_in_progress ) ) &&
- ( entry_ptr->header.addr != new_addr ) ) ) {
+ if ( ! done ) {
- pass = FALSE;
- failure_mssg = "error in H5C_rename_entry().";
+ if ( ( result < 0 ) ||
+ ( ( ! ( entry_ptr->header.destroy_in_progress ) ) &&
+ ( entry_ptr->header.addr != new_addr ) ) ) {
- } else {
+ pass = FALSE;
+ failure_mssg = "error in H5C_move_entry().";
+
+ } else {
- entry_ptr->addr = new_addr;
- entry_ptr->at_main_addr = main_addr;
+ entry_ptr->addr = new_addr;
+ entry_ptr->at_main_addr = main_addr;
+ }
}
- }
- HDassert( ((entry_ptr->header).type)->id == type );
+ HDassert( ((entry_ptr->header).type)->id == type );
- HDassert( entry_ptr->header.is_dirty );
- HDassert( entry_ptr->is_dirty );
+ HDassert( entry_ptr->header.is_dirty );
+ HDassert( entry_ptr->is_dirty );
+ }
return;
-} /* rename_entry() */
+} /* move_entry() */
/*-------------------------------------------------------------------------
@@ -3364,7 +3227,6 @@ protect_entry(H5F_t * file_ptr,
int32_t type,
int32_t idx)
{
- /* const char * fcn_name = "protect_entry()"; */
H5C_t * cache_ptr;
test_entry_t * base_addr;
test_entry_t * entry_ptr;
@@ -3459,10 +3321,9 @@ protect_entry_ro(H5F_t * file_ptr,
int32_t type,
int32_t idx)
{
- /* const char * fcn_name = "protect_entry_ro()"; */
H5C_t *cache_ptr;
- test_entry_t * base_addr;
- test_entry_t * entry_ptr;
+ test_entry_t *base_addr;
+ test_entry_t *entry_ptr;
H5C_cache_entry_t * cache_entry_ptr;
if ( pass ) {
@@ -3596,13 +3457,11 @@ void
unpin_entry(int32_t type,
int32_t idx)
{
- /* const char * fcn_name = "unpin_entry()"; */
herr_t result;
test_entry_t * base_addr;
test_entry_t * entry_ptr;
if ( pass ) {
-
HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) );
HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) );
@@ -3617,7 +3476,7 @@ unpin_entry(int32_t type,
HDassert( entry_ptr->is_pinned );
HDassert( entry_ptr->pinned_from_client );
- result = H5C_unpin_entry((void *)entry_ptr);
+ result = H5C_unpin_entry(entry_ptr);
if ( ( result < 0 ) ||
( entry_ptr->header.pinned_from_client ) ||
@@ -3663,11 +3522,8 @@ void
unprotect_entry(H5F_t * file_ptr,
int32_t type,
int32_t idx,
- int dirty,
unsigned int flags)
{
- /* const char * fcn_name = "unprotect_entry()"; */
- H5C_t *cache_ptr;
herr_t result;
hbool_t pin_flag_set;
hbool_t unpin_flag_set;
@@ -3675,10 +3531,6 @@ unprotect_entry(H5F_t * file_ptr,
test_entry_t * entry_ptr;
if ( pass ) {
-
- cache_ptr = file_ptr->shared->cache;
-
- HDassert( cache_ptr );
HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) );
HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) );
@@ -3688,7 +3540,6 @@ unprotect_entry(H5F_t * file_ptr,
HDassert( entry_ptr->index == idx );
HDassert( entry_ptr->type == type );
HDassert( entry_ptr == entry_ptr->self );
- HDassert( entry_ptr->cache_ptr == cache_ptr );
HDassert( entry_ptr->header.is_protected );
HDassert( entry_ptr->is_protected );
@@ -3699,15 +3550,11 @@ unprotect_entry(H5F_t * file_ptr,
HDassert ( ( ! pin_flag_set ) || ( ! (entry_ptr->is_pinned) ) );
HDassert ( ( ! unpin_flag_set ) || ( entry_ptr->is_pinned ) );
- if ( ( dirty == TRUE ) || ( dirty == FALSE ) ) {
-
- flags |= (dirty ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET);
- entry_ptr->is_dirty = (hbool_t)(entry_ptr->is_dirty || dirty);
- }
+ if(flags & H5C__DIRTIED_FLAG)
+ entry_ptr->is_dirty = TRUE;
result = H5C_unprotect(file_ptr, H5P_DATASET_XFER_DEFAULT, H5P_DATASET_XFER_DEFAULT,
- &(types[type]), entry_ptr->addr, (void *)entry_ptr, flags,
- (size_t)0);
+ &(types[type]), entry_ptr->addr, (void *)entry_ptr, flags);
if ( ( result < 0 ) ||
( ( entry_ptr->header.is_protected ) &&
@@ -3717,26 +3564,6 @@ unprotect_entry(H5F_t * file_ptr,
( entry_ptr->size != entry_ptr->header.size ) ||
( entry_ptr->addr != entry_ptr->header.addr ) ) {
-#if 1 /* JRM */
- if ( result < 0 ) {
- HDfprintf(stdout, "result is negative.\n");
- }
- if ( ( entry_ptr->header.is_protected ) &&
- ( ( ! ( entry_ptr->is_read_only ) ) ||
- ( entry_ptr->ro_ref_count <= 0 ) ) ) {
- HDfprintf(stdout, "protected and not RO or refcnt <= 0.\n");
- }
- if ( entry_ptr->header.type != &(types[type]) ) {
- HDfprintf(stdout, "type disagreement.\n");
- }
- if ( entry_ptr->size != entry_ptr->header.size ) {
- HDfprintf(stdout, "size disagreement.\n");
- }
- if ( entry_ptr->addr != entry_ptr->header.addr ) {
- HDfprintf(stdout, "addr disagreement.\n");
- }
-#endif /* JRM */
-
pass = FALSE;
failure_mssg = "error in H5C_unprotect().";
@@ -3794,155 +3621,9 @@ unprotect_entry(H5F_t * file_ptr,
/*-------------------------------------------------------------------------
- * Function: unprotect_entry_with_size_change()
- *
- * Purpose: Version of unprotect_entry() that allow access to the new
- * size change parameters in H5C_unprotect_entry()
- *
- * At present, only the sizes of VARIABLE_ENTRY_TYPE entries
- * can be changed. Thus this function will scream and die
- * if the H5C__SIZE_CHANGED_FLAG is set and the type is not
- * VARIABLE_ENTRY_TYPE.
- *
- * Do nothing if pass is FALSE on entry.
- *
- * Return: void
- *
- * Programmer: John Mainzer
- * 8/31/06
- *
- *-------------------------------------------------------------------------
- */
-
-void
-unprotect_entry_with_size_change(H5F_t * file_ptr,
- int32_t type,
- int32_t idx,
- unsigned int flags,
- size_t new_size)
-{
- const char * fcn_name = "unprotect_entry_with_size_change()";
- herr_t result;
- hbool_t dirty_flag_set;
- hbool_t pin_flag_set;
- hbool_t unpin_flag_set;
- hbool_t size_changed_flag_set;
- test_entry_t * base_addr;
- test_entry_t * entry_ptr;
-
- if ( pass ) {
-#ifndef NDEBUG
- H5C_t * cache_ptr;
-
- cache_ptr = file_ptr->shared->cache;
-
- HDassert( cache_ptr );
-#endif /* NDEBUG */
- HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) );
- HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) );
- HDassert( new_size <= entry_sizes[type] );
-
- base_addr = entries[type];
- entry_ptr = &(base_addr[idx]);
-
- HDassert( entry_ptr->index == idx );
- HDassert( entry_ptr->type == type );
- HDassert( entry_ptr == entry_ptr->self );
- HDassert( entry_ptr->cache_ptr == cache_ptr );
- HDassert( entry_ptr->header.is_protected );
- HDassert( entry_ptr->is_protected );
-
- dirty_flag_set = (hbool_t)((flags & H5C__DIRTIED_FLAG) != 0 );
- pin_flag_set = (hbool_t)((flags & H5C__PIN_ENTRY_FLAG) != 0 );
- unpin_flag_set = (hbool_t)((flags & H5C__UNPIN_ENTRY_FLAG) != 0 );
- size_changed_flag_set = (hbool_t)((flags & H5C__SIZE_CHANGED_FLAG) != 0 );
-
- HDassert ( ! ( pin_flag_set && unpin_flag_set ) );
- HDassert ( ( ! pin_flag_set ) || ( ! (entry_ptr->is_pinned) ) );
- HDassert ( ( ! unpin_flag_set ) || ( entry_ptr->is_pinned ) );
- HDassert ( ( ! size_changed_flag_set ) || ( new_size > 0 ) );
- HDassert ( ( ! size_changed_flag_set ) ||
- ( type == VARIABLE_ENTRY_TYPE ) );
-
- entry_ptr->is_dirty = (hbool_t)(entry_ptr->is_dirty || dirty_flag_set);
-
- if ( size_changed_flag_set ) {
-
- entry_ptr->is_dirty = TRUE;
- entry_ptr->size = new_size;
- }
-
- result = H5C_unprotect(file_ptr, H5P_DATASET_XFER_DEFAULT, H5P_DATASET_XFER_DEFAULT,
- &(types[type]), entry_ptr->addr, (void *)entry_ptr, flags,
- new_size);
-
- if ( ( result < 0 ) ||
- ( entry_ptr->header.is_protected ) ||
- ( entry_ptr->header.type != &(types[type]) ) ||
- ( entry_ptr->size != entry_ptr->header.size ) ||
- ( entry_ptr->addr != entry_ptr->header.addr ) ) {
-
- if ( result < 0 )
- HDfprintf(stdout, "%s: H5C_unprotect() failed.\n", fcn_name);
-
- if ( entry_ptr->header.is_protected )
- HDfprintf(stdout, "%s: entry still protected?!?.\n", fcn_name);
-
- if ( entry_ptr->header.type != &(types[type]) )
- HDfprintf(stdout, "%s: entry has bad type after unprotect.\n", fcn_name);
-
- if ( entry_ptr->size != entry_ptr->header.size )
- HDfprintf(stdout, "%s: bad entry size after unprotect. e/a = %d/%d\n", fcn_name,
- (int)(entry_ptr->size),
- (int)(entry_ptr->header.size));
-
- if ( entry_ptr->addr != entry_ptr->header.addr )
- HDfprintf(stdout, "%s: bad entry addr after unprotect. e/a = 0x%llx/0x%llx\n", fcn_name,
- (long long)(entry_ptr->addr),
- (long long)(entry_ptr->header.addr));
-
- pass = FALSE;
- failure_mssg = "error in H5C_unprotect().";
-
- }
- else
- {
- entry_ptr->is_protected = FALSE;
-
- if ( pin_flag_set ) {
-
- HDassert ( entry_ptr->header.is_pinned );
- entry_ptr->pinned_from_client = TRUE;
- entry_ptr->is_pinned = TRUE;
-
- } else if ( unpin_flag_set ) {
-
- HDassert ( entry_ptr->header.is_pinned == entry_ptr->header.pinned_from_cache );
- entry_ptr->pinned_from_client = FALSE;
- entry_ptr->is_pinned = entry_ptr->pinned_from_cache;
-
- }
- }
-
- HDassert( ((entry_ptr->header).type)->id == type );
-
- if ( ( flags & H5C__DIRTIED_FLAG ) != 0
- && ( (flags & H5C__DELETED_FLAG) == 0 ) ) {
-
- HDassert( entry_ptr->header.is_dirty );
- HDassert( entry_ptr->is_dirty );
- }
- }
-
- return;
-
-} /* unprotect_entry_with_size_change() */
-
-
-/*-------------------------------------------------------------------------
* Function: row_major_scan_forward()
*
- * Purpose: Do a sequence of inserts, protects, unprotects, renames,
+ * Purpose: Do a sequence of inserts, protects, unprotects, moves,
* destroys while scanning through the set of entries. If
* pass is false on entry, do nothing.
*
@@ -3962,9 +3643,8 @@ row_major_scan_forward(H5F_t * file_ptr,
hbool_t display_stats,
hbool_t display_detailed_stats,
hbool_t do_inserts,
- hbool_t dirty_inserts,
- hbool_t do_renames,
- hbool_t rename_to_main_addr,
+ hbool_t do_moves,
+ hbool_t move_to_main_addr,
hbool_t do_destroys,
hbool_t do_mult_ro_protects,
int dirty_destroys,
@@ -4011,8 +3691,7 @@ row_major_scan_forward(H5F_t * file_ptr,
if ( verbose )
HDfprintf(stdout, "(i, %d, %d) ", type, (idx + lag));
- insert_entry(file_ptr, type, (idx + lag), dirty_inserts,
- H5C__NO_FLAGS_SET);
+ insert_entry(file_ptr, type, (idx + lag), H5C__NO_FLAGS_SET);
}
@@ -4033,17 +3712,16 @@ row_major_scan_forward(H5F_t * file_ptr,
if ( verbose )
HDfprintf(stdout, "(u, %d, %d) ", type, (idx + lag - 2));
- unprotect_entry(file_ptr, type, idx+lag-2, NO_CHANGE,
- H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, idx+lag-2, H5C__NO_FLAGS_SET);
}
- if ( ( pass ) && ( do_renames ) && ( (idx + lag - 2) >= 0 ) &&
+ if ( ( pass ) && ( do_moves ) && ( (idx + lag - 2) >= 0 ) &&
( (idx + lag - 2) <= max_indices[type] ) &&
( ( (idx + lag - 2) % 3 ) == 0 ) ) {
- rename_entry(cache_ptr, type, (idx + lag - 2),
- rename_to_main_addr);
+ move_entry(cache_ptr, type, (idx + lag - 2),
+ move_to_main_addr);
}
@@ -4064,8 +3742,7 @@ row_major_scan_forward(H5F_t * file_ptr,
if ( verbose )
HDfprintf(stdout, "(u, %d, %d) ", type, (idx + lag - 5));
- unprotect_entry(file_ptr, type, idx+lag-5, NO_CHANGE,
- H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, idx+lag-5, H5C__NO_FLAGS_SET);
}
if ( do_mult_ro_protects )
@@ -4111,8 +3788,7 @@ row_major_scan_forward(H5F_t * file_ptr,
HDfprintf(stdout, "(u-ro, %d, %d) ", type,
(idx + lag - 7));
- unprotect_entry(file_ptr, type, (idx + lag - 7),
- FALSE, H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, (idx + lag - 7), H5C__NO_FLAGS_SET);
}
if ( ( pass ) && ( (idx + lag - 8) >= 0 ) &&
@@ -4123,8 +3799,7 @@ row_major_scan_forward(H5F_t * file_ptr,
HDfprintf(stdout, "(u-ro, %d, %d) ", type,
(idx + lag - 8));
- unprotect_entry(file_ptr, type, (idx + lag - 8),
- FALSE, H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, (idx + lag - 8), H5C__NO_FLAGS_SET);
}
if ( ( pass ) && ( (idx + lag - 9) >= 0 ) &&
@@ -4135,8 +3810,7 @@ row_major_scan_forward(H5F_t * file_ptr,
HDfprintf(stdout, "(u-ro, %d, %d) ", type,
(idx + lag - 9));
- unprotect_entry(file_ptr, type, (idx + lag - 9),
- FALSE, H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, (idx + lag - 9), H5C__NO_FLAGS_SET);
}
} /* if ( do_mult_ro_protects ) */
@@ -4155,8 +3829,7 @@ row_major_scan_forward(H5F_t * file_ptr,
if ( verbose )
HDfprintf(stdout, "(u, %d, %d) ", type, (idx - lag + 2));
- unprotect_entry(file_ptr, type, idx-lag+2, NO_CHANGE,
- H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, idx-lag+2, H5C__NO_FLAGS_SET);
}
if ( ( pass ) && ( (idx - lag + 1) >= 0 ) &&
@@ -4178,38 +3851,33 @@ row_major_scan_forward(H5F_t * file_ptr,
switch ( (idx - lag) %4 ) {
case 0: /* we just did an insert */
- unprotect_entry(file_ptr, type, idx - lag,
- NO_CHANGE, H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, idx - lag, H5C__NO_FLAGS_SET);
break;
case 1:
if ( (entries[type])[idx-lag].is_dirty ) {
- unprotect_entry(file_ptr, type, idx - lag,
- NO_CHANGE, H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, idx - lag, H5C__NO_FLAGS_SET);
} else {
unprotect_entry(file_ptr, type, idx - lag,
- dirty_unprotects,
- H5C__NO_FLAGS_SET);
+ (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET));
}
break;
case 2: /* we just did an insrt */
- unprotect_entry(file_ptr, type, idx - lag,
- NO_CHANGE, H5C__DELETED_FLAG);
+ unprotect_entry(file_ptr, type, idx - lag, H5C__DELETED_FLAG);
break;
case 3:
if ( (entries[type])[idx-lag].is_dirty ) {
- unprotect_entry(file_ptr, type, idx - lag,
- NO_CHANGE, H5C__DELETED_FLAG);
+ unprotect_entry(file_ptr, type, idx - lag, H5C__DELETED_FLAG);
} else {
unprotect_entry(file_ptr, type, idx - lag,
- dirty_destroys,
- H5C__DELETED_FLAG);
+ (dirty_destroys ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)
+ | H5C__DELETED_FLAG);
}
break;
@@ -4228,7 +3896,7 @@ row_major_scan_forward(H5F_t * file_ptr,
HDfprintf(stdout, "(u, %d, %d) ", type, (idx - lag));
unprotect_entry(file_ptr, type, idx - lag,
- dirty_unprotects, H5C__NO_FLAGS_SET);
+ (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET));
}
}
@@ -4272,8 +3940,7 @@ hl_row_major_scan_forward(H5F_t * file_ptr,
hbool_t reset_stats,
hbool_t display_stats,
hbool_t display_detailed_stats,
- hbool_t do_inserts,
- hbool_t dirty_inserts)
+ hbool_t do_inserts)
{
const char * fcn_name = "hl_row_major_scan_forward";
H5C_t * cache_ptr;
@@ -4317,8 +3984,7 @@ hl_row_major_scan_forward(H5F_t * file_ptr,
if ( verbose )
HDfprintf(stdout, "(i, %d, %d) ", type, (idx + lag));
- insert_entry(file_ptr, type, (idx + lag), dirty_inserts,
- H5C__NO_FLAGS_SET);
+ insert_entry(file_ptr, type, (idx + lag), H5C__NO_FLAGS_SET);
}
i = idx;
@@ -4335,8 +4001,7 @@ hl_row_major_scan_forward(H5F_t * file_ptr,
if ( verbose )
HDfprintf(stdout, "(u, %d, %d) ", type, i);
- unprotect_entry(file_ptr, type, i, NO_CHANGE,
- H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, i, H5C__NO_FLAGS_SET);
}
i--;
}
@@ -4362,7 +4027,7 @@ hl_row_major_scan_forward(H5F_t * file_ptr,
/*-------------------------------------------------------------------------
* Function: row_major_scan_backward()
*
- * Purpose: Do a sequence of inserts, protects, unprotects, renames,
+ * Purpose: Do a sequence of inserts, protects, unprotects, moves,
* destroys while scanning backwards through the set of
* entries. If pass is false on entry, do nothing.
*
@@ -4382,9 +4047,8 @@ row_major_scan_backward(H5F_t * file_ptr,
hbool_t display_stats,
hbool_t display_detailed_stats,
hbool_t do_inserts,
- hbool_t dirty_inserts,
- hbool_t do_renames,
- hbool_t rename_to_main_addr,
+ hbool_t do_moves,
+ hbool_t move_to_main_addr,
hbool_t do_destroys,
hbool_t do_mult_ro_protects,
int dirty_destroys,
@@ -4425,8 +4089,7 @@ row_major_scan_backward(H5F_t * file_ptr,
if ( verbose )
HDfprintf(stdout, "(i, %d, %d) ", type, (idx - lag));
- insert_entry(file_ptr, type, (idx - lag), dirty_inserts,
- H5C__NO_FLAGS_SET);
+ insert_entry(file_ptr, type, (idx - lag), H5C__NO_FLAGS_SET);
}
@@ -4447,17 +4110,16 @@ row_major_scan_backward(H5F_t * file_ptr,
if ( verbose )
HDfprintf(stdout, "(u, %d, %d) ", type, (idx - lag + 2));
- unprotect_entry(file_ptr, type, idx-lag+2, NO_CHANGE,
- H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, idx-lag+2, H5C__NO_FLAGS_SET);
}
- if ( ( pass ) && ( do_renames ) && ( (idx - lag + 2) >= 0 ) &&
+ if ( ( pass ) && ( do_moves ) && ( (idx - lag + 2) >= 0 ) &&
( (idx - lag + 2) <= max_indices[type] ) &&
( ( (idx - lag + 2) % 3 ) == 0 ) ) {
- rename_entry(cache_ptr, type, (idx - lag + 2),
- rename_to_main_addr);
+ move_entry(cache_ptr, type, (idx - lag + 2),
+ move_to_main_addr);
}
@@ -4478,8 +4140,7 @@ row_major_scan_backward(H5F_t * file_ptr,
if ( verbose )
HDfprintf(stdout, "(u, %d, %d) ", type, (idx - lag + 5));
- unprotect_entry(file_ptr, type, idx-lag+5, NO_CHANGE,
- H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, idx-lag+5, H5C__NO_FLAGS_SET);
}
if ( do_mult_ro_protects )
@@ -4525,8 +4186,7 @@ row_major_scan_backward(H5F_t * file_ptr,
HDfprintf(stdout, "(u-ro, %d, %d) ", type,
(idx - lag + 7));
- unprotect_entry(file_ptr, type, (idx - lag + 7),
- FALSE, H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, (idx - lag + 7), H5C__NO_FLAGS_SET);
}
if ( ( pass ) && ( (idx - lag + 8) >= 0 ) &&
@@ -4537,8 +4197,7 @@ row_major_scan_backward(H5F_t * file_ptr,
HDfprintf(stdout, "(u-ro, %d, %d) ", type,
(idx - lag + 8));
- unprotect_entry(file_ptr, type, (idx - lag + 8),
- FALSE, H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, (idx - lag + 8), H5C__NO_FLAGS_SET);
}
if ( ( pass ) && ( (idx - lag + 9) >= 0 ) &&
@@ -4549,8 +4208,7 @@ row_major_scan_backward(H5F_t * file_ptr,
HDfprintf(stdout, "(u-ro, %d, %d) ", type,
(idx - lag + 9));
- unprotect_entry(file_ptr, type, (idx - lag + 9),
- FALSE, H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, (idx - lag + 9), H5C__NO_FLAGS_SET);
}
} /* if ( do_mult_ro_protects ) */
@@ -4570,8 +4228,7 @@ row_major_scan_backward(H5F_t * file_ptr,
if ( verbose )
HDfprintf(stdout, "(u, %d, %d) ", type, (idx + lag - 2));
- unprotect_entry(file_ptr, type, idx+lag-2, NO_CHANGE,
- H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, idx+lag-2, H5C__NO_FLAGS_SET);
}
if ( ( pass ) && ( (idx + lag - 1) >= 0 ) &&
@@ -4595,37 +4252,32 @@ row_major_scan_backward(H5F_t * file_ptr,
case 0:
if ( (entries[type])[idx+lag].is_dirty ) {
- unprotect_entry(file_ptr, type, idx + lag,
- NO_CHANGE, H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, idx + lag, H5C__NO_FLAGS_SET);
} else {
unprotect_entry(file_ptr, type, idx + lag,
- dirty_unprotects,
- H5C__NO_FLAGS_SET);
+ (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET));
}
break;
case 1: /* we just did an insert */
- unprotect_entry(file_ptr, type, idx + lag,
- NO_CHANGE, H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, idx + lag, H5C__NO_FLAGS_SET);
break;
case 2:
if ( (entries[type])[idx + lag].is_dirty ) {
- unprotect_entry(file_ptr, type, idx + lag,
- NO_CHANGE, H5C__DELETED_FLAG);
+ unprotect_entry(file_ptr, type, idx + lag, H5C__DELETED_FLAG);
} else {
unprotect_entry(file_ptr, type, idx + lag,
- dirty_destroys,
- H5C__DELETED_FLAG);
+ (dirty_destroys ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET)
+ | H5C__DELETED_FLAG);
}
break;
case 3: /* we just did an insrt */
- unprotect_entry(file_ptr, type, idx + lag,
- NO_CHANGE, H5C__DELETED_FLAG);
+ unprotect_entry(file_ptr, type, idx + lag, H5C__DELETED_FLAG);
break;
default:
@@ -4639,10 +4291,10 @@ row_major_scan_backward(H5F_t * file_ptr,
( ( idx + lag) <= max_indices[type] ) ) {
if ( verbose )
- HDfprintf(stdout, "(u, %d, %d) ", type, (idx - lag));
+ HDfprintf(stdout, "(u, %d, %d) ", type, (idx + lag));
unprotect_entry(file_ptr, type, idx + lag,
- dirty_unprotects, H5C__NO_FLAGS_SET);
+ (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET));
}
}
@@ -4686,8 +4338,7 @@ hl_row_major_scan_backward(H5F_t * file_ptr,
hbool_t reset_stats,
hbool_t display_stats,
hbool_t display_detailed_stats,
- hbool_t do_inserts,
- hbool_t dirty_inserts)
+ hbool_t do_inserts)
{
const char * fcn_name = "hl_row_major_scan_backward";
H5C_t * cache_ptr;
@@ -4731,8 +4382,7 @@ hl_row_major_scan_backward(H5F_t * file_ptr,
if ( verbose )
HDfprintf(stdout, "(i, %d, %d) ", type, (idx + lag));
- insert_entry(file_ptr, type, (idx + lag), dirty_inserts,
- H5C__NO_FLAGS_SET);
+ insert_entry(file_ptr, type, (idx + lag), H5C__NO_FLAGS_SET);
}
i = idx;
@@ -4749,8 +4399,7 @@ hl_row_major_scan_backward(H5F_t * file_ptr,
if ( verbose )
HDfprintf(stdout, "(u, %d, %d) ", type, i);
- unprotect_entry(file_ptr, type, i, NO_CHANGE,
- H5C__NO_FLAGS_SET);
+ unprotect_entry(file_ptr, type, i, H5C__NO_FLAGS_SET);
}
i--;
}
@@ -4785,8 +4434,6 @@ hl_row_major_scan_backward(H5F_t * file_ptr,
* Programmer: John Mainzer
* 6/23/04
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
@@ -4798,7 +4445,6 @@ col_major_scan_forward(H5F_t * file_ptr,
hbool_t display_stats,
hbool_t display_detailed_stats,
hbool_t do_inserts,
- hbool_t dirty_inserts,
int dirty_unprotects)
{
const char * fcn_name = "col_major_scan_forward()";
@@ -4837,8 +4483,7 @@ col_major_scan_forward(H5F_t * file_ptr,
if ( verbose )
HDfprintf(stdout, "(i, %d, %d) ", type, (idx + lag));
- insert_entry(file_ptr, type, (idx + lag), dirty_inserts,
- H5C__NO_FLAGS_SET);
+ insert_entry(file_ptr, type, (idx + lag), H5C__NO_FLAGS_SET);
}
if ( ( pass ) && ( idx >= 0 ) && ( idx <= max_indices[type] ) ) {
@@ -4856,7 +4501,7 @@ col_major_scan_forward(H5F_t * file_ptr,
HDfprintf(stdout, "(u, %d, %d) ", type, (idx - lag));
unprotect_entry(file_ptr, type, idx - lag,
- dirty_unprotects, H5C__NO_FLAGS_SET);
+ (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET));
}
if ( verbose )
@@ -4901,7 +4546,6 @@ hl_col_major_scan_forward(H5F_t * file_ptr,
hbool_t display_stats,
hbool_t display_detailed_stats,
hbool_t do_inserts,
- hbool_t dirty_inserts,
int dirty_unprotects)
{
const char * fcn_name = "hl_col_major_scan_forward()";
@@ -4953,8 +4597,7 @@ hl_col_major_scan_forward(H5F_t * file_ptr,
if ( verbose )
HDfprintf(stdout, "(i, %d, %d) ", type, i);
- insert_entry(file_ptr, type, i, dirty_inserts,
- H5C__NO_FLAGS_SET);
+ insert_entry(file_ptr, type, i, H5C__NO_FLAGS_SET);
}
if ( ( pass ) && ( i >= 0 ) && ( i <= local_max_index ) ) {
@@ -4972,7 +4615,7 @@ hl_col_major_scan_forward(H5F_t * file_ptr,
HDfprintf(stdout, "(u, %d, %d) ", type, i);
unprotect_entry(file_ptr, type, i,
- dirty_unprotects, H5C__NO_FLAGS_SET);
+ (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET));
}
if ( verbose )
@@ -5020,7 +4663,6 @@ col_major_scan_backward(H5F_t * file_ptr,
hbool_t display_stats,
hbool_t display_detailed_stats,
hbool_t do_inserts,
- hbool_t dirty_inserts,
int dirty_unprotects)
{
const char * fcn_name = "col_major_scan_backward()";
@@ -5066,8 +4708,7 @@ col_major_scan_backward(H5F_t * file_ptr,
if ( verbose )
HDfprintf(stdout, "(i, %d, %d) ", type, (idx - lag));
- insert_entry(file_ptr, type, (idx - lag), dirty_inserts,
- H5C__NO_FLAGS_SET);
+ insert_entry(file_ptr, type, (idx - lag), H5C__NO_FLAGS_SET);
}
if ( ( pass ) && ( idx >= 0 ) && ( idx <= max_indices[type] ) ) {
@@ -5085,7 +4726,7 @@ col_major_scan_backward(H5F_t * file_ptr,
HDfprintf(stdout, "(u, %d, %d) ", type, (idx + lag));
unprotect_entry(file_ptr, type, idx + lag,
- dirty_unprotects, H5C__NO_FLAGS_SET);
+ (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET));
}
if ( verbose )
@@ -5136,7 +4777,6 @@ hl_col_major_scan_backward(H5F_t * file_ptr,
hbool_t display_stats,
hbool_t display_detailed_stats,
hbool_t do_inserts,
- hbool_t dirty_inserts,
int dirty_unprotects)
{
const char * fcn_name = "hl_col_major_scan_backward()";
@@ -5187,8 +4827,7 @@ hl_col_major_scan_backward(H5F_t * file_ptr,
if ( verbose )
HDfprintf(stdout, "(i, %d, %d) ", type, i);
- insert_entry(file_ptr, type, i, dirty_inserts,
- H5C__NO_FLAGS_SET);
+ insert_entry(file_ptr, type, i, H5C__NO_FLAGS_SET);
}
if ( ( pass ) && ( i >= 0 ) && ( i <= local_max_index ) ) {
@@ -5206,7 +4845,7 @@ hl_col_major_scan_backward(H5F_t * file_ptr,
HDfprintf(stdout, "(u, %d, %d) ", type, i);
unprotect_entry(file_ptr, type, i,
- dirty_unprotects, H5C__NO_FLAGS_SET);
+ (dirty_unprotects ? H5C__DIRTIED_FLAG : H5C__NO_FLAGS_SET));
}
if ( verbose )
@@ -5439,3 +5078,455 @@ destroy_flush_dependency(int32_t par_type,
} /* destroy_flush_dependency() */
+
+/*** H5AC level utility functions ***/
+
+
+/*-------------------------------------------------------------------------
+ * Function: check_and_validate_cache_hit_rate()
+ *
+ * Purpose: Use the API functions to get and reset the cache hit rate.
+ * Verify that the value returned by the API call agrees with
+ * the cache internal data structures.
+ *
+ * If the number of cache accesses exceeds the value provided
+ * in the min_accesses parameter, and the hit rate is less than
+ * min_hit_rate, set pass to FALSE, and set failure_mssg to
+ * a string indicating that hit rate was unexpectedly low.
+ *
+ * Return hit rate in *hit_rate_ptr, and print the data to
+ * stdout if requested.
+ *
+ * If an error is detected, set pass to FALSE, and set
+ * failure_mssg to an appropriate value.
+ *
+ * Return: void
+ *
+ * Programmer: John Mainzer
+ * 4/18/04
+ *
+ *-------------------------------------------------------------------------
+ */
+
+void
+check_and_validate_cache_hit_rate(hid_t file_id,
+ double * hit_rate_ptr,
+ hbool_t dump_data,
+ int64_t min_accesses,
+ double min_hit_rate)
+{
+ /* const char * fcn_name = "check_and_validate_cache_hit_rate()"; */
+ herr_t result;
+ int64_t cache_hits = 0;
+ int64_t cache_accesses = 0;
+ double expected_hit_rate;
+ double hit_rate;
+ H5F_t * file_ptr = NULL;
+ H5C_t * cache_ptr = NULL;
+
+ /* get a pointer to the files internal data structure */
+ if ( pass ) {
+
+ file_ptr = (H5F_t *)H5I_object_verify(file_id, H5I_FILE);
+
+ if ( file_ptr == NULL ) {
+
+ pass = FALSE;
+ failure_mssg = "Can't get file_ptr.";
+
+ } else {
+
+ cache_ptr = file_ptr->shared->cache;
+ }
+ }
+
+ /* verify that we can access the cache data structure */
+ if ( pass ) {
+
+ if ( ( cache_ptr == NULL ) ||
+ ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ) {
+
+ pass = FALSE;
+ failure_mssg = "Can't access cache resize_ctl.";
+ }
+ }
+
+ /* compare the cache's internal configuration with the expected value */
+ if ( pass ) {
+
+ cache_hits = cache_ptr->cache_hits;
+ cache_accesses = cache_ptr->cache_accesses;
+
+ if ( cache_accesses > 0 ) {
+
+ expected_hit_rate = ((double)cache_hits) / ((double)cache_accesses);
+
+ } else {
+
+ expected_hit_rate = 0.0;
+ }
+
+ result = H5Fget_mdc_hit_rate(file_id, &hit_rate);
+
+ if ( result < 0 ) {
+
+ pass = FALSE;
+ failure_mssg = "H5Fget_mdc_hit_rate() failed.";
+
+ } else if ( ! DBL_REL_EQUAL(hit_rate, expected_hit_rate, 0.00001) ) {
+
+ pass = FALSE;
+ failure_mssg = "unexpected hit rate.";
+
+ }
+ }
+
+ if ( pass ) { /* reset the hit rate */
+
+ result = H5Freset_mdc_hit_rate_stats(file_id);
+
+ if ( result < 0 ) {
+
+ pass = FALSE;
+ failure_mssg = "H5Freset_mdc_hit_rate_stats() failed.";
+ }
+ }
+
+ /* set *hit_rate_ptr if appropriate */
+ if ( ( pass ) && ( hit_rate_ptr != NULL ) ) {
+
+ *hit_rate_ptr = hit_rate;
+ }
+
+ /* dump data to stdout if requested */
+ if ( ( pass ) && ( dump_data ) ) {
+
+ HDfprintf(stdout,
+ "cache_hits: %ld, cache_accesses: %ld, hit_rate: %lf\n",
+ (long)cache_hits, (long)cache_accesses, hit_rate);
+ }
+
+ if ( ( pass ) &&
+ ( cache_accesses > min_accesses ) &&
+ ( hit_rate < min_hit_rate ) ) {
+
+ pass = FALSE;
+ failure_mssg = "Unexpectedly low hit rate.";
+ }
+
+ return;
+
+} /* check_and_validate_cache_hit_rate() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: check_and_validate_cache_size()
+ *
+ * Purpose: Use the API function to get the cache size data. Verify
+ * that the values returned by the API call agree with
+ * the cache internal data structures.
+ *
+ * Return size data in the locations specified by the pointer
+ * parameters if these parameters are not NULL. Print the
+ * data to stdout if requested.
+ *
+ * If an error is detected, set pass to FALSE, and set
+ * failure_mssg to an appropriate value.
+ *
+ * Return: void
+ *
+ * Programmer: John Mainzer
+ * 4/18/04
+ *
+ *-------------------------------------------------------------------------
+ */
+
+void
+check_and_validate_cache_size(hid_t file_id,
+ size_t * max_size_ptr,
+ size_t * min_clean_size_ptr,
+ size_t * cur_size_ptr,
+ int32_t * cur_num_entries_ptr,
+ hbool_t dump_data)
+{
+ /* const char * fcn_name = "check_and_validate_cache_size()"; */
+ herr_t result;
+ size_t expected_max_size;
+ size_t max_size;
+ size_t expected_min_clean_size;
+ size_t min_clean_size;
+ size_t expected_cur_size;
+ size_t cur_size;
+ int32_t expected_cur_num_entries;
+ int cur_num_entries;
+ H5F_t * file_ptr = NULL;
+ H5C_t * cache_ptr = NULL;
+
+ /* get a pointer to the files internal data structure */
+ if ( pass ) {
+
+ file_ptr = (H5F_t *)H5I_object_verify(file_id, H5I_FILE);
+
+ if ( file_ptr == NULL ) {
+
+ pass = FALSE;
+ failure_mssg = "Can't get file_ptr.";
+
+ } else {
+
+ cache_ptr = file_ptr->shared->cache;
+ }
+ }
+
+ /* verify that we can access the cache data structure */
+ if ( pass ) {
+
+ if ( ( cache_ptr == NULL ) ||
+ ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ) {
+
+ pass = FALSE;
+ failure_mssg = "Can't access cache data structure.";
+ }
+ }
+
+ /* compare the cache's internal configuration with the expected value */
+ if ( pass ) {
+
+ expected_max_size = cache_ptr->max_cache_size;
+ expected_min_clean_size = cache_ptr->min_clean_size;
+ expected_cur_size = cache_ptr->index_size;
+ expected_cur_num_entries = cache_ptr->index_len;
+
+ result = H5Fget_mdc_size(file_id,
+ &max_size,
+ &min_clean_size,
+ &cur_size,
+ &cur_num_entries);
+
+ if ( result < 0 ) {
+
+ pass = FALSE;
+ failure_mssg = "H5Fget_mdc_size() failed.";
+
+ } else if ( ( max_size != expected_max_size ) ||
+ ( min_clean_size != expected_min_clean_size ) ||
+ ( cur_size != expected_cur_size ) ||
+ ( cur_num_entries != (int)expected_cur_num_entries ) ) {
+
+ pass = FALSE;
+ failure_mssg = "H5Fget_mdc_size() returned unexpected value(s).";
+
+ }
+ }
+
+ /* return size values if requested */
+ if ( ( pass ) && ( max_size_ptr != NULL ) ) {
+
+ *max_size_ptr = max_size;
+ }
+
+ if ( ( pass ) && ( min_clean_size_ptr != NULL ) ) {
+
+ *min_clean_size_ptr = min_clean_size;
+ }
+
+ if ( ( pass ) && ( cur_size_ptr != NULL ) ) {
+
+ *cur_size_ptr = cur_size;
+ }
+
+ if ( ( pass ) && ( cur_num_entries_ptr != NULL ) ) {
+
+ *cur_num_entries_ptr = cur_num_entries;
+ }
+
+
+ /* dump data to stdout if requested */
+ if ( ( pass ) && ( dump_data ) ) {
+
+ HDfprintf(stdout,
+ "max_sz: %ld, min_clean_sz: %ld, cur_sz: %ld, cur_ent: %ld\n",
+ (long)max_size, (long)min_clean_size, (long)cur_size,
+ (long)cur_num_entries);
+ }
+
+ return;
+
+} /* check_and_validate_cache_size() */
+
+hbool_t
+resize_configs_are_equal(const H5C_auto_size_ctl_t *a,
+ const H5C_auto_size_ctl_t *b,
+ hbool_t compare_init)
+{
+ if(a->version != b->version)
+ return(FALSE);
+ else if(a->rpt_fcn != b->rpt_fcn)
+ return(FALSE);
+ else if(compare_init && (a->set_initial_size != b->set_initial_size))
+ return(FALSE);
+ else if(compare_init && (a->initial_size != b->initial_size))
+ return(FALSE);
+ else if(HDfabs(a->min_clean_fraction - b->min_clean_fraction) > FP_EPSILON)
+ return(FALSE);
+ else if(a->max_size != b->max_size)
+ return(FALSE);
+ else if(a->min_size != b->min_size)
+ return(FALSE);
+ else if(a->epoch_length != b->epoch_length)
+ return(FALSE);
+ else if(a->incr_mode != b->incr_mode)
+ return(FALSE);
+ else if(HDfabs(a->lower_hr_threshold - b->lower_hr_threshold) > FP_EPSILON)
+ return(FALSE);
+ else if(HDfabs(a->increment - b->increment) > FP_EPSILON)
+ return(FALSE);
+ else if(a->apply_max_increment != b->apply_max_increment)
+ return(FALSE);
+ else if(a->max_increment != b->max_increment)
+ return(FALSE);
+ else if(a->flash_incr_mode != b->flash_incr_mode)
+ return(FALSE);
+ else if(HDfabs(a->flash_multiple - b->flash_multiple) > FP_EPSILON)
+ return(FALSE);
+ else if(HDfabs(a->flash_threshold - b->flash_threshold) > FP_EPSILON)
+ return(FALSE);
+ else if(a->decr_mode != b->decr_mode)
+ return(FALSE);
+ else if(HDfabs(a->upper_hr_threshold - b->upper_hr_threshold) > FP_EPSILON)
+ return(FALSE);
+ else if(HDfabs(a->decrement - b->decrement) > FP_EPSILON)
+ return(FALSE);
+ else if(a->apply_max_decrement != b->apply_max_decrement)
+ return(FALSE);
+ else if(a->max_decrement != b->max_decrement)
+ return(FALSE);
+ else if(a->epochs_before_eviction != b->epochs_before_eviction)
+ return(FALSE);
+ else if(a->apply_empty_reserve != b->apply_empty_reserve)
+ return(FALSE);
+ else if(HDfabs(a->empty_reserve - b->empty_reserve) > FP_EPSILON)
+ return(FALSE);
+ return(TRUE);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: validate_mdc_config()
+ *
+ * Purpose: Verify that the file indicated by the file_id parameter
+ * has both internal and external configuration matching
+ * *config_ptr.
+ *
+ * Do nothin on success. On failure, set pass to FALSE, and
+ * load an error message into failue_mssg. Note that
+ * failure_msg is assumed to be at least 128 bytes in length.
+ *
+ * Return: void
+ *
+ * Programmer: John Mainzer
+ * 4/14/04
+ *
+ *-------------------------------------------------------------------------
+ */
+
+void
+validate_mdc_config(hid_t file_id,
+ H5AC_cache_config_t * ext_config_ptr,
+ hbool_t compare_init,
+ int test_num)
+{
+ /* const char * fcn_name = "validate_mdc_config()"; */
+ static char msg[256];
+ H5F_t * file_ptr = NULL;
+ H5C_t * cache_ptr = NULL;
+ H5AC_cache_config_t scratch;
+ H5C_auto_size_ctl_t int_config;
+
+ XLATE_EXT_TO_INT_MDC_CONFIG(int_config, (*ext_config_ptr))
+
+ /* get a pointer to the files internal data structure */
+ if ( pass ) {
+
+ file_ptr = (H5F_t *)H5I_object_verify(file_id, H5I_FILE);
+
+ if ( file_ptr == NULL ) {
+
+ pass = FALSE;
+ HDsnprintf(msg, (size_t)128, "Can't get file_ptr #%d.", test_num);
+ failure_mssg = msg;
+
+ } else {
+
+ cache_ptr = file_ptr->shared->cache;
+ }
+ }
+
+ /* verify that we can access the internal version of the cache config */
+ if ( pass ) {
+
+ if ( ( cache_ptr == NULL ) ||
+ ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ||
+ ( cache_ptr->resize_ctl.version != H5C__CURR_AUTO_SIZE_CTL_VER ) ){
+
+ pass = FALSE;
+ HDsnprintf(msg, (size_t)128,
+ "Can't access cache resize_ctl #%d.", test_num);
+ failure_mssg = msg;
+ }
+ }
+
+ /* compare the cache's internal configuration with the expected value */
+ if ( pass ) {
+
+ if ( ! resize_configs_are_equal(&int_config, &cache_ptr->resize_ctl,
+ compare_init) ) {
+
+ pass = FALSE;
+ HDsnprintf(msg, (size_t)128,
+ "Unexpected internal config #%d.", test_num);
+ failure_mssg = msg;
+ }
+ }
+
+ /* obtain external cache config */
+ if ( pass ) {
+
+ scratch.version = H5AC__CURR_CACHE_CONFIG_VERSION;
+
+ if ( H5Fget_mdc_config(file_id, &scratch) < 0 ) {
+
+ pass = FALSE;
+ HDsnprintf(msg, (size_t)128,
+ "H5Fget_mdc_config() failed #%d.", test_num);
+ failure_mssg = msg;
+ }
+ }
+
+ if ( pass ) {
+
+ /* Recall that in any configuration supplied by the cache
+ * at run time, the set_initial_size field will always
+ * be FALSE, regardless of the value passed in. Thus we
+ * always presume that this field need not match that of
+ * the supplied external configuration.
+ *
+ * The cache also sets the initial_size field to the current
+ * cache max size instead of the value initialy supplied.
+ * Depending on circumstances, this may or may not match
+ * the original. Hence the compare_init parameter.
+ */
+ if ( ! CACHE_CONFIGS_EQUAL((*ext_config_ptr), scratch, \
+ FALSE, compare_init) ) {
+
+ pass = FALSE;
+ HDsnprintf(msg, (size_t)128,
+ "Unexpected external config #%d.", test_num);
+ failure_mssg = msg;
+ }
+ }
+
+ return;
+
+} /* validate_mdc_config() */
+