MemoryManager Class Reference

HiCR: HiCR::MemoryManager Class Reference
HiCR
HiCR::MemoryManager Class Referenceabstract

#include <memoryManager.hpp>

Inheritance diagram for HiCR::MemoryManager:
HiCR::backend::ascend::MemoryManager HiCR::backend::hwloc::MemoryManager HiCR::backend::lpf::MemoryManager HiCR::backend::mpi::MemoryManager HiCR::backend::opencl::MemoryManager

Public Member Functions

virtual ~MemoryManager ()=default
 
__INLINE__ std::shared_ptr< LocalMemorySlotallocateLocalMemorySlot (const std::shared_ptr< MemorySpace > &memorySpace, const size_t size)
 
virtual std::shared_ptr< LocalMemorySlotregisterLocalMemorySlot (const std::shared_ptr< HiCR::MemorySpace > &memorySpace, void *const ptr, const size_t size)
 
__INLINE__ void deregisterLocalMemorySlot (const std::shared_ptr< HiCR::LocalMemorySlot > &memorySlot)
 
__INLINE__ void memset (const std::shared_ptr< HiCR::LocalMemorySlot > &memorySlot, int value, size_t size)
 
__INLINE__ void freeLocalMemorySlot (const std::shared_ptr< HiCR::LocalMemorySlot > &memorySlot)
 

Protected Member Functions

virtual std::shared_ptr< HiCR::LocalMemorySlotallocateLocalMemorySlotImpl (std::shared_ptr< HiCR::MemorySpace > memorySpace, const size_t size)=0
 
virtual std::shared_ptr< LocalMemorySlotregisterLocalMemorySlotImpl (std::shared_ptr< HiCR::MemorySpace > memorySpace, void *const ptr, const size_t size)=0
 
virtual void memsetImpl (const std::shared_ptr< HiCR::LocalMemorySlot > memorySlot, int value, size_t size)
 
virtual void freeLocalMemorySlotImpl (std::shared_ptr< HiCR::LocalMemorySlot > memorySlot)=0
 
virtual void deregisterLocalMemorySlotImpl (std::shared_ptr< HiCR::LocalMemorySlot > memorySlot)=0
 

Detailed Description

Encapsulates a HiCR Backend Memory Manager.

Backends represent plugins to HiCR that provide support for a communication or device library. By adding new plugins developers extend HiCR's support for new hardware and software technologies.

Backends need to fulfill the abstract virtual functions described here, so that HiCR can perform memory allocation/free/register operations on the supported device/network library.

Constructor & Destructor Documentation

◆ ~MemoryManager()

virtual HiCR::MemoryManager::~MemoryManager ( )
virtualdefault

Member Function Documentation

◆ allocateLocalMemorySlot()

__INLINE__ std::shared_ptr< LocalMemorySlot > HiCR::MemoryManager::allocateLocalMemorySlot ( const std::shared_ptr< MemorySpace > &  memorySpace,
const size_t  size 
)
inline

Allocates a local memory slot in the specified memory space

Parameters
[in]memorySpaceMemory space in which to perform the allocation.
[in]sizeSize of the memory slot to create
Returns
The pointer of the newly allocated memory slot

◆ allocateLocalMemorySlotImpl()

virtual std::shared_ptr< HiCR::LocalMemorySlot > HiCR::MemoryManager::allocateLocalMemorySlotImpl ( std::shared_ptr< HiCR::MemorySpace memorySpace,
const size_t  size 
)
protectedpure virtual

Backend-internal implementation of the allocateLocalMemorySlot function

Parameters
[in]memorySpaceMemory space to allocate memory from
[in]sizeSize of the memory slot to create
Returns
The internal pointer associated to the local memory slot

Implemented in HiCR::backend::lpf::MemoryManager, and HiCR::backend::mpi::MemoryManager.

◆ deregisterLocalMemorySlot()

__INLINE__ void HiCR::MemoryManager::deregisterLocalMemorySlot ( const std::shared_ptr< HiCR::LocalMemorySlot > &  memorySlot)
inline

De-registers a previously registered local memory slot

Parameters
[in]memorySlotMemory slot to deregister.

◆ deregisterLocalMemorySlotImpl()

virtual void HiCR::MemoryManager::deregisterLocalMemorySlotImpl ( std::shared_ptr< HiCR::LocalMemorySlot memorySlot)
protectedpure virtual

Backend-internal implementation of the deregisterMemorySlot function

Parameters
[in]memorySlotMemory slot to deregister.

◆ freeLocalMemorySlot()

__INLINE__ void HiCR::MemoryManager::freeLocalMemorySlot ( const std::shared_ptr< HiCR::LocalMemorySlot > &  memorySlot)
inline

Frees up a memory slot reserved from this memory space

Parameters
[in]memorySlotMemory slot to free up. It becomes unusable after freeing.

◆ freeLocalMemorySlotImpl()

virtual void HiCR::MemoryManager::freeLocalMemorySlotImpl ( std::shared_ptr< HiCR::LocalMemorySlot memorySlot)
protectedpure virtual

Backend-internal implementation of the freeLocalMemorySlot function

Parameters
[in]memorySlotLocal memory slot to free up. It becomes unusable after freeing.

◆ memset()

__INLINE__ void HiCR::MemoryManager::memset ( const std::shared_ptr< HiCR::LocalMemorySlot > &  memorySlot,
int  value,
size_t  size 
)
inline

Fills a memory slot with a given value. This is a blocking operation.

Like standard memset, this function fills the memory slot with the given value, starting from the beginning of the memory slot. No bounds checking is performed, so the caller must ensure that the memory slot is large enough to hold the requested number of bytes, should the size parameter be provided.

Parameters
[in]memorySlotMemory slot to fill
[in]valueValue to fill the memory slot with
[in]sizeNumber of bytes to fill, from the start of the memory slot. If not provided, the whole memory slot is filled.
Note
: The size parameter is not checked against the memory slot's size, so the caller must ensure that the size is valid.

◆ memsetImpl()

virtual void HiCR::MemoryManager::memsetImpl ( const std::shared_ptr< HiCR::LocalMemorySlot memorySlot,
int  value,
size_t  size 
)
inlineprotectedvirtual

Backend-internal implementation of the memset function

Parameters
[in]memorySlotMemory slot to fill
[in]valueValue to fill the memory slot with
[in]sizeNumber of bytes to fill, from the start of the memory slot

◆ registerLocalMemorySlot()

virtual std::shared_ptr< LocalMemorySlot > HiCR::MemoryManager::registerLocalMemorySlot ( const std::shared_ptr< HiCR::MemorySpace > &  memorySpace,
void *const  ptr,
const size_t  size 
)
inlinevirtual

Registers a local memory slot from a given address

Parameters
[in]memorySpaceMemory space in which to perform the allocation.
[in]ptrPointer to the start of the memory slot
[in]sizeSize of the memory slot to create
Returns
The pointer of the newly registered memory slot

◆ registerLocalMemorySlotImpl()

virtual std::shared_ptr< LocalMemorySlot > HiCR::MemoryManager::registerLocalMemorySlotImpl ( std::shared_ptr< HiCR::MemorySpace memorySpace,
void *const  ptr,
const size_t  size 
)
protectedpure virtual

Backend-internal implementation of the registerLocalMemorySlot function

Parameters
[in]memorySpaceMemory space to register memory in
[in]ptrPointer to the start of the memory slot
[in]sizeSize of the memory slot to create
Returns
A newly created memory slot

Implemented in HiCR::backend::lpf::MemoryManager, and HiCR::backend::mpi::MemoryManager.


The documentation for this class was generated from the following file: