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

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

Inheritance diagram for umpire::strategy::QuickPool:

Public Types

using Pointer = void *
 

Public Member Functions

 QuickPool (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< QuickPool > should_coalesce=percent_releasable_hwm(100)) noexcept
 Construct a new QuickPool. More...
 
 ~QuickPool ()
 
 QuickPool (const QuickPool &)=delete
 
void * allocate (std::size_t bytes) override
 Allocate bytes of memory. More...
 
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 getActualSize () const noexcept override
 Get the current amount of memory allocated by this allocator. More...
 
std::size_t getReleasableSize () const noexcept
 
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 override
 
bool tracksMemoryUse () const noexcept override
 
std::size_t getBlocksInPool () const noexcept
 Return the number of memory blocks – both leased to application and internal free memory – that the pool holds. More...
 
std::size_t getLargestAvailableBlock () noexcept
 Get the largest allocatable number of bytes from pool before the pool will grow. More...
 
std::size_t getReleasableBlocks () const noexcept
 
std::size_t getTotalBlocks () const noexcept
 
void coalesce () noexcept
 
void do_coalesce (std::size_t suggested_size) 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< QuickPoolpercent_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< QuickPoolpercent_releasable_hwm (int percentage)
 
static PoolCoalesceHeuristic< QuickPoolblocks_releasable (std::size_t nblocks)
 
static PoolCoalesceHeuristic< QuickPoolblocks_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
 

Member Typedef Documentation

◆ Pointer

Constructor & Destructor Documentation

◆ QuickPool() [1/2]

umpire::strategy::QuickPool::QuickPool ( 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< QuickPool should_coalesce = percent_releasable_hwm(100) 
)
noexcept

Construct a new QuickPool.

Parameters
nameName of this instance of the QuickPool
idUnique identifier for this instance
allocatorAllocation resource that pool uses
first_minimum_pool_allocation_sizeSize the pool initially allocates
next_minimum_pool_allocation_sizeThe minimum size of all future allocations
alignmentNumber of bytes with which to align allocation sizes (power-of-2)
should_coalesceHeuristic for when to perform coalesce operation

◆ ~QuickPool()

umpire::strategy::QuickPool::~QuickPool ( )

◆ QuickPool() [2/2]

umpire::strategy::QuickPool::QuickPool ( const QuickPool )
delete

References allocate(), and deallocate().

Member Function Documentation

◆ percent_releasable()

PoolCoalesceHeuristic< QuickPool > umpire::strategy::QuickPool::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< QuickPool > umpire::strategy::QuickPool::percent_releasable_hwm ( int  percentage)
static

References UMPIRE_ERROR, and UMPIRE_UNUSED_ARG.

◆ blocks_releasable()

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

◆ blocks_releasable_hwm()

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

◆ allocate()

◆ deallocate()

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

◆ release()

◆ getActualSize()

std::size_t umpire::strategy::QuickPool::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.

Referenced by umpire::strategy::MixedPool::getActualSize().

◆ getReleasableSize()

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

◆ getActualHighwaterMark()

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

◆ getAlignedSize()

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

◆ getAlignedHighwaterMark()

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

◆ getPlatform()

Platform umpire::strategy::QuickPool::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(), and umpire::strategy::mixins::AlignedAllocation::m_allocator.

◆ getTraits()

MemoryResourceTraits umpire::strategy::QuickPool::getTraits ( ) const
overridevirtualnoexcept

◆ tracksMemoryUse()

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

◆ getBlocksInPool()

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

Return the number of memory blocks – both leased to application and internal free memory – that the pool holds.

◆ getLargestAvailableBlock()

std::size_t umpire::strategy::QuickPool::getLargestAvailableBlock ( )
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

◆ getReleasableBlocks()

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

◆ getTotalBlocks()

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

◆ coalesce()

◆ do_coalesce()

void umpire::strategy::QuickPool::do_coalesce ( std::size_t  suggested_size)
noexcept

References umpire::util::message::Debug, and UMPIRE_LOG.

Referenced by coalesce(), and deallocate().

◆ 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::QuickPool::s_default_first_block_size {512 * 1024 * 1024}
staticconstexpr

◆ s_default_next_block_size

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

◆ s_default_alignment

constexpr std::size_t umpire::strategy::QuickPool::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