|
Hedgehog
0.0.0
A library to generate hybrid pipeline workflow systems
|
Abstract interface for Hedgehog's Memory manager. More...
#include "abstract_memory_manager.h"


Public Member Functions | |
| AbstractMemoryManager ()=delete | |
| Deleted Default constructor. | |
| AbstractMemoryManager (size_t const &capacity) | |
| Only used constructor. More... | |
| virtual | ~AbstractMemoryManager ()=default |
| Default destructor. | |
| virtual std::shared_ptr< AbstractMemoryManager< ManagedMemory > > | copy () |
| Virtual copy method used for task duplication and execution pipeline. More... | |
| void | deviceId (int deviceId) |
| Device id setter. More... | |
| void | profiler (const std::shared_ptr< NvtxProfiler > &profiler) |
| NVTX profiler setter. More... | |
| size_t | currentSize () |
| Return the current size of the inside pool. More... | |
| std::shared_ptr< ManagedMemory > | getManagedMemory () |
| Get an available managed memory, block if none are available. More... | |
| void | recycleMemory (std::shared_ptr< MemoryData< ManagedMemory >> managedMemory) |
| Recycle memory. More... | |
| virtual void | initialize () |
| Initialize the memory manager. More... | |
| virtual void | initializeMemoryManager () |
| User-definable initialization step for a memory manager. | |
Protected Member Functions | |
| std::unique_ptr< behavior::Pool< ManagedMemory > > const & | pool () const |
| Inside pool accessor. More... | |
| size_t | capacity () const |
| Capacity accessor. More... | |
| bool | isInitialized () const |
| Initialized flag accessor. More... | |
| std::mutex & | memoryManagerMutex () |
| User api mutex accessor. More... | |
| void | initialized () |
| Flag the memory manager has initialized. | |
| int | deviceId () const |
| Device Id accessor. More... | |
Protected Attributes | |
| std::mutex | memoryManagerMutex_ = {} |
| Mutex for user interface. | |
Private Attributes | |
| int | deviceId_ = 0 |
| Device Id of linked task. | |
| bool | initialized_ = false |
| Flag to determine if AbstractMemoryManager has been initialized. | |
| std::unique_ptr< behavior::Pool< ManagedMemory > > | pool_ = {} |
| Inside pool to store the data. | |
| std::shared_ptr< NvtxProfiler > | profiler_ = nullptr |
| NVTX profiler instance to follow memory manager state. | |
Abstract interface for Hedgehog's Memory manager.
The memory managers for Hedgehog have two main goals:
The amount of data available is set at construction: AbstractMemoryManager(size_t const &capacity). At construction, these data are default constructed and stored into a Pool. When constructed, a memory manager can be attached to a task with AbstractTask::connectMemoryManager().
Data can be retrieved from the memory manager from within the AbstractTask::execute method with AbstractMemoryManager::getManagedMemory(). If no data is available (i.e. the Pool is empty), the task will block on the call and wait for data to be recycled and available. To return data to the memory manager from another task, or, outside the graph, the method MemoryData::returnToMemoryManager() should be called.
The only pure virtual method is the copy method to duplicate a derived AbstractMemoryManager to different graphs in an ExecutionPipeline.
If an initialize step is needed to be added, AbstractMemoryManager::initializeMemoryManager() can be overload.
| ManagedMemory | Type of data that will be managed by an AbstractMemoryManager |
Definition at line 160 of file abstract_memory_manager.h.
|
inlineexplicit |
Only used constructor.
| capacity | Memory Manager capacity, number of elements available, set to 1 if 0 |
Definition at line 177 of file abstract_memory_manager.h.
|
inlineprotected |
Capacity accessor.
Definition at line 259 of file abstract_memory_manager.h.

|
inlinevirtual |
Virtual copy method used for task duplication and execution pipeline.
Reimplemented in hh::StaticMemoryManager< ManagedMemory, Args >.
Definition at line 188 of file abstract_memory_manager.h.
|
inline |
Return the current size of the inside pool.
Lock the api user mutex before getting the current size of the inside pool
Definition at line 203 of file abstract_memory_manager.h.

|
inline |
Device id setter.
| deviceId | Task's device id to set |
Definition at line 194 of file abstract_memory_manager.h.

|
inlineprotected |
|
inline |
Get an available managed memory, block if none are available.
Definition at line 210 of file abstract_memory_manager.h.
|
inlinevirtual |
Initialize the memory manager.
Lock the user api mutex, fill the pool with default constructed data, and call initializeMemoryManager()
Reimplemented in hh::StaticMemoryManager< ManagedMemory, Args >.
Definition at line 235 of file abstract_memory_manager.h.
|
inlineprotected |
Initialized flag accessor.
Definition at line 263 of file abstract_memory_manager.h.

|
inlineprotected |
User api mutex accessor.
Definition at line 267 of file abstract_memory_manager.h.
|
inlineprotected |
Inside pool accessor.
Definition at line 255 of file abstract_memory_manager.h.

|
inline |
NVTX profiler setter.
| profiler | NVTX profiler to set |
Definition at line 198 of file abstract_memory_manager.h.

|
inline |
Recycle memory.
Lock the user api mutex before call used(), canBeRecycled() and if true, recycle() and push it back into the pool
| managedMemory | Data to recycle |
Definition at line 223 of file abstract_memory_manager.h.
