|
| TaskGraphConf () |
| Constructs a TaskGraph.
|
|
| TaskGraphConf (size_t pipelineId, size_t numPipelines, std::string baseAddress) |
| Constructs a TaskGraph. More...
|
|
| ~TaskGraphConf () override |
| Destructor, handles releasing all ITask memory that is managed by the TaskGraph.
|
|
AnyTaskGraphConf * | copy () override |
| Creates an exact copy of this task graph. More...
|
|
TaskGraphConf< T, U > * | copy (size_t pipelineId, size_t numPipelines) |
| Creates a mirror copy of the TaskGraph with the specified pipelineId and number of pipelines. More...
|
|
TaskGraphConf< T, U > * | copy (size_t pipelineId, size_t numPipelines, std::shared_ptr< Connector< T >> input, std::shared_ptr< Connector< U >> output, std::string baseAddress) |
| Creates a mirror copy of the TaskGraph with the specified pipelineId and number of pipelines, and updates the input and output connectors for the graph copy. More...
|
|
template<class V , class W , class X > |
void | addEdge (ITask< V, W > *producer, ITask< W, X > *consumer) |
| Adds an edge to the graph, where one task produces data for a consumer task. More...
|
|
template<class V , class IRuleType , class W , class X > |
void | addRuleEdge (Bookkeeper< V > *bookkeeper, std::shared_ptr< IRuleType > rule, ITask< W, X > *consumer) |
| Creates a rule edge that is managed by a bookkeeper. More...
|
|
template<class V , class W , class X > |
void | addRuleEdge (Bookkeeper< V > *bookkeeper, IRule< V, W > *iRule, ITask< W, X > *consumer) |
| Creates a rule edge that is managed by a bookkeeper. More...
|
|
template<class V , class IMemoryAllocatorType > |
void | addCudaMemoryManagerEdge (std::string name, AnyITask *getMemoryTask, std::shared_ptr< IMemoryAllocatorType > allocator, size_t memoryPoolSize, MMType type, int *gpuIds) |
| Adds a CudaMemoryManager edge with the specified name to the TaskGraphConf. More...
|
|
template<class V > |
void | addCudaMemoryManagerEdge (std::string name, AnyITask *getMemoryTask, IMemoryAllocator< V > *allocator, size_t memoryPoolSize, MMType type, int *gpuIds) |
| Adds a CudaMemoryManager edge with the specified name to the TaskGraphConf. More...
|
|
template<class V > |
void | addRuleEdgeAsGraphProducer (Bookkeeper< V > *bookkeeper, IRule< V, U > *iRule) |
|
template<class V > |
void | addCustomMemoryManagerEdge (AnyITask *getMemoryTask, MemoryManager< V > *memoryManager) |
| Adds a custom MemoryManager with the specified name to the TaskGraphConf. More...
|
|
template<class V , class IMemoryAllocatorType > |
void | addMemoryManagerEdge (std::string name, AnyITask *getMemoryTask, std::shared_ptr< IMemoryAllocatorType > allocator, size_t memoryPoolSize, MMType type) |
| Adds a MemoryManager edge with the specified name to the TaskGraphConf. More...
|
|
template<class V > |
void | addMemoryManagerEdge (std::string name, AnyITask *getMemoryTask, IMemoryAllocator< V > *allocator, size_t memoryPoolSize, MMType type) |
| Adds a MemoryManager edge with the specified name to the TaskGraphConf. More...
|
|
std::shared_ptr< AnyConnector > | getInputConnector () override |
| Pure virtual function that gets the task manager that is consuming data from the graph's input. More...
|
|
std::shared_ptr< AnyConnector > | getOutputConnector () override |
| Virtual function that gets the connector used for graph output. More...
|
|
void | updateTaskManagersAddressingAndPipelines () |
| Updates the task managers addresses, pipelineIds and the number of pipelines for all tasks in the TaskGraph. More...
|
|
void | incrementGraphProducer () |
| Sets the input connector for the task graph. More...
|
|
void | finishedProducingData () |
| Decrements the input connector and wakes up any consumer of the graph's input if the input connector is finished producing data. More...
|
|
template<class W > |
void | setGraphConsumerTask (ITask< T, W > *task) |
| Sets the task that is consuming data from the input of the graph. More...
|
|
template<class W > |
void | addGraphProducerTask (ITask< W, U > *task) |
| Sets the task that is producing data for the output of the graph. More...
|
|
void | produceData (T *data) |
| Produces data for the input of the TaskGraph. More...
|
|
void | produceData (std::shared_ptr< T > data) |
| Produces data for the input of the TaskGraph. More...
|
|
void | produceData (std::list< std::shared_ptr< T >> *dataList) |
| Adds a list of data into the TaskGraph Must specify the TaskGraph input using addGraphInputConsumer() and use incrementGraphInputProducer() to indicate an input stream is feeding data to the TaskGraph. More...
|
|
std::shared_ptr< U > | consumeData () |
| Consumes data from the output of a TaskGraph. More...
|
|
std::shared_ptr< U > | pollData (size_t microTimeout) |
| Polls for data from the output of the TaskGraph. More...
|
|
bool | isOutputTerminated () |
| Checks if the output of the TaskGraph has finished producing data. More...
|
|
void | setOutputConnector (std::shared_ptr< AnyConnector > connector) |
| Sets the output connector for the task graph configuration. More...
|
|
void | setInputConnector (std::shared_ptr< AnyConnector > connector) |
| Sets the input connector for the task graph configuration. More...
|
|
template<class V > |
void | releaseMemory (m_data_t< V > memory) |
| Releases memory back to its memory manager. More...
|
|
std::string | genCustomDotForTasks (ProfileUtils *profileUtils, int colorFlag) |
| Generates the custom dot profiles for all tasks in this graph. More...
|
|
std::string | genDotGraphEdgesWithoutConnectors (std::map< AnyTaskManager *, TaskManagerProfile *> *allTaskManagerProfiles, int flags) |
| Generates the edges between tasks without connectors. More...
|
|
std::string | genDotGraph (int flags, int colorFlag, std::string graphTitle="", std::string customTitleText="") override |
| Generates the dot graph as a string.
|
|
void | debug () |
| Provides debug output for the TaskGraphConf. More...
|
|
ExecutionPipeline< T, U > * | createExecutionPipeline (size_t numPipelines, std::string name="Execution Pipeline", bool waitForInit=true) |
| Wraps this task graph into an execution pipeline task, which will then be used to duplicate and execute across multiple GPUs. More...
|
|
TGTask< T, U > * | createTaskGraphTask (std::string name="TGTask", bool waitForInit=true) |
| Wraps this task graph into a TGTask. More...
|
|
GraphEdge< T > * | getGraphConsumerEdge () const |
|
std::list< GraphEdge< U > * > * | getGraphProducerEdges () const |
|
| AnyTaskGraphConf (size_t pipelineId, size_t numPipelines, std::string baseAddress) |
| Constructs the AnyTaskGraphConf. More...
|
|
virtual | ~AnyTaskGraphConf () |
| Destructor.
|
|
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...
|
|
TaskNameConnectorMap * | getTaskConnectorNameMap () 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...
|
|
AnyITask * | getCopy (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...
|
|
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)
|
|
void | copyTasks (std::list< AnyTaskManager *> *tasks) |
| Creates a copy of each task from the list of AnyTaskManagers passed as a parameter. More...
|
|
AnyTaskManager * | getTaskManagerCopy (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...
|
|
template<class T, class U>
class htgs::TaskGraphConf< T, U >
Manages a group of connected ITasks and their connections.
Each ITask that is added into the TaskGraphConf is stored in the TaskGraphConf's metadata to allow for quick copying using copy().
The main methods for adding each ITask into the graph are addEdge(), addRuleEdge(), addMemoryManagerEdge(), addCudaMemoryManagerEdge(), setGraphConsumerTask(), and addGraphProducerTask()
When using these methods, the TaskGraphConf builds a TaskManager, which manages an ITask. Parameters for customizing the thread pool, polling abilities, etc., are specified in the ITask constructors: ITask::ITask()
Special memory edge functions are provided. For normal CPU memory edges use: addMemoryManagerEdge()
For Cuda memory use: addCudaMemoryManagerEdge()
Every TaskGraphConf has an input and output type (T and U). If a TaskGraph does not have an input or output type, then the data type can be specified as VoidData. There can be only one task consuming data from the graph. If multiple tasks need to process data from the input, then add a bookkeeper as the first task and rules to distribute data. There can be any number of tasks producing output data for the graph.
To add data into the input of a TaskGraph use the produceData() function. Once finished producing data for the graph, use the finishedProducingData() function to indicate a data input stream is is closing. If additional data streams are added as input for the graph, then use the incrementGraphProducer() function. By default a task graph starts with one producer for the graph for the main thread, if there are no producers (such as the first task in the graph begins processing immediately), then call finishedProducingData().
To process the output of a TaskGraph use the consumeData() function. To determine if data is no longer being produced by a TaskGraph use the isOutputTerminated() function. The output of the consumeData function could produce nullptr data when the graph is closing.
Example Usage:
int numLoadThreads = 2;
int numMulThreads = 20;
LoadMatrixTask *loadMatrixTask = new LoadMatrixTask(numLoadThreads, blockSize, width, height);
ScalarMultiplyTask *scalMulTask = new ScalarMultiplyTask(numMulThreads, blockSize, width, height);
MatrixLoadRule *loadRule = new MatrixLoadRule(width/blockSize, height/blockSize);
taskGraph->
addEdge(loadMatrixTask, bkTask);
MatrixAllocator *matrixAlloc = new MatrixAllocator(blockSize, blockSize);
int poolSize = 50;
for (blockRow = 0; blockRow < blockHeight; blockRow++)
{
for(blockCol = 0; blockCol < blockWidth; blockCol++)
{
taskGraph->
produceData(
new MatrixBlockRequest(blockRow, blockCol,
"MatrixA"));
taskGraph->
produceData(
new MatrixBlockRequest(blockRow, blockCol,
"MatrixB"));
}
}
{
std::shared_ptr<MatrixBlockRequest> mbr = taskGraph->
consumeData();
if (mbr != nullptr)
{
}
}
- Template Parameters
-
T | the input data type for the TaskGraph, T must derive from IData. |
U | the output data type for the TaskGraph, U must derive from IData. |