Hedgehog  3.1.0
A library to generate hybrid pipeline workflow systems
Loading...
Searching...
No Matches
hh::core::CoreExecutionPipeline< Separator, AllTypes > Class Template Reference

Execution pipeline core. More...

#include "core_execution_pipeline.h"

Inheritance diagram for hh::core::CoreExecutionPipeline< Separator, AllTypes >:
Inheritance graph
Collaboration diagram for hh::core::CoreExecutionPipeline< Separator, AllTypes >:
Collaboration graph

Public Member Functions

 CoreExecutionPipeline (AbstractExecutionPipeline< Separator, AllTypes... > *const &executionPipeline, std::shared_ptr< CoreGraph< Separator, AllTypes... > > const coreGraph, std::vector< int > deviceIds, std::string const name="Execution pipeline")
 Constructor using a user-defined execution pipeline, the base CoreGraph and the deviceIds to determine the number of graphs in the execution pipeline. The name is set as default as "Execution pipeline".
 
 CoreExecutionPipeline (AbstractExecutionPipeline< Separator, AllTypes... > *const &executionPipeline, std::shared_ptr< CoreGraph< Separator, AllTypes... > > const coreGraph, size_t numberGraphs, std::string const name="Execution pipeline")
 Constructor using a user-defined execution pipeline, the base CoreGraph, and the number of graphs in the execution pipeline. The name is set as default as "Execution pipeline".
 
 ~CoreExecutionPipeline () override=default
 Default destructor.
 
void preRun () override
 Do nothing as pre-run step.
 
void run () override
 Main core execution pipeline logic.
 
void postRun () override
 Post run logic, disconnects the switch and waits for each graph to terminate.
 
std::string extraPrintingInformation () const override
 Extra printing information for the execution pipeline.
 
void visit (Printer *printer) override
 Visit an execution pipeline.
 
void registerNode (abstraction::GraphNodeAbstraction *belongingGraph) override
 Register the execution pipeline into the belongingGraph.
 
std::pair< std::chrono::nanoseconds, std::chrono::nanoseconds > minMaxExecutionDuration () const override
 Getter to the min max execution duration from the nodes inside the graphs in the execution pipeline.
 
std::pair< std::chrono::nanoseconds, std::chrono::nanoseconds > minMaxWaitDuration () const override
 Getter to the min max wait duration from the nodes inside the graphs in the execution pipeline.
 
- Public Member Functions inherited from hh::core::abstraction::ExecutionPipelineNodeAbstraction
 ExecutionPipelineNodeAbstraction (std::string const &name, behavior::Node *node)
 Constructor using the node name.
 
 ~ExecutionPipelineNodeAbstraction () override=default
 Default destructor.
 
std::vector< std::pair< std::string const, std::string const > > ids () const override
 Node ids [nodeId, nodeGroupId] accessor.
 
bool hasMemoryManagerAttached () const override
 Test if a node has a memory attached, an execution pipeline can't have a memory manager.
 
std::shared_ptr< AbstractMemoryManagermemoryManager () const override
 Accessor to memory manager, an execution pipeline has no memory manager.
 
virtual void launchGraphThreads (bool waitForInitialization)=0
 Launch the graphs inside of the execution pipeline, called when the outer graph is executed.
 
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.
 
- Public Member Functions inherited from hh::core::abstraction::TaskNodeAbstraction
 TaskNodeAbstraction (std::string const &name, behavior::Node *node)
 Create the abstraction with the node's name.
 
 ~TaskNodeAbstraction () override=default
 Default destructor.
 
bool isActive () const
 Accessor to task status.
 
bool isInitialized () const
 Accessor to initialized flag.
 
size_t numberReceivedElements () const
 Accessor to the number of received elements.
 
std::chrono::nanoseconds const & waitDuration () const
 Accessor to the duration the node was in a wait state.
 
std::chrono::nanoseconds const & memoryWaitDuration () const
 Accessor to the duration the node was in a memory wait state.
 
std::shared_ptr< NvtxProfiler > const & nvtxProfiler () const
 Accessor to the NVTX profiler attached to the node.
 
std::chrono::nanoseconds perElementExecutionDuration () const
 Accessor to the duration the average duration of processing an input data.
 
void isActive (bool isActive)
 Setter to the task status.
 
void incrementNumberReceivedElements ()
 Increment the number of elements received.
 
void incrementWaitDuration (std::chrono::nanoseconds const &wait)
 Increment the wait duration.
 
void incrementMemoryWaitDuration (std::chrono::nanoseconds const &wait)
 Increase the memory wait duration.
 
void incrementPerElementExecutionDuration (std::chrono::nanoseconds const &exec)
 Increase the execution time per elements.
 
virtual void preRun ()=0
 Pre run method, called only once.
 
virtual void run ()=0
 Run method, called when thread is attached.
 
virtual void postRun ()=0
 Post run method, called only once.
 
virtual std::string extraPrintingInformation () const =0
 Abstraction to add user-defined message for the printers.
 
virtual bool hasMemoryManagerAttached () const =0
 Flag accessor to the presence of memory manager attached.
 
virtual std::shared_ptr< AbstractMemoryManagermemoryManager () const =0
 Accessor to the attached memory manager.
 
behavior::Nodenode () const override
 Node accessor.
 
- Public Member Functions inherited from hh::core::abstraction::NodeAbstraction
 NodeAbstraction (std::string name)
 Core node constructor using the core's name.
 
virtual ~NodeAbstraction ()=default
 DEfault destructor.
 
std::string const & name () const
 Accessor to the core's name.
 
virtual std::string id () const
 Core's id ('x' + address of abstraction) as string.
 
bool isRegistered () const
 Accessor to registration flag.
 
GraphNodeAbstractionbelongingGraph () const
 Belonging graph accessor.
 
virtual int deviceId () const
 Get the device identifier (got from belonging graph)
 
virtual size_t graphId () const
 Get the graph identifier (got from belonging graph)
 
std::chrono::nanoseconds const & executionDuration () const
 Execution duration.
 
std::chrono::time_point< std::chrono::system_clock > const & startExecutionTimeStamp () const
 Accessor to the starting execution timestamp.
 
void startExecutionTimeStamp (std::chrono::time_point< std::chrono::system_clock > const &startExecutionTimeStamp)
 Setter to the starting execution timestamp.
 
void incrementExecutionDuration (std::chrono::nanoseconds const &exec)
 Increment execution duration.
 
virtual void registerNode (GraphNodeAbstraction *belongingGraph)
 Register node to the given graph.
 
virtual std::vector< std::pair< std::string const, std::string const > > ids () const =0
 Node ids [nodeId, nodeGroupId] accessor.
 
virtual behavior::Nodenode () const =0
 Node accessor.
 
- Public Member Functions inherited from hh::core::abstraction::PrintableAbstraction
tool::PrintOptions const & printOptions () const
 Print options const accessor.
 
tool::PrintOptionsprintOptions ()
 Print options accessor.
 
virtual void visit (Printer *printer)=0
 Visitor method, used by the printer to visit all nodes in the graph.
 
- Public Member Functions inherited from hh::core::abstraction::ClonableAbstraction
 ClonableAbstraction ()
 Default constructor.
 
virtual ~ClonableAbstraction ()=default
 Default destructor.
 
void storeClone (std::shared_ptr< abstraction::NodeAbstraction > const &clone)
 Store a core clone.
 
virtual std::shared_ptr< abstraction::NodeAbstractionclone (std::map< NodeAbstraction *, std::shared_ptr< NodeAbstraction > > &correspondenceMap)=0
 Clone virtual function.
 
virtual void duplicateEdge (std::map< NodeAbstraction *, std::shared_ptr< NodeAbstraction > > &mapping)=0
 Duplicate the output edges of a node.
 

Private Member Functions

void initializeCoreExecutionPipeline (std::shared_ptr< CoreGraph< Separator, AllTypes... > > const coreGraph)
 Initialize the execution pipeline.
 
void registerAndDuplicateGraph (std::shared_ptr< CoreGraph< Separator, AllTypes... > > const coreGraph)
 Register and duplicate the coreGraph in the execution pipeline.
 
void connectCoreGraphs ()
 Connect all of the core graphs into the execution pipeline (connection to the switch and output of the execution pipeline)
 
template<class InputTypes , size_t ... Indices>
void operateReceivers (std::index_sequence< Indices... >)
 Operate the receivers for all input types.
 
template<class Input >
void operateReceiver ()
 Operate the receiver for a specific input type.
 
void launchGraphThreads (bool waitForInitialization) override
 Create graph's inner groups and launch graph's threads.
 
std::string id () const override
 Get the exec pipeline id.
 
std::shared_ptr< abstraction::NodeAbstractionclone (std::map< NodeAbstraction *, std::shared_ptr< NodeAbstraction > > &correspondenceMap) override
 Clone method, to duplicate an execution pipeline when it is part of another graph in an execution pipeline.
 
void duplicateEdge (std::map< NodeAbstraction *, std::shared_ptr< NodeAbstraction > > &mapping) override
 Duplicate the execution pipeline edge.
 

Private Attributes

AbstractExecutionPipeline< Separator, AllTypes... > *const executionPipeline_ = nullptr
 Pointer to the execution pipeline node.
 
std::vector< std::shared_ptr< CoreGraph< Separator, AllTypes... > > > coreGraphs_ {}
 Vector of CoreGraph handled by the execution pipeline.
 
std::vector< intdeviceIds_ {}
 Device ids matching the core graphs.
 

Additional Inherited Members

- Protected Member Functions inherited from hh::core::abstraction::TaskNodeAbstraction
void setInitialized ()
 Set the task as initialized.
 

Detailed Description

template<size_t Separator, class ... AllTypes>
class hh::core::CoreExecutionPipeline< Separator, AllTypes >

Execution pipeline core.

Template Parameters
SeparatorSeparator position between input types and output types
AllTypesList of input and output types

Definition at line 59 of file core_execution_pipeline.h.

Constructor & Destructor Documentation

◆ CoreExecutionPipeline() [1/2]

template<size_t Separator, class ... AllTypes>
hh::core::CoreExecutionPipeline< Separator, AllTypes >::CoreExecutionPipeline ( AbstractExecutionPipeline< Separator, AllTypes... > *const &  executionPipeline,
std::shared_ptr< CoreGraph< Separator, AllTypes... > > const  coreGraph,
std::vector< int deviceIds,
std::string const  name = "Execution pipeline" 
)
inline

Constructor using a user-defined execution pipeline, the base CoreGraph and the deviceIds to determine the number of graphs in the execution pipeline. The name is set as default as "Execution pipeline".

Parameters
executionPipelineUser-defined execution pipeline
coreGraphBase CoreGraph
deviceIdsDevice Ids to set to the different graphs in the execution pipeline. The vector size determine the number of graphs in the execution pipeline.
nameName of the execution pipeline

Definition at line 80 of file core_execution_pipeline.h.

Here is the call graph for this function:

◆ CoreExecutionPipeline() [2/2]

template<size_t Separator, class ... AllTypes>
hh::core::CoreExecutionPipeline< Separator, AllTypes >::CoreExecutionPipeline ( AbstractExecutionPipeline< Separator, AllTypes... > *const &  executionPipeline,
std::shared_ptr< CoreGraph< Separator, AllTypes... > > const  coreGraph,
size_t  numberGraphs,
std::string const  name = "Execution pipeline" 
)
inline

Constructor using a user-defined execution pipeline, the base CoreGraph, and the number of graphs in the execution pipeline. The name is set as default as "Execution pipeline".

The device ids are set in sequence, the base graph as 0 and each clone as previous + 1.

Parameters
executionPipelineUSer-defined execution pipeline
coreGraphBase CoreGraph
numberGraphsNumber of graphs in the execution pipeline
nameName of the Execution pipeline, default is "Execution pipeline"

Definition at line 100 of file core_execution_pipeline.h.

Here is the call graph for this function:

◆ ~CoreExecutionPipeline()

template<size_t Separator, class ... AllTypes>
hh::core::CoreExecutionPipeline< Separator, AllTypes >::~CoreExecutionPipeline ( )
overridedefault

Default destructor.

Member Function Documentation

◆ clone()

template<size_t Separator, class ... AllTypes>
std::shared_ptr< abstraction::NodeAbstraction > hh::core::CoreExecutionPipeline< Separator, AllTypes >::clone ( std::map< NodeAbstraction *, std::shared_ptr< NodeAbstraction > > &  correspondenceMap)
inlineoverrideprivate

Clone method, to duplicate an execution pipeline when it is part of another graph in an execution pipeline.

Parameters
correspondenceMapCorrespondence map of belonging graph's node
Returns
Clone of this execution pipeline

Definition at line 329 of file core_execution_pipeline.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ connectCoreGraphs()

template<size_t Separator, class ... AllTypes>
void hh::core::CoreExecutionPipeline< Separator, AllTypes >::connectCoreGraphs ( )
inlineprivate

Connect all of the core graphs into the execution pipeline (connection to the switch and output of the execution pipeline)

Definition at line 270 of file core_execution_pipeline.h.

Here is the caller graph for this function:

◆ duplicateEdge()

template<size_t Separator, class ... AllTypes>
void hh::core::CoreExecutionPipeline< Separator, AllTypes >::duplicateEdge ( std::map< NodeAbstraction *, std::shared_ptr< NodeAbstraction > > &  mapping)
inlineoverrideprivate

Duplicate the execution pipeline edge.

Parameters
mappingCorrespondence map of belonging graph's node

Definition at line 339 of file core_execution_pipeline.h.

◆ extraPrintingInformation()

template<size_t Separator, class ... AllTypes>
std::string hh::core::CoreExecutionPipeline< Separator, AllTypes >::extraPrintingInformation ( ) const
inlineoverridevirtual

Extra printing information for the execution pipeline.

Returns
An empty string

Implements hh::core::abstraction::TaskNodeAbstraction.

Definition at line 173 of file core_execution_pipeline.h.

◆ id()

template<size_t Separator, class ... AllTypes>
std::string hh::core::CoreExecutionPipeline< Separator, AllTypes >::id ( ) const
inlineoverrideprivatevirtual

Get the exec pipeline id.

In fact get switch id, they share the same id

Returns
Execution pipeline id

Reimplemented from hh::core::abstraction::NodeAbstraction.

Definition at line 324 of file core_execution_pipeline.h.

◆ initializeCoreExecutionPipeline()

template<size_t Separator, class ... AllTypes>
void hh::core::CoreExecutionPipeline< Separator, AllTypes >::initializeCoreExecutionPipeline ( std::shared_ptr< CoreGraph< Separator, AllTypes... > > const  coreGraph)
inlineprivate

Initialize the execution pipeline.

Register, duplicate and connect the graph given in parameter

Parameters
coreGraphBase core graph
Exceptions
std::runtime_errorIf the graph is not valid, in the right state or the device ids are not valid

Definition at line 229 of file core_execution_pipeline.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ launchGraphThreads()

template<size_t Separator, class ... AllTypes>
void hh::core::CoreExecutionPipeline< Separator, AllTypes >::launchGraphThreads ( bool  waitForInitialization)
inlineoverrideprivatevirtual

Create graph's inner groups and launch graph's threads.

Parameters
waitForInitializationWait for internal nodes to be initialized flags

Implements hh::core::abstraction::ExecutionPipelineNodeAbstraction.

Definition at line 315 of file core_execution_pipeline.h.

◆ minMaxExecutionDuration()

template<size_t Separator, class ... AllTypes>
std::pair< std::chrono::nanoseconds, std::chrono::nanoseconds > hh::core::CoreExecutionPipeline< Separator, AllTypes >::minMaxExecutionDuration ( ) const
inlineoverridevirtual

Getter to the min max execution duration from the nodes inside the graphs in the execution pipeline.

Returns
Min max execution duration from the nodes inside the graphs in the execution pipeline

Implements hh::core::abstraction::ExecutionPipelineNodeAbstraction.

Definition at line 196 of file core_execution_pipeline.h.

◆ minMaxWaitDuration()

template<size_t Separator, class ... AllTypes>
std::pair< std::chrono::nanoseconds, std::chrono::nanoseconds > hh::core::CoreExecutionPipeline< Separator, AllTypes >::minMaxWaitDuration ( ) const
inlineoverridevirtual

Getter to the min max wait duration from the nodes inside the graphs in the execution pipeline.

Returns
Min max wait duration from the nodes inside the graphs in the execution pipeline

Implements hh::core::abstraction::ExecutionPipelineNodeAbstraction.

Definition at line 211 of file core_execution_pipeline.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operateReceiver()

template<size_t Separator, class ... AllTypes>
template<class Input >
void hh::core::CoreExecutionPipeline< Separator, AllTypes >::operateReceiver ( )
inlineprivate

Operate the receiver for a specific input type.

  • Lock the mutex
  • If there is an input data available
    • get the data
    • unlock the mutex
    • for each graph
    • if the data can be send to the graph, send it
  • else, unlock the mutex
    Template Parameters
    Input

Definition at line 296 of file core_execution_pipeline.h.

Here is the call graph for this function:

◆ operateReceivers()

template<size_t Separator, class ... AllTypes>
template<class InputTypes , size_t ... Indices>
void hh::core::CoreExecutionPipeline< Separator, AllTypes >::operateReceivers ( std::index_sequence< Indices... >  )
inlineprivate

Operate the receivers for all input types.

Template Parameters
InputTypesInput data types
IndicesIndices to travers the tuple of input types

Definition at line 281 of file core_execution_pipeline.h.

◆ postRun()

template<size_t Separator, class ... AllTypes>
void hh::core::CoreExecutionPipeline< Separator, AllTypes >::postRun ( )
inlineoverridevirtual

Post run logic, disconnects the switch and waits for each graph to terminate.

Implements hh::core::abstraction::TaskNodeAbstraction.

Definition at line 165 of file core_execution_pipeline.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ preRun()

template<size_t Separator, class ... AllTypes>
void hh::core::CoreExecutionPipeline< Separator, AllTypes >::preRun ( )
inlineoverridevirtual

Do nothing as pre-run step.

Implements hh::core::abstraction::TaskNodeAbstraction.

Definition at line 118 of file core_execution_pipeline.h.

◆ registerAndDuplicateGraph()

template<size_t Separator, class ... AllTypes>
void hh::core::CoreExecutionPipeline< Separator, AllTypes >::registerAndDuplicateGraph ( std::shared_ptr< CoreGraph< Separator, AllTypes... > > const  coreGraph)
inlineprivate

Register and duplicate the coreGraph in the execution pipeline.

The CoreGraph is duplicated n times cy calling clone() on it, all of the graphs are initialized and registered in the execution pipeline.

Parameters
coreGraphCoreGraph to duplicate and register

Definition at line 251 of file core_execution_pipeline.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ registerNode()

template<size_t Separator, class ... AllTypes>
void hh::core::CoreExecutionPipeline< Separator, AllTypes >::registerNode ( abstraction::GraphNodeAbstraction belongingGraph)
inlineoverridevirtual

Register the execution pipeline into the belongingGraph.

Parameters
belongingGraphGraph to register the execution pipeline into

Reimplemented from hh::core::abstraction::NodeAbstraction.

Definition at line 189 of file core_execution_pipeline.h.

Here is the call graph for this function:

◆ run()

template<size_t Separator, class ... AllTypes>
void hh::core::CoreExecutionPipeline< Separator, AllTypes >::run ( )
inlineoverridevirtual

Main core execution pipeline logic.

  • while the execution pipeline runs
    • wait for data or termination
    • if can terminate, break
    • get a piece of data from the queue
    • for each graphs
      • if data need to be sent to the graph, send to the graph
  • disconnect the switch from each graphs
  • wait for each graph to terminate

Implements hh::core::abstraction::TaskNodeAbstraction.

Definition at line 130 of file core_execution_pipeline.h.

Here is the call graph for this function:

◆ visit()

template<size_t Separator, class ... AllTypes>
void hh::core::CoreExecutionPipeline< Separator, AllTypes >::visit ( Printer printer)
inlineoverridevirtual

Visit an execution pipeline.

Parameters
printerPrinter used to gather information

Implements hh::core::abstraction::PrintableAbstraction.

Definition at line 177 of file core_execution_pipeline.h.

Here is the call graph for this function:

Member Data Documentation

◆ coreGraphs_

template<size_t Separator, class ... AllTypes>
std::vector<std::shared_ptr<CoreGraph<Separator, AllTypes...> > > hh::core::CoreExecutionPipeline< Separator, AllTypes >::coreGraphs_ {}
private

Vector of CoreGraph handled by the execution pipeline.

Definition at line 68 of file core_execution_pipeline.h.

◆ deviceIds_

template<size_t Separator, class ... AllTypes>
std::vector<int> hh::core::CoreExecutionPipeline< Separator, AllTypes >::deviceIds_ {}
private

Device ids matching the core graphs.

Definition at line 70 of file core_execution_pipeline.h.

◆ executionPipeline_

template<size_t Separator, class ... AllTypes>
AbstractExecutionPipeline<Separator, AllTypes...>* const hh::core::CoreExecutionPipeline< Separator, AllTypes >::executionPipeline_ = nullptr
private

Pointer to the execution pipeline node.

Definition at line 66 of file core_execution_pipeline.h.