| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

ExecutionFlowGraph.h
Go to the documentation of this file.
1 #ifndef GAUDIHIVE_EXECUTIONFLOWGRAPH_H
2 #define GAUDIHIVE_EXECUTIONFLOWGRAPH_H
3
4 // std includes
5 #include <vector>
6 #include <algorithm>
7 #include <unordered_map>
8 #include <chrono>
9 #include <fstream>
10 #include <sstream>
11
12 #include <boost/graph/adjacency_list.hpp>
13 #include <boost/graph/graphml.hpp>
14
15 // fwk includes
16 #include "AlgsExecutionStates.h"
17 #include "EventSlot.h"
18 #include "IGraphVisitor.h"
19 #include "GaudiKernel/Algorithm.h"
20 #include "GaudiKernel/CommonMessaging.h"
21
22 #include "CPUCruncher.h"
23
24 namespace boost {
25
26 struct AlgoNodeStruct {
27 AlgoNodeStruct () {}
28 AlgoNodeStruct (const std::string& name, const int index = -1, const int& rank = -1, const double& runtime = -1, const double& eccentricity = -1.0) :
29 m_name(name), m_index(index), m_rank(rank), m_runtime(runtime), m_eccentricity(eccentricity) {}
30 std::string m_name;
31 int m_index;
32 int m_rank;
33 double m_runtime;
34 double m_eccentricity;
35 };
36
37 typedef boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, AlgoNodeStruct> ExecPlan;
38 typedef graph_traits<ExecPlan>::vertex_descriptor AlgoVertex;
39 }
40
41 namespace concurrency {
42
43 typedef AlgsExecutionStates::State State;
44 class ExecutionFlowGraph;
45
46 class ControlFlowNode {
47 public:
49 ControlFlowNode(ExecutionFlowGraph& graph, unsigned int nodeIndex, const std::string& name) :
50 m_graph(&graph), m_nodeIndex(nodeIndex), m_nodeName(name) {};
52 virtual ~ControlFlowNode() {};
54 virtual void initialize(const std::unordered_map<std::string,unsigned int>& algname_index_map) = 0;
56 virtual bool accept(IGraphVisitor& visitor) = 0;
58 virtual bool promoteToControlReadyState(const int& slotNum,
59 AlgsExecutionStates& states,
60 std::vector<int>& node_decisions) const = 0;
62 virtual int updateState(AlgsExecutionStates& states,
63 std::vector<int>& node_decisions) const = 0;
65 virtual void printState(std::stringstream& output,
66 AlgsExecutionStates& states,
67 const std::vector<int>& node_decisions,
68 const unsigned int& recursionLevel) const = 0;
70 const unsigned int& getNodeIndex() const { return m_nodeIndex; }
71 const std::string& getNodeName() const { return m_nodeName; }
72 virtual void updateDecision(const int& slotNum,
73 AlgsExecutionStates& states,
74 std::vector<int>& node_decisions,
75 const AlgorithmNode* requestor = nullptr) const = 0;
76 public:
77 ExecutionFlowGraph* m_graph;
78 protected:
80 std::string stateToString(const int& stateId) const;
81 unsigned int m_nodeIndex;
82 std::string m_nodeName;
83 };
84
85
86 class DecisionNode : public ControlFlowNode {
87 public:
89 DecisionNode(ExecutionFlowGraph& graph, unsigned int nodeIndex, const std::string& name, bool modeOR, bool allPass, bool isLazy) :
90 ControlFlowNode(graph, nodeIndex, name),
91 m_modeOR(modeOR), m_allPass(allPass), m_isLazy(isLazy), m_children()
92 {};
94 virtual ~DecisionNode();
96 virtual void initialize(const std::unordered_map<std::string,unsigned int>& algname_index_map);
97 virtual bool accept(IGraphVisitor& visitor);
99 virtual bool promoteToControlReadyState(const int& slotNum,
100 AlgsExecutionStates& states,
101 std::vector<int>& node_decisions) const;
103 virtual void updateDecision(const int& slotNum,
104 AlgsExecutionStates& states,
105 std::vector<int>& node_decisions,
106 const AlgorithmNode* requestor = nullptr) const;
108 virtual int updateState(AlgsExecutionStates& states,
109 std::vector<int>& node_decisions) const;
111 void addParentNode(DecisionNode* node);
113 void addDaughterNode(ControlFlowNode* node);
115 const std::vector<ControlFlowNode*>& getDaughters() const {return m_children;}
117 virtual void printState(std::stringstream& output,
118 AlgsExecutionStates& states,
119 const std::vector<int>& node_decisions,
120 const unsigned int& recursionLevel) const;
121 public:
123 bool m_modeOR;
125 bool m_allPass;
127 bool m_isLazy;
128 private:
130 std::vector<ControlFlowNode*> m_children;
132 std::vector<DecisionNode*> m_parents;
133 };
134
135 class DataNode;
136
137 class AlgorithmNode : public ControlFlowNode {
138 public:
140 AlgorithmNode(ExecutionFlowGraph& graph, unsigned int nodeIndex, const std::string& algoName, bool inverted, bool allPass) :
141 ControlFlowNode(graph, nodeIndex, algoName),
142 m_algoIndex(0),m_algoName(algoName),m_inverted(inverted),m_allPass(allPass),m_rank(-1)
143 {};
145 ~AlgorithmNode();
147 virtual void initialize(const std::unordered_map<std::string,unsigned int>& algname_index_map);
149 virtual bool accept(IGraphVisitor& visitor);
151 void addParentNode(DecisionNode* node);
152
154 void addSupplierNode(AlgorithmNode* node) { m_suppliers.push_back(node); }
156 void addConsumerNode(AlgorithmNode* node) { m_consumers.push_back(node); }
158 void attachAlgorithm(IAlgorithm* ialgo) { m_representatives.push_back(ialgo); }
160 const std::vector<IAlgorithm*>& getAlgorithmRepresentatives () const { return m_representatives; }
162 const std::vector<AlgorithmNode*>& getSupplierNodes() const {return m_suppliers;}
164 const std::vector<AlgorithmNode*>& getConsumerNodes() const {return m_consumers;}
165
167 void addOutputDataNode(DataNode* node);
169 void addInputDataNode(DataNode* node);
171 const std::vector<DataNode*>& getOutputDataNodes() const {return m_outputs;}
173 const std::vector<DataNode*>& getInputDataNodes() const {return m_inputs;}
175 void setRank(float& rank) {m_rank = rank;}
177 const float& getRank() const {return m_rank;}
178
180 const unsigned int& getAlgoIndex() const { return m_algoIndex; }
182 bool dataDependenciesSatisfied(const int& slotNum) const;
183 bool dataDependenciesSatisfied(AlgsExecutionStates& states) const;
185 virtual int updateState(AlgsExecutionStates& states,
186 std::vector<int>& node_decisions) const;
188 virtual bool promoteToControlReadyState(const int& slotNum,
189 AlgsExecutionStates& states,
190 std::vector<int>& node_decisions) const;
192 bool promoteToDataReadyState(const int& slotNum, const AlgorithmNode* requestor = nullptr) const;
194 virtual void updateDecision(const int& slotNum,
195 AlgsExecutionStates& states,
196 std::vector<int>& node_decisions,
197 const AlgorithmNode* requestor = nullptr) const;
199 virtual void printState(std::stringstream& output,
200 AlgsExecutionStates& states,
201 const std::vector<int>& node_decisions,
202 const unsigned int& recursionLevel) const;
203 private:
205 unsigned int m_algoIndex;
207 std::string m_algoName;
209 bool m_inverted;
211 bool m_allPass;
213 std::vector<DecisionNode*> m_parents;
214
217 std::vector<AlgorithmNode*> m_suppliers;
219 std::vector<AlgorithmNode*> m_consumers;
220
223 std::vector<DataNode*> m_outputs;
225 std::vector<DataNode*> m_inputs;
227 float m_rank;
229 std::vector<IAlgorithm*> m_representatives;
230 };
231
232 class DataNode {
233 public:
235 DataNode(ExecutionFlowGraph& /*graph*/, const DataObjID& path): m_data_object_path(path) {}
237 ~DataNode() {}
238 const DataObjID& getPath() {return m_data_object_path;}
240 void addProducerNode(AlgorithmNode* node) {
241 if (std::find(m_producers.begin(),m_producers.end(),node) == m_producers.end())
242 m_producers.push_back(node);
243 }
245 void addConsumerNode(AlgorithmNode* node) {
246 if (std::find(m_consumers.begin(),m_consumers.end(),node) == m_consumers.end())
247 m_consumers.push_back(node);
248 }
250 const std::vector<AlgorithmNode*>& getProducers() const {return m_producers;}
252 const std::vector<AlgorithmNode*>& getConsumers() const {return m_consumers;}
253 private:
254 DataObjID m_data_object_path;
255 std::vector<AlgorithmNode*> m_producers;
256 std::vector<AlgorithmNode*> m_consumers;
257 };
258
259 typedef std::unordered_map<std::string,AlgorithmNode*> AlgoNodesMap;
260 typedef std::unordered_map<std::string,DecisionNode*> DecisionHubsMap;
261 typedef std::unordered_map<DataObjID,DataNode*,DataObjID_Hasher> DataNodesMap;
262
263 typedef std::unordered_map<std::string, DataObjIDColl > AlgoInputsMap;
264 typedef std::unordered_map<std::string, DataObjIDColl > AlgoOutputsMap;
265
266 class ExecutionFlowManager;
267 struct IExecutionFlowGraph {
268 virtual ~IExecutionFlowGraph() = default;
269 };
270
271 class ExecutionFlowGraph : public CommonMessaging<IExecutionFlowGraph> {
272 friend ExecutionFlowManager;
273 public:
275 ExecutionFlowGraph(const std::string& name, SmartIF<ISvcLocator> svc) :
276 m_headNode(0), m_nodeCounter(0), m_svcLocator(svc), m_name(name), m_initTime(std::chrono::high_resolution_clock::now()),
277 m_eventSlots(nullptr) {}
279 ~ExecutionFlowGraph() override {
280 if (m_headNode != 0) delete m_headNode;
281 }
283 StatusCode initialize(const std::unordered_map<std::string,unsigned int>& algname_index_map);
284 StatusCode initialize(const std::unordered_map<std::string,unsigned int>& algname_index_map,
285 std::vector<EventSlot>& eventSlots);
287 void registerIODataObjects(const Algorithm* algo);
289 StatusCode buildDataDependenciesRealm();
291 StatusCode buildAugmentedDataDependenciesRealm();
293 void addHeadNode(const std::string& headName, bool modeOR, bool allPass, bool isLazy);
295 StatusCode addAlgorithmNode(Algorithm* daughterAlgo, const std::string& parentName, bool inverted, bool allPass);
297 template<class T>
298 void attachAlgorithmsToNodes(const std::string& algo_name, const T& container) {
299 auto node = getAlgorithmNode(algo_name);
300 for (auto ialgoIt = container.unsafe_begin(); ialgoIt != container.unsafe_end(); ++ialgoIt)
301 node->attachAlgorithm(*ialgoIt);
302 }
304 AlgorithmNode* getAlgorithmNode(const std::string& algoName) const;
306 StatusCode addDataNode(const DataObjID& dataPath);
308 DataNode* getDataNode(const DataObjID& dataPath) const;
310 StatusCode addDecisionHubNode(Algorithm* daughterAlgo, const std::string& parentName, bool modeOR, bool allPass, bool isLazy);
312 unsigned int getControlFlowNodeCounter() const {return m_nodeCounter;}
314 void updateEventState(AlgsExecutionStates& states,
315 std::vector<int>& node_decisions) const;
317 void updateDecision(const std::string& algo_name,
318 const int& slotNum,
319 AlgsExecutionStates& states,
320 std::vector<int>& node_decisions) const;
322 void rankAlgorithms(IGraphVisitor& ranker) const;
324 void printState(std::stringstream& output,
325 AlgsExecutionStates& states,
326 const std::vector<int>& node_decisions,
327 const unsigned int& recursionLevel) const {m_headNode->printState(output,states,node_decisions,recursionLevel);};
329 const std::vector<AlgorithmNode*> getDataIndependentNodes() const;
331 const std::string& name() const override {return m_name;}
333 SmartIF<ISvcLocator>& serviceLocator() const override {return m_svcLocator;}
335 const std::chrono::system_clock::time_point getInitTime() const {return m_initTime;};
337 AlgsExecutionStates& getAlgoStates(const int& slotNum) const {return m_eventSlots->at(slotNum).algsStates;};
339 std::vector<int>& getNodeDecisions(const int& slotNum) const {return m_eventSlots->at(slotNum).controlFlowState;}
341 std::string dumpDataFlow() const;
343 void dumpExecutionPlan();
345 void addEdgeToExecutionPlan(const AlgorithmNode* u, const AlgorithmNode* v);
346
347 private:
349 DecisionNode* m_headNode;
351 AlgoNodesMap m_algoNameToAlgoNodeMap;
353 DecisionHubsMap m_decisionNameToDecisionHubMap;
355 DataNodesMap m_dataPathToDataNodeMap;
357 AlgoInputsMap m_algoNameToAlgoInputsMap;
358 AlgoOutputsMap m_algoNameToAlgoOutputsMap;
360 unsigned int m_nodeCounter;
362 mutable SmartIF<ISvcLocator> m_svcLocator;
363 const std::string m_name;
364 const std::chrono::system_clock::time_point m_initTime;
366 std::vector<EventSlot>* m_eventSlots;
368 boost::ExecPlan m_ExecPlan;
369 std::map<std::string,boost::AlgoVertex> m_exec_plan_map;
370 };
371
372
373 } // namespace concurrency
374
375
376 #endif
concurrency::DecisionNode::m_isLazy
bool m_isLazy
Whether to evaluate lazily - i.e. whether to stop once result known.
Definition: ExecutionFlowGraph.h:127
boost::AlgoNodeStruct::m_index
int m_index
Definition: ExecutionFlowGraph.h:31
concurrency::ControlFlowNode::stateToString
std::string stateToString(const int &stateId) const
Translation between state id and name.
Definition: ExecutionFlowGraph.cpp:7
concurrency::AlgorithmNode::m_outputs
std::vector< DataNode * > m_outputs
Vectors, used in augmented data dependencies realm Outputs of the algorithm, represented as DataNode'...
Definition: ExecutionFlowGraph.h:223
concurrency::ExecutionFlowGraph::getDataIndependentNodes
const std::vector< AlgorithmNode * > getDataIndependentNodes() const
Definition: ExecutionFlowGraph.cpp:718
Algorithm.h
concurrency::AlgorithmNode::getAlgoIndex
const unsigned int & getAlgoIndex() const
XXX: CF tests.
Definition: ExecutionFlowGraph.h:180
concurrency::AlgorithmNode::promoteToControlReadyState
virtual bool promoteToControlReadyState(const int &slotNum, AlgsExecutionStates &states, std::vector< int > &node_decisions) const
XXX: CF tests.
Definition: ExecutionFlowGraph.cpp:209
SmartIF< ISvcLocator >
concurrency::DecisionNode::m_parents
std::vector< DecisionNode * > m_parents
XXX: CF tests. All direct parent nodes in the tree.
Definition: ExecutionFlowGraph.h:132
concurrency::DecisionNode
Definition: ExecutionFlowGraph.h:86
concurrency::AlgoOutputsMap
std::unordered_map< std::string, DataObjIDColl > AlgoOutputsMap
Definition: ExecutionFlowGraph.h:264
concurrency::ExecutionFlowGraph::initialize
StatusCode initialize(const std::unordered_map< std::string, unsigned int > &algname_index_map)
Initialize graph.
Definition: ExecutionFlowGraph.cpp:405
concurrency::AlgorithmNode::m_algoIndex
unsigned int m_algoIndex
The index of the algorithm.
Definition: ExecutionFlowGraph.h:205
concurrency::ExecutionFlowGraph::m_nodeCounter
unsigned int m_nodeCounter
Total number of nodes in the graph.
Definition: ExecutionFlowGraph.h:360
concurrency::ExecutionFlowGraph::getControlFlowNodeCounter
unsigned int getControlFlowNodeCounter() const
Get total number of graph nodes.
Definition: ExecutionFlowGraph.h:312
concurrency::IExecutionFlowGraph::~IExecutionFlowGraph
virtual ~IExecutionFlowGraph()=default
boost::AlgoNodeStruct::AlgoNodeStruct
AlgoNodeStruct(const std::string &name, const int index=-1, const int &rank=-1, const double &runtime=-1, const double &eccentricity=-1.0)
Definition: ExecutionFlowGraph.h:28
concurrency::ExecutionFlowGraph::m_ExecPlan
boost::ExecPlan m_ExecPlan
temporary items to experiment with execution planning
Definition: ExecutionFlowGraph.h:368
concurrency::ExecutionFlowGraph::buildAugmentedDataDependenciesRealm
StatusCode buildAugmentedDataDependenciesRealm()
Build data dependency realm WITH data object nodes participating.
Definition: ExecutionFlowGraph.cpp:517
boost
The namespace threadpool contains a thread pool and related utility classes.
Definition: iter_pos.hpp:13
concurrency::ExecutionFlowGraph::ExecutionFlowManager
friend ExecutionFlowManager
Definition: ExecutionFlowGraph.h:272
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
concurrency::DecisionNode::addDaughterNode
void addDaughterNode(ControlFlowNode *node)
Add a daughter node.
Definition: ExecutionFlowGraph.cpp:36
concurrency::ExecutionFlowGraph::addDecisionHubNode
StatusCode addDecisionHubNode(Algorithm *daughterAlgo, const std::string &parentName, bool modeOR, bool allPass, bool isLazy)
Add a node, which aggregates decisions of direct daughter nodes.
Definition: ExecutionFlowGraph.cpp:647
concurrency::IExecutionFlowGraph
Definition: ExecutionFlowGraph.h:267
concurrency::AlgorithmNode::updateState
virtual int updateState(AlgsExecutionStates &states, std::vector< int > &node_decisions) const
Method to set algos to CONTROLREADY, if possible.
Definition: ExecutionFlowGraph.cpp:315
DataObjID
Definition: DataObjID.h:38
concurrency::DecisionNode::accept
virtual bool accept(IGraphVisitor &visitor)
Definition: ExecutionFlowGraph.cpp:177
concurrency::DataNode
Definition: ExecutionFlowGraph.h:232
concurrency::ExecutionFlowGraph::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service locator (needed to access the MessageSvc)
Definition: ExecutionFlowGraph.h:362
concurrency::ControlFlowNode::initialize
virtual void initialize(const std::unordered_map< std::string, unsigned int > &algname_index_map)=0
Initialize.
concurrency::AlgorithmNode::m_algoName
std::string m_algoName
The name of the algorithm.
Definition: ExecutionFlowGraph.h:207
boost::ExecPlan
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, AlgoNodeStruct > ExecPlan
Definition: ExecutionFlowGraph.h:37
concurrency::AlgorithmNode::getInputDataNodes
const std::vector< DataNode * > & getInputDataNodes() const
Get all consumer nodes.
Definition: ExecutionFlowGraph.h:173
concurrency::AlgorithmNode::dataDependenciesSatisfied
bool dataDependenciesSatisfied(const int &slotNum) const
Method to check whether the Algorithm has its all data dependency satisfied.
Definition: ExecutionFlowGraph.cpp:264
concurrency
Definition: EFGraphVisitors.cpp:3
concurrency::AlgorithmNode::m_consumers
std::vector< AlgorithmNode * > m_consumers
AlgorithmNodes that represent algorithms which need the output of the algorithm.
Definition: ExecutionFlowGraph.h:219
EventSlot::algsStates
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:37
concurrency::AlgorithmNode::AlgorithmNode
AlgorithmNode(ExecutionFlowGraph &graph, unsigned int nodeIndex, const std::string &algoName, bool inverted, bool allPass)
Constructor.
Definition: ExecutionFlowGraph.h:140
concurrency::AlgorithmNode::setRank
void setRank(float &rank)
Set Algorithm rank.
Definition: ExecutionFlowGraph.h:175
concurrency::DecisionNode::m_children
std::vector< ControlFlowNode * > m_children
All direct daughter nodes in the tree.
Definition: ExecutionFlowGraph.h:130
concurrency::ExecutionFlowGraph::m_dataPathToDataNodeMap
DataNodesMap m_dataPathToDataNodeMap
Index: map of data path to DataNode.
Definition: ExecutionFlowGraph.h:355
concurrency::DecisionHubsMap
std::unordered_map< std::string, DecisionNode * > DecisionHubsMap
Definition: ExecutionFlowGraph.h:260
concurrency::ExecutionFlowGraph::m_algoNameToAlgoOutputsMap
AlgoOutputsMap m_algoNameToAlgoOutputsMap
Definition: ExecutionFlowGraph.h:358
concurrency::DataNode::~DataNode
~DataNode()
Destructor.
Definition: ExecutionFlowGraph.h:237
concurrency::AlgorithmNode::getAlgorithmRepresentatives
const std::vector< IAlgorithm * > & getAlgorithmRepresentatives() const
get Algorithm representatives
Definition: ExecutionFlowGraph.h:160
concurrency::AlgorithmNode::m_parents
std::vector< DecisionNode * > m_parents
XXX: CF tests.
Definition: ExecutionFlowGraph.h:213
concurrency::ControlFlowNode
Definition: ExecutionFlowGraph.h:46
std
STL namespace.
concurrency::AlgorithmNode::getOutputDataNodes
const std::vector< DataNode * > & getOutputDataNodes() const
Get all supplier nodes.
Definition: ExecutionFlowGraph.h:171
boost::AlgoNodeStruct::m_rank
int m_rank
Definition: ExecutionFlowGraph.h:32
concurrency::ExecutionFlowGraph::updateDecision
void updateDecision(const std::string &algo_name, const int &slotNum, AlgsExecutionStates &states, std::vector< int > &node_decisions) const
A method to update algorithm node decision, and propagate it upwards.
Definition: ExecutionFlowGraph.cpp:699
concurrency::ExecutionFlowGraph::m_exec_plan_map
std::map< std::string, boost::AlgoVertex > m_exec_plan_map
Definition: ExecutionFlowGraph.h:369
concurrency::ControlFlowNode::accept
virtual bool accept(IGraphVisitor &visitor)=0
concurrency::ExecutionFlowGraph::getNodeDecisions
std::vector< int > & getNodeDecisions(const int &slotNum) const
Definition: ExecutionFlowGraph.h:339
concurrency::ControlFlowNode::updateDecision
virtual void updateDecision(const int &slotNum, AlgsExecutionStates &states, std::vector< int > &node_decisions, const AlgorithmNode *requestor=nullptr) const =0
concurrency::AlgorithmNode::m_inverted
bool m_inverted
Whether the selection result is negated or not.
Definition: ExecutionFlowGraph.h:209
concurrency::DecisionNode::m_allPass
bool m_allPass
Whether always passing regardless of daughter results.
Definition: ExecutionFlowGraph.h:125
concurrency::ExecutionFlowGraph::dumpDataFlow
std::string dumpDataFlow() const
Print out all data origins and destinations, as reflected in the EF graph.
Definition: ExecutionFlowGraph.cpp:735
concurrency::ControlFlowNode::m_graph
ExecutionFlowGraph * m_graph
Definition: ExecutionFlowGraph.h:77
concurrency::AlgorithmNode::~AlgorithmNode
~AlgorithmNode()
Destructor.
Definition: ExecutionFlowGraph.cpp:195
concurrency::DecisionNode::initialize
virtual void initialize(const std::unordered_map< std::string, unsigned int > &algname_index_map)
Initialize.
Definition: ExecutionFlowGraph.cpp:22
boost::AlgoNodeStruct::m_runtime
double m_runtime
Definition: ExecutionFlowGraph.h:33
std::map< std::string, boost::AlgoVertex >
std::stringstream
STL class.
plotSpeedupsPyRoot.graph
tuple graph
Definition: plotSpeedupsPyRoot.py:134
concurrency::ExecutionFlowGraph::m_algoNameToAlgoNodeMap
AlgoNodesMap m_algoNameToAlgoNodeMap
Index: map of algorithm's name to AlgorithmNode.
Definition: ExecutionFlowGraph.h:351
std::string
STL class.
concurrency::ExecutionFlowGraph::getAlgoStates
AlgsExecutionStates & getAlgoStates(const int &slotNum) const
Definition: ExecutionFlowGraph.h:337
concurrency::ExecutionFlowGraph::getDataNode
DataNode * getDataNode(const DataObjID &dataPath) const
Get DataNode by DataObject path using graph index.
Definition: ExecutionFlowGraph.cpp:641
concurrency::ExecutionFlowGraph::registerIODataObjects
void registerIODataObjects(const Algorithm *algo)
Register algorithm in the Data Dependency index.
Definition: ExecutionFlowGraph.cpp:435
concurrency::ControlFlowNode::~ControlFlowNode
virtual ~ControlFlowNode()
Destructor.
Definition: ExecutionFlowGraph.h:52
boost::AlgoNodeStruct::m_eccentricity
double m_eccentricity
Definition: ExecutionFlowGraph.h:34
boost::AlgoNodeStruct::AlgoNodeStruct
AlgoNodeStruct()
Definition: ExecutionFlowGraph.h:27
concurrency::DecisionNode::m_modeOR
bool m_modeOR
Whether acting as "and" (false) or "or" node (true)
Definition: ExecutionFlowGraph.h:123
std::vector::at
T at(T...args)
concurrency::AlgorithmNode::addInputDataNode
void addInputDataNode(DataNode *node)
Associate an AlgorithmNode, which is a data consumer of this one.
Definition: ExecutionFlowGraph.cpp:398
std::vector::push_back
T push_back(T...args)
boost::AlgoNodeStruct
Definition: ExecutionFlowGraph.h:26
concurrency::AlgorithmNode::getRank
const float & getRank() const
Get Algorithm rank.
Definition: ExecutionFlowGraph.h:177
concurrency::ExecutionFlowGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph; may want to have multiple ones once supporting trigger paths...
Definition: ExecutionFlowGraph.h:349
AlgsExecutionStates
The AlgsExecutionStates encodes the state machine for the execution of algorithms within a single eve...
Definition: AlgsExecutionStates.h:28
concurrency::ExecutionFlowManager
Manage the execution flow using an execution flow graph Once initialized, the graph is const and can ...
Definition: ExecutionFlowManager.h:21
concurrency::ExecutionFlowGraph::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: ExecutionFlowGraph.h:333
EventSlot::controlFlowState
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:43
concurrency::ExecutionFlowGraph::~ExecutionFlowGraph
~ExecutionFlowGraph() override
Destructor.
Definition: ExecutionFlowGraph.h:279
concurrency::ExecutionFlowGraph::m_name
const std::string m_name
Definition: ExecutionFlowGraph.h:363
concurrency::DataNode::getPath
const DataObjID & getPath()
Definition: ExecutionFlowGraph.h:238
concurrency::ControlFlowNode::m_nodeIndex
unsigned int m_nodeIndex
Definition: ExecutionFlowGraph.h:81
concurrency::ExecutionFlowGraph::printState
void printState(std::stringstream &output, AlgsExecutionStates &states, const std::vector< int > &node_decisions, const unsigned int &recursionLevel) const
Print a string representing the control flow state.
Definition: ExecutionFlowGraph.h:324
concurrency::DataNode::m_consumers
std::vector< AlgorithmNode * > m_consumers
Definition: ExecutionFlowGraph.h:256
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
concurrency::DataNodesMap
std::unordered_map< DataObjID, DataNode *, DataObjID_Hasher > DataNodesMap
Definition: ExecutionFlowGraph.h:261
concurrency::AlgorithmNode::accept
virtual bool accept(IGraphVisitor &visitor)
Definition: ExecutionFlowGraph.cpp:372
concurrency::DecisionNode::getDaughters
const std::vector< ControlFlowNode * > & getDaughters() const
Definition: ExecutionFlowGraph.h:115
CommonMessaging.h
boost::AlgoVertex
graph_traits< ExecPlan >::vertex_descriptor AlgoVertex
Definition: ExecutionFlowGraph.h:38
concurrency::ExecutionFlowGraph::ExecutionFlowGraph
ExecutionFlowGraph(const std::string &name, SmartIF< ISvcLocator > svc)
Constructor.
Definition: ExecutionFlowGraph.h:275
concurrency::AlgorithmNode::printState
virtual void printState(std::stringstream &output, AlgsExecutionStates &states, const std::vector< int > &node_decisions, const unsigned int &recursionLevel) const
Print a string representing the control flow state.
Definition: ExecutionFlowGraph.cpp:302
concurrency::AlgoInputsMap
std::unordered_map< std::string, DataObjIDColl > AlgoInputsMap
Definition: ExecutionFlowGraph.h:263
boost::AlgoNodeStruct::m_name
std::string m_name
Definition: ExecutionFlowGraph.h:30
concurrency::DataNode::getConsumers
const std::vector< AlgorithmNode * > & getConsumers() const
Get all data object consumers.
Definition: ExecutionFlowGraph.h:252
concurrency::IGraphVisitor
Definition: IGraphVisitor.h:9
concurrency::AlgorithmNode::getConsumerNodes
const std::vector< AlgorithmNode * > & getConsumerNodes() const
Get all consumer nodes.
Definition: ExecutionFlowGraph.h:164
CPUCruncher.h
concurrency::AlgorithmNode::addConsumerNode
void addConsumerNode(AlgorithmNode *node)
Associate an AlgorithmNode, which is a data consumer of this one.
Definition: ExecutionFlowGraph.h:156
concurrency::DecisionNode::~DecisionNode
virtual ~DecisionNode()
Destructor.
Definition: ExecutionFlowGraph.cpp:15
concurrency::ExecutionFlowGraph::name
const std::string & name() const override
Retrieve name of the service.
Definition: ExecutionFlowGraph.h:331
concurrency::AlgorithmNode::attachAlgorithm
void attachAlgorithm(IAlgorithm *ialgo)
Attach Algorithm representative.
Definition: ExecutionFlowGraph.h:158
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:25
concurrency::ExecutionFlowGraph::buildDataDependenciesRealm
StatusCode buildDataDependenciesRealm()
Build data dependency realm WITHOUT data object nodes: just interconnect algorithm nodes directly...
Definition: ExecutionFlowGraph.cpp:462
concurrency::ExecutionFlowGraph::m_decisionNameToDecisionHubMap
DecisionHubsMap m_decisionNameToDecisionHubMap
Index: map of decision's name to DecisionHub.
Definition: ExecutionFlowGraph.h:353
concurrency::DataNode::m_data_object_path
DataObjID m_data_object_path
Definition: ExecutionFlowGraph.h:254
concurrency::AlgorithmNode::initialize
virtual void initialize(const std::unordered_map< std::string, unsigned int > &algname_index_map)
Initialize.
Definition: ExecutionFlowGraph.cpp:203
Gaudi::Utils::Histos::path
GAUDI_API std::string path(const AIDA::IBaseHistogram *aida)
get the path in THS for AIDA histogram
Definition: HistoTableFormat.cpp:191
concurrency::ControlFlowNode::promoteToControlReadyState
virtual bool promoteToControlReadyState(const int &slotNum, AlgsExecutionStates &states, std::vector< int > &node_decisions) const =0
XXX: CF tests. Method to set algos to CONTROLREADY, if possible.
concurrency::ControlFlowNode::m_nodeName
std::string m_nodeName
Definition: ExecutionFlowGraph.h:82
concurrency::AlgorithmNode::m_rank
float m_rank
Algorithm rank of any kind.
Definition: ExecutionFlowGraph.h:227
concurrency::AlgorithmNode::addOutputDataNode
void addOutputDataNode(DataNode *node)
Associate an AlgorithmNode, which is a data supplier for this one.
Definition: ExecutionFlowGraph.cpp:391
concurrency::AlgorithmNode::m_representatives
std::vector< IAlgorithm * > m_representatives
Representatives (including clones) of the node.
Definition: ExecutionFlowGraph.h:229
concurrency::AlgoNodesMap
std::unordered_map< std::string, AlgorithmNode * > AlgoNodesMap
Definition: ExecutionFlowGraph.h:259
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
std::find
T find(T...args)
concurrency::AlgorithmNode::addSupplierNode
void addSupplierNode(AlgorithmNode *node)
Associate an AlgorithmNode, which is a data supplier for this one.
Definition: ExecutionFlowGraph.h:154
concurrency::ExecutionFlowGraph::rankAlgorithms
void rankAlgorithms(IGraphVisitor &ranker) const
Rank Algorithm nodes by the number of data outputs.
Definition: ExecutionFlowGraph.cpp:708
concurrency::DecisionNode::updateDecision
virtual void updateDecision(const int &slotNum, AlgsExecutionStates &states, std::vector< int > &node_decisions, const AlgorithmNode *requestor=nullptr) const
XXX: CF tests.
Definition: ExecutionFlowGraph.cpp:85
concurrency::ExecutionFlowGraph::addEdgeToExecutionPlan
void addEdgeToExecutionPlan(const AlgorithmNode *u, const AlgorithmNode *v)
set cause-effect connection between two algorithms in the execution plan
Definition: ExecutionFlowGraph.cpp:780
std::vector< int >
concurrency::ExecutionFlowGraph::addAlgorithmNode
StatusCode addAlgorithmNode(Algorithm *daughterAlgo, const std::string &parentName, bool inverted, bool allPass)
Add algorithm node.
Definition: ExecutionFlowGraph.cpp:581
concurrency::AlgorithmNode::getSupplierNodes
const std::vector< AlgorithmNode * > & getSupplierNodes() const
Get all supplier nodes.
Definition: ExecutionFlowGraph.h:162
concurrency::AlgorithmNode::m_inputs
std::vector< DataNode * > m_inputs
Inputs of the algorithm, represented as DataNode's.
Definition: ExecutionFlowGraph.h:225
concurrency::ControlFlowNode::ControlFlowNode
ControlFlowNode(ExecutionFlowGraph &graph, unsigned int nodeIndex, const std::string &name)
Constructor.
Definition: ExecutionFlowGraph.h:49
concurrency::DecisionNode::addParentNode
void addParentNode(DecisionNode *node)
XXX: CF tests. Method to add a parent node.
Definition: ExecutionFlowGraph.cpp:29
concurrency::ControlFlowNode::printState
virtual void printState(std::stringstream &output, AlgsExecutionStates &states, const std::vector< int > &node_decisions, const unsigned int &recursionLevel) const =0
Print a string representing the control flow state.
time_point
Clock::time_point time_point
Definition: ITimelineSvc.h:12
concurrency::ControlFlowNode::updateState
virtual int updateState(AlgsExecutionStates &states, std::vector< int > &node_decisions) const =0
XXX: CF tests. Method to set algos to CONTROLREADY, if possible.
concurrency::ExecutionFlowGraph
Definition: ExecutionFlowGraph.h:271
concurrency::DataNode::m_producers
std::vector< AlgorithmNode * > m_producers
Definition: ExecutionFlowGraph.h:255
concurrency::DecisionNode::updateState
virtual int updateState(AlgsExecutionStates &states, std::vector< int > &node_decisions) const
Method to set algos to CONTROLREADY, if possible.
Definition: ExecutionFlowGraph.cpp:56
concurrency::ExecutionFlowGraph::m_initTime
const std::chrono::system_clock::time_point m_initTime
Definition: ExecutionFlowGraph.h:364
concurrency::ExecutionFlowGraph::dumpExecutionPlan
void dumpExecutionPlan()
dump to file encountered execution plan
Definition: ExecutionFlowGraph.cpp:765
concurrency::ExecutionFlowGraph::m_eventSlots
std::vector< EventSlot > * m_eventSlots
Definition: ExecutionFlowGraph.h:366
CommonMessaging
Definition: CommonMessaging.h:58
concurrency::ExecutionFlowGraph::addHeadNode
void addHeadNode(const std::string &headName, bool modeOR, bool allPass, bool isLazy)
Add a node, which has no parents.
Definition: ExecutionFlowGraph.cpp:679
concurrency::AlgorithmNode
Definition: ExecutionFlowGraph.h:137
concurrency::AlgorithmNode::addParentNode
void addParentNode(DecisionNode *node)
XXX: CF tests. Method to add a parent node.
Definition: ExecutionFlowGraph.cpp:384
IGraphVisitor.h
concurrency::DecisionNode::printState
virtual void printState(std::stringstream &output, AlgsExecutionStates &states, const std::vector< int > &node_decisions, const unsigned int &recursionLevel) const
Print a string representing the control flow state.
Definition: ExecutionFlowGraph.cpp:43
concurrency::AlgorithmNode::updateDecision
virtual void updateDecision(const int &slotNum, AlgsExecutionStates &states, std::vector< int > &node_decisions, const AlgorithmNode *requestor=nullptr) const
XXX: CF tests.
Definition: ExecutionFlowGraph.cpp:339
concurrency::ExecutionFlowGraph::m_algoNameToAlgoInputsMap
AlgoInputsMap m_algoNameToAlgoInputsMap
Indexes: maps of algorithm's name to algorithm's inputs/outputs.
Definition: ExecutionFlowGraph.h:357
concurrency::DataNode::DataNode
DataNode(ExecutionFlowGraph &, const DataObjID &path)
Constructor.
Definition: ExecutionFlowGraph.h:235
concurrency::ControlFlowNode::getNodeName
const std::string & getNodeName() const
Definition: ExecutionFlowGraph.h:71
concurrency::ControlFlowNode::getNodeIndex
const unsigned int & getNodeIndex() const
XXX: CF tests.
Definition: ExecutionFlowGraph.h:70
concurrency::AlgorithmNode::m_suppliers
std::vector< AlgorithmNode * > m_suppliers
Vectors, used in data dependencies realm AlgorithmNodes that represent algorithms producing an input ...
Definition: ExecutionFlowGraph.h:217
AlgsExecutionStates.h
AlgsExecutionStates::State
State
Execution states of the algorithms.
Definition: AlgsExecutionStates.h:32
concurrency::ExecutionFlowGraph::attachAlgorithmsToNodes
void attachAlgorithmsToNodes(const std::string &algo_name, const T &container)
Attach pointers to real Algorithms (and their clones) to Algorithm nodes of the graph.
Definition: ExecutionFlowGraph.h:298
concurrency::ExecutionFlowGraph::updateEventState
void updateEventState(AlgsExecutionStates &states, std::vector< int > &node_decisions) const
XXX CF tests. Is needed for older CF implementation.
Definition: ExecutionFlowGraph.cpp:693
concurrency::ExecutionFlowGraph::getAlgorithmNode
AlgorithmNode * getAlgorithmNode(const std::string &algoName) const
Get the AlgorithmNode from by algorithm name using graph index.
Definition: ExecutionFlowGraph.cpp:614
concurrency::ExecutionFlowGraph::getInitTime
const std::chrono::system_clock::time_point getInitTime() const
Definition: ExecutionFlowGraph.h:335
EventSlot.h
concurrency::AlgorithmNode::m_allPass
bool m_allPass
Whether the selection result is relevant or always "pass".
Definition: ExecutionFlowGraph.h:211
concurrency::DataNode::addProducerNode
void addProducerNode(AlgorithmNode *node)
Associate an AlgorithmNode, which is a data supplier for this one.
Definition: ExecutionFlowGraph.h:240
concurrency::DataNode::getProducers
const std::vector< AlgorithmNode * > & getProducers() const
Get all data object producers.
Definition: ExecutionFlowGraph.h:250
concurrency::DecisionNode::DecisionNode
DecisionNode(ExecutionFlowGraph &graph, unsigned int nodeIndex, const std::string &name, bool modeOR, bool allPass, bool isLazy)
Constructor.
Definition: ExecutionFlowGraph.h:89
concurrency::AlgorithmNode::promoteToDataReadyState
bool promoteToDataReadyState(const int &slotNum, const AlgorithmNode *requestor=nullptr) const
Definition: ExecutionFlowGraph.cpp:228
concurrency::ExecutionFlowGraph::addDataNode
StatusCode addDataNode(const DataObjID &dataPath)
Add DataNode that represents DataObject.
Definition: ExecutionFlowGraph.cpp:620
std::unordered_map< std::string, unsigned int >
concurrency::State
AlgsExecutionStates::State State
Definition: ExecutionFlowGraph.h:43
concurrency::DataNode::addConsumerNode
void addConsumerNode(AlgorithmNode *node)
Associate an AlgorithmNode, which is a data consumer of this one.
Definition: ExecutionFlowGraph.h:245
concurrency::DecisionNode::promoteToControlReadyState
virtual bool promoteToControlReadyState(const int &slotNum, AlgsExecutionStates &states, std::vector< int > &node_decisions) const
XXX: CF tests. Method to set algos to CONTROLREADY, if possible.
Definition: ExecutionFlowGraph.cpp:155