|
|
| Graph () |
| | Default graph constructor, the default name is "Graph".
|
| |
| | Graph (std::string_view const &name) |
| | Graph constructor with a custom name. More...
|
| |
| | Graph (std::string_view const &name, std::unique_ptr< AbstractScheduler > scheduler) |
| | Graph constructor with a custom name and a custom scheduler. More...
|
| |
|
virtual | ~Graph ()=default |
| | Default Graph destructor.
|
| |
| std::shared_ptr< core::CoreNode > | core () final |
| | Graph core accessor. More...
|
| |
| std::string_view const & | name () |
| | Graph name accessor. More...
|
| |
| void | deviceId (int deviceId) |
| | Device Id for the graph, all inside nodes will be bound to this device Id. More...
|
| |
| template<class UserDefinedMultiReceiver , class InputsMR = typename UserDefinedMultiReceiver::inputs_t, class InputsG = typename behavior::MultiReceivers<GraphInputs...>::inputs_t, class isMultiReceiver = typename std::enable_if_t< std::is_base_of_v<typename helper::HelperMultiReceiversType<InputsMR>::type, UserDefinedMultiReceiver> >, class isInputCompatible = typename std::enable_if_t<traits::is_included_v<InputsMR, InputsG>>> |
| void | input (std::shared_ptr< UserDefinedMultiReceiver > input) |
| | Set a node as input for the graph. More...
|
| |
| template<class UserDefinedSender , class IsSender = typename std::enable_if_t< std::is_base_of_v< behavior::Sender<GraphOutput>, UserDefinedSender > >> |
| void | output (std::shared_ptr< UserDefinedSender > output) |
| | Set a node as output for the graph. More...
|
| |
| template<class UserDefinedSender , class UserDefinedMultiReceiver , class Output = typename UserDefinedSender::output_t, class Inputs = typename UserDefinedMultiReceiver::inputs_t, class IsSender = typename std::enable_if_t<std::is_base_of_v<behavior::Sender<Output>, UserDefinedSender>>, class IsMultiReceivers = typename std::enable_if_t< std::is_base_of_v< typename helper::HelperMultiReceiversType<Inputs>::type, UserDefinedMultiReceiver > >> |
| void | addEdge (std::shared_ptr< UserDefinedSender > from, std::shared_ptr< UserDefinedMultiReceiver > to) |
| | Add a directed edge from a compatible "from" node to "to" node. More...
|
| |
| void | executeGraph () |
| | Launch the graph once it has been structured. More...
|
| |
| template<class Input , class = typename std::enable_if_t<traits::Contains<Input, GraphInputs...>::value>> |
| void | pushData (std::shared_ptr< Input > data) |
| | Push data into the graph. More...
|
| |
|
void | finishPushingData () |
| | Signal the graph that no more data will be pushed into the graph.
|
| |
| std::shared_ptr< GraphOutput > | getBlockingResult () |
| | Get a data out of the graph. More...
|
| |
|
void | waitForTermination () |
| | Wait for the graph to terminate (data to be processed, all threads to join)
|
| |
| void | createDotFile (std::filesystem::path const &dotFilePath, ColorScheme colorScheme=ColorScheme::NONE, StructureOptions structureOptions=StructureOptions::NONE, DebugOptions debugOption=DebugOptions::NONE) |
| | 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. More...
|
| |
| 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...
|
| |
template<class GraphOutput, class ... GraphInputs>
class hh::Graph< GraphOutput, GraphInputs >
Main Hedgehog object that does computation.
Hedgehog represents an algorithm with a dataflow graph.
Data in the graph represents any primitive type, struct, class, etc., that is used to pass to operations.
Data is sent to the graph through the method Graph::pushData, while broadcasts to all input nodes. A node is an input node if:
- The node is registered as graph's input with Graph::input,
- The node can receive data,
- At least one of the node's input types matches to a graph's input type. Data of this common type received by the graph will be transferred to this node.
Directed edges can be added between two nodes "from" to "to" with Graph::addEdge, if:
- The from's output type is one of to's input type,
- from is a node that can send data,
- to is a node that can receive data.
Data is received from the Graph with Graph::getBlockingResult, from output nodes. A node is an output node if:
- The node is registered as a graph's output with Graph::output (there can be any number of nodes registered as output),
- The node can send data,
- The node's output type matches a graph's output type.
Data is sent to the graph with Graph::pushData, which will be directed to the input tasks. Each input task will be executed with their Execute::execute method.
The graph needs to be signaled to terminate with Graph::finishPushingData, when all data has been pushed.
While results are available Graph::getBlockingResult will return a shared_ptr with a value. The call is blocking, so the thread handling the graph will wait to get the result. The final value from Graph::getBlockingResult is nullptr, which is an indicator that the graph has terminated.
Before deletion, Graph::waitForTermination needs to be called to wait for inside threads to terminate.
Also, a graph visualization is available through the call to Graph::createDotFile.
For computation with an accelerator a graph can be bound to a device with Graph::deviceId, in this case all inside nodes will be bound to this device. If the computation is distributed through multiple accelerators, the graph can be copied for each accelerator, and set to a specific device with an AbstractExecutionPipeline.
A graph can be embedded into another graph as a node. To help sharing a specialized graph, the specialized graph can derive from Graph and be used as-is. Once linked into another graph, the inner graph cannot be manipulated (modified, such as adding edges).
- Template Parameters
-
| GraphOutput | Graph Output Type |
| GraphInputs | Graph Input types |
Definition at line 85 of file graph.h.