UMPIRE
Umpire: resource management and provision
umpire::strategy::DynamicPoolList Class Reference

Simple dynamic pool for allocations. More...

#include </home/docs/checkouts/readthedocs.org/user_builds/umpire/checkouts/develop/src/umpire/strategy/DynamicPoolList.hpp>

Inheritance diagram for umpire::strategy::DynamicPoolList:

Public Member Functions

 DynamicPoolList (const std::string &name, int id, Allocator allocator, const std::size_t first_minimum_pool_allocation_size=s_default_first_block_size, const std::size_t next_minimum_pool_allocation_size=s_default_next_block_size, const std::size_t alignment=s_default_alignment, PoolCoalesceHeuristic< DynamicPoolList > should_coalesce=percent_releasable_hwm(100)) noexcept
 Construct a new DynamicPoolList. More...
 
 DynamicPoolList (const DynamicPoolList &)=delete
 
void * allocate (size_t bytes) override
 
void deallocate (void *ptr, std::size_t size) override
 Free the memory at ptr. More...
 
void release () override
 Release any and all unused memory held by this AllocationStrategy. More...
 
std::size_t getReleasableBlocks () const noexcept
 
std::size_t getTotalBlocks () const noexcept
 
std::size_t getActualSize () const noexcept override
 Get the current amount of memory allocated by this allocator. More...
 
std::size_t getActualHighwaterMark () const noexcept
 
std::size_t getAlignedSize () const noexcept
 
std::size_t getAlignedHighwaterMark () const noexcept
 
Platform getPlatform () noexcept override
 Get the platform associated with this AllocationStrategy. More...
 
MemoryResourceTraits getTraits () const noexcept final override
 
bool tracksMemoryUse () const noexcept override
 
std::size_t getReleasableSize () const noexcept
 Get the number of bytes that may be released back to resource. More...
 
std::size_t getBlocksInPool () const noexcept
 Get the number of memory blocks that the pool has. More...
 
std::size_t getLargestAvailableBlock () const noexcept
 Get the largest allocatable number of bytes from pool before the pool will grow. More...
 
void coalesce () noexcept
 
void * allocate_internal (std::size_t bytes)
 
void * allocate_named_internal (const std::string &name, std::size_t bytes)
 
void deallocate_internal (void *ptr, std::size_t size=0)
 
virtual std::size_t getCurrentSize () const noexcept
 Get current (total) size of the allocated memory. More...
 
virtual std::size_t getHighWatermark () const noexcept
 Get the high watermark of the total allocated size. More...
 
virtual std::size_t getAllocationCount () const noexcept
 Get the total number of active allocations by this allocator. More...
 
const std::string & getName () noexcept
 Get the name of this AllocationStrategy. More...
 
const std::string & getStrategyName () const noexcept
 
int getId () noexcept
 Get the id of this AllocationStrategy. More...
 
virtual AllocationStrategygetParent () const noexcept
 Traces where the allocator came from. More...
 
bool isTracked () const noexcept
 

Static Public Member Functions

static PoolCoalesceHeuristic< DynamicPoolListpercent_releasable (int percentage)
 Coalescing Heuristic functions for Percent-Releasable and Blocks-Releasable. Both have the option to reallocate to High Watermark instead of actual size of the pool (actual size is currently the default). More...
 
static PoolCoalesceHeuristic< DynamicPoolListpercent_releasable_hwm (int percentage)
 
static PoolCoalesceHeuristic< DynamicPoolListblocks_releasable (std::size_t nblocks)
 
static PoolCoalesceHeuristic< DynamicPoolListblocks_releasable_hwm (std::size_t nblocks)
 

Public Attributes

std::size_t m_current_size {0}
 
std::size_t m_high_watermark {0}
 
std::size_t m_allocation_count {0}
 

Static Public Attributes

static constexpr std::size_t s_default_first_block_size {512 * 1024 * 1024}
 
static constexpr std::size_t s_default_next_block_size {1 * 1024 * 1024}
 
static constexpr std::size_t s_default_alignment {16}
 

Protected Member Functions

void setTracking (bool) noexcept
 

Protected Attributes

std::string m_name
 
std::string m_strategy_name
 
int m_id
 
bool m_tracked {true}
 
AllocationStrategym_parent
 

Detailed Description

Simple dynamic pool for allocations.

This AllocationStrategy uses Simpool to provide pooling for allocations of any size. The behavior of the pool can be controlled by two parameters: the initial allocation size, and the minimum allocation size.

The initial size controls how large the first piece of memory allocated is, and the minimum size controls the lower bound on all future chunk allocations.

Constructor & Destructor Documentation

◆ DynamicPoolList() [1/2]

umpire::strategy::DynamicPoolList::DynamicPoolList ( const std::string &  name,
int  id,
Allocator  allocator,
const std::size_t  first_minimum_pool_allocation_size = s_default_first_block_size,
const std::size_t  next_minimum_pool_allocation_size = s_default_next_block_size,
const std::size_t  alignment = s_default_alignment,
PoolCoalesceHeuristic< DynamicPoolList should_coalesce = percent_releasable_hwm(100) 
)
noexcept

Construct a new DynamicPoolList.

Parameters
nameName of this instance of the DynamicPoolList.
idId of this instance of the DynamicPoolList.
allocatorAllocation resource that pool uses
first_minimum_pool_allocation_sizeMinimum size the pool initially allocates
next_minimum_pool_allocation_sizeThe minimum size of all future allocations.
align_bytesNumber of bytes with which to align allocation sizes (power-of-2)
do_heuristicHeuristic for when to perform coalesce operation

◆ DynamicPoolList() [2/2]

umpire::strategy::DynamicPoolList::DynamicPoolList ( const DynamicPoolList )
delete

Member Function Documentation

◆ percent_releasable()

PoolCoalesceHeuristic< DynamicPoolList > umpire::strategy::DynamicPoolList::percent_releasable ( int  percentage)
static

Coalescing Heuristic functions for Percent-Releasable and Blocks-Releasable. Both have the option to reallocate to High Watermark instead of actual size of the pool (actual size is currently the default).

References UMPIRE_ERROR, and UMPIRE_UNUSED_ARG.

◆ percent_releasable_hwm()

PoolCoalesceHeuristic< DynamicPoolList > umpire::strategy::DynamicPoolList::percent_releasable_hwm ( int  percentage)
static

References UMPIRE_ERROR, and UMPIRE_UNUSED_ARG.

◆ blocks_releasable()

PoolCoalesceHeuristic< DynamicPoolList > umpire::strategy::DynamicPoolList::blocks_releasable ( std::size_t  nblocks)
static

◆ blocks_releasable_hwm()

PoolCoalesceHeuristic< DynamicPoolList > umpire::strategy::DynamicPoolList::blocks_releasable_hwm ( std::size_t  nblocks)
static

◆ allocate()

void * umpire::strategy::DynamicPoolList::allocate ( size_t  bytes)
override

◆ deallocate()

void umpire::strategy::DynamicPoolList::deallocate ( void *  ptr,
std::size_t  size 
)
overridevirtual

◆ release()

void umpire::strategy::DynamicPoolList::release ( )
overridevirtual

Release any and all unused memory held by this AllocationStrategy.

Reimplemented from umpire::strategy::AllocationStrategy.

References umpire::util::message::Debug, DynamicSizePool< IA >::release(), and UMPIRE_LOG.

◆ getReleasableBlocks()

std::size_t umpire::strategy::DynamicPoolList::getReleasableBlocks ( ) const
noexcept

◆ getTotalBlocks()

std::size_t umpire::strategy::DynamicPoolList::getTotalBlocks ( ) const
noexcept

◆ getActualSize()

std::size_t umpire::strategy::DynamicPoolList::getActualSize ( ) const
overridevirtualnoexcept

Get the current amount of memory allocated by this allocator.

Note that this can be larger than getCurrentSize(), particularly if the AllocationStrategy implements some kind of pooling.

Returns
The total size of all the memory this object has allocated.

Reimplemented from umpire::strategy::AllocationStrategy.

References umpire::util::message::Debug, DynamicSizePool< IA >::getActualSize(), and UMPIRE_LOG.

◆ getActualHighwaterMark()

std::size_t umpire::strategy::DynamicPoolList::getActualHighwaterMark ( ) const
noexcept

◆ getAlignedSize()

std::size_t umpire::strategy::DynamicPoolList::getAlignedSize ( ) const
noexcept

◆ getAlignedHighwaterMark()

std::size_t umpire::strategy::DynamicPoolList::getAlignedHighwaterMark ( ) const
noexcept

◆ getPlatform()

Platform umpire::strategy::DynamicPoolList::getPlatform ( )
overridevirtualnoexcept

Get the platform associated with this AllocationStrategy.

The Platform distinguishes the appropriate place to execute operations on memory allocated by this AllocationStrategy.

Returns
The platform associated with this AllocationStrategy.

Implements umpire::strategy::AllocationStrategy.

References umpire::strategy::AllocationStrategy::getPlatform().

◆ getTraits()

MemoryResourceTraits umpire::strategy::DynamicPoolList::getTraits ( ) const
finaloverridevirtualnoexcept

◆ tracksMemoryUse()

bool umpire::strategy::DynamicPoolList::tracksMemoryUse ( ) const
overridevirtualnoexcept

◆ getReleasableSize()

std::size_t umpire::strategy::DynamicPoolList::getReleasableSize ( ) const
noexcept

Get the number of bytes that may be released back to resource.

A memory pool has a set of blocks that have no allocations against them. If the size of the set is greater than one, then the pool will have a number of bytes that may be released back to the resource or coalesced into a larger block.

Returns
The total number of bytes that are releasable

References umpire::util::message::Debug, DynamicSizePool< IA >::getReleasableSize(), and UMPIRE_LOG.

◆ getBlocksInPool()

std::size_t umpire::strategy::DynamicPoolList::getBlocksInPool ( ) const
noexcept

Get the number of memory blocks that the pool has.

Returns
The total number of blocks that are allocated by the pool

References umpire::util::message::Debug, DynamicSizePool< IA >::getBlocksInPool(), and UMPIRE_LOG.

◆ getLargestAvailableBlock()

std::size_t umpire::strategy::DynamicPoolList::getLargestAvailableBlock ( ) const
noexcept

Get the largest allocatable number of bytes from pool before the pool will grow.

return The largest number of bytes that may be allocated without causing pool growth

References umpire::util::message::Debug, DynamicSizePool< IA >::getLargestAvailableBlock(), and UMPIRE_LOG.

◆ coalesce()

◆ allocate_internal()

◆ allocate_named_internal()

void * umpire::strategy::AllocationStrategy::allocate_named_internal ( const std::string &  name,
std::size_t  bytes 
)
inherited

◆ deallocate_internal()

◆ getCurrentSize()

std::size_t umpire::strategy::AllocationStrategy::getCurrentSize ( ) const
virtualnoexceptinherited

◆ getHighWatermark()

std::size_t umpire::strategy::AllocationStrategy::getHighWatermark ( ) const
virtualnoexceptinherited

Get the high watermark of the total allocated size.

This is equivalent to the highest observed value of getCurrentSize.

Returns
High watermark allocation size.

Reimplemented in umpire::strategy::FixedPool, umpire::strategy::MonotonicAllocationStrategy, umpire::resource::SyclDeviceMemoryResource< _allocator >, umpire::resource::NullMemoryResource, umpire::resource::NoOpMemoryResource, and umpire::resource::FileMemoryResource.

References umpire::strategy::AllocationStrategy::m_high_watermark.

Referenced by umpire::Allocator::getHighWatermark().

◆ getAllocationCount()

std::size_t umpire::strategy::AllocationStrategy::getAllocationCount ( ) const
virtualnoexceptinherited

Get the total number of active allocations by this allocator.

Returns
The total number of active allocations this object has allocated.

References umpire::strategy::AllocationStrategy::m_allocation_count.

Referenced by umpire::Allocator::getAllocationCount().

◆ getName()

◆ getStrategyName()

const std::string & umpire::strategy::AllocationStrategy::getStrategyName ( ) const
noexceptinherited

◆ getId()

int umpire::strategy::AllocationStrategy::getId ( )
noexceptinherited

◆ getParent()

AllocationStrategy * umpire::strategy::AllocationStrategy::getParent ( ) const
virtualnoexceptinherited

Traces where the allocator came from.

Returns
Pointer to the parent AllocationStrategy.

References umpire::strategy::AllocationStrategy::m_parent.

Referenced by umpire::ResourceManager::destroyAllocator(), umpire::Allocator::getParent(), and umpire::is_accessible().

◆ isTracked()

bool umpire::strategy::AllocationStrategy::isTracked ( ) const
noexceptinherited

◆ setTracking()

void umpire::strategy::AllocationStrategy::setTracking ( bool  tracking)
protectednoexceptinherited

Member Data Documentation

◆ s_default_first_block_size

constexpr std::size_t umpire::strategy::DynamicPoolList::s_default_first_block_size {512 * 1024 * 1024}
staticconstexpr

◆ s_default_next_block_size

constexpr std::size_t umpire::strategy::DynamicPoolList::s_default_next_block_size {1 * 1024 * 1024}
staticconstexpr

◆ s_default_alignment

constexpr std::size_t umpire::strategy::DynamicPoolList::s_default_alignment {16}
staticconstexpr

◆ m_current_size

◆ m_high_watermark

◆ m_allocation_count

◆ m_name

std::string umpire::strategy::AllocationStrategy::m_name
protectedinherited

◆ m_strategy_name

std::string umpire::strategy::AllocationStrategy::m_strategy_name
protectedinherited

◆ m_id

int umpire::strategy::AllocationStrategy::m_id
protectedinherited

◆ m_tracked

bool umpire::strategy::AllocationStrategy::m_tracked {true}
protectedinherited

◆ m_parent

AllocationStrategy* umpire::strategy::AllocationStrategy::m_parent
protectedinherited