13 #ifndef HTGS_MEMORYMANAGER_H 14 #define HTGS_MEMORYMANAGER_H 75 if (this->
pool !=
nullptr) {
76 pool->releaseAllMemory();
90 std::shared_ptr<Connector<MemoryData<T>>> inputConnector = std::static_pointer_cast<
Connector<MemoryData<T>>>(anyInputConnector);
94 bool allocate =
false;
95 if (
type == MMType::Static)
121 if (data !=
nullptr) {
125 if (data->canReleaseMemory()) {
126 if (
type == MMType::Static)
127 this->
pool->addMemory(data);
128 else if (
type == MMType::Dynamic) {
130 this->
pool->addMemory(data);
135 std::cerr <<
"Memory manager received data from another pipeline!" << std::endl;
139 while (!this->
pool->isPoolEmpty()) {
157 switch (this->
type) {
158 case MMType::Static:typeStr =
"static";
160 case MMType::Dynamic:typeStr =
"dynamic";
163 return std::string(
"MM(" + typeStr +
"): " + this->
name);
204 #if defined( __GLIBCXX__ ) || defined( __GLIBCPP__ ) 206 char *realName = abi::__cxa_demangle(
typeid(T).
name(), 0, 0, &status);
207 std::string ret(realName);
213 return typeid(T).
name();
231 std::shared_ptr<AnyConnector> input,
232 std::shared_ptr<AnyConnector> output)
override {
238 std::ostringstream oss;
240 if (output !=
nullptr) {
241 oss << dotId <<
" -> " << output->getDotId() <<
"[color=sienna];" << std::endl;
242 oss << output->getDotId() <<
"[label=\"" + this->
typeName()
243 <<
"\",style=filled,shape=oval,width=.2,height=.2, fillcolor=sienna, color=sienna];" << std::endl;
246 oss << dotId +
";" << std::endl;
266 #endif //HTGS_MEMORYMANAGER_H std::shared_ptr< AnyConnector > getInputConnector() override
Gets the input Connector.
Definition: TaskManager.hpp:119
std::string getMemoryManagerName()
Gets the name of the memory manager.
Definition: MemoryManager.hpp:197
size_t memoryPoolSize
The size of the memory pool.
Definition: MemoryManager.hpp:258
virtual std::string genDot(int flags, std::string dotId, std::shared_ptr< AnyConnector > input, std::shared_ptr< AnyConnector > output) override
Virtual function that generates the input/output and per-task dot notation.
Definition: MemoryManager.hpp:229
MMType
The memory manager types.
Definition: MMType.hpp:38
void executeTask(std::shared_ptr< MemoryData< T >> data) override
Processes memory data.
Definition: MemoryManager.hpp:120
void debug() override
Provides debug output for MemoryManager.
Definition: MemoryManager.hpp:147
virtual size_t getMemoryPoolSize()
Virtual function to gets the size of the MemoryPool.
Definition: MemoryManager.hpp:180
std::string name
The name of the memory manager.
Definition: MemoryManager.hpp:260
std::string typeName()
Gets the demangled type name of the connector.
Definition: MemoryManager.hpp:203
Describes memory allocated by a MemoryManager to manage shared memory across multiple ITask...
Definition: ICudaTask.hpp:28
Creates a pool of memory that allocates/frees MemoryData.
Definition: MemoryPool.hpp:39
void addResult(std::shared_ptr< MemoryData< T > > result)
Adds results to the output list to be sent to the next connected ITask in a TaskGraph.
Definition: ITask.hpp:357
Manages the input/output of IData between Tasks.
Definition: Connector.hpp:62
size_t getPipelineId()
Gets the pipeline ID.
Definition: AnyITask.hpp:367
Implements the MemoryPool class.
#define DOTGEN_FLAG_HIDE_MEM_EDGES
Hides memory edges during dot generation.
Definition: TaskGraphDotGenFlags.hpp:20
virtual std::string getName() override
Gets the name of the MemoryManager.
Definition: MemoryManager.hpp:155
std::shared_ptr< IMemoryAllocator< T > > allocator
The allocator used for allocating and freeing memory.
Definition: MemoryManager.hpp:257
Defines the Memory Manager types MMType.
#define HTGS_DEBUG(msg)
Prints a debug message to std::cerr with standard level If DEBUG_FLAG is not defined, this equates to a no op Each message includes the file and line number for where the debug is called.
Definition: debug_message.hpp:65
void initialize() override
Initializes the MemoryManager, getting the size of the memory pool, and filling the memory pool with ...
Definition: MemoryManager.hpp:87
Processes MemoryData between two ITasks using a memory pool.
Definition: MemoryManager.hpp:47
TaskManager< MemoryData< T >, MemoryData< T > > * getOwnerTaskManager()
Gets the owner task manager for this ITask.
Definition: ITask.hpp:527
An interface to process input data and forward results within a TaskGraph.
Definition: ITask.hpp:165
Abstract class that describes how memory is allocated and freed.
Definition: IMemoryAllocator.hpp:67
MMType getType() const
Gets the memory manager type.
Definition: MemoryManager.hpp:221
MMType type
The memory manager type.
Definition: MemoryManager.hpp:261
virtual std::shared_ptr< IMemoryAllocator< T > > getAllocator()
Gets the allocator that is responsible for allocating and freeing memory for the MemoryPool.
Definition: MemoryManager.hpp:188
virtual MemoryManager< T > * copy() override
Creates a shallow copy of the MemoryManager.
Definition: MemoryManager.hpp:171
MemoryManager(std::string name, size_t memoryPoolSize, std::shared_ptr< IMemoryAllocator< T >> memoryAllocator, MMType type)
Creates the MemoryManager with the specified memory pool size and allocator.
Definition: MemoryManager.hpp:58
void shutdown() override
Shuts down the MemoryManager memory is only released when the underlying graph destructs the memory m...
Definition: MemoryManager.hpp:105
MemoryPool< T > * pool
The memory pool.
Definition: MemoryManager.hpp:259
~MemoryManager() override
Destructor.
Definition: MemoryManager.hpp:74
std::string getDotFillColor() override
Gets the color for filling the shape for graphviz dot.
Definition: MemoryManager.hpp:252
An interface to process input data and forward results within a TaskGraph.
Definition: Bookkeeper.hpp:23
Defines how memory is allocated and freed.