Hedgehog  0.0.0
A library to generate hybrid pipeline workflow systems
hh::AbstractExecutionPipeline< GraphOutput, GraphInputs > Class Template Reference

Node interface made for duplicating a graph, for example in the case of multi-GPU computation. More...

#include "abstract_execution_pipeline.h"

Inheritance diagram for hh::AbstractExecutionPipeline< GraphOutput, GraphInputs >:
Inheritance graph
Collaboration diagram for hh::AbstractExecutionPipeline< GraphOutput, GraphInputs >:
Collaboration graph

Public Member Functions

 AbstractExecutionPipeline ()=delete
 Deleted default constructor, an execution pipeline need to be constructed with a compatible graph.
 
 AbstractExecutionPipeline (std::shared_ptr< Graph< GraphOutput, GraphInputs... >> graph, size_t const &numberGraphDuplications, bool iota=false)
 Constructor to set an execution pipeline with a graph and the total number of graphs. More...
 
 AbstractExecutionPipeline (std::shared_ptr< Graph< GraphOutput, GraphInputs... >> graph, size_t const &numberGraphDuplications, std::vector< int > const deviceIds, bool automaticStart=false)
 Constructor to set an execution pipeline with a graph, the total number of graphs, the device Ids, and set the execution to automatically start. More...
 
 AbstractExecutionPipeline (std::string_view const &name, std::shared_ptr< Graph< GraphOutput, GraphInputs... >> const &graph, size_t const &numberGraphDuplications, std::vector< int > const &deviceIds, bool automaticStart=false)
 Constructor to set an execution pipeline with a graph, the total number of graphs, the device Ids and set the execution to automatically start. More...
 
virtual ~AbstractExecutionPipeline ()=default
 Default destructor.
 
std::shared_ptr< core::CoreNodecore () override
 Execution Pipeline accessor core. More...
 
std::shared_ptr< Graph< GraphOutput, GraphInputs... > > const & graph () const
 Inner graph accessor. More...
 
- Public Member Functions inherited from hh::behavior::Node
virtual std::string extraPrintingInformation () const
 Adds node information to print in the dot file. More...
 
virtual bool canTerminate ()
 Determine if the node can terminate. More...
 
- Public Member Functions inherited from hh::behavior::SwitchRule< GraphInputs >
virtual bool sendToGraph (std::shared_ptr< GraphInputs > &data, size_t const &graphId)=0
 Switch rule to determine if data should be sent to the graph graphId managed by an AbstractExecutionPipeline. More...
 

Private Attributes

std::shared_ptr< Graph< GraphOutput, GraphInputs... > > graph_ = nullptr
 Original Graph that will be duplicated.
 
std::shared_ptr< core::CoreDefaultExecutionPipeline< GraphOutput, GraphInputs... > > coreExecutionPipeline_ = nullptr
 Execution Pipeline core.
 

Additional Inherited Members

- Public Types inherited from hh::behavior::MultiReceivers< GraphInputs... >
using inputs_t = std::tuple< Inputs... >
 Tuple with the list of input types.
 
- Public Types inherited from hh::behavior::Sender< GraphOutput >
using output_t = GraphOutput
 Output Type.
 

Detailed Description

template<class GraphOutput, class ... GraphInputs>
class hh::AbstractExecutionPipeline< GraphOutput, GraphInputs >

Node interface made for duplicating a graph, for example in the case of multi-GPU computation.

The duplicated graph will run concurrently, and their inside nodes is also duplicated. Each graph will be distinguished thanks to a device ID (deviceId), from 0, the original to n the number of duplications minus one.

Also, it is used as tool to enable multi-GPU computation, each graph will be bounded to a specific device id accessible from the graph's inside nodes.

Attention
The template parameters GraphOutput and GraphInputs have to exactly match to the managed graph.
There is no default constructor, because a graph is mandatory.

The code below is from Hedgehog tutorial 5.

template<class MatrixType>
class MultiGPUExecPipeline : public AbstractExecutionPipeline<
MatrixBlockData<MatrixType, 'p', Order::Column>,
MatrixBlockData<MatrixType, 'a', Order::Column>,
MatrixBlockData<MatrixType, 'b', Order::Column>> {
private:
size_t
numberGraphDuplication_ = 0;
public:
MultiGPUExecPipeline(std::shared_ptr<
Graph<MatrixBlockData<MatrixType, 'p', Order::Column>,
MatrixBlockData<MatrixType, 'a', Order::Column>,
MatrixBlockData<MatrixType, 'b', Order::Column>>> const &graph,
size_t const &numberGraphDuplications,
std::vector<int> const &deviceIds) : AbstractExecutionPipeline<
MatrixBlockData<MatrixType, 'p', Order::Column>,
MatrixBlockData<MatrixType, 'a', Order::Column>,
MatrixBlockData<MatrixType, 'b', Order::Column>>("Cuda Execution Pipeline", graph, numberGraphDuplications,
deviceIds), numberGraphDuplication_(numberGraphDuplications) {}
virtual ~MultiGPUExecPipeline() = default;
[[maybe_unused]]std::shared_ptr<MatrixBlockData<MatrixType, 'a', Order::Column>> &data,
[[maybe_unused]]size_t const &graphId) override {
return data->colIdx() % numberGraphDuplication_ == graphId;
}
[[maybe_unused]]std::shared_ptr<MatrixBlockData<MatrixType, 'b', Order::Column>> &data,
[[maybe_unused]]size_t const &graphId) override {
return data->rowIdx() % numberGraphDuplication_ == graphId;
}
};
// Main
// GPU Graph
auto cudaMatrixMultiplication = std::make_shared<CUDAComputationGraph<MatrixType>>(n, m, p, blockSize,
numberThreadProduct);
// Execution Pipeline
auto executionPipeline =
std::make_shared<MultiGPUExecPipeline<MatrixType>>(cudaMatrixMultiplication, deviceIds.size(), deviceIds);

A data send to a specialized AbstractExecutionPipeline, before reaching a graph will first go through SwitchRule::sendToGraph that will send it to the graph's copy or not.

Virtual functions
SwitchRule::sendToGraph for each input data type
Template Parameters
GraphOutputGraph output data type
GraphInputsGraph inputs data type

Definition at line 97 of file abstract_execution_pipeline.h.

Constructor & Destructor Documentation

◆ AbstractExecutionPipeline() [1/3]

template<class GraphOutput, class ... GraphInputs>
hh::AbstractExecutionPipeline< GraphOutput, GraphInputs >::AbstractExecutionPipeline ( std::shared_ptr< Graph< GraphOutput, GraphInputs... >>  graph,
size_t const &  numberGraphDuplications,
bool  iota = false 
)
inline

Constructor to set an execution pipeline with a graph and the total number of graphs.

If iota is set to true, the device ids are initialized from 0 to numberGraphDuplications - 1, if iota is set to false, the device Ids are all set to 0.

Parameters
graphInside Base Graph
numberGraphDuplicationsTotal number of graphs inside the execution pipeline (numberGraphDuplications - 1 duplications)
iotaIf true the device Id are set from 0 to numberGraphDuplications - 1 (using std::iota), else all device Ids are set to 0.

Definition at line 123 of file abstract_execution_pipeline.h.

◆ AbstractExecutionPipeline() [2/3]

template<class GraphOutput, class ... GraphInputs>
hh::AbstractExecutionPipeline< GraphOutput, GraphInputs >::AbstractExecutionPipeline ( std::shared_ptr< Graph< GraphOutput, GraphInputs... >>  graph,
size_t const &  numberGraphDuplications,
std::vector< int > const  deviceIds,
bool  automaticStart = false 
)
inline

Constructor to set an execution pipeline with a graph, the total number of graphs, the device Ids, and set the execution to automatically start.

Parameters
graphInside Base Graph
numberGraphDuplicationsTotal number of graphs inside the execution pipeline (numberGraphDuplications - 1 duplications)
deviceIdsVector of Ids, corresponding to device Ids for each inside graphs
automaticStartIf True, the execution pipeline will be automatically started by sending nullptr to the SwitchRule::sendToGraph, else not

Definition at line 143 of file abstract_execution_pipeline.h.

◆ AbstractExecutionPipeline() [3/3]

template<class GraphOutput, class ... GraphInputs>
hh::AbstractExecutionPipeline< GraphOutput, GraphInputs >::AbstractExecutionPipeline ( std::string_view const &  name,
std::shared_ptr< Graph< GraphOutput, GraphInputs... >> const &  graph,
size_t const &  numberGraphDuplications,
std::vector< int > const &  deviceIds,
bool  automaticStart = false 
)
inline

Constructor to set an execution pipeline with a graph, the total number of graphs, the device Ids and set the execution to automatically start.

Parameters
nameExecution pipeline's name
graphInside Base Graph
numberGraphDuplicationsTotal number of graphs inside the execution pipeline (numberGraphDuplications - 1 duplications)
deviceIdsVector of Ids, corresponding to device Ids for each inside graphs
automaticStartIf True, the execution pipeline will be automatically started by sending nullptr to the SwitchRule::sendToGraph, else not

Definition at line 163 of file abstract_execution_pipeline.h.

Member Function Documentation

◆ core()

template<class GraphOutput, class ... GraphInputs>
std::shared_ptr<core::CoreNode> hh::AbstractExecutionPipeline< GraphOutput, GraphInputs >::core ( )
inlineoverridevirtual

Execution Pipeline accessor core.

Returns
Execution Pipeline's core

Implements hh::behavior::Node.

Definition at line 183 of file abstract_execution_pipeline.h.

◆ graph()

template<class GraphOutput, class ... GraphInputs>
std::shared_ptr<Graph<GraphOutput, GraphInputs...> > const& hh::AbstractExecutionPipeline< GraphOutput, GraphInputs >::graph ( ) const
inline

Inner graph accessor.

Returns
Inner graph

Definition at line 187 of file abstract_execution_pipeline.h.

Here is the caller graph for this function:

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