Hedgehog  3.1.0
A library to generate hybrid pipeline workflow systems
Loading...
Searching...
No Matches
hh::AbstractExecutionPipeline< Separator, AllTypes > Class Template Reference

Execution pipeline abstraction. More...

#include "abstract_execution_pipeline.h"

Inheritance diagram for hh::AbstractExecutionPipeline< Separator, AllTypes >:
Inheritance graph
Collaboration diagram for hh::AbstractExecutionPipeline< Separator, AllTypes >:
Collaboration graph

Public Member Functions

 AbstractExecutionPipeline (std::shared_ptr< Graph< Separator, AllTypes... > > const graph, size_t const &numberGraphs, std::string const name="Execution pipeline")
 Create an execution pipeline that duplicates a graph, numberGraphs - 1 times. The graph id and the device id associated to each graph are generated in sequence. The given name is "Execution pipeline" by default.
 
 AbstractExecutionPipeline (std::shared_ptr< Graph< Separator, AllTypes... > > const graph, std::vector< int > const &deviceIds, std::string const name="Execution pipeline")
 Create an execution pipeline from a graph and the given device ids. If there are n device ids given, the graph will be duplicated n-1 times (for a total of n graphs), and each device ids will be associated to each graph. The given name is "Execution pipeline" by default.
 
 ~AbstractExecutionPipeline () override=default
 Default destructor.
 
- Public Member Functions inherited from hh::behavior::Node
 Node (std::shared_ptr< hh::core::abstraction::NodeAbstraction > core)
 Constructor's node.
 
virtual ~Node ()=default
 Default destructor.
 
std::shared_ptr< hh::core::abstraction::NodeAbstraction > const & core () const
 Core accessor.
 
std::string name () const
 Node's name accessor.
 
- Public Member Functions inherited from hh::behavior::Copyable< AbstractExecutionPipeline< Separator, AllTypes... > >
 Copyable (size_t const numberThreads)
 Copyable constructor, set the number of threads for a node.
 
virtual ~Copyable ()=default
 Default destructor.
 
size_t numberThreads () const
 Number of threads accessor.
 
std::vector< AbstractExecutionPipeline< Separator, AllTypes... > const * > group () const
 Get the group of nodes that hold the current nodes.
 
virtual std::shared_ptr< AbstractExecutionPipeline< Separator, AllTypes... > > copy ()
 Copy method called to either create a group of node or duplicate a node when an execution pipeline is created.
 

Private Member Functions

std::shared_ptr< Graph< Separator, AllTypes... > > const & graph () const
 Accessor top the base graph.
 
void graph (std::shared_ptr< Graph< Separator, AllTypes... > > graph)
 Base graph setter.
 

Private Attributes

std::shared_ptr< Graph< Separator, AllTypes... > > graph_ = nullptr
 Original Graph that will be duplicated.
 
std::shared_ptr< core::CoreExecutionPipeline< Separator, AllTypes... > > const coreExecutionPipeline_ = nullptr
 Execution Pipeline core.
 

Detailed Description

template<size_t Separator, class ... AllTypes>
class hh::AbstractExecutionPipeline< Separator, AllTypes >

Execution pipeline abstraction.

Duplicate a graph with the same input and output types and associate each of the duplicates to a specified device id (GPU). If none is provided, the devices are generated in sequence (for 3 duplicates, 4 graphs total, the device ids are 0,1,2,3). When implementing, the switch rules need to be provided. They are used to redirect an input data sent to the execution pipeline to a specific graph. Each of the graphs inside an execution pipeline has an id (generated in sequence) used to discriminate the graphs in the switch rules. If the Execution pipeline is duplicated (because it is part of a graph which is also in another execution pipeline), the copy method needs to be implemented.

// Implementation of an execution pipeline that accepts int, float and double data and produces int, float and double data.
class IntFloatDoubleExecutionPipeline
: public hh::AbstractExecutionPipeline<3, int, float, double, int, float, double> {
public:
IntFloatDoubleExecutionPipeline(std::shared_ptr<hh::Graph<3, int, float, double, int, float, double>> const &graph,
size_t const &numberGraphs)
: hh::AbstractExecutionPipeline<3, int, float, double, int, float, double>(graph, numberGraphs) {}
~IntFloatDoubleExecutionPipeline() override = default;
bool sendToGraph(std::shared_ptr<int> &data, size_t const &graphId) override {
// Return true of false if the int data needs to be sent to the graph of id graphId
}
bool sendToGraph(std::shared_ptr<float> &data, size_t const &graphId) override {
// Return true of false if the float data needs to be sent to the graph of id graphId
}
bool sendToGraph(std::shared_ptr<double> &data, size_t const &graphId) override {
// Return true of false if the double data needs to be sent to the graph of id graphId
}
};
// Instantiate a graph and the execution pipeline
auto insideGraph = std::make_shared<hh::Graph<3, int, float, double, int, float, double>>();
auto innerInputInt = std::make_shared<IntFloatDoubleTask>();
auto innerTaskFloat = std::make_shared<IntFloatDoubleTask>();
auto innerOutput = std::make_shared<IntFloatDoubleTask>();
auto innerSM = std::make_shared<hh::StateManager<1, int, int>>(std::make_shared<IntState>());
auto innerGraph = std::make_shared<IntFloatDoubleGraph>();
// Create a graph
insideGraph->input<int>(innerInputInt);
insideGraph->input<float>(innerTaskFloat);
insideGraph->inputs(innerSM);
insideGraph->inputs(innerGraph);
insideGraph->edges(innerInputInt, innerOutput);
insideGraph->edges(innerSM, innerOutput);
insideGraph->edges(innerTaskFloat, innerOutput);
insideGraph->outputs(innerOutput);
insideGraph->outputs(innerGraph);
auto ep = std::make_shared<IntFloatDoubleExecutionPipeline>(insideGraph, 5);
Hedgehog main namespace.
Execution pipeline abstraction.
Hedgehog graph abstraction.
Definition: graph.h:137
Attention
The duplicated graph needs to be totally created before set to an execution pipeline, it won't be modifiable thereafter.
Template Parameters
SeparatorSeparator position between input types and output types
AllTypesList of input and output types

Definition at line 89 of file abstract_execution_pipeline.h.

Constructor & Destructor Documentation

◆ AbstractExecutionPipeline() [1/2]

template<size_t Separator, class ... AllTypes>
hh::AbstractExecutionPipeline< Separator, AllTypes >::AbstractExecutionPipeline ( std::shared_ptr< Graph< Separator, AllTypes... > > const  graph,
size_t const &  numberGraphs,
std::string const  name = "Execution pipeline" 
)
inline

Create an execution pipeline that duplicates a graph, numberGraphs - 1 times. The graph id and the device id associated to each graph are generated in sequence. The given name is "Execution pipeline" by default.

Parameters
graphGraph to duplicate
numberGraphsNumber of graph in total in the execution pipeline
nameName of the execution pipeline

Definition at line 111 of file abstract_execution_pipeline.h.

Here is the call graph for this function:

◆ AbstractExecutionPipeline() [2/2]

template<size_t Separator, class ... AllTypes>
hh::AbstractExecutionPipeline< Separator, AllTypes >::AbstractExecutionPipeline ( std::shared_ptr< Graph< Separator, AllTypes... > > const  graph,
std::vector< int > const &  deviceIds,
std::string const  name = "Execution pipeline" 
)
inline

Create an execution pipeline from a graph and the given device ids. If there are n device ids given, the graph will be duplicated n-1 times (for a total of n graphs), and each device ids will be associated to each graph. The given name is "Execution pipeline" by default.

Parameters
graphGraph to duplicate
deviceIdsVector of device ids associated to the graphs in the execution pipeline
nameName of the execution pipeline

Definition at line 132 of file abstract_execution_pipeline.h.

Here is the call graph for this function:

◆ ~AbstractExecutionPipeline()

template<size_t Separator, class ... AllTypes>
hh::AbstractExecutionPipeline< Separator, AllTypes >::~AbstractExecutionPipeline ( )
overridedefault

Default destructor.

Member Function Documentation

◆ graph() [1/2]

template<size_t Separator, class ... AllTypes>
std::shared_ptr< Graph< Separator, AllTypes... > > const & hh::AbstractExecutionPipeline< Separator, AllTypes >::graph ( ) const
inlineprivate

Accessor top the base graph.

Returns
The base Graph

Definition at line 150 of file abstract_execution_pipeline.h.

Here is the caller graph for this function:

◆ graph() [2/2]

template<size_t Separator, class ... AllTypes>
void hh::AbstractExecutionPipeline< Separator, AllTypes >::graph ( std::shared_ptr< Graph< Separator, AllTypes... > >  graph)
inlineprivate

Base graph setter.

Parameters
graphGraph to set

Definition at line 156 of file abstract_execution_pipeline.h.

Here is the call graph for this function:

Member Data Documentation

◆ coreExecutionPipeline_

template<size_t Separator, class ... AllTypes>
std::shared_ptr<core::CoreExecutionPipeline<Separator, AllTypes...> > const hh::AbstractExecutionPipeline< Separator, AllTypes >::coreExecutionPipeline_ = nullptr
private

Execution Pipeline core.

Definition at line 104 of file abstract_execution_pipeline.h.

◆ graph_

template<size_t Separator, class ... AllTypes>
std::shared_ptr<Graph<Separator, AllTypes...> > hh::AbstractExecutionPipeline< Separator, AllTypes >::graph_ = nullptr
private

Original Graph that will be duplicated.

Definition at line 101 of file abstract_execution_pipeline.h.