19#ifndef HEDGEHOG_ABSTRACT_MEMORY_MANAGER_H_
20#define HEDGEHOG_ABSTRACT_MEMORY_MANAGER_H_
28#include "../../../tools/nvtx_profiler.h"
33#ifndef DOXYGEN_SHOULD_SKIP_THIS
45 std::unique_ptr<tool::Pool<ManagedMemory>>
pool_ = {};
69 auto s = this->
pool()->size();
70 memoryManagerMutex_.unlock();
77 return this->
pool()->capacity();
96 virtual void recycleMemory(std::shared_ptr<ManagedMemory>
const &managedMemory) = 0;
100 virtual std::shared_ptr<AbstractMemoryManager>
copy() = 0;
113 [[nodiscard]] std::shared_ptr<NvtxProfiler>
const &
profiler()
const {
119 [[nodiscard]] std::unique_ptr<tool::Pool<ManagedMemory>>
const &
pool()
const {
return pool_; }
Abstraction used to manage an user type with a memory manager.
std::shared_ptr< NvtxProfiler > profiler_
NVTX profiler instance to follow memory manager state.
std::mutex memoryManagerMutex_
Mutex for user interface.
int deviceId() const
Device Id accessor.
virtual void initialize()=0
Initialize the memory manager.
virtual std::shared_ptr< ManagedMemory > getManagedMemory()=0
Get an available managed memory, block if none are available.
std::shared_ptr< NvtxProfiler > const & profiler() const
Accessor to NVTX profiler.
AbstractMemoryManager(size_t const &capacity)
Only used constructor.
bool isInitialized() const
Initialized flag accessor.
std::mutex & memoryManagerMutex()
User api mutex accessor.
size_t capacity() const
Capacity accessor.
void profiler(const std::shared_ptr< NvtxProfiler > &profiler)
NVTX profiler setter.
virtual ~AbstractMemoryManager()=default
Default destructor.
void deviceId(int deviceId)
Device id setter.
virtual std::string managedType() const =0
Return the real managed type under the form of a string.
std::unique_ptr< tool::Pool< ManagedMemory > > pool_
Inside pool to store the data.
std::unique_ptr< tool::Pool< ManagedMemory > > const & pool() const
Inside pool accessor.
virtual std::shared_ptr< AbstractMemoryManager > copy()=0
Virtual copy method used for task duplication and execution pipeline.
size_t currentSize()
Return the current size of the inside pool.
int deviceId_
Device Id of linked task.
bool initialized_
Flag to determine if AbstractMemoryManager has been initialized.
void initialized()
Flag the memory manager has initialized.
virtual void recycleMemory(std::shared_ptr< ManagedMemory > const &managedMemory)=0
Recycle memory.