HTGS  v2.0
The Hybrid Task Graph Scheduler
htgs::AnyTaskGraphConf Class Referenceabstract

Implements the base class for the TaskGraphConf class, removing the template arguments and providing functionality that is applicable to any task graph configuration. More...

#include <htgs/core/graph/AnyTaskGraphConf.hpp>

Inheritance diagram for htgs::AnyTaskGraphConf:
Inheritance graph
Collaboration diagram for htgs::AnyTaskGraphConf:
Collaboration graph

Public Member Functions

 AnyTaskGraphConf (size_t pipelineId, size_t numPipelines, std::string baseAddress)
 Constructs the AnyTaskGraphConf. More...
 
virtual ~AnyTaskGraphConf ()
 Destructor.
 
virtual std::shared_ptr< AnyConnectorgetInputConnector ()=0
 Pure virtual function that gets the task manager that is consuming data from the graph's input. More...
 
virtual std::shared_ptr< AnyConnectorgetOutputConnector ()=0
 Virtual function that gets the connector used for graph output. More...
 
std::list< AnyTaskManager * > * getTaskManagers ()
 Virtual function that initiates updating the task graph communicator. More...
 
void gatherProfilingData (std::map< AnyTaskManager *, TaskManagerProfile *> *taskManagerProfiles)
 Gathers profiling data for this task graph's task managers, which is added into the task manager profiles map. More...
 
template<class V , class W >
std::shared_ptr< IRule< V, W > > getIRule (IRule< V, W > *iRule)
 Gets the shared_ptr reference for a particular IRule. More...
 
template<class V >
std::shared_ptr< IMemoryAllocator< V > > getMemoryAllocator (IMemoryAllocator< V > *allocator)
 Gets the shared_ptr reference for a particular IMemoryAllocator. More...
 
void initialize ()
 Initializes the task graph just prior to spawning threads.
 
virtual void finishedSetup ()
 Called when the task graph has finished setting up its tasks and launched all threads for the graph.
 
void shutdown ()
 Called when all the threads in this graph have finished executing.
 
void waitForInitialization ()
 Waits for all task managers to finish initializing. More...
 
std::condition_variable * getInitializationCondition ()
 Notifies the task graph to check if all task managers have been initialized or not. More...
 
std::mutex * getInitializationMutex ()
 Gets the initialization mutex, used for signaling when initialization is done. More...
 
TaskNameConnectorMapgetTaskConnectorNameMap () const
 Gets the task name connector map that maps the task name to its input connector. More...
 
template<class T , class U >
ITask< T, U > * getCopy (ITask< T, U > *orig)
 Gets the copy for an ITask based on some original ITask reference. More...
 
AnyITaskgetCopy (AnyITask *orig)
 Gets the copy for an AnyITask based on some original AnyITask reference. More...
 
template<class T , class U >
TaskManager< T, U > * getTaskManager (ITask< T, U > *task)
 Gets the task manager that is responsible for a particular ITask. More...
 
void addTaskManager (AnyTaskManager *taskManager)
 Adds a task manager to the task graph. More...
 
void printProfile ()
 Prints profile data to console for all task managers.
 
size_t getPipelineId ()
 Gets the pipeline ID for the task graph configuration. More...
 
size_t getNumPipelines ()
 Gets the number of pipelines that exist for this task graph. More...
 
void writeDotToFile (std::string file, int flags=0, std::string graphTitle="", std::string customTitleText="")
 Writes the dot representation of the task graph to disk with additional options such as profiling. More...
 
virtual void updateTaskManagersAddressingAndPipelines ()=0
 Updates the task managers addresses, pipelineIds and the number of pipelines for all tasks in the TaskGraph. More...
 
std::string getAddress ()
 Gets the address for the task graph. More...
 
size_t getNumberOfSubGraphs () const
 Gets the number of sub graphs within this task graph. More...
 
unsigned long long int getGraphComputeTime () const
 Gets the total time the graph was computing. More...
 
unsigned long long int getGraphCreationTime () const
 Gets the total time the graph was getting created. More...
 
std::string genDotGraphContent (int flags)
 Generate the content only of the graph (excludes all graph definitions and attributes)
 
virtual AnyTaskGraphConfcopy ()=0
 Creates an exact copy of this task graph. More...
 
virtual std::string genDotGraph (int flags, int colorFlag, std::string graphTitle="", std::string customTitleText="")=0
 Generates the dot graph as a string.
 
void copyTasks (std::list< AnyTaskManager *> *tasks)
 Creates a copy of each task from the list of AnyTaskManagers passed as a parameter. More...
 
AnyTaskManagergetTaskManagerCopy (AnyITask *iTask)
 Gets the task manager copy for a given ITask. More...
 
bool hasTask (AnyITask *task)
 Checks whether an ITask is in the graph or not. More...
 

Private Member Functions

void createCopy (AnyTaskManager *taskManager)
 Creates a copy of a task manager and adds the copy and a mapping between the task manager copy and the original ITask that the manager is responsible for. More...
 

Private Attributes

ITaskMaptaskCopyMap
 The ITask copy map that maps an original ITask to a task manager copy.
 
std::list< AnyTaskManager * > * taskManagers
 The list of task managers for the task graph.
 
size_t pipelineId
 The pipelineId for the task graph.
 
size_t numPipelines
 The number of pipelines from this graph.
 
std::string address
 The address for this task graph and its tasks.
 
TaskNameConnectorMaptaskConnectorNameMap
 Maps the tsak name to the task's connector.
 
size_t numberOfSubGraphs
 The number of sub-graphs that will be spawned.
 
IRuleMapiRuleMap
 A mapping for each IRule pointer to the shared pointer for that IRule.
 
MemAllocMapmemAllocMap
 A mapping for each IMemoryAllocator to its associated shared_ptr.
 
std::chrono::time_point< std::chrono::high_resolution_clock > graphCreationTimestamp
 Timestamp when graph constructor was called.
 
std::chrono::time_point< std::chrono::high_resolution_clock > graphExecutingTimestamp
 Timestamp for how long the graph executed.
 
unsigned long long int graphComputeTime
 The total time to execute the graph.
 
unsigned long long int graphCreationTime
 The total time to create the graph.
 
std::condition_variable initializeCondition
 The condition variable to signal to check if initialization has finished.
 
std::mutex initializeMutex
 Mutex used to signal initializational.
 

Detailed Description

Implements the base class for the TaskGraphConf class, removing the template arguments and providing functionality that is applicable to any task graph configuration.

For example, storing the base address, pipeline ID, etc.

Constructor & Destructor Documentation

◆ AnyTaskGraphConf()

htgs::AnyTaskGraphConf::AnyTaskGraphConf ( size_t  pipelineId,
size_t  numPipelines,
std::string  baseAddress 
)
inline

Constructs the AnyTaskGraphConf.

Parameters
pipelineIdthe pipeline ID associated with this task graph
numPipelinesthe number of pipelines that exist for the task graph
baseAddressthe base address for the graph, if it is an empty string then this graph is the first/root graph.

Member Function Documentation

◆ addTaskManager()

void htgs::AnyTaskGraphConf::addTaskManager ( AnyTaskManager taskManager)
inline

Adds a task manager to the task graph.

Parameters
taskManagerthe task manager

◆ copy()

virtual AnyTaskGraphConf* htgs::AnyTaskGraphConf::copy ( )
pure virtual

Creates an exact copy of this task graph.

Returns
a copy of the task graph.

Implemented in htgs::TaskGraphConf< T, U >.

◆ copyTasks()

void htgs::AnyTaskGraphConf::copyTasks ( std::list< AnyTaskManager *> *  tasks)
inline

Creates a copy of each task from the list of AnyTaskManagers passed as a parameter.

Each copy is added into this graph and a mapping between the original and the copy is made.

Parameters
tasksthe tasks to make copies of.

◆ createCopy()

void htgs::AnyTaskGraphConf::createCopy ( AnyTaskManager taskManager)
inlineprivate

Creates a copy of a task manager and adds the copy and a mapping between the task manager copy and the original ITask that the manager is responsible for.

Parameters
taskManagerthe task manager to create a copy for.

◆ gatherProfilingData()

void htgs::AnyTaskGraphConf::gatherProfilingData ( std::map< AnyTaskManager *, TaskManagerProfile *> *  taskManagerProfiles)
inline

Gathers profiling data for this task graph's task managers, which is added into the task manager profiles map.

Parameters
taskManagerProfilesthe map that stores all the profile data for each task manager.

◆ getAddress()

std::string htgs::AnyTaskGraphConf::getAddress ( )
inline

Gets the address for the task graph.

All tasks within this graph share the same address as the graph.

Returns
the address

◆ getCopy() [1/2]

template<class T , class U >
ITask<T, U>* htgs::AnyTaskGraphConf::getCopy ( ITask< T, U > *  orig)
inline

Gets the copy for an ITask based on some original ITask reference.

This function is used to find the associated ITask reference to ensure connections are maintained when copying the TaskGraphConf.

Template Parameters
Tthe input type of the ITask
Uthe output type of the ITask
Parameters
origthe pointer to the original ITask that may have been copied before
Returns
the ITask's copy or nullptr if the copy is not found.

◆ getCopy() [2/2]

AnyITask* htgs::AnyTaskGraphConf::getCopy ( AnyITask orig)
inline

Gets the copy for an AnyITask based on some original AnyITask reference.

This function is used to find the associated ITask reference to ensure connections are maintained when copying the TaskGraphConf. This version does not use the template arguments.

Parameters
origthe pointer to the original AnyITask that may have been copied before
Returns
the AnyITask's copy or nullptr if the copy is not found.

◆ getGraphComputeTime()

unsigned long long int htgs::AnyTaskGraphConf::getGraphComputeTime ( ) const
inline

Gets the total time the graph was computing.

Returns
the total time the graph was computing.

◆ getGraphCreationTime()

unsigned long long int htgs::AnyTaskGraphConf::getGraphCreationTime ( ) const
inline

Gets the total time the graph was getting created.

Returns
the total time the graph was getting created.

◆ getInitializationCondition()

std::condition_variable* htgs::AnyTaskGraphConf::getInitializationCondition ( )
inline

Notifies the task graph to check if all task managers have been initialized or not.

Note

◆ getInitializationMutex()

std::mutex* htgs::AnyTaskGraphConf::getInitializationMutex ( )
inline

Gets the initialization mutex, used for signaling when initialization is done.

Returns
the initialization mutex

◆ getInputConnector()

virtual std::shared_ptr<AnyConnector> htgs::AnyTaskGraphConf::getInputConnector ( )
pure virtual

Pure virtual function that gets the task manager that is consuming data from the graph's input.

Returns
the task manager that is consuming data from the graph's input. Gets the list of task managers that are producing data for the graph's output
the list of task managers that are producing data for the graph's output. Virtual function that gets the connector used for graph input
the connector used for graph input

Implemented in htgs::TaskGraphConf< T, U >.

◆ getIRule()

template<class V , class W >
std::shared_ptr<IRule<V, W> > htgs::AnyTaskGraphConf::getIRule ( IRule< V, W > *  iRule)
inline

Gets the shared_ptr reference for a particular IRule.

Template Parameters
Vthe input type of the IRule
Wthe output type of the IRule
Parameters
iRulethe IRule
Returns
the shared_ptr reference to the IRule

◆ getMemoryAllocator()

template<class V >
std::shared_ptr<IMemoryAllocator<V> > htgs::AnyTaskGraphConf::getMemoryAllocator ( IMemoryAllocator< V > *  allocator)
inline

Gets the shared_ptr reference for a particular IMemoryAllocator.

Template Parameters
Vthe data type that is allocated
Parameters
allocatorthe IMemoryAllocator
Returns
the shared_ptr reference to the IMemoryAllocator

◆ getNumberOfSubGraphs()

size_t htgs::AnyTaskGraphConf::getNumberOfSubGraphs ( ) const
inline

Gets the number of sub graphs within this task graph.

This number represents the number of subgraphs spawned by all execution pipelines in the graph.

Returns
the number of sub graphs.

◆ getNumPipelines()

size_t htgs::AnyTaskGraphConf::getNumPipelines ( )
inline

Gets the number of pipelines that exist for this task graph.

Returns
the number of pipelines

◆ getOutputConnector()

virtual std::shared_ptr<AnyConnector> htgs::AnyTaskGraphConf::getOutputConnector ( )
pure virtual

Virtual function that gets the connector used for graph output.

Returns
the connector used for graph output

Implemented in htgs::TaskGraphConf< T, U >.

◆ getPipelineId()

size_t htgs::AnyTaskGraphConf::getPipelineId ( )
inline

Gets the pipeline ID for the task graph configuration.

Returns
the pipeline ID

◆ getTaskConnectorNameMap()

TaskNameConnectorMap* htgs::AnyTaskGraphConf::getTaskConnectorNameMap ( ) const
inline

Gets the task name connector map that maps the task name to its input connector.

Returns
the task name connector map that namps the task name to its input connector.

◆ getTaskManager()

template<class T , class U >
TaskManager<T, U>* htgs::AnyTaskGraphConf::getTaskManager ( ITask< T, U > *  task)
inline

Gets the task manager that is responsible for a particular ITask.

Template Parameters
Tthe input type of the TaskManager/ITask
Uthe output type of the TaskManager/ITask
Parameters
taskthe ITask
Returns
the task manager responsible for the ITask

◆ getTaskManagerCopy()

AnyTaskManager* htgs::AnyTaskGraphConf::getTaskManagerCopy ( AnyITask iTask)
inline

Gets the task manager copy for a given ITask.

Parameters
iTaskthe ITask to lookup.
Returns
the task manager used to manage the ITask

◆ getTaskManagers()

std::list<AnyTaskManager *>* htgs::AnyTaskGraphConf::getTaskManagers ( )
inline

Virtual function that initiates updating the task graph communicator.

Virtual function that gets the task graph communicator.

Returns
Get the vertices of the TaskGraph
the vertices of the TaskGraph

◆ hasTask()

bool htgs::AnyTaskGraphConf::hasTask ( AnyITask task)
inline

Checks whether an ITask is in the graph or not.

Parameters
taskthe ITask to check
Returns
true if the task is in this graph, otherwise false
Return values
TRUEif the task is in the graph
FALSEif the task is not in the graph

◆ updateTaskManagersAddressingAndPipelines()

virtual void htgs::AnyTaskGraphConf::updateTaskManagersAddressingAndPipelines ( )
pure virtual

Updates the task managers addresses, pipelineIds and the number of pipelines for all tasks in the TaskGraph.

Note
This function should only be called by the HTGS API

Implemented in htgs::TaskGraphConf< T, U >.

◆ waitForInitialization()

void htgs::AnyTaskGraphConf::waitForInitialization ( )
inline

Waits for all task managers to finish initializing.

When this returns it is safe to assume that all tasks have been initialized from the graph.

Note
Only call this function after htgs::TaskGraphRuntime::executeRuntime has been called for the graph.

◆ writeDotToFile()

void htgs::AnyTaskGraphConf::writeDotToFile ( std::string  file,
int  flags = 0,
std::string  graphTitle = "",
std::string  customTitleText = "" 
)
inline

Writes the dot representation of the task graph to disk with additional options such as profiling.

Example: taskGraph->writeDotToFile("example.dot", DOTGEN_FLAG_HIDE_MEM_EDGES | DOTGEN_FLAG_SHOW_IN_OUT_TYPES);

The bit flags are aggregated using bit-wise OR operator.

Parameters
filethe filename (will not create directories)
flagsthe flags for DOTGEN
graphTitlethe title of the graph that is inserted into a graph title section in the visualization
customTitleTextcustom text that can be inserted into the graph title section in the visualization
Note
Use the directive PROFILE to enable profiling output and call after execution.
See TaskGraphDotGenFlags.hpp for list of bit flags
Calling this function prior to execution show the graph structure.

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