CYNQ  0.3.0
Framework to develop FPGA applications in C++ with the easiness of PYNQ
cynq::IExecutionGraph Class Referenceabstract

Execution Graph Interface. More...

#include <execution-graph.hpp>

Inheritance diagram for cynq::IExecutionGraph:

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< IExecutionGraphCreate (const IExecutionGraph::Type type, const std::shared_ptr< ExecutionGraphParameters > params)
 Factory method to create a new implementation. More...
 

Detailed Description

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.

Member Typedef Documentation

◆ Function

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.

Member Enumeration Documentation

◆ Type

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

Constructor & Destructor Documentation

◆ ~IExecutionGraph()

virtual cynq::IExecutionGraph::~IExecutionGraph ( )
virtualdefault

Default destructor

Member Function Documentation

◆ Add()

virtual IExecutionGraph::NodeID cynq::IExecutionGraph::Add ( const Function function,
const std::vector< NodeID dependencies = std::vector< NodeID >(0) 
)
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.

Parameters
functionauxiliar 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.
dependenciesdependency 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.
Returns
NodeID id of the newly added node. If the NodeID is -1, it means that the function could not be added. One possible reason is that the node of interest never existed. If the dependencies are already executed, the node will be enqueue as a dangling node or enqueued last.

Implemented in cynq::ExecutionStream.

◆ Create()

std::shared_ptr< IExecutionGraph > cynq::IExecutionGraph::Create ( const IExecutionGraph::Type  type,
const std::shared_ptr< ExecutionGraphParameters params 
)
static

Factory method to create a new implementation.

Parameters
typetype of implementation given by IExecutionGraph::Type
paramsparameters passed to the implementation's constructor
Returns
std::shared_ptr<IExecutionGraph> new IExecutionGraph implementation
Examples
structures/execution-stream.cpp.

◆ GetLastError()

virtual Status cynq::IExecutionGraph::GetLastError ( )
pure virtual

Get the Last Error found during the execution.

It returns the last error that happened during the execution.

Returns
Status status object with the error

Implemented in cynq::ExecutionStream.

◆ Sync()

virtual Status cynq::IExecutionGraph::Sync ( const NodeID  node = -1)
pure virtual

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.

Parameters
nodewait until the node is completed (defaults to: -1), which means that it will block until the entire graph execution is completed.
Returns
Status

Implemented in cynq::ExecutionStream.


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