HTGS  v2.0
The Hybrid Task Graph Scheduler
htgs::TGTask< T, U > Class Template Reference

TGTask is the task graph task, which is used to bundle a graph as a task, which can then be connected to other graphs. More...

#include <htgs/api/TGTask.hpp>

Inheritance diagram for htgs::TGTask< T, U >:
Inheritance graph
Collaboration diagram for htgs::TGTask< T, U >:
Collaboration graph

Public Member Functions

 TGTask (TaskGraphConf< T, U > *taskGraphConf, std::string name="TGTask", bool waitForInitialization=true)
 Constructs a TGTask that will redirect the input and output of the TGTask to its underlying task graph. More...
 
 ~TGTask ()
 Deconstructs the TGTask.
 
void initialize () override
 Initializes the TGTask, which will redirect the input/output connectors that are attached to its underlying htgs::TaskGraphConf. More...
 
void executeTask (std::shared_ptr< T > data) override
 Not called, as the thread will terminate after initialization is done. More...
 
size_t getNumGraphsSpawned () override
 Gets the number of graphs spawned by the TGTask. More...
 
void shutdown () override
 Shutsdown the TGTask by waiting for the underlying htgs::TaskGraphConfg to finish running.
 
std::string getName () override
 Gets the name of the TGTask. More...
 
ITask< T, U > * copy () override
 Creates a copy of the TGTask. More...
 
std::string genCustomDot (ProfileUtils *profileUtils, int colorFlag) override
 Virtual function to generate customized dot file. More...
 
void gatherProfileData (std::map< AnyTaskManager *, TaskManagerProfile *> *taskManagerProfiles) override
 Gathers profiling data for the underlying htgs::TaskGraphConf. More...
 
void printProfile () override
 Prints profile information to console.
 
bool canTerminate (std::shared_ptr< AnyConnector > inputConnector) override
 The TGTask is set to terminate immediately, as the primary functionality is done at initialization. More...
 
virtual std::string genDotProducerEdgeToTask (std::map< std::shared_ptr< AnyConnector >, AnyITask *> &inputConnectorDotMap, int dotFlags) override
 
virtual std::string genDotProducerEdgeFromConnector (std::shared_ptr< AnyConnector > connector, int flags)
 
virtual std::string genDotConsumerEdgeFromConnector (std::shared_ptr< AnyConnector > connector, int flags) override
 
std::string getConsumerDotIds () override
 
std::string getProducerDotIds () override
 
std::string genDot (int flags, std::string dotId, std::shared_ptr< AnyConnector > input, std::shared_ptr< AnyConnector > output) override
 Generates the sub graph dot file representation of the TGTask. More...
 
std::string cleanupVisualization (TaskGraphConf< T, U > *graph, std::string str)
 Moves the output connector outside of the execution pipeline graphs to cleanup how the graph looks during graph visualization. More...
 
- Public Member Functions inherited from htgs::ITask< T, U >
 ITask ()
 Creates an ITask with number of threads equal to 1.
 
 ITask (size_t numThreads)
 Constructs an ITask with a specified number of threads. More...
 
 ITask (size_t numThreads, bool isStartTask, bool poll, size_t microTimeoutTime)
 Constructs an ITask with a specified number of threads as well as additional scheduling options. More...
 
virtual void executeTaskFinal () override
 Virtual function that is called just before the task has shutdown. More...
 
virtual std::string getDotLabelName () override
 Virtual function to get the label name used for dot graph viz. More...
 
virtual std::string getDotShapeColor () override
 Gets the color of the shape for graphviz dot. More...
 
virtual std::string getDotFillColor () override
 Gets the color for filling the shape for graphviz dot. More...
 
virtual std::string getDotShape () override
 Gets the shape for graphviz dot. More...
 
virtual std::string getDotCustomProfile () override
 Adds the string text to the profiling of this task in the graphviz dot visualization. More...
 
ITask< T, U > * copyITask (bool deep) override
 Copies the ITask (including a copy of all memory edges) More...
 
void addResult (std::shared_ptr< U > result)
 Adds results to the output list to be sent to the next connected ITask in a TaskGraph. More...
 
void addResult (U *result)
 Adds results to the output list to be sent to the next connected ITask in a TaskGraph. More...
 
void initialize (size_t pipelineId, size_t numPipeline, TaskManager< T, U > *ownerTask)
 Function that is called when an ITask is being initialized by it's owner thread. More...
 
template<class V >
m_data_t< V > getMemory (std::string name, IMemoryReleaseRule *releaseRule)
 Retrieves memory from a memory edge. More...
 
template<class V >
m_data_t< V > getDynamicMemory (std::string name, IMemoryReleaseRule *releaseRule, size_t numElems)
 Retrieves memory from a memory edge. More...
 
template<class V >
void releaseMemory (m_data_t< V > memory)
 Releases memory onto a memory edge, which is transferred by the graph communicator. More...
 
void resetProfile ()
 Resets profile data.
 
size_t getThreadID ()
 Gets the thread ID associated with this task. More...
 
unsigned long long int getTaskComputeTime () const
 Gets the task's compute time. More...
 
std::string inTypeName () override final
 Gets the demangled input type name of the connector. More...
 
std::string outTypeName () override final
 Gets the demangled output type name of the connector. More...
 
std::string getAddress () override final
 Gets the address from the owner task, which is the address of the task graph. More...
 
void setTaskManager (TaskManager< T, U > *ownerTask)
 Sets the owner task manager for this ITask. More...
 
TaskManager< T, U > * getOwnerTaskManager ()
 Gets the owner task manager for this ITask. More...
 
- Public Member Functions inherited from htgs::AnyITask
 AnyITask ()
 Creates an ITask with number of threads equal to 1.
 
 AnyITask (size_t numThreads)
 Constructs an ITask with a specified number of threads. More...
 
 AnyITask (size_t numThreads, bool isStartTask, bool poll, size_t microTimeoutTime)
 Constructs an ITask with a specified number of threads as well as additional scheduling options. More...
 
virtual ~AnyITask ()
 Destructor.
 
virtual std::string genDot (int flags, std::string dotId, std::shared_ptr< htgs::AnyConnector > input, std::shared_ptr< htgs::AnyConnector > output)
 Virtual function that generates the input/output and per-task dot notation. More...
 
virtual std::string genDot (int flags, std::string dotId)
 Virtual function that adds additional dot attributes to this node. More...
 
virtual void debug ()
 Virtual function that is called to debug the ITask.
 
virtual std::string debugDotNode ()
 Provides debug output for a node in the dot graph. More...
 
virtual void profile ()
 Virtual function that is called to provide profile output for the ITask. More...
 
virtual std::string profileStr ()
 Virtual function that is called after executionTask is called. More...
 
void initialize (size_t pipelineId, size_t numPipeline)
 Virtual function that is called when an ITask is being initialized by it's owner thread. More...
 
void setPipelineId (size_t pipelineId)
 Sets the pipeline Id for this ITask. More...
 
size_t getPipelineId ()
 Gets the pipeline ID. More...
 
void setNumPipelines (size_t numPipelines)
 Sets the number of pipelines that this ITask belongs too. More...
 
size_t getNumPipelines () const
 Sets the task graph communicator. More...
 
size_t getNumThreads () const
 Gets the number of threads associated with this ITask. More...
 
bool isStartTask () const
 Gets whether this ITask is a starting task. More...
 
bool isPoll () const
 Gets whether this ITask is polling for data or not. More...
 
size_t getMicroTimeoutTime () const
 Gets the timeout time for polling. More...
 
void copyMemoryEdges (AnyITask *iTaskCopy)
 Copies the memory edges from this AnyITask to another AnyITask. More...
 
std::string genDot (int flags, std::shared_ptr< AnyConnector > input, std::shared_ptr< AnyConnector > output)
 Creates a dot notation representation for this task. More...
 
void profileITask ()
 Provides profile output for the ITask,. More...
 
std::string getDotId ()
 Gets the id used for dot nodes. More...
 
std::string getNameWithPipelineId ()
 Gets the name of the ITask with it's pipeline ID. More...
 
const std::shared_ptr< ConnectorMap > & getMemoryEdges () const
 Gets the memory edges for the task. More...
 
const std::shared_ptr< ConnectorMap > & getReleaseMemoryEdges () const
 Gets the memory edges for releasing memory for the memory manager, used to shutdown the memory manager. More...
 
bool hasMemoryEdge (std::string name)
 Checks whether this ITask contains a memory edge for a specified name. More...
 
void attachMemoryEdge (std::string name, std::shared_ptr< AnyConnector > getMemoryConnector, std::shared_ptr< AnyConnector > releaseMemoryConnector, MMType type)
 Attaches a memory edge to this ITask to get memory. More...
 
unsigned long long int getMemoryWaitTime () const
 Gets the amount of time the task was waiting for memory. More...
 
void incMemoryWaitTime (unsigned long long int val)
 Increments memory wait time. More...
 

Private Attributes

TaskGraphConf< T, U > * taskGraphConf
 The task graph that the TGTask is managing.
 
TaskGraphRuntimeruntime
 The runtime that is associate with the task graph.
 
bool waitForInitialization
 Whether to wait for initialization of the task graph or not.
 
std::string name
 The name of the TGTask.
 

Detailed Description

template<class T, class U>
class htgs::TGTask< T, U >

TGTask is the task graph task, which is used to bundle a graph as a task, which can then be connected to other graphs.

The primary function of this task is to help provide more generalization of custom graphs, which can then be incorporated easily into other projects. An added bonus is the ability to visualize graphs and sub-graphs from within a single graph.

Common usage:

// Add edges and other components within taskGraph
...
bool waitForInit = true;
htgs::TGTask<htgs::VoidData, htgs::VoidData> *tgTask = taskGraph->createTaskGraphTask("CustomName", waitForInit);
// Add tgTask into another graph as needed.
Template Parameters
Tthe input data type for the TGTask, T must derive from IData and match the input type of the htgs::TaskGraphConf.
Uthe output data type for the TGTask, U must derive from IData and match the output type of the htgs::TaskGraphConf.

Constructor & Destructor Documentation

◆ TGTask()

template<class T, class U>
htgs::TGTask< T, U >::TGTask ( TaskGraphConf< T, U > *  taskGraphConf,
std::string  name = "TGTask< T, U >",
bool  waitForInitialization = true 
)
inline

Constructs a TGTask that will redirect the input and output of the TGTask to its underlying task graph.

Parameters
taskGraphConfthe task graph to redirect input and output too.
namethe name of the TGTask, default = "TGTask"
waitForInitializationwhether to wait for initialization or not, default = true

Member Function Documentation

◆ canTerminate()

template<class T, class U>
bool htgs::TGTask< T, U >::canTerminate ( std::shared_ptr< AnyConnector inputConnector)
inlineoverridevirtual

The TGTask is set to terminate immediately, as the primary functionality is done at initialization.

Parameters
inputConnectorthe input connector
Returns
true

Reimplemented from htgs::ITask< T, U >.

◆ cleanupVisualization()

template<class T, class U>
std::string htgs::TGTask< T, U >::cleanupVisualization ( TaskGraphConf< T, U > *  graph,
std::string  str 
)
inline

Moves the output connector outside of the execution pipeline graphs to cleanup how the graph looks during graph visualization.

Parameters
graphthe graph
strthe dot file string to be cleaned up
Returns
the improved dot file text

◆ copy()

template<class T, class U>
ITask<T, U>* htgs::TGTask< T, U >::copy ( )
inlineoverridevirtual

Creates a copy of the TGTask.

This will also create a new copy of the htgs::TaskGraphConf

Returns
the copy of the TGTask

Implements htgs::ITask< T, U >.

◆ executeTask()

template<class T, class U>
void htgs::TGTask< T, U >::executeTask ( std::shared_ptr< T >  data)
inlineoverridevirtual

Not called, as the thread will terminate after initialization is done.

Parameters
data

Implements htgs::ITask< T, U >.

◆ gatherProfileData()

template<class T, class U>
void htgs::TGTask< T, U >::gatherProfileData ( std::map< AnyTaskManager *, TaskManagerProfile *> *  taskManagerProfiles)
inlineoverridevirtual

Gathers profiling data for the underlying htgs::TaskGraphConf.

Parameters
taskManagerProfilesthe profiling data

Reimplemented from htgs::ITask< T, U >.

◆ genCustomDot()

template<class T, class U>
std::string htgs::TGTask< T, U >::genCustomDot ( ProfileUtils profileUtils,
int  colorFlag 
)
inlineoverridevirtual

Virtual function to generate customized dot file.

Parameters
profilerthe profiler that contains color maps
Returns
the dot file text that will be added near the end of the dot file

Reimplemented from htgs::AnyITask.

◆ genDot()

template<class T, class U>
std::string htgs::TGTask< T, U >::genDot ( int  flags,
std::string  dotId,
std::shared_ptr< AnyConnector input,
std::shared_ptr< AnyConnector output 
)
inlineoverride

Generates the sub graph dot file representation of the TGTask.

Parameters
flagsdot flags
dotIdthe id for the TGTask
inputthe input connector for the TGTask
outputthe output connector for the TGTask
Returns
the string representation of the TGTask sub graph.

◆ getName()

template<class T, class U>
std::string htgs::TGTask< T, U >::getName ( )
inlineoverridevirtual

Gets the name of the TGTask.

Returns
the name

Reimplemented from htgs::ITask< T, U >.

◆ getNumGraphsSpawned()

template<class T, class U>
size_t htgs::TGTask< T, U >::getNumGraphsSpawned ( )
inlineoverridevirtual

Gets the number of graphs spawned by the TGTask.

Returns
the number of graphs spawned

Reimplemented from htgs::ITask< T, U >.

◆ initialize()

template<class T, class U>
void htgs::TGTask< T, U >::initialize ( )
inlineoverridevirtual

Initializes the TGTask, which will redirect the input/output connectors that are attached to its underlying htgs::TaskGraphConf.

The task graph will have all of its spawned. If waitForInitialization is set to true, then this function will only return once all threads have spawned for its task graph.

Reimplemented from htgs::ITask< T, U >.


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