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

Implements the parent ITask, which removes the template arguments of an ITask. More...

#include <htgs/core/task/AnyITask.hpp>

Inheritance diagram for htgs::AnyITask:
Inheritance graph
Collaboration diagram for htgs::AnyITask:
Collaboration graph

Public Member Functions

 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 AnyITaskcopy ()=0
 Pure virtual function to copy an ITask. More...
 
virtual std::string getName ()=0
 Virtual function to get the name of an ITask. More...
 
virtual std::string getDotLabelName ()=0
 Virtual function to get the label name used for dot graph viz. More...
 
virtual std::string getDotShapeColor ()=0
 Gets the color of the shape for graphviz dot. More...
 
virtual std::string getDotFillColor ()=0
 Gets the color for filling the shape for graphviz dot. More...
 
virtual std::string getDotShape ()=0
 Gets the shape for graphviz dot. More...
 
virtual std::string getDotCustomProfile ()=0
 Virtual function that can be used to add custom output for dot visualizations. More...
 
virtual void shutdown ()=0
 Virtual function that is called when an ITask is being shutdown by it's owner thread. More...
 
virtual void initialize ()=0
 Virtual function that is called when an ITask is being initialized by it's owner thread.
 
virtual void executeTaskFinal ()=0
 Virtual function that is called just before the task has shutdown. More...
 
virtual bool canTerminate (std::shared_ptr< AnyConnector > inputConnector)=0
 Virtual function that is called when an ITask is checking if it can be terminated. More...
 
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 genDotProducerEdgeToTask (std::map< std::shared_ptr< AnyConnector >, AnyITask *> &inputConnectorDotMap, int dotFlags)=0
 
virtual std::string genDotConsumerEdgeFromConnector (std::shared_ptr< AnyConnector > connector, int flags)=0
 
virtual std::string genDotProducerEdgeFromConnector (std::shared_ptr< AnyConnector > connector, int flags)=0
 
virtual std::string genDot (int flags, std::string dotId)
 Virtual function that adds additional dot attributes to this node. More...
 
virtual std::string genCustomDot (ProfileUtils *profileUtils, int colorFlag)
 Virtual function to generate customized dot file. 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...
 
virtual std::string inTypeName ()=0
 Gets the demangled input type name of the connector. More...
 
virtual std::string outTypeName ()=0
 Gets the demangled output type name of the connector. More...
 
virtual std::string getAddress ()=0
 Gets the address from the owner task, which is the address of the task graph. More...
 
virtual AnyITaskcopyITask (bool deep)=0
 Copies the ITask including its list of memGetters and memReleasers. More...
 
virtual void printProfile ()=0
 Prints the profile data to std::out.
 
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

size_t numThreads
 The number of threads to be used with this ITask (forms a thread pool) used when creating a TaskManager.
 
bool startTask
 Whether the ITask will be a start task used when creating a TaskManager.
 
bool poll
 Whether the ITask should poll for data used when creating a TaskManager.
 
size_t microTimeoutTime
 The timeout time for polling in microseconds used when creating a TaskManager.
 
size_t pipelineId
 The execution pipeline id for the ITask.
 
size_t numPipelines
 The number of pipelines that exist for this task.
 
std::shared_ptr< ConnectorMapmemoryEdges
 A mapping from memory edge name to memory manager connector for getting memory.
 
std::shared_ptr< ConnectorMapreleaseMemoryEdges
 A mapping from the memory edge name to the memory manager's input connector to shutdown the memory manager.
 
unsigned long long int memoryWaitTime
 The amount of time this task waited for memory.
 

Detailed Description

Implements the parent ITask, which removes the template arguments of an ITask.

Used anywhere the template arguments for an ITask are not needed.

Constructor & Destructor Documentation

◆ AnyITask() [1/2]

htgs::AnyITask::AnyITask ( size_t  numThreads)
inline

Constructs an ITask with a specified number of threads.

Parameters
numThreadsthe number of threads associated with this ITask

◆ AnyITask() [2/2]

htgs::AnyITask::AnyITask ( size_t  numThreads,
bool  isStartTask,
bool  poll,
size_t  microTimeoutTime 
)
inline

Constructs an ITask with a specified number of threads as well as additional scheduling options.

Parameters
numThreadsthe number of threads associated with this ITask
isStartTaskwhether this ITask starts executing immediately and passes nullptr to executeTask()
pollwhether this task will poll for data, if the timeout period expires, nullptr is passed to executeTask()
microTimeoutTimethe timeout period for checking for data
Note
If the ITask is declared as a start task or is polling, then executeTask() should properly handle nullptr data

Member Function Documentation

◆ attachMemoryEdge()

void htgs::AnyITask::attachMemoryEdge ( std::string  name,
std::shared_ptr< AnyConnector getMemoryConnector,
std::shared_ptr< AnyConnector releaseMemoryConnector,
MMType  type 
)
inline

Attaches a memory edge to this ITask to get memory.

Parameters
namethe name of the memory edge
getMemoryConnectorthe connector for getting memory for the MemoryManager
releaseMemoryConnectorthe connector for releasing memory for the MemoryManager
typethe memory manager type
Note
This function should only be called by the HTGS API, use TaskGraph::addMemoryManagerEdge instead.

◆ canTerminate()

virtual bool htgs::AnyITask::canTerminate ( std::shared_ptr< AnyConnector inputConnector)
pure virtual

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()

Implemented in htgs::ITask< T, U >, htgs::ITask< U, W >, htgs::ITask< T, VoidData >, htgs::ITask< MemoryData< T >, MemoryData< T > >, htgs::TGTask< T, U >, and htgs::Bookkeeper< T >.

◆ copy()

◆ copyITask()

virtual AnyITask* htgs::AnyITask::copyITask ( bool  deep)
pure virtual

Copies the ITask including its list of memGetters and memReleasers.

Returns
a deep copy of the ITask
Note
This function should only be called by the HTGS API

Implemented in htgs::ITask< T, U >, htgs::ITask< U, W >, htgs::ITask< T, VoidData >, and htgs::ITask< MemoryData< T >, MemoryData< T > >.

◆ copyMemoryEdges()

void htgs::AnyITask::copyMemoryEdges ( AnyITask iTaskCopy)
inline

Copies the memory edges from this AnyITask to another AnyITask.

Parameters
iTaskCopythe other AnyITask to copy the memory edges too

◆ debugDotNode()

virtual std::string htgs::AnyITask::debugDotNode ( )
inlinevirtual

Provides debug output for a node in the dot graph.

Returns
a string representation of the debug output that is added to the dot graph.

◆ executeTaskFinal()

virtual void htgs::AnyITask::executeTaskFinal ( )
pure virtual

Virtual function that is called just before the task has shutdown.

This is the last call for executeTask. This is only called by the very last thread that is bound for this task.

Example: If you have multiple threads bound to a task, then this function is only called once for the last thread

Implemented in htgs::ITask< T, U >, htgs::ITask< U, W >, htgs::ITask< T, VoidData >, and htgs::ITask< MemoryData< T >, MemoryData< T > >.

◆ genCustomDot()

virtual std::string htgs::AnyITask::genCustomDot ( ProfileUtils profileUtils,
int  colorFlag 
)
inlinevirtual

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 in htgs::ExecutionPipeline< T, U >, and htgs::TGTask< T, U >.

◆ genDot() [1/3]

virtual std::string htgs::AnyITask::genDot ( int  flags,
std::string  dotId,
std::shared_ptr< htgs::AnyConnector input,
std::shared_ptr< htgs::AnyConnector output 
)
inlinevirtual

Virtual function that generates the input/output and per-task dot notation.

Parameters
flagsthe DOTGEN flags
dotIdthe id for this task
inputthe input connector for this task
outputthe output connector for this task
Returns
the dot that represents the interaction between the input/output and the internal custom dot notation

◆ genDot() [2/3]

virtual std::string htgs::AnyITask::genDot ( int  flags,
std::string  dotId 
)
inlinevirtual

Virtual function that adds additional dot attributes to this node.

Parameters
flagsthe dot gen flags
dotIdthe for the node in dot
Returns
the additiona dota attributes for the dot graph representation

Reimplemented in htgs::Bookkeeper< T >.

◆ genDot() [3/3]

std::string htgs::AnyITask::genDot ( int  flags,
std::shared_ptr< AnyConnector input,
std::shared_ptr< AnyConnector output 
)
inline

Creates a dot notation representation for this task.

Parameters
flagsthe DOTGEN flags
inputthe input connector for this task
outputthe output connector for this task
Returns
the dot notation for the task.

◆ getAddress()

virtual std::string htgs::AnyITask::getAddress ( )
pure virtual

Gets the address from the owner task, which is the address of the task graph.

Returns
the address

Implemented in htgs::ITask< T, U >, htgs::ITask< U, W >, htgs::ITask< T, VoidData >, and htgs::ITask< MemoryData< T >, MemoryData< T > >.

◆ getDotCustomProfile()

virtual std::string htgs::AnyITask::getDotCustomProfile ( )
pure virtual

Virtual function that can be used to add custom output for dot visualizations.

Returns
the values for dot visualization added to the label for the task's dot node, use '
' to create newlines to add additional profile data

Implemented in htgs::ITask< T, U >, htgs::ITask< U, W >, htgs::ITask< T, VoidData >, and htgs::ITask< MemoryData< T >, MemoryData< T > >.

◆ getDotFillColor()

virtual std::string htgs::AnyITask::getDotFillColor ( )
pure virtual

Gets the color for filling the shape for graphviz dot.

Returns
the fill color

Implemented in htgs::ITask< T, U >, htgs::ITask< U, W >, htgs::ITask< T, VoidData >, htgs::ITask< MemoryData< T >, MemoryData< T > >, htgs::MemoryManager< T >, and htgs::ICudaTask< T, U >.

◆ getDotId()

std::string htgs::AnyITask::getDotId ( )
inline

Gets the id used for dot nodes.

Returns
the unique dot id (uses the memory address of this AnyITask)

◆ getDotLabelName()

virtual std::string htgs::AnyITask::getDotLabelName ( )
pure virtual

Virtual function to get the label name used for dot graph viz.

Returns
the label name used for graphviz

Implemented in htgs::ITask< T, U >, htgs::ITask< U, W >, htgs::ITask< T, VoidData >, htgs::ITask< MemoryData< T >, MemoryData< T > >, and htgs::Bookkeeper< T >.

◆ getDotShape()

virtual std::string htgs::AnyITask::getDotShape ( )
pure virtual

Gets the shape for graphviz dot.

Returns
the shape

Implemented in htgs::ITask< T, U >, htgs::ITask< U, W >, htgs::ITask< T, VoidData >, and htgs::ITask< MemoryData< T >, MemoryData< T > >.

◆ getDotShapeColor()

virtual std::string htgs::AnyITask::getDotShapeColor ( )
pure virtual

Gets the color of the shape for graphviz dot.

Returns
the shape color

Implemented in htgs::ITask< T, U >, htgs::ITask< U, W >, htgs::ITask< T, VoidData >, and htgs::ITask< MemoryData< T >, MemoryData< T > >.

◆ getMemoryEdges()

const std::shared_ptr<ConnectorMap>& htgs::AnyITask::getMemoryEdges ( ) const
inline

Gets the memory edges for the task.

Returns
the memory edges

◆ getMemoryWaitTime()

unsigned long long int htgs::AnyITask::getMemoryWaitTime ( ) const
inline

Gets the amount of time the task was waiting for memory.

Returns
the amount of time the task waited for memory

◆ getMicroTimeoutTime()

size_t htgs::AnyITask::getMicroTimeoutTime ( ) const
inline

Gets the timeout time for polling.

Returns
the timeout time

◆ getName()

◆ getNameWithPipelineId()

std::string htgs::AnyITask::getNameWithPipelineId ( )
inline

Gets the name of the ITask with it's pipeline ID.

Returns
the name of the task with the pipeline ID

◆ getNumPipelines()

size_t htgs::AnyITask::getNumPipelines ( ) const
inline

Sets the task graph communicator.

Parameters
communicatorGets the task graph communicator
Returns
the task graph communicator Gets the number of pipelines for the task's execution pipeline
the number of pipelines

◆ getNumThreads()

size_t htgs::AnyITask::getNumThreads ( ) const
inline

Gets the number of threads associated with this ITask.

Returns
the number of threads

◆ getPipelineId()

size_t htgs::AnyITask::getPipelineId ( )
inline

Gets the pipeline ID.

Returns
the pipeline id

◆ getReleaseMemoryEdges()

const std::shared_ptr<ConnectorMap>& htgs::AnyITask::getReleaseMemoryEdges ( ) const
inline

Gets the memory edges for releasing memory for the memory manager, used to shutdown the memory manager.

Returns
the mapping between the memory edge name and the memory release connectors

◆ hasMemoryEdge()

bool htgs::AnyITask::hasMemoryEdge ( std::string  name)
inline

Checks whether this ITask contains a memory edge for a specified name.

Parameters
namethe name of the memGetter edge
Returns
whether this ITask has a memGetter with the specified name
Return values
TRUEif the ITask has a memGetter with the specified name
FALSEif the ITask does not have a memGetter with the specified name
Note
To add a memGetter to this ITask use TaskGraph::addMemoryManagerEdge

◆ incMemoryWaitTime()

void htgs::AnyITask::incMemoryWaitTime ( unsigned long long int  val)
inline

Increments memory wait time.

Parameters
valthe amount of time passed waiting for memory

◆ initialize()

void htgs::AnyITask::initialize ( size_t  pipelineId,
size_t  numPipeline 
)
inline

Virtual function that is called when an ITask is being initialized by it's owner thread.

Parameters
pipelineIdthe pipelineId, only used if the ITask is inside of an ExecutionPipeline
numPipelinethe number of pipelines, only used if the ITask is inside of an ExecutionPipeline

◆ inTypeName()

virtual std::string htgs::AnyITask::inTypeName ( )
pure virtual

Gets the demangled input type name of the connector.

Returns
the demangled type name for the input

Implemented in htgs::ITask< T, U >, htgs::ITask< U, W >, htgs::ITask< T, VoidData >, and htgs::ITask< MemoryData< T >, MemoryData< T > >.

◆ isPoll()

bool htgs::AnyITask::isPoll ( ) const
inline

Gets whether this ITask is polling for data or not.

Returns
whether the ITask is polling
Return values
TRUEif the task is polling for data, it will wait until the timeout period expires.
FALSEif the task is not polling for data

◆ isStartTask()

bool htgs::AnyITask::isStartTask ( ) const
inline

Gets whether this ITask is a starting task.

Returns
whether the ITask is a starting task
Return values
TRUEif the task will begin execution immediately when it is bound to a thread
FALSEif the task must wait for data before it can begin exection

◆ outTypeName()

virtual std::string htgs::AnyITask::outTypeName ( )
pure virtual

Gets the demangled output type name of the connector.

Returns
the demangled output type name for the input

Implemented in htgs::ITask< T, U >, htgs::ITask< U, W >, htgs::ITask< T, VoidData >, and htgs::ITask< MemoryData< T >, MemoryData< T > >.

◆ profile()

virtual void htgs::AnyITask::profile ( )
inlinevirtual

Virtual function that is called to provide profile output for the ITask.

Note
#define PROFILE to enable profiling

◆ profileITask()

void htgs::AnyITask::profileITask ( )
inline

Provides profile output for the ITask,.

Note
this function should only be called by the HTGS API

◆ profileStr()

virtual std::string htgs::AnyITask::profileStr ( )
inlinevirtual

Virtual function that is called after executionTask is called.

This can be used to provide detailed profile (or debug) data to be sent for visualization using the HTGS_Visualizer. The format uses <key>:<value> pairs, separated by semi-colons.

i.e.: gflops:<#>;bandwidth:<#>;...

Returns
the string representation as key value pairs

◆ setNumPipelines()

void htgs::AnyITask::setNumPipelines ( size_t  numPipelines)
inline

Sets the number of pipelines that this ITask belongs too.

Parameters
numPipelinesthe number of pipelines
Note
This function should only be used by the HTGS API

◆ setPipelineId()

void htgs::AnyITask::setPipelineId ( size_t  pipelineId)
inline

Sets the pipeline Id for this ITask.

Parameters
pipelineIdthe pipelineId
Note
This function should only be used by the HTGS API

◆ shutdown()

virtual void htgs::AnyITask::shutdown ( )
pure virtual

Virtual function that is called when an ITask is being shutdown by it's owner thread.

This is done once per thread for the task. The output connectors/edges are still active, so it is okay to call ITask::addResult from within this function safely. This is useful for flushing any final remaining data from the thread to the next task.

Note
If you want to do a parallel reduction such that only the last thread produces data, then override the AnyITask::executeTaskFinal function.

Implemented in htgs::ICudaTask< T, U >, htgs::ExecutionPipeline< T, U >, htgs::ITask< T, U >, htgs::ITask< U, W >, htgs::ITask< T, VoidData >, htgs::ITask< MemoryData< T >, MemoryData< T > >, htgs::Bookkeeper< T >, htgs::TGTask< T, U >, and htgs::MemoryManager< T >.


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