Hedgehog
3.1.0
A library to generate hybrid pipeline workflow systems
|
Hedgehog graph abstraction. More...
#include "graph.h"
Public Member Functions | |
Graph (std::string const &name="Graph", std::unique_ptr< Scheduler > scheduler=std::make_unique< DefaultScheduler >()) | |
Default graph constructor, construct a graph with the name "Graph" and with a default scheduler. | |
~Graph () override=default | |
Default graph destructor. | |
template<tool::CompatibleInputNode< typename core::GIM< Separator, AllTypes... >::inputs_t > InputNode_t> | |
void | inputs (std::shared_ptr< InputNode_t > inputNode) |
Set an input node and connect the node to the graph's inputs for all common types. | |
template<class InputDataType , tool::CompatibleInputNodeForAType< InputDataType, typename core::GIM< Separator, AllTypes... >::inputs_t > InputNode_t> | |
void | input (std::shared_ptr< InputNode_t > inputNode) |
Set an input node and connect the node to the graph's input InputDataType. | |
template<tool::CompatibleOutputNode< typename core::GOM< Separator, AllTypes... >::outputs_t > OutputNode_t> | |
void | outputs (std::shared_ptr< OutputNode_t > outputNode) |
Set an output node and connect the node to the graph's outputs for all common types. | |
template<class OutputType , tool::CompatibleOutputNodeForAType< OutputType, typename core::GOM< Separator, AllTypes... >::outputs_t > OutputNode_t> | |
void | output (std::shared_ptr< OutputNode_t > outputNode) |
Set an output node and connect the node to the graph's output OutputDataType. | |
template<tool::SenderNode SenderNode_t, tool::ReceiverNode ReceiverNode_t> | |
void | edges (std::shared_ptr< SenderNode_t > sender, std::shared_ptr< ReceiverNode_t > receiver) |
Create an edge between two nodes for all common types. | |
template<class CommonType , tool::SenderNodeForAType< CommonType > SenderNode_t, tool::ReceiverNodeForAType< CommonType > ReceiverNode_t> | |
void | edge (std::shared_ptr< SenderNode_t > sender, std::shared_ptr< ReceiverNode_t > receiver) |
Create an edge between two nodes for a specific type. | |
void | executeGraph (bool waitForInitialization=false) |
Execute the graph. | |
void | finishPushingData () |
Indicate to the graph that no more input data are pushed to the graph. | |
template<tool::MatchInputTypeConcept< tool::Inputs< Separator, AllTypes... > > CompatibleInputType_t> | |
void | pushData (std::shared_ptr< CompatibleInputType_t > data) |
Push data into the graph. | |
void | waitForTermination () |
Wait for the graph to terminate. | |
auto | getBlockingResult () |
Get result data from the graph. | |
void | createDotFile (std::filesystem::path const &dotFilePath, ColorScheme colorScheme=ColorScheme::NONE, StructureOptions structureOptions=StructureOptions::NONE, DebugOptions debugOption=DebugOptions::NONE, std::unique_ptr< ColorPicker > colorPicker=std::make_unique< JetColor >(), bool verbose=false) |
Create a dot file representing a snapshot of the state of the graph at the moment of the call, the graph is saved into the file dotFilePath. | |
void | deviceId (int deviceId) |
Set the device id (GPU ID) for all the nodes in a graph. | |
void | cleanGraph () |
Clean the graph. | |
![]() | |
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. | |
Private Attributes | |
std::shared_ptr< core::CoreGraph< Separator, AllTypes... > > const | coreGraph_ = nullptr |
Core of the graph. | |
std::unique_ptr< std::set< std::shared_ptr< Node > > > | nodes_ = nullptr |
Set of nodes given by the end user. | |
Hedgehog graph abstraction.
The graph in the Hedgehog library allows the user to create a dataflow. The graph regroups a set of nodes representing parts of the computation. The most important nodes are the tasks (for heavy computation), the state managers (to manage the local state of the computation) and the graph themselves (nested computation).
If a node is set as input of the graph (Graph::input / Graph::inputs), the data sent to the graph are transmitted to the input nodes. The output nodes (set with Graph::output / Graph::outputs) produce the output data of the graph. Between the input and the output nodes, the nodes need to be connected via edges(Graph::edge / Graph::edges).
A graph can be duplicated with ah hh::AbstractExecutionPipeline. Useful for mapping data across multiple devices (such as GPUs).
The difference between the singular and plural method (Graph::input / Graph::inputs, Graph::output / Graph::outputs, Graph::edge / Graph::edges) is/are the type[s] used for the connection: if it is plural the connection is made for all possible types, if it is singular the connection is only made for the user specified type.
The sequence of operations to use a graph are:
Separator | Separator position between input types and output types |
AllTypes | List of input and output types |
|
inlineexplicit |
Default graph constructor, construct a graph with the name "Graph" and with a default scheduler.
name | Name of the graph to construct |
scheduler | Scheduler used by the graph (should inherit from hh::Scheduler) |
std::runtime_error | if the core is not valid, should derives from CoreGraph |
Definition at line 156 of file graph.h.
|
overridedefault |
Default graph destructor.
|
inline |
Create a dot file representing a snapshot of the state of the graph at the moment of the call, the graph is saved into the file dotFilePath.
dotFilePath | Path where the file is stored. |
colorScheme | Color scheme used to color the tasks, either to show difference in execution or in waiting times, or nothing. The chosen color depends on the colorPicker. |
structureOptions | Show how the graph is represented, with or without input queue size, with or without all task groups. |
debugOption | Add debug information on the dot graph. |
colorPicker | Color scheme used to generate the dotfile, JetColor by default. |
verbose | Enable verbose mode: report when dot files are created or overwritten to standard out, default false. |
Definition at line 324 of file graph.h.
|
inline |
Create an edge between two nodes for a specific type.
Validate the sender and receiver node and if valid, create an edge for the CommonType type
SenderNode_t | Type of the sender node |
ReceiverNode_t | Type of the receiver node |
sender | Sender node |
receiver | Receiver node |
|
inline |
Create an edge between two nodes for all common types.
Validate the sender and receiver node and if valid, create an edge for all common types between the sender output types and the receiver input types
SenderNode_t | Type of the sender node |
ReceiverNode_t | Type of the receiver node |
sender | Sender node |
receiver | Receiver node |
|
inline |
Get result data from the graph.
Get result from the graph while blocking the main thread. The results are presented under the form of
If the output type is known in advance one can use
If multiple types are possible the following code can be used:
|
inline |
Set an input node and connect the node to the graph's input InputDataType.
Check if the input node is a valid object, and then connect it to the graph input for the InputDataType type.
InputDataType | Input type used for the connection between the node and the graph |
InputNode_t | Type of the input node |
inputNode | Input node to connect |
|
inline |
Set an input node and connect the node to the graph's inputs for all common types.
Check if the input node is a valid object, and then connect it to the graph for all common types.
InputNode_t | Type of the input node |
inputNode | Input node to connect |
|
inline |
Set an output node and connect the node to the graph's output OutputDataType.
Check if the output node is a valid object, and then connect it to the graph output for the OutputDataType type.
OutputDataType | Output type used for the connection between the node and the graph |
OutputNode_t | Type of the output node |
outputNode | Output node to connect |
|
inline |
Set an output node and connect the node to the graph's outputs for all common types.
Check if the output node is a valid object, and then connect it to the graph output for all common types.
OutputNode_t | Type of the output node |
outputNode | Output node to connect |
|
inline |
|
private |