21#ifndef HEDGEHOG_GRAPH_NODE_ABSTRACTION_H 
   22#define HEDGEHOG_GRAPH_NODE_ABSTRACTION_H 
   33namespace abstraction {
 
   41  std::chrono::time_point<std::chrono::system_clock> 
const 
   43  std::chrono::nanoseconds
 
   50  std::unique_ptr<std::map<NodeAbstraction *, std::vector<NodeAbstraction *>>> 
const 
   79  [[nodiscard]] std::chrono::time_point<std::chrono::system_clock> 
const &
graphStartCreation()
 const {
 
  111    std::pair<std::chrono::nanoseconds, std::chrono::nanoseconds> minMaxExecDuration = {
 
  112        std::chrono::nanoseconds::max(), std::chrono::nanoseconds::min()
 
  118      node = insideNode.first;
 
  126          minMaxExecDuration.first = std::min(minMaxExecDuration.first, graphMinMax.first);
 
  127          minMaxExecDuration.second = std::max(minMaxExecDuration.second, graphMinMax.second);
 
  130          auto epMinMax = nodeAsEP->minMaxExecutionDuration();
 
  131          minMaxExecDuration.first = std::min(minMaxExecDuration.first, epMinMax.first);
 
  132          minMaxExecDuration.second = std::max(minMaxExecDuration.second, epMinMax.second);
 
  134          auto execDuration = 
node->executionDuration();
 
  135          minMaxExecDuration.first = std::min(minMaxExecDuration.first, execDuration);
 
  136          minMaxExecDuration.second = std::max(minMaxExecDuration.second, execDuration);
 
  137          std::vector<NodeAbstraction *> &group = insideNode.second;
 
  138          if (!group.empty()) {
 
  139            auto [minElement, maxElement] = std::minmax_element(
 
  140                group.begin(), group.end(),
 
  141                [](
auto lhs, 
auto rhs) { return lhs->executionDuration() < rhs->executionDuration(); }
 
  143            minMaxExecDuration.first = std::min(minMaxExecDuration.first, (*minElement)->executionDuration());
 
  144            minMaxExecDuration.second = std::max(minMaxExecDuration.second, (*maxElement)->executionDuration());
 
  150    return minMaxExecDuration;
 
  156  [[nodiscard]] std::pair<std::chrono::nanoseconds, std::chrono::nanoseconds> 
minMaxWaitDuration()
 const {
 
  158        std::chrono::nanoseconds::max(), std::chrono::nanoseconds::min()
 
  164      node = insideNode.first;
 
  176          auto epMinMax = nodeAsEP->minMaxWaitDuration();
 
  180          auto waitDuration = task->waitDuration();
 
  183          std::vector<NodeAbstraction *> &group = insideNode.second;
 
  184          if (!group.empty()) {
 
  185            auto [minElement, maxElement] = std::minmax_element(
 
  186                group.begin(), group.end(),
 
  187                [](
auto lhs, 
auto rhs) {
 
  188                  auto lhsAsTask = dynamic_cast<TaskNodeAbstraction const *>(lhs);
 
  189                  auto rhsAsTask = dynamic_cast<TaskNodeAbstraction const *>(rhs);
 
  190                  if (lhsAsTask && rhsAsTask) {
 
  191                    return lhsAsTask->waitDuration() < rhsAsTask->waitDuration();
 
  193                    throw std::runtime_error(
 
  194                        "All the nodes in a group should be of the same type, the representative is of" 
  195                        " type TaskNodeAbstraction but not the nodes in the group.");
 
  201            if (minTask && maxTask) {
 
  205              throw std::runtime_error(
"All the nodes in a group should be of the same type, the representative is of" 
  206                                       " type TaskNodeAbstraction but not the nodes in the group.");
 
  210          return {std::chrono::nanoseconds::zero(), std::chrono::nanoseconds::zero()};
 
Abstraction specialized for the execution pipeline.
virtual std::pair< std::chrono::nanoseconds, std::chrono::nanoseconds > minMaxExecutionDuration() const =0
Getter to the min max execution duration from the nodes inside the graphs in the execution pipeline.
virtual std::pair< std::chrono::nanoseconds, std::chrono::nanoseconds > minMaxWaitDuration() const =0
Getter to the min max wait duration from the nodes inside the graphs in the execution pipeline.
Base graph node abstraction.
int deviceId() const override
Device id accessor.
std::chrono::time_point< std::chrono::system_clock > const graphStartCreation_
graph creation timestamp
virtual void setInside()=0
Set a graph inside another one.
virtual void createInnerGroupsAndLaunchThreads(bool waitForInitialization)=0
Create the groups and launch the threads of the inside nodes.
std::chrono::nanoseconds const & graphConstructionDuration() const
Graph construction duration accessor.
std::pair< std::chrono::nanoseconds, std::chrono::nanoseconds > minMaxWaitDuration() const
Accessor to the min / max wait duration of the nodes in the graph.
~GraphNodeAbstraction() override=default
Default destructor.
void graphId(size_t graphId)
Setter to the graph id.
GraphNodeAbstraction(std::string const &name)
Base graph abstraction.
Status graphStatus_
Group status.
size_t graphId() const override
Graph id accessor.
void registerNode(GraphNodeAbstraction *belongingGraph) override
Register a graph inside a graph.
std::pair< std::chrono::nanoseconds, std::chrono::nanoseconds > minMaxExecutionDuration() const
Accessor to the min / max execution duration of the nodes in the graph.
Status graphStatus() const
Graph status accessor.
virtual void joinThreads()=0
Interface to join the threads inside of a graph, called by the Default scheduler.
std::chrono::time_point< std::chrono::system_clock > const & graphStartCreation() const
Graph start creation timestamp accessor.
virtual void registerNodeInsideGraph(NodeAbstraction *core)=0
Register a core inside a graph.
std::unique_ptr< std::map< NodeAbstraction *, std::vector< NodeAbstraction * > > > const insideNodesAndGroups_
All nodes of the graph, mapped to their group nodes.
Status
Graph status (INITialisation, EXECution, TERMination, INSide)
int deviceId_
Device Id used for computation on devices.
size_t graphId_
Graph Id used to identify a graph in an execution pipeline.
std::chrono::nanoseconds graphConstructionDuration_
Node creation duration.
void graphConstructionDuration(std::chrono::nanoseconds const &graphConstructionDuration)
Setter to the graph construction duration.
void deviceId(int deviceId)
Setter to the device id.
Base core node abstraction.
virtual void registerNode(GraphNodeAbstraction *belongingGraph)
Register node to the given graph.
virtual behavior::Node * node() const =0
Node accessor.
GraphNodeAbstraction * belongingGraph() const
Belonging graph accessor.
std::string const & name() const
Accessor to the core's name.
Task core abstraction used to define some method for task-like behaving cores like CoreExecutionPipel...
PrintAbstraction, used to determine if the node should be visited by the printer and colored.