Updated memory pool implementation to contain buffers of different sizes.

-- In existing design memory pool supports buffers of only one
     size, This size is determined at compile time to support buffer
     needed for biggest block size and data type. However, the size
     calculation is not generic as it considers sizes only for GEMM.
     Also it assumes that the buffer will not be used for any other
     purpose than packing operations.

  -- If the new buffer is requested whose size is bigger than existing
     size, The pool is re-initialized to contain buffers of new size,
     however, this is done only if the pool is empty. If the pool is not
     empty the execution is aborted. This is undesirable as in
     mulithreaded scenarios it is possible that different threads needs
     buffers of different sizes at the same time (i.e. while other thread
     is still in middle of the operation).

  -- This commit removes the restriction of single size buffer, when
     new buffer is requested whose size if bigger than exiting one, no
     re-init is done. New buffer of required size is allocated, added
     to the pool and returned to the user.

Change-Id: I20acdb60eb06ab2e53366d51713aa83c4b2df0da
This commit is contained in:
Dipal M Zambare
2021-06-18 10:09:03 +05:30
parent 4b90ae3112
commit 2eede504b5

View File

@@ -5,7 +5,7 @@
libraries.
Copyright (C) 2014, The University of Texas at Austin
Copyright (C) 2018 - 2019, Advanced Micro Devices, Inc.
Copyright (C) 2018 - 2021, Advanced Micro Devices, Inc. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
@@ -128,10 +128,18 @@ void bli_pool_finalize
// Sanity check: The top_index should be zero.
if ( top_index != 0 )
{
#ifdef BLIS_ENABLE_MEM_TRACING
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();
fflush( stdout );
#endif
// We will not abort if there are checked out buffers as
// they will be freed when returned to the pool. This allows us to have
// buffers of different sizes in the pool.
//bli_abort();
}
// Query the free() function pointer for the pool.