| The Gaudi Framework v28r2-patches (bc4ad17a)

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

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Attributes | List of all members
concurrency::ExecutionFlowManager Class Reference

Manage the execution flow using a graph of task precedence rules Once initialized, the graph is const and can be shared across events. More...

`#include <GaudiHive/src/ExecutionFlowManager.h>`

Inheritance diagram for concurrency::ExecutionFlowManager:
[legend]
Collaboration diagram for concurrency::ExecutionFlowManager:
[legend]

## Public Member Functions
| ExecutionFlowManager ()
| Constructor. More...
| ~ExecutionFlowManager () override=default
| Destructor. More...
StatusCode | initialize (PrecedenceRulesGraph *graph, const std::unordered_map< std::string, unsigned int > &algname_index_map)
| Initialize the control flow manager It greps the topalg list and the index map for the algo names. More...
StatusCode | initialize (PrecedenceRulesGraph *graph, const std::unordered_map< std::string, unsigned int > &algname_index_map, std::vector< EventSlot > &eventSlots, const std::string &mode)
void | simulateExecutionFlow (IGraphVisitor &visitor) const
PrecedenceRulesGraph * | getPrecedenceRulesGraph () const
| Get the flow graph instance. More...
bool | needsAlgorithmToRun (const unsigned int iAlgo) const
| A little bit silly, but who cares. ;-) More...
void | updateEventState (AlgsExecutionStates &algo_states, std::vector< int > &node_decisions) const
| Update the state of algorithms to controlready, where possible. More...
void | updateDecision (const std::string &algo_name, const int &slotNum, AlgsExecutionStates &states, std::vector< int > &node_decisions) const
void | updateEventState (AlgsExecutionStates &algo_states) const
| XXX: CF tests. More...
void | promoteToControlReadyState (AlgsExecutionStates &algo_states, std::vector< int > &node_decisions, const int &slotNum=-1) const
| XXX: CF tests. More...
bool | algoDataDependenciesSatisfied (const std::string &algo_name, const int &slotNum) const
| Check all data dependencies of an algorithm are satisfied. More...
bool | rootDecisionResolved (const std::vector< int > &node_decisions) const
| Check whether root decision was resolved. More...
void | printEventState (std::stringstream &ss, AlgsExecutionStates &states, const std::vector< int > &node_decisions, const unsigned int &recursionLevel) const
| Print the state of the control flow for a given event. More...
void | touchReadyAlgorithms (IGraphVisitor &visitor) const
| Promote all algorithms, ready to be executed, to DataReady state. More...
const std::string & | name () const override
| Retrieve name of the service. More...
SmartIF< ISvcLocator > & | serviceLocator () const override
| Retrieve pointer to service locator. More...
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...
MSG::Level | msgLevel () const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const __attribute__((deprecated))
| Backward compatibility function for getting the output level. More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...

## Private Attributes
std::string | m_name
PrecedenceRulesGraph * | m_PRGraph
| the graph of precedence rules More...

## Additional Inherited Members
Public Types inherited from CommonMessaging< IExecutionFlowManager >
using | base_class = CommonMessaging
Protected Member Functions inherited from CommonMessaging< IExecutionFlowManager >
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...

## Detailed Description

Manage the execution flow using a graph of task precedence rules Once initialized, the graph is const and can be shared across events.

Author
  Benedikt Hegner
  Illya Shapoval

Definition at line 21 of file ExecutionFlowManager.h.

## Constructor & Destructor Documentation

concurrency::ExecutionFlowManager::ExecutionFlowManager | ( |  | ) |
| inline

Constructor.

Definition at line 24 of file ExecutionFlowManager.h.

24 : m_name("ExecutionFlowManager"), m_PRGraph(0) {};
concurrency::ExecutionFlowManager::m_name
std::string m_name
Definition: ExecutionFlowManager.h:71
concurrency::ExecutionFlowManager::m_PRGraph
PrecedenceRulesGraph * m_PRGraph
the graph of precedence rules
Definition: ExecutionFlowManager.h:73

concurrency::ExecutionFlowManager::~ExecutionFlowManager | ( |  | ) |
| override default

Destructor.

## Member Function Documentation

bool concurrency::ExecutionFlowManager::algoDataDependenciesSatisfied | ( | const std::string & | algo_name,
|  | const int & | slotNum
| ) |  | const

Check all data dependencies of an algorithm are satisfied.

Definition at line 116 of file ExecutionFlowManager.cpp.

116 {
117 return m_PRGraph->getAlgorithmNode(algo_name)->dataDependenciesSatisfied(slotNum);
118 }
concurrency::AlgorithmNode::dataDependenciesSatisfied
bool dataDependenciesSatisfied(const int &slotNum) const
Method to check whether the Algorithm has its all data dependency satisfied.
Definition: PrecedenceRulesGraph.cpp:292
concurrency::PrecedenceRulesGraph::getAlgorithmNode
AlgorithmNode * getAlgorithmNode(const std::string &algoName) const
Get the AlgorithmNode from by algorithm name using graph index.
Definition: PrecedenceRulesGraph.cpp:645
concurrency::ExecutionFlowManager::m_PRGraph
PrecedenceRulesGraph * m_PRGraph
the graph of precedence rules
Definition: ExecutionFlowManager.h:73

PrecedenceRulesGraph* concurrency::ExecutionFlowManager::getPrecedenceRulesGraph | ( |  | ) | const
| inline

Get the flow graph instance.

Definition at line 38 of file ExecutionFlowManager.h.

38 {return m_PRGraph;}
concurrency::ExecutionFlowManager::m_PRGraph
PrecedenceRulesGraph * m_PRGraph
the graph of precedence rules
Definition: ExecutionFlowManager.h:73

StatusCode concurrency::ExecutionFlowManager::initialize | ( | PrecedenceRulesGraph * | graph,
|  | const std::unordered_map< std::string, unsigned int > & | algname_index_map
| ) |  |

Initialize the control flow manager It greps the topalg list and the index map for the algo names.

Definition at line 6 of file ExecutionFlowManager.cpp.

7 {
8 m_PRGraph = graph;
9 StatusCode sc = graph->initialize(algname_index_map);
10 if (!sc.isSuccess())
11 error() << "Could not initialize the flow graph." << endmsg;
12
13 return sc;
14 }
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:117
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
plotSpeedupsPyRoot.graph
graph
Definition: plotSpeedupsPyRoot.py:134
concurrency::ExecutionFlowManager::m_PRGraph
PrecedenceRulesGraph * m_PRGraph
the graph of precedence rules
Definition: ExecutionFlowManager.h:73
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode concurrency::ExecutionFlowManager::initialize | ( | PrecedenceRulesGraph * | graph,
|  | const std::unordered_map< std::string, unsigned int > & | algname_index_map,
|  | std::vector< EventSlot > & | eventSlots,
|  | const std::string & | mode
| ) |  |

Definition at line 17 of file ExecutionFlowManager.cpp.

20 {
21 m_PRGraph = graph;
22 StatusCode sc = graph->initialize(algname_index_map, eventSlots);
23 if (!sc.isSuccess()) {
24 error() << "Could not initialize the execution flow graph." << endmsg;
25 return sc;
26 }
27
28 // Rank algorithms if any known optimization mode is supplied
29 if (mode == "PCE") {
30 auto ranker = concurrency::RankerByProductConsumption();
31 m_PRGraph->rankAlgorithms(ranker);
32 } else if (mode == "COD") {
33 auto ranker = concurrency::RankerByCummulativeOutDegree();
34 m_PRGraph->rankAlgorithms(ranker);
35 } else if (mode == "E") {
36 auto ranker = concurrency::RankerByEccentricity();
37 m_PRGraph->rankAlgorithms(ranker);
38 } else if (mode == "T") {
39 auto ranker = concurrency::RankerByTiming();
40 m_PRGraph->rankAlgorithms(ranker);
41 } else if (mode == "DRE") {
42 auto ranker = concurrency::RankerByDataRealmEccentricity();
43 m_PRGraph->rankAlgorithms(ranker);
44 } else if (!mode.empty()){
45 error() << "Requested optimization mode '" << mode << "' is not known." << endmsg;
46 sc = StatusCode::FAILURE;
47 }
48
49 return sc;
50 }
std::string::empty
T empty(T...args)
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
concurrency::PrecedenceRulesGraph::rankAlgorithms
void rankAlgorithms(IGraphVisitor &ranker) const
Rank Algorithm nodes by the number of data outputs.
Definition: PrecedenceRulesGraph.cpp:747
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:117
concurrency::RankerByTiming
Definition: PRGraphVisitors.h:145
concurrency::RankerByDataRealmEccentricity
Definition: PRGraphVisitors.h:197
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
concurrency::RankerByEccentricity
Definition: PRGraphVisitors.h:171
plotSpeedupsPyRoot.graph
graph
Definition: plotSpeedupsPyRoot.py:134
concurrency::RankerByProductConsumption
Definition: PRGraphVisitors.h:91
concurrency::ExecutionFlowManager::m_PRGraph
PrecedenceRulesGraph * m_PRGraph
the graph of precedence rules
Definition: ExecutionFlowManager.h:73
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
concurrency::RankerByCummulativeOutDegree
Definition: PRGraphVisitors.h:117

const std::string& concurrency::ExecutionFlowManager::name | ( |  | ) | const
| inline override

Retrieve name of the service.

Definition at line 67 of file ExecutionFlowManager.h.

67 {return m_name;}
concurrency::ExecutionFlowManager::m_name
std::string m_name
Definition: ExecutionFlowManager.h:71

bool concurrency::ExecutionFlowManager::needsAlgorithmToRun | ( | const unsigned int | iAlgo | ) | const

A little bit silly, but who cares. ;-)

void concurrency::ExecutionFlowManager::printEventState | ( | std::stringstream & | ss,
|  | AlgsExecutionStates & | states,
|  | const std::vector< int > & | node_decisions,
|  | const unsigned int & | recursionLevel
| ) |  | const
| inline

Print the state of the control flow for a given event.

Definition at line 60 of file ExecutionFlowManager.h.

63 {m_PRGraph->printState(ss,states,node_decisions,recursionLevel);}
concurrency::PrecedenceRulesGraph::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: PrecedenceRulesGraph.h:333
concurrency::ExecutionFlowManager::m_PRGraph
PrecedenceRulesGraph * m_PRGraph
the graph of precedence rules
Definition: ExecutionFlowManager.h:73

void concurrency::ExecutionFlowManager::promoteToControlReadyState | ( | AlgsExecutionStates & | algo_states,
|  | std::vector< int > & | node_decisions,
|  | const int & | slotNum = `-1`
| ) |  | const

XXX: CF tests.

Definition at line 109 of file ExecutionFlowManager.cpp.

111 {
112 m_PRGraph->m_headNode->promoteToControlReadyState(slotNum, algo_states, node_decisions);
113 }
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph; may want to have multiple ones once supporting trigger paths...
Definition: PrecedenceRulesGraph.h:358
concurrency::DecisionNode::promoteToControlReadyState
bool promoteToControlReadyState(const int &slotNum, AlgsExecutionStates &states, std::vector< int > &node_decisions) const override
XXX: CF tests. Method to set algos to CONTROLREADY, if possible.
Definition: PrecedenceRulesGraph.cpp:170
concurrency::ExecutionFlowManager::m_PRGraph
PrecedenceRulesGraph * m_PRGraph
the graph of precedence rules
Definition: ExecutionFlowManager.h:73

bool concurrency::ExecutionFlowManager::rootDecisionResolved | ( | const std::vector< int > & | node_decisions | ) | const

Check whether root decision was resolved.

Definition at line 121 of file ExecutionFlowManager.cpp.

121 {
122
123 return (-1 != node_decisions[m_PRGraph->m_headNode->getNodeIndex()]) ? true : false;
124 }
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph; may want to have multiple ones once supporting trigger paths...
Definition: PrecedenceRulesGraph.h:358
concurrency::ControlFlowNode::getNodeIndex
const unsigned int & getNodeIndex() const
XXX: CF tests.
Definition: PrecedenceRulesGraph.h:70
concurrency::ExecutionFlowManager::m_PRGraph
PrecedenceRulesGraph * m_PRGraph
the graph of precedence rules
Definition: ExecutionFlowManager.h:73

SmartIF<ISvcLocator>& concurrency::ExecutionFlowManager::serviceLocator | ( |  | ) | const
| inline override

Retrieve pointer to service locator.

Definition at line 69 of file ExecutionFlowManager.h.

69 {return m_PRGraph->serviceLocator();}
concurrency::PrecedenceRulesGraph::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: PrecedenceRulesGraph.h:342
concurrency::ExecutionFlowManager::m_PRGraph
PrecedenceRulesGraph * m_PRGraph
the graph of precedence rules
Definition: ExecutionFlowManager.h:73

void concurrency::ExecutionFlowManager::simulateExecutionFlow | ( | IGraphVisitor & | visitor | ) | const

Definition at line 53 of file ExecutionFlowManager.cpp.

53 {
54
55 std::vector<int>& nodeDecisions = m_PRGraph->getNodeDecisions(0);
56
57 std::vector<int> fixedNodeDecisions;
58 int cntr = 0;
59 std::vector<int> counters;
60 while (!rootDecisionResolved(nodeDecisions)) {
61 cntr += 1;
62 int prevAlgosNum = visitor.m_nodesSucceeded;
63 debug() << " Proceeding with iteration #" << cntr << endmsg;
64 fixedNodeDecisions = m_PRGraph->getNodeDecisions(0);
65 m_PRGraph->m_headNode->accept(visitor);
66 if ( fixedNodeDecisions == nodeDecisions) {
67 error() << " No progress on iteration " << cntr << " detected" << endmsg;
68 debug() << nodeDecisions << endmsg;
69 break;
70 }
71 info() << " Iteration #" << cntr << " finished, total algorithms executed: " << visitor.m_nodesSucceeded << endmsg;
72
73 std::stringstream s;
74 s << cntr << ", " << (visitor.m_nodesSucceeded-prevAlgosNum) << "\n";
75
76 std::ofstream myfile;
77 myfile.open("RunSimulation.csv", std::ios::app);
78 myfile << s.str();
79 myfile.close();
80
81
82 if (visitor.m_nodesSucceeded != prevAlgosNum)
83 counters.push_back(visitor.m_nodesSucceeded);
84 }
85
86 info() << "Asymptotical concurrency speedup depth: " << (float) visitor.m_nodesSucceeded / (float) counters.size() << endmsg;
87
88 // Reset algorithm states and node decisions
89 m_PRGraph->getAlgoStates(0).reset();
90 nodeDecisions.assign(nodeDecisions.size(),-1);
91
92 }
std::ofstream::open
T open(T...args)
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:123
concurrency::PrecedenceRulesGraph::getNodeDecisions
std::vector< int > & getNodeDecisions(const int &slotNum) const
Definition: PrecedenceRulesGraph.h:348
std::stringstream
STL class.
concurrency::DecisionNode::accept
bool accept(IGraphVisitor &visitor) override
Definition: PrecedenceRulesGraph.cpp:192
std::vector::push_back
T push_back(T...args)
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:117
std::ofstream
STL class.
concurrency::ExecutionFlowManager::rootDecisionResolved
bool rootDecisionResolved(const std::vector< int > &node_decisions) const
Check whether root decision was resolved.
Definition: ExecutionFlowManager.cpp:121
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph; may want to have multiple ones once supporting trigger paths...
Definition: PrecedenceRulesGraph.h:358
std::stringstream::str
T str(T...args)
concurrency::PrecedenceRulesGraph::getAlgoStates
AlgsExecutionStates & getAlgoStates(const int &slotNum) const
Definition: PrecedenceRulesGraph.h:346
std::vector::size
T size(T...args)
std::vector::assign
T assign(T...args)
std::vector< int >
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:126
AlgsExecutionStates::reset
void reset()
Definition: AlgsExecutionStates.h:52
BrunelScenarioForwardScheduler.app
app
Definition: BrunelScenarioForwardScheduler.py:137
gaudirun.s
string s
Definition: gaudirun.py:245
concurrency::ExecutionFlowManager::m_PRGraph
PrecedenceRulesGraph * m_PRGraph
the graph of precedence rules
Definition: ExecutionFlowManager.h:73
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

void concurrency::ExecutionFlowManager::touchReadyAlgorithms | ( | IGraphVisitor & | visitor | ) | const

Promote all algorithms, ready to be executed, to DataReady state.

Definition at line 127 of file ExecutionFlowManager.cpp.

127 {
128
129 //auto& states = m_PRGraph->getAlgoStates(visitor.m_slotNum);
130 //auto& decisions = m_PRGraph->getNodeDecisions(visitor.m_slotNum);
131
132 //m_PRGraph->m_headNode->promoteToControlReadyState(slotNum,states,decisions);
133
134 m_PRGraph->m_headNode->accept(visitor);
135
136 }
concurrency::DecisionNode::accept
bool accept(IGraphVisitor &visitor) override
Definition: PrecedenceRulesGraph.cpp:192
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph; may want to have multiple ones once supporting trigger paths...
Definition: PrecedenceRulesGraph.h:358
concurrency::ExecutionFlowManager::m_PRGraph
PrecedenceRulesGraph * m_PRGraph
the graph of precedence rules
Definition: ExecutionFlowManager.h:73

void concurrency::ExecutionFlowManager::updateDecision | ( | const std::string & | algo_name,
|  | const int & | slotNum,
|  | AlgsExecutionStates & | states,
|  | std::vector< int > & | node_decisions
| ) |  | const

Definition at line 101 of file ExecutionFlowManager.cpp.

104 {
105 m_PRGraph->updateDecision(algo_name, slotNum, algo_states, node_decisions);
106 }
concurrency::PrecedenceRulesGraph::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: PrecedenceRulesGraph.cpp:738
concurrency::ExecutionFlowManager::m_PRGraph
PrecedenceRulesGraph * m_PRGraph
the graph of precedence rules
Definition: ExecutionFlowManager.h:73

void concurrency::ExecutionFlowManager::updateEventState | ( | AlgsExecutionStates & | algo_states,
|  | std::vector< int > & | node_decisions
| ) |  | const

Update the state of algorithms to controlready, where possible.

Definition at line 95 of file ExecutionFlowManager.cpp.

96 {
97 m_PRGraph->updateEventState(algo_states, node_decisions);
98 }
concurrency::PrecedenceRulesGraph::updateEventState
void updateEventState(AlgsExecutionStates &states, std::vector< int > &node_decisions) const
XXX CF tests. Is needed for older CF implementation.
Definition: PrecedenceRulesGraph.cpp:732
concurrency::ExecutionFlowManager::m_PRGraph
PrecedenceRulesGraph * m_PRGraph
the graph of precedence rules
Definition: ExecutionFlowManager.h:73

void concurrency::ExecutionFlowManager::updateEventState | ( | AlgsExecutionStates & | algo_states | ) | const

XXX: CF tests.

## Member Data Documentation

std::string concurrency::ExecutionFlowManager::m_name
| private

Definition at line 71 of file ExecutionFlowManager.h.

PrecedenceRulesGraph* concurrency::ExecutionFlowManager::m_PRGraph
| private

the graph of precedence rules

Definition at line 73 of file ExecutionFlowManager.h.

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

- GaudiHive/src/ExecutionFlowManager.h
- GaudiHive/src/ExecutionFlowManager.cpp