UMPIRE
Umpire: resource management and provision
umpire::strategy::AllocationStrategy Class Referenceabstract

AllocationStrategy provides a unified interface to all classes that can be used to allocate and free data. More...

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

Inheritance diagram for umpire::strategy::AllocationStrategy:

Public Member Functions

 AllocationStrategy (const std::string &name, int id, AllocationStrategy *parent, const std::string &strategy_name) noexcept
 Construct a new AllocationStrategy object. More...
 
virtual ~AllocationStrategy ()=default
 
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 void release ()
 Release any and all unused memory held by this AllocationStrategy. More...
 
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 getActualSize () const noexcept
 Get the current amount of memory allocated by this allocator. More...
 
virtual std::size_t getAllocationCount () const noexcept
 Get the total number of active allocations by this allocator. More...
 
virtual Platform getPlatform () noexcept=0
 Get the platform associated with this AllocationStrategy. 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 MemoryResourceTraits getTraits () const noexcept
 
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
 

Friends

class umpire::ResourceManager
 
class umpire::Allocator
 
std::ostream & operator<< (std::ostream &os, const AllocationStrategy &strategy)
 

Detailed Description

AllocationStrategy provides a unified interface to all classes that can be used to allocate and free data.

Constructor & Destructor Documentation

◆ AllocationStrategy()

umpire::strategy::AllocationStrategy::AllocationStrategy ( const std::string &  name,
int  id,
AllocationStrategy parent,
const std::string &  strategy_name 
)
noexcept

Construct a new AllocationStrategy object.

All AllocationStrategy objects must will have a unique name and id. This uniqueness is enforced by the ResourceManager.

Parameters
nameThe name of this AllocationStrategy object.
idThe id of this AllocationStrategy object.

◆ ~AllocationStrategy()

virtual umpire::strategy::AllocationStrategy::~AllocationStrategy ( )
virtualdefault

Member Function Documentation

◆ allocate_internal()

◆ allocate_named_internal()

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

◆ deallocate_internal()

◆ release()

void umpire::strategy::AllocationStrategy::release ( )
virtual

◆ getCurrentSize()

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

Get current (total) size of the allocated memory.

This is the total size of all allocation currently 'live' that have been made by this AllocationStrategy object.

Returns
Current total size of allocations.

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

References m_current_size.

Referenced by getActualSize(), and umpire::Allocator::getCurrentSize().

◆ getHighWatermark()

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

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 m_high_watermark.

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

◆ getActualSize()

std::size_t umpire::strategy::AllocationStrategy::getActualSize ( ) const
virtualnoexcept

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 in umpire::strategy::FixedPool, umpire::strategy::ResourceAwarePool, umpire::strategy::QuickPool, umpire::strategy::MixedPool, umpire::strategy::DynamicPoolList, and umpire::resource::HostSharedMemoryResource.

References getCurrentSize().

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

◆ getAllocationCount()

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

Get the total number of active allocations by this allocator.

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

References m_allocation_count.

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

◆ getPlatform()

virtual Platform umpire::strategy::AllocationStrategy::getPlatform ( )
pure virtualnoexcept

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.

Implemented in umpire::resource::MemoryResource, umpire::strategy::FixedPool, umpire::strategy::ThreadSafeAllocator, umpire::strategy::SlotPool, umpire::strategy::SizeLimiter, umpire::strategy::ResourceAwarePool, umpire::strategy::QuickPool, umpire::strategy::NumaPolicy, umpire::strategy::NamingShim, umpire::strategy::NamedAllocationStrategy, umpire::strategy::MonotonicAllocationStrategy, umpire::strategy::MixedPool, umpire::strategy::DynamicPoolList, umpire::strategy::DeviceIpcAllocator, umpire::strategy::AllocationPrefetcher, umpire::strategy::AllocationAdvisor, umpire::strategy::AlignedAllocator, umpire::resource::HostSharedMemoryResource, umpire::resource::HostMpi3SharedMemoryResource, umpire::resource::SyclDeviceMemoryResource< _allocator >, umpire::resource::NullMemoryResource, umpire::resource::NoOpMemoryResource, umpire::resource::HipUnifiedMemoryResource, umpire::resource::HipPinnedMemoryResource, umpire::resource::HipDeviceMemoryResource, umpire::resource::HipConstantMemoryResource, umpire::resource::FileMemoryResource, umpire::resource::DefaultMemoryResource< _allocator >, umpire::resource::CudaDeviceMemoryResource, and umpire::resource::CudaConstantMemoryResource.

Referenced by umpire::strategy::AlignedAllocator::AlignedAllocator(), umpire::op::MemoryOperationRegistry::find(), umpire::Allocator::getPlatform(), umpire::strategy::AlignedAllocator::getPlatform(), umpire::strategy::AllocationAdvisor::getPlatform(), umpire::strategy::AllocationPrefetcher::getPlatform(), umpire::strategy::DeviceIpcAllocator::getPlatform(), umpire::strategy::DynamicPoolList::getPlatform(), umpire::strategy::MixedPool::getPlatform(), umpire::strategy::MonotonicAllocationStrategy::getPlatform(), umpire::strategy::NamedAllocationStrategy::getPlatform(), umpire::strategy::NamingShim::getPlatform(), umpire::strategy::QuickPool::getPlatform(), umpire::strategy::ResourceAwarePool::getPlatform(), umpire::strategy::SizeLimiter::getPlatform(), umpire::strategy::SlotPool::getPlatform(), and umpire::strategy::ThreadSafeAllocator::getPlatform().

◆ getName()

◆ getStrategyName()

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

◆ getId()

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

Get the id of this AllocationStrategy.

Returns
The id of this AllocationStrategy.

References m_id.

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

◆ getParent()

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

Traces where the allocator came from.

Returns
Pointer to the parent AllocationStrategy.

References m_parent.

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

◆ getTraits()

MemoryResourceTraits umpire::strategy::AllocationStrategy::getTraits ( ) const
virtualnoexcept

Reimplemented in umpire::strategy::FixedPool, umpire::strategy::ThreadSafeAllocator, umpire::strategy::SlotPool, umpire::strategy::SizeLimiter, umpire::strategy::ResourceAwarePool, umpire::strategy::QuickPool, umpire::strategy::NumaPolicy, umpire::strategy::NamingShim, umpire::strategy::NamedAllocationStrategy, umpire::strategy::MonotonicAllocationStrategy, umpire::strategy::MixedPool, umpire::strategy::DeviceIpcAllocator, umpire::strategy::AllocationPrefetcher, umpire::strategy::AllocationAdvisor, umpire::strategy::AlignedAllocator, umpire::resource::MemoryResource, and umpire::strategy::DynamicPoolList.

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

Referenced by umpire::op::OpenMPTargetMemsetOperation::apply(), umpire::op::SyclMemPrefetchOperation::apply(), umpire::op::SyclMemsetOperation::apply(), umpire::strategy::DynamicPoolList::getTraits(), umpire::strategy::AlignedAllocator::getTraits(), umpire::strategy::AllocationAdvisor::getTraits(), umpire::strategy::AllocationPrefetcher::getTraits(), umpire::strategy::DeviceIpcAllocator::getTraits(), umpire::strategy::MixedPool::getTraits(), umpire::strategy::MonotonicAllocationStrategy::getTraits(), umpire::strategy::NamedAllocationStrategy::getTraits(), umpire::strategy::NamingShim::getTraits(), umpire::strategy::NumaPolicy::getTraits(), umpire::strategy::QuickPool::getTraits(), umpire::strategy::ResourceAwarePool::getTraits(), umpire::strategy::SizeLimiter::getTraits(), umpire::strategy::SlotPool::getTraits(), umpire::strategy::ThreadSafeAllocator::getTraits(), umpire::op::OpenMPTargetCopyOperation::transform(), umpire::op::SyclCopyOperation::transform(), umpire::op::SyclCopyFromOperation::transform(), and umpire::op::SyclCopyToOperation::transform().

◆ tracksMemoryUse()

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

◆ isTracked()

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

References m_tracked.

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

◆ setTracking()

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

Friends And Related Function Documentation

◆ umpire::ResourceManager

friend class umpire::ResourceManager
friend

◆ umpire::Allocator

friend class umpire::Allocator
friend

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const AllocationStrategy strategy 
)
friend

Member Data Documentation

◆ m_current_size

◆ m_high_watermark

std::size_t umpire::strategy::AllocationStrategy::m_high_watermark {0}

◆ m_allocation_count

◆ m_name

std::string umpire::strategy::AllocationStrategy::m_name
protected

◆ m_strategy_name

std::string umpire::strategy::AllocationStrategy::m_strategy_name
protected

Referenced by getStrategyName().

◆ m_id

int umpire::strategy::AllocationStrategy::m_id
protected

Referenced by getId().

◆ m_tracked

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

Referenced by isTracked().

◆ m_parent

AllocationStrategy* umpire::strategy::AllocationStrategy::m_parent
protected

Referenced by getParent().