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

Special task used to manage rules. More...

#include <htgs/api/Bookkeeper.hpp>

Inheritance diagram for htgs::Bookkeeper< T >:
Inheritance graph
Collaboration diagram for htgs::Bookkeeper< T >:
Collaboration graph

Public Member Functions

 Bookkeeper ()
 Constructs a bookkeeper.
 
virtual ~Bookkeeper () override
 Destructor destroys RuleManager memory.
 
void addRuleManager (AnyRuleManager *ruleManager)
 Adds rule manager to this bookkeeper. More...
 
template<class U >
void addRuleManager (RuleManager< T, U > *ruleManager)
 Adds rule manager to this bookkeeper. More...
 
void executeTask (std::shared_ptr< T > data) override
 Executes the bookkeeper on data. More...
 
std::string getName () override
 Gets the name of this bookkeeper and all rule managers it controls. More...
 
virtual std::string getDotLabelName () override
 Gets just the name "Bookkeeper" for the dot label. More...
 
void debug () override
 Provides debug output for the rule manager. More...
 
bool canTerminate (std::shared_ptr< AnyConnector > inputConnector) override
 Virtual function that is called when an ITask is checking if it can be terminated. More...
 
void initialize () override
 Initializes the bookkeeper and all RuleManagers. More...
 
void shutdown ()
 Shuts down this bookkeeper and all of it's RuleManagers. More...
 
Bookkeeper< T > * copy ()
 Creates a shallow copy of this bookkeeper. More...
 
std::string genDot (int flags, std::string idStr)
 Generates the dot notation for the bookkeeper.
 
std::string genDotProducerEdgeToTask (std::map< std::shared_ptr< AnyConnector >, AnyITask *> &inputConnectorDotMap, int dotFlags) override
 
std::string genDotProducerEdgeFromConnector (std::shared_ptr< AnyConnector > connector, int flags)
 
std::list< AnyRuleManagerInOnly< T > * > * getRuleManagers ()
 
- Public Member Functions inherited from htgs::ITask< T, VoidData >
 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...
 
void initialize (size_t pipelineId, size_t numPipeline, TaskManager< T, VoidData > *ownerTask)
 Function that is called when an ITask is being initialized by it's owner thread. More...
 
virtual void executeTaskFinal () override
 
virtual std::string getDotShapeColor () override
 
virtual std::string getDotFillColor () override
 
virtual std::string getDotShape () override
 
virtual std::string getDotCustomProfile () override
 Adds the string text to the profiling of this task in the graphviz dot visualization. More...
 
virtual void printProfile () override
 
virtual size_t getNumGraphsSpawned ()
 Gets the number of graphs spawned by this ITask. More...
 
virtual std::string genDotConsumerEdgeFromConnector (std::shared_ptr< AnyConnector > connector, int flags) override
 
ITask< T, VoidData > * copyITask (bool deep) override
 Copies the ITask (including a copy of all memory edges) More...
 
void addResult (std::shared_ptr< VoidData > result)
 Adds results to the output list to be sent to the next connected ITask in a TaskGraph. More...
 
void addResult (VoidData *result)
 Adds results to the output list to be sent to the next connected ITask in a TaskGraph. More...
 
m_data_t< V > getMemory (std::string name, IMemoryReleaseRule *releaseRule)
 Retrieves memory from a memory edge. More...
 
m_data_t< V > getDynamicMemory (std::string name, IMemoryReleaseRule *releaseRule, size_t numElems)
 Retrieves memory from a memory edge. More...
 
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
 
std::string outTypeName () override final
 
std::string getAddress () override final
 
void setTaskManager (TaskManager< T, VoidData > *ownerTask)
 Sets the owner task manager for this ITask. More...
 
TaskManager< T, VoidData > * getOwnerTaskManager ()
 Gets the owner task manager for this ITask. More...
 
virtual void gatherProfileData (std::map< AnyTaskManager *, TaskManagerProfile * > *taskManagerProfiles)
 Gathers profile data. 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 getConsumerDotIds ()
 
virtual std::string getProducerDotIds ()
 
virtual std::string genCustomDot (ProfileUtils *profileUtils, int colorFlag)
 Virtual function to generate customized dot file. More...
 
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

std::list< AnyRuleManagerInOnly< T > * > * ruleManagers
 The list of ruleManagers (one per consumer)
 
std::string ruleManagerInfo
 A string representation of all rule managers.
 

Detailed Description

template<class T>
class htgs::Bookkeeper< T >

Special task used to manage rules.

The Bookkeeper manages one or more rules, which customizes the flow of data within a task graph. These rules specify a scheduling over input data. When data enters the Bookkeeper, each rule executes on that data synchronously.

To use the bookkeeper, create an IRule and an ITask. The IRule represents the rule that produces data to the ITask. An edge is created with a RuleManager acting as the intermediary between the IRule and the ITask. These RuleManagers are created automatically when adding the bookkeeper using the TaskGraphConf::addRuleEdge function. Each RuleManager represents a different edge to another ITask connected to a Bookkeeper and have one IRule connecting the ITask.

If you wish to share an IRule with multiple Bookkeepers, you must wrap the IRule into a shared_ptr prior to calling the TaskGraphConf::addRuleEdge function.

Example usage:

htgs::Bookkeeper<MatrixData> *bk = new htgs::BookKeeper<MatrixData>();
// ScalMultiplyTask has inputType: MultiMatrixData
ScalMultiplyTask *scalMul = new ScalMultiplyTask();
// Submits data from bk to scalMul using rule MatrixRule. Only submits data if MatrixRule adds results
tGraph->addRuleEdge(bk, scalMul, new MatrixRule());
Template Parameters
Tthe input data type for the Bookkeeper ITask, T must derive from IData.

Member Function Documentation

◆ addRuleManager() [1/2]

template<class T>
void htgs::Bookkeeper< T >::addRuleManager ( AnyRuleManager ruleManager)
inline

Adds rule manager to this bookkeeper.

Parameters
ruleManagerthe rule manager
Note
This function should only be called by the HTGS API - users of the HTGS API should instead use addRuleManager(RuleManager<T, U> *ruleManager)

◆ addRuleManager() [2/2]

template<class T>
template<class U >
void htgs::Bookkeeper< T >::addRuleManager ( RuleManager< T, U > *  ruleManager)
inline

Adds rule manager to this bookkeeper.

Parameters
ruleManagerthe rule manager
Template Parameters
Uthe output type for the rule manager (output edge type)

◆ canTerminate()

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

Virtual function that is called when an ITask is checking if it can be terminated.

Parameters
inputConnectorthe connector responsible for giving data to this Task
Returns
whether the ITask can be terminated or not
Return values
TRUEif the ITask is ready to be terminated
FALSEif the ITask is not ready to be terminated
Note
By default this function checks if the input no longer sending data using inputConnector->isInputTerminated()

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

◆ copy()

template<class T>
Bookkeeper<T>* htgs::Bookkeeper< T >::copy ( )
inlinevirtual

Creates a shallow copy of this bookkeeper.

Returns
a shallow copy (No rule managers) of this bookkeeper
Note
This function should only be called by the HTGS API

Implements htgs::ITask< T, VoidData >.

◆ debug()

template<class T>
void htgs::Bookkeeper< T >::debug ( )
inlineoverridevirtual

Provides debug output for the rule manager.

Note
#define DEBUG_FLAG to enable debugging

Reimplemented from htgs::AnyITask.

◆ executeTask()

template<class T>
void htgs::Bookkeeper< T >::executeTask ( std::shared_ptr< T >  data)
inlineoverridevirtual

Executes the bookkeeper on data.

The bookkeeper forwards the data to each rule manager.

Parameters
datathe data
Note
This function should only be called by the HTGS API

Implements htgs::ITask< T, VoidData >.

◆ getDotLabelName()

template<class T>
virtual std::string htgs::Bookkeeper< T >::getDotLabelName ( )
inlineoverridevirtual

Gets just the name "Bookkeeper" for the dot label.

Returns
the name of the bookkeeper

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

◆ getName()

template<class T>
std::string htgs::Bookkeeper< T >::getName ( )
inlineoverridevirtual

Gets the name of this bookkeeper and all rule managers it controls.

Returns
the name of this bookkeeper

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

◆ initialize()

template<class T>
void htgs::Bookkeeper< T >::initialize ( )
inlineoverridevirtual

Initializes the bookkeeper and all RuleManagers.

Note
This function should only be called by the HTGS API

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

◆ shutdown()

template<class T>
void htgs::Bookkeeper< T >::shutdown ( )
inlinevirtual

Shuts down this bookkeeper and all of it's RuleManagers.

Note
This function should only be called by the HTGS API

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


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