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

A faster pool that pulls from a series of pools. More...

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

Inheritance diagram for umpire::strategy::MixedPool:

Public Member Functions

 MixedPool (const std::string &name, int id, Allocator allocator, std::size_t smallest_fixed_obj_size=(1<< 8), std::size_t largest_fixed_obj_size=(1<< 17), std::size_t max_initial_fixed_pool_size=1024 *1024 *2, std::size_t fixed_size_multiplier=16, const std::size_t quick_pool_initial_alloc_size=(512 *1024 *1024), const std::size_t quick_pool_min_alloc_size=(1 *1024 *1024), const std::size_t quick_pool_align_bytes=16, PoolCoalesceHeuristic< QuickPool > should_coalesce=QuickPool::percent_releasable(100)) noexcept
 Creates a MixedPool of one or more fixed pools and a quick pool for large allocations. More...
 
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...
 
Platform getPlatform () noexcept override
 Get the platform associated with this AllocationStrategy. More...
 
MemoryResourceTraits getTraits () const noexcept override
 
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...
 
virtual bool tracksMemoryUse () const noexcept
 
bool isTracked () const noexcept
 

Public Attributes

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

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

A faster pool that pulls from a series of pools.

Pool implementation using a series of FixedPools for small sizes, and a QuickPool for sizes larger than (1 << LastFixed) bytes.

Constructor & Destructor Documentation

◆ MixedPool()

umpire::strategy::MixedPool::MixedPool ( const std::string &  name,
int  id,
Allocator  allocator,
std::size_t  smallest_fixed_obj_size = (1 << 8),
std::size_t  largest_fixed_obj_size = (1 << 17),
std::size_t  max_initial_fixed_pool_size = 1024 * 1024 * 2,
std::size_t  fixed_size_multiplier = 16,
const std::size_t  quick_pool_initial_alloc_size = (512 * 1024 * 1024),
const std::size_t  quick_pool_min_alloc_size = (1 * 1024 * 1024),
const std::size_t  quick_pool_align_bytes = 16,
PoolCoalesceHeuristic< QuickPool should_coalesce = QuickPool::percent_releasable(100) 
)
noexcept

Creates a MixedPool of one or more fixed pools and a quick pool for large allocations.

Parameters
nameName of the pool
idUnique identifier for lookup later in ResourceManager
allocatorUnderlying allocator
smallest_fixed_obj_sizeSmallest fixed pool object size in bytes
largest_fixed_obj_sizeLargest fixed pool object size in bytes
max_initial_fixed_pool_sizeLargest initial size of any fixed pool
fixed_size_multiplierFixed pool object size increase factor
quick_pool_initial_alloc_sizeSize the quick pool initially allocates
quick_pool_min_alloc_bytesMinimum size of all future allocations in the quick pool
quick_pool_align_bytesSize with which to align allocations (for the quick pool)
should_coalesceHeuristic callback function (for the quick pool)

Member Function Documentation

◆ allocate()

void * umpire::strategy::MixedPool::allocate ( std::size_t  bytes)
overridevirtual

Allocate bytes of memory.

Parameters
bytesNumber of bytes to allocate.
Returns
Pointer to start of allocated bytes.

Implements umpire::strategy::AllocationStrategy.

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

◆ deallocate()

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

Free the memory at ptr.

Parameters
ptrPointer to free.

Implements umpire::strategy::AllocationStrategy.

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

◆ release()

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

Release any and all unused memory held by this AllocationStrategy.

Reimplemented from umpire::strategy::AllocationStrategy.

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

◆ getActualSize()

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

◆ getPlatform()

Platform umpire::strategy::MixedPool::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::MixedPool::getTraits ( ) const
overridevirtualnoexcept

◆ 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().

◆ tracksMemoryUse()

bool umpire::strategy::AllocationStrategy::tracksMemoryUse ( ) const
virtualnoexceptinherited

◆ isTracked()

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

◆ setTracking()

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

Member Data Documentation

◆ 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