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

The parent class for a Task that removes the template arguments. More...

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

Inheritance diagram for htgs::AnyTaskManager:
Inheritance graph
Collaboration diagram for htgs::AnyTaskManager:
Collaboration graph

Public Member Functions

 AnyTaskManager (size_t numThreads, bool isStartTask, size_t pipelineId, size_t numPipelines, std::string address)
 Constructs an AnyTaskManager with an ITask as the task function and specific runtime parameters. More...
 
 AnyTaskManager (size_t numThreads, bool isStartTask, bool poll, size_t microTimeoutTime, size_t pipelineId, size_t numPipelines, std::string address)
 Constructs an AnyTaskManager with an ITask as the task function and specific runtime parameters. More...
 
virtual ~AnyTaskManager ()
 Destructor.
 
virtual AnyITaskgetTaskFunction ()=0
 Gets the ITask function associated with the TaskManager. More...
 
virtual std::shared_ptr< AnyConnectorgetInputConnector ()=0
 Gets the input Connector. More...
 
virtual std::shared_ptr< AnyConnectorgetOutputConnector ()=0
 Gets the output Connector. More...
 
virtual AnyTaskManagercopy (bool deep)=0
 Copies the TaskManager. More...
 
virtual void initialize ()=0
 Initializes the TaskManager.
 
virtual void executeTask ()=0
 Executes the TaskManager. More...
 
virtual void setRuntimeThread (TaskManagerThread *runtimeThread)=0
 Sets the thread that is executing this TaskManager. More...
 
virtual void setInputConnector (std::shared_ptr< AnyConnector > connector)=0
 Sets the input BaseConnector. More...
 
virtual void setOutputConnector (std::shared_ptr< AnyConnector > connector)=0
 Sets the output BaseConnector. More...
 
virtual void terminateConnections ()=0
 Terminates all Connector edges. More...
 
virtual void gatherProfileData (std::map< AnyTaskManager *, TaskManagerProfile *> *taskManagerProfiles)=0
 Gathers profiling data for the TaskProfiler. More...
 
virtual size_t getThreadsRemaining ()=0
 Gets the number of threads that are still running for the task. More...
 
void printProfile ()
 Prints the profiling data to std::cout.
 
void updateAddressAndPipelines (std::string address, size_t pipelineId, size_t numPipelines)
 Sets the task graph communicator. More...
 
std::string getAddress ()
 Gets the address of the task manager. More...
 
void setNumPipelines (size_t numPipelines)
 Sets the number of pipelines associated with the TaskManager. More...
 
size_t getNumPipelines ()
 Gets the number of pipelines that this task manager belongs too. More...
 
void setPipelineId (size_t id)
 Sets the pipeline Id associated with the TaskManager. More...
 
size_t getPipelineId ()
 Gets the pipeline identifer for this task from 0 to number of pipelines - 1. More...
 
size_t getNumThreads () const
 Gets the number of threads associated with this TaskManager. More...
 
void setAlive (bool val)
 Sets the alive state for this task manager. More...
 
bool isAlive ()
 Gets whether the TaskManager is alive or not. More...
 
void setInitialized (bool val)
 Sets the initialized state for the task manager. More...
 
bool isInitialized ()
 Gets whether the TaskManager has initialized or not. More...
 
void setStartTask (bool val)
 Sets whether this task manager is a start task or not, which will immediately begin executing by sending nullptr data to the underlying task as soon as this task executes. More...
 
bool isStartTask ()
 Gets whether this task manager will begin executing immediately with nullptr data or not. More...
 
bool isPoll ()
 Gets whether the task manager is polling for data or not. More...
 
size_t getTimeout ()
 Gets the timeout period in microseconds for the task when the task is polling for data. More...
 
void incTaskComputeTime (int64_t val)
 Increments the compute time profile value. More...
 
void incWaitTime (int64_t val)
 Increments the wait time profile value. More...
 
void shutdown ()
 Shuts down the TaskManager.
 
std::string getName ()
 Gets the name of the ITask. More...
 
void debug ()
 Provides debug output. More...
 
std::string getNameWithPipelineId ()
 Gets the name of the ITask with it's pipeline ID. More...
 
std::string getDot (int flags)
 Gets the dot notation for this TaskManager.
 
void setThreadId (size_t id)
 Sets the thread id associated with the TaskManager. More...
 
size_t getThreadId ()
 Gets the thread id associated with the TaskManager. More...
 
unsigned long long int getComputeTime ()
 Gets the compute time for the task manager, removing the memory wait time. More...
 
unsigned long long int getExecuteTime ()
 Gets the total execution time for the task manager, including any waiting for memory within the execute function. More...
 
unsigned long long int getWaitTime ()
 Gets the wait time for the task manager. More...
 
size_t getMaxQueueSize ()
 Gets the maximum size the input queue became during execution. More...
 
void resetProfile ()
 Resets the profile data for this task.
 
unsigned long long int getTaskComputeTime ()
 Gets the task's compute time. More...
 

Private Attributes

unsigned long long int taskComputeTime
 The total compute time for the task.
 
unsigned long long int taskWaitTime
 The total wait time for the task.
 
size_t timeout
 The timeout time for polling in microseconds.
 
bool poll
 Whether the manager should poll for data.
 
bool startTask
 Whether the task should start immediately.
 
bool alive
 Whether the task is still alive.
 
bool initialized
 Whether the task has been intitialized or not (called initialize function)
 
size_t threadId
 The thread id for the task (set after initialization)
 
size_t numThreads
 The number of threads spawned for the manager.
 
size_t pipelineId
 The execution pipeline id.
 
size_t numPipelines
 The number of execution pipelines.
 
std::string address
 The address of the task graph this manager belongs too.
 

Detailed Description

The parent class for a Task that removes the template arguments.

The AnyTaskManager provides access to functionality that does not require template arguments and allows storage of a Task.

Note
This class should only be called by the HTGS API

Constructor & Destructor Documentation

◆ AnyTaskManager() [1/2]

htgs::AnyTaskManager::AnyTaskManager ( size_t  numThreads,
bool  isStartTask,
size_t  pipelineId,
size_t  numPipelines,
std::string  address 
)
inline

Constructs an AnyTaskManager with an ITask as the task function and specific runtime parameters.

Parameters
numThreadsthe number of threads to operate with the TaskManager
isStartTaskwhether the TaskManager is a start task or not (immediately launches the ITask::execute when bound to a thread)
pipelineIdthe pipeline Id associated with the TaskManager
numPipelinesthe number of pipelines
addressthe address of the task graph that owns this task

◆ AnyTaskManager() [2/2]

htgs::AnyTaskManager::AnyTaskManager ( size_t  numThreads,
bool  isStartTask,
bool  poll,
size_t  microTimeoutTime,
size_t  pipelineId,
size_t  numPipelines,
std::string  address 
)
inline

Constructs an AnyTaskManager with an ITask as the task function and specific runtime parameters.

Parameters
numThreadsthe number of threads to operate with the TaskManager
isStartTaskwhether the TaskManager is a start task or not (immediately launches the ITask::execute when bound to a thread)
pollwhether the TaskManager should poll for data
microTimeoutTimethe timeout time in microseconds
pipelineIdthe pipeline Id associated with the TaskManager
numPipelinesthe number of pipelines
addressthe address of the task graph that owns this task

Member Function Documentation

◆ copy()

virtual AnyTaskManager* htgs::AnyTaskManager::copy ( bool  deep)
pure virtual

Copies the TaskManager.

Parameters
deepwhether a deep copy is required
Returns
the TaskManager copy

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

◆ debug()

void htgs::AnyTaskManager::debug ( )
inline

Provides debug output.

Note
#define DEBUG_FLAG to enable debugging.

◆ executeTask()

virtual void htgs::AnyTaskManager::executeTask ( )
pure virtual

Executes the TaskManager.

Using the following procedure: 0. If the ITask is a start task, then send ITask::executeTask with nullptr and set that it is no longer a startTask

  1. Checks if the ITask::isTerminated, if it is then reduce thread pool count for the runtime and wakeup any tasks waiting on this TaskManager's input queue. If the thread pool count is zero, then indicate that this task is no longer producing data and wakup all consumers waiting on the output connector. Also indicate this task is no longer releasing memory and wakeup all memory managers that this task is releasing memory to.
  2. Get input from input Connector. (optional polls for data, if timeout period expires, then will recheck if the ITask is terminated and try to get input again)
  3. If the data is not nullptr, then sends the data to the ITask::executeTask function.
Note
#define PROFILE to enable profiling.

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

◆ gatherProfileData()

virtual void htgs::AnyTaskManager::gatherProfileData ( std::map< AnyTaskManager *, TaskManagerProfile *> *  taskManagerProfiles)
pure virtual

Gathers profiling data for the TaskProfiler.

Parameters
taskManagerProfilesthe mapping of the task manager to its TaskManagerProfile

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

◆ getAddress()

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

Gets the address of the task manager.

Can also be thought of as the address for the task graph that this task belongs too.

Returns
the address

◆ getComputeTime()

unsigned long long int htgs::AnyTaskManager::getComputeTime ( )
inline

Gets the compute time for the task manager, removing the memory wait time.

Use getExecuteTime() to get the entire runtime of the task, including wait time.

Returns
the compute time
Note
Must define the directive PROFILE to enable profiling

◆ getExecuteTime()

unsigned long long int htgs::AnyTaskManager::getExecuteTime ( )
inline

Gets the total execution time for the task manager, including any waiting for memory within the execute function.

Returns
the total time spent in the execute function.

◆ getInputConnector()

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

◆ getMaxQueueSize()

size_t htgs::AnyTaskManager::getMaxQueueSize ( )
inline

Gets the maximum size the input queue became during execution.

Returns
the maximum input queue size
Note
Must define the directive PROFILE to enable profiling

◆ getName()

std::string htgs::AnyTaskManager::getName ( )
inline

Gets the name of the ITask.

Returns
the name of the ITask

◆ getNameWithPipelineId()

std::string htgs::AnyTaskManager::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::AnyTaskManager::getNumPipelines ( )
inline

Gets the number of pipelines that this task manager belongs too.

Returns
the number of pipelines spawned from the execution pipeline task

◆ getNumThreads()

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

Gets the number of threads associated with this TaskManager.

Returns
the number of the threads that will execute the TaskManager

◆ getOutputConnector()

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

◆ getPipelineId()

size_t htgs::AnyTaskManager::getPipelineId ( )
inline

Gets the pipeline identifer for this task from 0 to number of pipelines - 1.

Returns
the pipeline identifier

◆ getTaskComputeTime()

unsigned long long int htgs::AnyTaskManager::getTaskComputeTime ( )
inline

Gets the task's compute time.

Returns
the compute time in microseconds.

◆ getTaskFunction()

virtual AnyITask* htgs::AnyTaskManager::getTaskFunction ( )
pure virtual

◆ getThreadId()

size_t htgs::AnyTaskManager::getThreadId ( )
inline

Gets the thread id associated with the TaskManager.

Returns
the thread id

◆ getThreadsRemaining()

virtual size_t htgs::AnyTaskManager::getThreadsRemaining ( )
pure virtual

Gets the number of threads that are still running for the task.

Returns
the number of threads remaining

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

◆ getTimeout()

size_t htgs::AnyTaskManager::getTimeout ( )
inline

Gets the timeout period in microseconds for the task when the task is polling for data.

Returns
the timeout time in microseconds for polling

◆ getWaitTime()

unsigned long long int htgs::AnyTaskManager::getWaitTime ( )
inline

Gets the wait time for the task manager.

Returns
the wait time
Note
Must define the directive PROFILE to enable profiling

◆ incTaskComputeTime()

void htgs::AnyTaskManager::incTaskComputeTime ( int64_t  val)
inline

Increments the compute time profile value.

Parameters
valthe value to increment by

◆ incWaitTime()

void htgs::AnyTaskManager::incWaitTime ( int64_t  val)
inline

Increments the wait time profile value.

Parameters
valthe value to increment by

◆ isAlive()

bool htgs::AnyTaskManager::isAlive ( )
inline

Gets whether the TaskManager is alive or not.

Returns
whether the TaskManager is alive
Return values
TRUEif the TaskManager is alive
FALSEif the TaskManager is not alive

◆ isInitialized()

bool htgs::AnyTaskManager::isInitialized ( )
inline

Gets whether the TaskManager has initialized or not.

Returns
whether the TaskManager is initialized
Return values
TRUEif the TaskManager has finished initializing
FALSEif the TaskManager has not been initialized

◆ isPoll()

bool htgs::AnyTaskManager::isPoll ( )
inline

Gets whether the task manager is polling for data or not.

Returns
whether the task manager is polling or not
Return values
TRUEif the task manager is polling for data from its input
FALSEif the task manager is not polling (waiting) for data from its input

◆ isStartTask()

bool htgs::AnyTaskManager::isStartTask ( )
inline

Gets whether this task manager will begin executing immediately with nullptr data or not.

Returns
whether the task manager will start immediately.
Return values
TRUEif the task manager will begin executing immediately
FALSEif the task manager will not begin and wait for its first input data

◆ setAlive()

void htgs::AnyTaskManager::setAlive ( bool  val)
inline

Sets the alive state for this task manager.

Parameters
valthe value to set, true = alive, false = dead/terminating

◆ setInitialized()

void htgs::AnyTaskManager::setInitialized ( bool  val)
inline

Sets the initialized state for the task manager.

Parameters
valthe value to set, true = initialize has been called an thread is bound to the task waiting for data, false = thread is not ready

◆ setInputConnector()

virtual void htgs::AnyTaskManager::setInputConnector ( std::shared_ptr< AnyConnector connector)
pure virtual

Sets the input BaseConnector.

Parameters
connectorthe input connector

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

◆ setNumPipelines()

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

Sets the number of pipelines associated with the TaskManager.

Parameters
numPipelinesthe number of pipelines

◆ setOutputConnector()

virtual void htgs::AnyTaskManager::setOutputConnector ( std::shared_ptr< AnyConnector connector)
pure virtual

Sets the output BaseConnector.

Parameters
connectorthe output connector

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

◆ setPipelineId()

void htgs::AnyTaskManager::setPipelineId ( size_t  id)
inline

Sets the pipeline Id associated with the TaskManager.

Parameters
idthe pipeline Id

◆ setRuntimeThread()

virtual void htgs::AnyTaskManager::setRuntimeThread ( TaskManagerThread runtimeThread)
pure virtual

Sets the thread that is executing this TaskManager.

Parameters
runtimeThreadthe thread that is executing the TaskManager

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

◆ setStartTask()

void htgs::AnyTaskManager::setStartTask ( bool  val)
inline

Sets whether this task manager is a start task or not, which will immediately begin executing by sending nullptr data to the underlying task as soon as this task executes.

Parameters
valthe value to set, true = is a start task, false = not a start task
Note
Should be set before a task begins executing (attached to a thread)

◆ setThreadId()

void htgs::AnyTaskManager::setThreadId ( size_t  id)
inline

Sets the thread id associated with the TaskManager.

Parameters
idthe thread id

◆ terminateConnections()

virtual void htgs::AnyTaskManager::terminateConnections ( )
pure virtual

Terminates all Connector edges.

This is called after all threads have shutdown.

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

◆ updateAddressAndPipelines()

void htgs::AnyTaskManager::updateAddressAndPipelines ( std::string  address,
size_t  pipelineId,
size_t  numPipelines 
)
inline

Sets the task graph communicator.

Parameters
communicatorthe task graph communicator Sends data packet along task graph communicator
packetthe data packet to communicate Updates the address, pipelineID, and number of pipelines for the task manager.
addressthe address (or task graph address) of this task manager
pipelineIdthe ID for which execution pipeline this task belongs
numPipelinesthe number of pipelines that exist for the execution pipeline

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