Execution Graph Interface. More...
#include <execution-graph.hpp>
Data Structures | |
struct | Node |
Node structure to hold information about each node in a generic manner. More... | |
Public Types | |
enum | Type { None = 0 , STREAM } |
Enum with the multiple implementations of the IExecutionGraph. More... | |
typedef int | NodeID |
Underlying type for the NodeID. | |
typedef std::function< Status()> | Function |
Underlying type for the auxiliar functions. More... | |
Public Member Functions | |
virtual IExecutionGraph::NodeID | Add (const Function &function, const std::vector< NodeID > dependencies=std::vector< NodeID >(0))=0 |
Adds a function to the execution graph. More... | |
virtual Status | Sync (const NodeID node=-1)=0 |
Synchronises the execution of the graph. More... | |
virtual Status | GetLastError ()=0 |
Get the Last Error found during the execution. More... | |
virtual | ~IExecutionGraph ()=default |
Static Public Member Functions | |
static std::shared_ptr< IExecutionGraph > | Create (const IExecutionGraph::Type type, const std::shared_ptr< ExecutionGraphParameters > params) |
Factory method to create a new implementation. More... | |
Execution Graph Interface.
This interface is used to create execution graphs for asynchronous running. There are several possible implementations, such as execution streams (like the ones from CUDA) or graphs, where you can have nodes that depend on two different tasks.
In the future, we plan to add support for Events. In the mean time, you can synchronise using the Sync(node_id) for synchronising at a certain point of the execution.
All functions and their arguments added to the ExecutionGraph must be accesible all the time that the graph is active. Otherwise, it may lead to catastrophic errors.
All implementations of this abstract interface must safeguard the platform independency and must not have any implementation detail.
typedef std::function<Status()> cynq::IExecutionGraph::Function |
Underlying type for the auxiliar functions.
Auxiliar functions are lambda-like functions that run the code of interest. This requires to all the members to be passed by value to ensure certain integrity. However, all objects must be reachable by all the program, especially if they are pointers.
Enum with the multiple implementations of the IExecutionGraph.
Enumerator | |
---|---|
None | No runtime. It is left for the future |
STREAM | Stream or queue based graph implementation |
|
virtualdefault |
Default destructor
|
pure virtual |
Adds a function to the execution graph.
This adds a new function to the graph for further execution. It is likely to be enqueued last in a queue. You can specify the dependencies it must have, so the data dependencies can be respected.
function | auxiliar function to add for execution. It is a lambda function with all elements passed by value (recommended) and all the variables used must be reachable. |
dependencies | dependency nodes of the graph. It defaults to nothing meaning that it depends on the last element of the queue or the data dependency is already thought by design. |
Implemented in cynq::ExecutionStream.
|
static |
Factory method to create a new implementation.
type | type of implementation given by IExecutionGraph::Type |
params | parameters passed to the implementation's constructor |
|
pure virtual |
Get the Last Error found during the execution.
It returns the last error that happened during the execution.
Implemented in cynq::ExecutionStream.
Synchronises the execution of the graph.
It synchronises the execution of the graph partially or completely. This is a blocking call, meaning that it will wait until the execution is completed. If the node passed by argument already executed, it returns immediately. Otherwise, it will wait until a notification of completion.
node | wait until the node is completed (defaults to: -1), which means that it will block until the entire graph execution is completed. |
Implemented in cynq::ExecutionStream.