Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinstate sanity check in bli_pool_finalize. #671

Merged
merged 3 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frame/base/bli_apool.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ void bli_apool_free_block
if ( pool != NULL )
{
// Finalize the pool.
bli_pool_finalize( pool );
bli_pool_finalize( pool, FALSE );

#ifdef BLIS_ENABLE_MEM_TRACING
printf( "bli_apool_free_block(): pool_t %d: ", ( int )i );
Expand Down
6 changes: 3 additions & 3 deletions frame/base/bli_pba.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,9 +389,9 @@ void bli_pba_finalize_pools
pool_t* pool_c = bli_pba_pool( index_c, pba );

// Finalize the memory pools for A, B, and C.
bli_pool_finalize( pool_a );
bli_pool_finalize( pool_b );
bli_pool_finalize( pool_c );
bli_pool_finalize( pool_a, FALSE );
bli_pool_finalize( pool_b, FALSE );
bli_pool_finalize( pool_c, FALSE );
}

// -----------------------------------------------------------------------------
Expand Down
22 changes: 9 additions & 13 deletions frame/base/bli_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ void bli_pool_init

void bli_pool_finalize
(
pool_t* pool
pool_t* pool,
bool reinit
)
{
// NOTE: This implementation assumes that either:
Expand All @@ -129,24 +130,22 @@ void bli_pool_finalize
// Query the total number of blocks currently allocated.
const siz_t num_blocks = bli_pool_num_blocks( pool );

// NOTE: This sanity check has been disabled because bli_pool_reinit()
// is currently implemented in terms of bli_pool_finalize() followed by
// bli_pool_init(). If that _reinit() takes place when some blocks are
// checked out, then we would expect top_index != 0, and therefore this
// check is not universally appropriate.
#if 0
// Query the top_index of the pool.
const siz_t top_index = bli_pool_top_index( pool );

// Sanity check: The top_index should be zero.
if ( top_index != 0 )
// NOTE: This sanity check is disabled when called from bli_pool_reinit()
// because it is currently implemented in terms of bli_pool_finalize() followed by
// bli_pool_init(). If that _reinit() takes place when some blocks are
// checked out, then we would expect top_index != 0, and therefore this
// check is not universally appropriate.
if ( top_index != 0 && !reinit )
{
printf( "bli_pool_finalize(): final top_index == %d (expected 0); block_size: %d.\n",
( int )top_index, ( int )bli_pool_block_size( pool ) );
printf( "bli_pool_finalize(): Implication: not all blocks were checked back in!\n" );
bli_abort();
}
#endif

// Query the free() function pointer for the pool.
free_ft free_fp = bli_pool_free_fp( pool );
Expand Down Expand Up @@ -215,7 +214,7 @@ void bli_pool_reinit
// those blocks back into the pool. (This condition can be detected
// since the block size is encoded into each pblk, which is copied
// upon checkout.)
bli_pool_finalize( pool );
bli_pool_finalize( pool, TRUE );

// Reinitialize the pool with the new parameters, in particular,
// the new block size.
Expand Down Expand Up @@ -407,9 +406,6 @@ void bli_pool_grow
=
bli_malloc_intl( block_ptrs_len_new * sizeof( pblk_t ), &r_val );

// Query the top_index of the pool.
const siz_t top_index = bli_pool_top_index( pool );

// Copy the contents of the old block_ptrs array to the new/resized
// array. Notice that we copy the entire array, including elements
// corresponding to blocks that have been checked out. Those elements
Expand Down
3 changes: 2 additions & 1 deletion frame/base/bli_pool.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,8 @@ void bli_pool_init
);
void bli_pool_finalize
(
pool_t* pool
pool_t* pool,
bool reinit
);
void bli_pool_reinit
(
Expand Down