CYNQ  0.3.0
Framework to develop FPGA applications in C++ with the easiness of PYNQ
execution-graph.hpp
1 /*
2  * See LICENSE for more information about licensing
3  *
4  * Copyright 2024
5  * Author: Luis G. Leon-Vega <luis.leon@ieee.org>
6  *
7  */
8 #pragma once
9 #include <condition_variable> // NOLINT
10 #include <cynq/enums.hpp>
11 #include <cynq/status.hpp>
12 #include <functional>
13 #include <memory>
14 #include <mutex> // NOLINT
15 #include <string>
16 #include <vector>
17 
18 namespace cynq {
25  std::string name;
28  uint64_t timeout = 100;
30  virtual ~ExecutionGraphParameters() = default;
31 };
32 
53  public:
57  typedef int NodeID;
58 
67  typedef std::function<Status()> Function;
68 
72  enum Type {
74  None = 0,
76  STREAM
77  };
78 
98  const Function &function,
99  const std::vector<NodeID> dependencies = std::vector<NodeID>(0)) = 0;
100 
113  virtual Status Sync(const NodeID node = -1) = 0;
114 
122  virtual Status GetLastError() = 0;
123 
127  virtual ~IExecutionGraph() = default;
128 
136  static std::shared_ptr<IExecutionGraph> Create(
137  const IExecutionGraph::Type type,
138  const std::shared_ptr<ExecutionGraphParameters> params);
139 
144  struct Node {
148  Function function;
150  std::vector<NodeID> dependencies = {};
152  std::vector<Node *> parents = {};
154  std::vector<Node *> children = {};
155  };
156 };
157 } // namespace cynq
Execution Graph Interface.
Definition: execution-graph.hpp:52
virtual IExecutionGraph::NodeID Add(const Function &function, const std::vector< NodeID > dependencies=std::vector< NodeID >(0))=0
Adds a function to the execution graph.
std::function< Status()> Function
Underlying type for the auxiliar functions.
Definition: execution-graph.hpp:67
Type
Enum with the multiple implementations of the IExecutionGraph.
Definition: execution-graph.hpp:72
@ STREAM
Definition: execution-graph.hpp:76
@ None
Definition: execution-graph.hpp:74
static std::shared_ptr< IExecutionGraph > Create(const IExecutionGraph::Type type, const std::shared_ptr< ExecutionGraphParameters > params)
Factory method to create a new implementation.
Definition: execution-graph.cpp:13
virtual Status Sync(const NodeID node=-1)=0
Synchronises the execution of the graph.
virtual Status GetLastError()=0
Get the Last Error found during the execution.
int NodeID
Underlying type for the NodeID.
Definition: execution-graph.hpp:57
virtual ~IExecutionGraph()=default
Define an abstract representation of the IExecutionGraph parameters with some prefilled fields.
Definition: execution-graph.hpp:23
virtual ~ExecutionGraphParameters()=default
uint64_t timeout
Definition: execution-graph.hpp:28
std::string name
Definition: execution-graph.hpp:25
Node structure to hold information about each node in a generic manner.
Definition: execution-graph.hpp:144
NodeID id
Definition: execution-graph.hpp:146
std::vector< Node * > children
Definition: execution-graph.hpp:154
std::vector< NodeID > dependencies
Definition: execution-graph.hpp:150
std::vector< Node * > parents
Definition: execution-graph.hpp:152
Structure to define the return characteristics of each function.
Definition: status.hpp:19