| The Gaudi Framework v29r1 (5cd95fa2)

- 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::PrecedenceRulesGraph Class Reference

`#include <src/PrecedenceRulesGraph.h>`

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

## Public Member Functions
| PrecedenceRulesGraph (const std::string &name, SmartIF< ISvcLocator > svc)
| Constructor. More...
| ~PrecedenceRulesGraph () override
| Destructor. More...
StatusCode | initialize ()
| Initialize graph. More...
void | accept (const std::string &algo_name, IGraphVisitor &visitor) const
| A method to update algorithm node decision, and propagate it upwards. More...
StatusCode | addDataNode (const DataObjID &dataPath)
| Add DataNode that represents DataObject. More...
DataNode * | getDataNode (const DataObjID &dataPath) const
| Get DataNode by DataObject path using graph index. More...
void | registerIODataObjects (const Algorithm *algo)
| Register algorithm in the Data Dependency index. More...
StatusCode | buildDataDependenciesRealm ()
| Build data dependency realm WITH data object nodes participating. More...
void | addHeadNode (const std::string &headName, bool modeConcurrent, bool modePromptDecision, bool modeOR, bool allPass)
| Add a node, which has no parents. More...
DecisionNode * | getHeadNode () const
| Get head node. More...
StatusCode | addAlgorithmNode (Algorithm *daughterAlgo, const std::string &parentName, bool inverted, bool allPass)
| Add algorithm node. More...
AlgorithmNode * | getAlgorithmNode (const std::string &algoName) const
| Get the AlgorithmNode from by algorithm name using graph index. More...
StatusCode | addDecisionHubNode (Algorithm *daughterAlgo, const std::string &parentName, bool modeConcurrent, bool modePromptDecision, bool modeOR, bool allPass)
| Add a node, which aggregates decisions of direct daughter nodes. More...
unsigned int | getControlFlowNodeCounter () const
| Get total number of control flow graph nodes. More...
void | rankAlgorithms (IGraphVisitor &ranker) const
| Rank Algorithm nodes by the number of data outputs. More...
const std::string & | name () const override
| Retrieve name of the service. More...
SmartIF< ISvcLocator > & | serviceLocator () const override
| Retrieve pointer to service locator. More...
const std::chrono::system_clock::time_point | getInitTime () const
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. More...
PRVertexDesc | node (const std::string &) const
| BGL-based facilities. More...
std::string | dumpDataFlow () const
| Print out all data origins and destinations, as reflected in the EF graph. More...
std::string | dumpControlFlow () const
| Print out control flow of Algorithms and Sequences. More...
void | dumpPrecRules (const boost::filesystem::path &, const EventSlot &slot)
| dump to file the precedence rules More...
void | dumpPrecTrace (const boost::filesystem::path &)
| dump to file the precedence trace More...
void | addEdgeToPrecTrace (const AlgorithmNode *u, const AlgorithmNode *v)
| set cause-effect connection between two algorithms in the precedence trace More...
void | dumpControlFlow (std::ostringstream &, ControlFlowNode *, const int &) const
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
const 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 cached level (originally extracted 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
DecisionNode * | m_headNode
| the head node of the control flow graph More...
AlgoNodesMap | m_algoNameToAlgoNodeMap
| Index: map of algorithm's name to AlgorithmNode. More...
DecisionHubsMap | m_decisionNameToDecisionHubMap
| Index: map of decision's name to DecisionHub. More...
DataNodesMap | m_dataPathToDataNodeMap
| Index: map of data path to DataNode. More...
AlgoInputsMap | m_algoNameToAlgoInputsMap
| Indexes: maps of algorithm's name to algorithm's inputs/outputs. More...
AlgoOutputsMap | m_algoNameToAlgoOutputsMap
unsigned int | m_nodeCounter
| Total number of nodes in the graph. More...
unsigned int | m_algoCounter
| Total number of algorithm nodes in the graph. More...
SmartIF< ISvcLocator > | m_svcLocator
| Service locator (needed to access the MessageSvc) More...
const std::string | m_name
const std::chrono::system_clock::time_point | m_initTime
precedence::PrecTrace | m_precTrace
| facilities for algorithm precedence tracing More...
std::map< std::string, precedence::AlgoTraceVertex > | m_prec_trace_map
precedence::PRGraph | m_PRGraph
| BGL-based graph of precedence rules. More...
bool | m_conditionsRealmEnabled {false}
| Enable conditions realm of precedence rules. More...

## Additional Inherited Members
Public Types inherited from CommonMessaging< IPrecedenceRulesGraph >
using | base_class = CommonMessaging
Protected Member Functions inherited from CommonMessaging< IPrecedenceRulesGraph >
MSG::Level | setUpMessaging ()
| Set up local caches. More...
MSG::Level | resetMessaging ()
| Reinitialize internal states. More...
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...

## Detailed Description

Definition at line 576 of file PrecedenceRulesGraph.h.

## Constructor & Destructor Documentation

concurrency::PrecedenceRulesGraph::PrecedenceRulesGraph | ( | const std::string & | name,
|  | SmartIF< ISvcLocator > | svc
| ) |  |
| inline

Constructor.

Definition at line 580 of file PrecedenceRulesGraph.h.

581 : m_headNode( 0 )
582 , m_nodeCounter( 0 )
583 , m_algoCounter( 0 )
584 , m_svcLocator( svc )
585 , m_name( name )
586 , m_initTime( std::chrono::system_clock::now() )
587 {
588 // make sure that CommonMessaging is initialized
589 setUpMessaging();
590 }
concurrency::PrecedenceRulesGraph::m_initTime
const std::chrono::system_clock::time_point m_initTime
Definition: PrecedenceRulesGraph.h:682
concurrency::PrecedenceRulesGraph::m_algoCounter
unsigned int m_algoCounter
Total number of algorithm nodes in the graph.
Definition: PrecedenceRulesGraph.h:676
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph
Definition: PrecedenceRulesGraph.h:662
concurrency::PrecedenceRulesGraph::m_name
const std::string m_name
Definition: PrecedenceRulesGraph.h:680
std::chrono::system_clock::now
T now(T...args)
concurrency::PrecedenceRulesGraph::m_nodeCounter
unsigned int m_nodeCounter
Total number of nodes in the graph.
Definition: PrecedenceRulesGraph.h:674
CommonMessaging< IPrecedenceRulesGraph >::setUpMessaging
MSG::Level setUpMessaging()
Set up local caches.
Definition: CommonMessaging.h:166
concurrency::PrecedenceRulesGraph::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service locator (needed to access the MessageSvc)
Definition: PrecedenceRulesGraph.h:679

concurrency::PrecedenceRulesGraph::~PrecedenceRulesGraph | ( |  | ) |
| inline override

Destructor.

Definition at line 592 of file PrecedenceRulesGraph.h.

593 {
594 if ( m_headNode != 0 ) delete m_headNode;
595 }
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph
Definition: PrecedenceRulesGraph.h:662

## Member Function Documentation

void concurrency::PrecedenceRulesGraph::accept | ( | const std::string & | algo_name,
|  | IGraphVisitor & | visitor
| ) |  | const

A method to update algorithm node decision, and propagate it upwards.

Definition at line 441 of file PrecedenceRulesGraph.cpp.

442 {
443 getAlgorithmNode( algo_name )->accept( visitor );
444 }
concurrency::PrecedenceRulesGraph::getAlgorithmNode
AlgorithmNode * getAlgorithmNode(const std::string &algoName) const
Get the AlgorithmNode from by algorithm name using graph index.
Definition: PrecedenceRulesGraph.cpp:302
concurrency::AlgorithmNode::accept
bool accept(IGraphVisitor &visitor) override
Visitor entry point.
Definition: PrecedenceRulesGraph.cpp:109

StatusCode concurrency::PrecedenceRulesGraph::addAlgorithmNode | ( | Algorithm * | daughterAlgo,
|  | const std::string & | parentName,
|  | bool | inverted,
|  | bool | allPass
| ) |  |

Add algorithm node.

Definition at line 257 of file PrecedenceRulesGraph.cpp.

259 {
260
261 StatusCode sc = StatusCode::SUCCESS;
262
263 // Create new, or fetch existent, AlgorithmNode
264 auto& algoName = algo->name();
265 auto itA = m_algoNameToAlgoNodeMap.find( algoName );
266 concurrency::AlgorithmNode* algoNode;
267 if ( itA != m_algoNameToAlgoNodeMap.end() ) {
268 algoNode = itA->second;
269 } else {
270 algoNode = new concurrency::AlgorithmNode( *this, algo, m_nodeCounter, m_algoCounter, inverted, allPass );
271 ON_DEBUG
272 { // Mirror the action above in the BGL-based graph
273 auto source =
274 boost::add_vertex( AlgoProps( algo, m_nodeCounter, m_algoCounter, inverted, allPass ), m_PRGraph );
275 boost::add_edge( source, node( parentName ), m_PRGraph );
276 }
277 ++m_nodeCounter;
278 ++m_algoCounter;
279 m_algoNameToAlgoNodeMap[algoName] = algoNode;
280 ON_VERBOSE verbose() << "AlgoNode " << algoName << " added @ " << algoNode << endmsg;
281 registerIODataObjects( algo );
282 }
283
284 // Attach AlgorithmNode to its CF decision hub
285 auto itP = m_decisionNameToDecisionHubMap.find( parentName );
286 if ( itP != m_decisionNameToDecisionHubMap.end() ) {
287 auto parentNode = itP->second;
288 ON_VERBOSE verbose() << "Attaching AlgorithmNode '" << algo->name() << "' to DecisionNode '" << parentName << "'"
289 << endmsg;
290
291 parentNode->addDaughterNode( algoNode );
292 algoNode->addParentNode( parentNode );
293 } else {
294 sc = StatusCode::FAILURE;
295 error() << "Requested DecisionNode '" << parentName << "' was not found" << endmsg;
296 }
297
298 return sc;
299 }
concurrency::PrecedenceRulesGraph::node
PRVertexDesc node(const std::string &) const
BGL-based facilities.
Definition: PrecedenceRulesGraph.cpp:424
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::FAILURE
Definition: StatusCode.h:31
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
AlgoNodesMap m_algoNameToAlgoNodeMap
Index: map of algorithm&#39;s name to AlgorithmNode.
Definition: PrecedenceRulesGraph.h:664
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:118
concurrency::PrecedenceRulesGraph::m_algoCounter
unsigned int m_algoCounter
Total number of algorithm nodes in the graph.
Definition: PrecedenceRulesGraph.h:676
std::unordered_map::end
T end(T...args)
ON_DEBUG
#define ON_DEBUG
Definition: PrecedenceRulesGraph.cpp:9
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:688
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
std::unordered_map::find
T find(T...args)
concurrency::PrecedenceRulesGraph::registerIODataObjects
void registerIODataObjects(const Algorithm *algo)
Register algorithm in the Data Dependency index.
Definition: PrecedenceRulesGraph.cpp:184
concurrency::PrecedenceRulesGraph::m_nodeCounter
unsigned int m_nodeCounter
Total number of nodes in the graph.
Definition: PrecedenceRulesGraph.h:674
concurrency::AlgorithmNode
Definition: PrecedenceRulesGraph.h:413
concurrency::AlgorithmNode::addParentNode
void addParentNode(DecisionNode *node)
Add a parent node.
Definition: PrecedenceRulesGraph.cpp:121
ON_VERBOSE
#define ON_VERBOSE
Definition: PrecedenceRulesGraph.cpp:10
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
concurrency::PrecedenceRulesGraph::m_decisionNameToDecisionHubMap
DecisionHubsMap m_decisionNameToDecisionHubMap
Index: map of decision&#39;s name to DecisionHub.
Definition: PrecedenceRulesGraph.h:666

StatusCode concurrency::PrecedenceRulesGraph::addDataNode | ( | const DataObjID & | dataPath | ) |

Add DataNode that represents DataObject.

Definition at line 309 of file PrecedenceRulesGraph.cpp.

310 {
311
312 StatusCode sc;
313
314 auto itD = m_dataPathToDataNodeMap.find( dataPath );
315 concurrency::DataNode* dataNode;
316 if ( itD != m_dataPathToDataNodeMap.end() ) {
317 dataNode = itD->second;
318 sc = StatusCode::SUCCESS;
319 } else {
320 if ( !m_conditionsRealmEnabled ) {
321 dataNode = new concurrency::DataNode( *this, dataPath );
322 ON_VERBOSE verbose() << " DataNode for " << dataPath << " added @ " << dataNode << endmsg;
323 } else {
324 SmartIF<ICondSvc> condSvc{serviceLocator()->service( "CondSvc", false )};
325 if ( condSvc->isRegistered( dataPath ) ) {
326 dataNode = new concurrency::ConditionNode( *this, dataPath, condSvc );
327 ON_VERBOSE verbose() << " ConditionNode for " << dataPath << " added @ " << dataNode << endmsg;
328 } else {
329 dataNode = new concurrency::DataNode( *this, dataPath );
330 ON_VERBOSE verbose() << " DataNode for " << dataPath << " added @ " << dataNode << endmsg;
331 }
332 }
333
334 m_dataPathToDataNodeMap[dataPath] = dataNode;
335
336 sc = StatusCode::SUCCESS;
337 ON_DEBUG
338 { // Mirror the action above in the BGL-based graph
339 boost::add_vertex( DataProps( dataPath ), m_PRGraph );
340 }
341 }
342
343 return sc;
344 }
StatusCode::SUCCESS
Definition: StatusCode.h:31
SmartIF< ICondSvc >
concurrency::DataNode
Definition: PrecedenceRulesGraph.h:498
concurrency::PrecedenceRulesGraph::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: PrecedenceRulesGraph.h:633
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:118
std::unordered_map::end
T end(T...args)
ON_DEBUG
#define ON_DEBUG
Definition: PrecedenceRulesGraph.cpp:9
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
concurrency::PrecedenceRulesGraph::m_conditionsRealmEnabled
bool m_conditionsRealmEnabled
Enable conditions realm of precedence rules.
Definition: PrecedenceRulesGraph.h:691
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:688
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
std::unordered_map::find
T find(T...args)
concurrency::ConditionNode
Definition: PrecedenceRulesGraph.h:541
ON_VERBOSE
#define ON_VERBOSE
Definition: PrecedenceRulesGraph.cpp:10
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
concurrency::PrecedenceRulesGraph::m_dataPathToDataNodeMap
DataNodesMap m_dataPathToDataNodeMap
Index: map of data path to DataNode.
Definition: PrecedenceRulesGraph.h:668

StatusCode concurrency::PrecedenceRulesGraph::addDecisionHubNode | ( | Algorithm * | daughterAlgo,
|  | const std::string & | parentName,
|  | bool | modeConcurrent,
|  | bool | modePromptDecision,
|  | bool | modeOR,
|  | bool | allPass
| ) |  |

Add a node, which aggregates decisions of direct daughter nodes.

Definition at line 354 of file PrecedenceRulesGraph.cpp.

357 {
358
359 StatusCode sc = StatusCode::SUCCESS;
360
361 auto& decisionHubName = decisionHubAlgo->name();
362
363 auto itP = m_decisionNameToDecisionHubMap.find( parentName );
364 concurrency::DecisionNode* parentNode;
365 if ( itP != m_decisionNameToDecisionHubMap.end() ) {
366 parentNode = itP->second;
367 auto itA = m_decisionNameToDecisionHubMap.find( decisionHubName );
368 concurrency::DecisionNode* decisionHubNode;
369 if ( itA != m_decisionNameToDecisionHubMap.end() ) {
370 decisionHubNode = itA->second;
371 } else {
372 decisionHubNode = new concurrency::DecisionNode( *this, m_nodeCounter, decisionHubName, modeConcurrent,
373 modePromptDecision, modeOR, allPass );
374 m_decisionNameToDecisionHubMap[decisionHubName] = decisionHubNode;
375
376 ON_DEBUG
377 { // Mirror the action above in the BGL-based graph
378 auto source = boost::add_vertex(
379 DecisionHubProps( decisionHubName, m_nodeCounter, modeConcurrent, modePromptDecision, modeOR, allPass ),
380 m_PRGraph );
381 boost::add_edge( source, node( parentName ), m_PRGraph );
382 }
383
384 ++m_nodeCounter;
385
386 ON_VERBOSE verbose() << "Decision hub node " << decisionHubName << " added @ " << decisionHubNode << endmsg;
387 }
388
389 parentNode->addDaughterNode( decisionHubNode );
390 decisionHubNode->addParentNode( parentNode );
391 } else {
392 sc = StatusCode::FAILURE;
393 error() << "Decision hub node " << parentName << ", requested to be parent, is not registered." << endmsg;
394 }
395
396 return sc;
397 }
concurrency::PrecedenceRulesGraph::node
PRVertexDesc node(const std::string &) const
BGL-based facilities.
Definition: PrecedenceRulesGraph.cpp:424
StatusCode::SUCCESS
Definition: StatusCode.h:31
concurrency::DecisionNode
Definition: PrecedenceRulesGraph.h:364
StatusCode::FAILURE
Definition: StatusCode.h:31
concurrency::DecisionNode::addDaughterNode
void addDaughterNode(ControlFlowNode *node)
Add a daughter node.
Definition: PrecedenceRulesGraph.cpp:42
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:118
std::unordered_map::end
T end(T...args)
ON_DEBUG
#define ON_DEBUG
Definition: PrecedenceRulesGraph.cpp:9
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:688
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
std::unordered_map::find
T find(T...args)
concurrency::DecisionNode::addParentNode
void addParentNode(DecisionNode *node)
Add a parent node.
Definition: PrecedenceRulesGraph.cpp:35
concurrency::PrecedenceRulesGraph::m_nodeCounter
unsigned int m_nodeCounter
Total number of nodes in the graph.
Definition: PrecedenceRulesGraph.h:674
ON_VERBOSE
#define ON_VERBOSE
Definition: PrecedenceRulesGraph.cpp:10
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
concurrency::PrecedenceRulesGraph::m_decisionNameToDecisionHubMap
DecisionHubsMap m_decisionNameToDecisionHubMap
Index: map of decision&#39;s name to DecisionHub.
Definition: PrecedenceRulesGraph.h:666

void concurrency::PrecedenceRulesGraph::addEdgeToPrecTrace | ( | const AlgorithmNode * | u,
|  | const AlgorithmNode * | v
| ) |  |

set cause-effect connection between two algorithms in the precedence trace

Definition at line 649 of file PrecedenceRulesGraph.cpp.

650 {
651
652 std::string u_name = u == nullptr ? "ENTRY" : u->getNodeName();
653 std::string v_name = v->getNodeName();
654
655 precedence::AlgoTraceVertex source;
656
657 if ( u == nullptr ) {
658 auto itT = m_prec_trace_map.find( "ENTRY" );
659 if ( itT != m_prec_trace_map.end() ) {
660 source = itT->second;
661 } else {
662 source = boost::add_vertex( precedence::AlgoTraceProps( "ENTRY", -1, -1, -1.0 ), m_precTrace );
663 m_prec_trace_map["ENTRY"] = source;
664 }
665 } else {
666 auto itS = m_prec_trace_map.find( u_name );
667 if ( itS != m_prec_trace_map.end() ) {
668 source = itS->second;
669 } else {
670
671 source =
672 boost::add_vertex( precedence::AlgoTraceProps( u_name, u->getAlgoIndex(), u->getRank(), -1 ), m_precTrace );
673 m_prec_trace_map[u_name] = source;
674 }
675 }
676
677 precedence::AlgoTraceVertex target;
678
679 auto itP = m_prec_trace_map.find( v_name );
680 if ( itP != m_prec_trace_map.end() ) {
681 target = itP->second;
682 } else {
683
684 target =
685 boost::add_vertex( precedence::AlgoTraceProps( v_name, v->getAlgoIndex(), v->getRank(), -1 ), m_precTrace );
686 m_prec_trace_map[v_name] = target;
687 }
688
689 boost::add_edge( source, target, m_precTrace );
690
691 ON_DEBUG debug() << u_name << "-->" << v_name << " precedence trait added" << endmsg;
692 }
concurrency::PrecedenceRulesGraph::m_precTrace
precedence::PrecTrace m_precTrace
facilities for algorithm precedence tracing
Definition: PrecedenceRulesGraph.h:685
precedence::AlgoTraceVertex
boost::graph_traits< PrecTrace >::vertex_descriptor AlgoTraceVertex
Definition: PrecedenceRulesGraph.h:44
concurrency::PrecedenceRulesGraph::m_prec_trace_map
std::map< std::string, precedence::AlgoTraceVertex > m_prec_trace_map
Definition: PrecedenceRulesGraph.h:686
precedence::AlgoTraceProps
Definition: PrecedenceRulesGraph.h:30
std::map::end
T end(T...args)
ON_DEBUG
#define ON_DEBUG
Definition: PrecedenceRulesGraph.cpp:9
std::string
STL class.
std::map::find
T find(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

void concurrency::PrecedenceRulesGraph::addHeadNode | ( | const std::string & | headName,
|  | bool | modeConcurrent,
|  | bool | modePromptDecision,
|  | bool | modeOR,
|  | bool | allPass
| ) |  |

Add a node, which has no parents.

Definition at line 400 of file PrecedenceRulesGraph.cpp.

402 {
403
404 auto itH = m_decisionNameToDecisionHubMap.find( headName );
405 if ( itH != m_decisionNameToDecisionHubMap.end() ) {
406 m_headNode = itH->second;
407 } else {
408 m_headNode = new concurrency::DecisionNode( *this, m_nodeCounter, headName, modeConcurrent, modePromptDecision,
409 modeOR, allPass );
410 m_decisionNameToDecisionHubMap[headName] = m_headNode;
411
412 ON_DEBUG
413 { // Mirror the action above in the BGL-based graph
414 boost::add_vertex(
415 DecisionHubProps( headName, m_nodeCounter, modeConcurrent, modePromptDecision, modeOR, allPass ),
416 m_PRGraph );
417 }
418
419 ++m_nodeCounter;
420 }
421 }
concurrency::DecisionNode
Definition: PrecedenceRulesGraph.h:364
std::unordered_map::end
T end(T...args)
ON_DEBUG
#define ON_DEBUG
Definition: PrecedenceRulesGraph.cpp:9
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:688
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph
Definition: PrecedenceRulesGraph.h:662
std::unordered_map::find
T find(T...args)
concurrency::PrecedenceRulesGraph::m_nodeCounter
unsigned int m_nodeCounter
Total number of nodes in the graph.
Definition: PrecedenceRulesGraph.h:674
concurrency::PrecedenceRulesGraph::m_decisionNameToDecisionHubMap
DecisionHubsMap m_decisionNameToDecisionHubMap
Index: map of decision&#39;s name to DecisionHub.
Definition: PrecedenceRulesGraph.h:666

StatusCode concurrency::PrecedenceRulesGraph::buildDataDependenciesRealm | ( |  | ) |

Build data dependency realm WITH data object nodes participating.

Definition at line 205 of file PrecedenceRulesGraph.cpp.

206 {
207
208 StatusCode global_sc( StatusCode::SUCCESS, true );
209
210 // Production of DataNodes by AlgorithmNodes (DataNodes are created here)
211 for ( auto algo : m_algoNameToAlgoNodeMap ) {
212
213 auto& outputs = m_algoNameToAlgoOutputsMap[algo.first];
214 for ( auto output : outputs ) {
215 const auto sc = addDataNode( output );
216 if ( !sc.isSuccess() ) {
217 error() << "Extra producer (" << algo.first << ") for DataObject @ " << output
218 << " has been detected: this is not allowed." << endmsg;
219 global_sc = sc;
220 }
221 auto dataNode = getDataNode( output );
222 dataNode->addProducerNode( algo.second );
223 algo.second->addOutputDataNode( dataNode );
224 ON_DEBUG
225 { // Mirror the action above in the BGL-based graph
226 boost::add_edge( node( algo.second->getNodeName() ), node( output.fullKey() ), m_PRGraph );
227 }
228 }
229 }
230
231 // Consumption of DataNodes by AlgorithmNodes
232 for ( auto algo : m_algoNameToAlgoNodeMap ) {
233
234 for ( auto input : m_algoNameToAlgoInputsMap[algo.first] ) {
235
236 DataNode* dataNode = nullptr;
237
238 auto itP = m_dataPathToDataNodeMap.find( input );
239
240 if ( itP != m_dataPathToDataNodeMap.end() ) dataNode = getDataNode( input );
241
242 if ( dataNode ) {
243 dataNode->addConsumerNode( algo.second );
244 algo.second->addInputDataNode( dataNode );
245 ON_DEBUG
246 { // Mirror the action above in the BGL-based graph
247 boost::add_edge( node( input.fullKey() ), node( algo.second->getNodeName() ), m_PRGraph );
248 }
249 }
250 }
251 }
252
253 return global_sc;
254 }
concurrency::PrecedenceRulesGraph::node
PRVertexDesc node(const std::string &) const
BGL-based facilities.
Definition: PrecedenceRulesGraph.cpp:424
StatusCode::SUCCESS
Definition: StatusCode.h:31
gaudirun.output
output
Definition: gaudirun.py:404
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
AlgoNodesMap m_algoNameToAlgoNodeMap
Index: map of algorithm&#39;s name to AlgorithmNode.
Definition: PrecedenceRulesGraph.h:664
std::unordered_map::end
T end(T...args)
concurrency::PrecedenceRulesGraph::addDataNode
StatusCode addDataNode(const DataObjID &dataPath)
Add DataNode that represents DataObject.
Definition: PrecedenceRulesGraph.cpp:309
ON_DEBUG
#define ON_DEBUG
Definition: PrecedenceRulesGraph.cpp:9
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:688
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoOutputsMap
AlgoOutputsMap m_algoNameToAlgoOutputsMap
Definition: PrecedenceRulesGraph.h:671
concurrency::PrecedenceRulesGraph::getDataNode
DataNode * getDataNode(const DataObjID &dataPath) const
Get DataNode by DataObject path using graph index.
Definition: PrecedenceRulesGraph.cpp:347
std::unordered_map::find
T find(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoInputsMap
AlgoInputsMap m_algoNameToAlgoInputsMap
Indexes: maps of algorithm&#39;s name to algorithm&#39;s inputs/outputs.
Definition: PrecedenceRulesGraph.h:670
concurrency::PrecedenceRulesGraph::m_dataPathToDataNodeMap
DataNodesMap m_dataPathToDataNodeMap
Index: map of data path to DataNode.
Definition: PrecedenceRulesGraph.h:668
concurrency::DataNode::addConsumerNode
void addConsumerNode(AlgorithmNode *node)
Add relationship to consumer AlgorithmNode.
Definition: PrecedenceRulesGraph.h:522

std::string concurrency::PrecedenceRulesGraph::dumpControlFlow | ( |  | ) | const

Print out control flow of Algorithms and Sequences.

Definition at line 458 of file PrecedenceRulesGraph.cpp.

459 {
460 std::ostringstream ost;
461 dumpControlFlow( ost, m_headNode, 0 );
462 return ost.str();
463 }
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph
Definition: PrecedenceRulesGraph.h:662
std::ostringstream
STL class.
std::ostringstream::str
T str(T...args)
concurrency::PrecedenceRulesGraph::dumpControlFlow
std::string dumpControlFlow() const
Print out control flow of Algorithms and Sequences.
Definition: PrecedenceRulesGraph.cpp:458

void concurrency::PrecedenceRulesGraph::dumpControlFlow | ( | std::ostringstream & | ost,
|  | ControlFlowNode * | node,
|  | const int & | indent
| ) |  | const

Definition at line 465 of file PrecedenceRulesGraph.cpp.

466 {
467 ost << std::string( indent * 2, ' ' );
468 DecisionNode* dn = dynamic_cast<DecisionNode*>( node );
469 AlgorithmNode* an = dynamic_cast<AlgorithmNode*>( node );
470 if ( dn != 0 ) {
471 if ( node != m_headNode ) {
472 ost << node->getNodeName() << " [Seq] ";
473 ost << ( ( dn->m_modeConcurrent ) ? " [Concurrent] " : " [Sequential] " );
474 ost << ( ( dn->m_modePromptDecision ) ? " [Prompt] " : "" );
475 ost << ( ( dn->m_modeOR ) ? " [OR] " : "" );
476 ost << ( ( dn->m_allPass ) ? " [PASS] " : "" );
477 ost << "\n";
478 }
479 const std::vector<ControlFlowNode*>& dth = dn->getDaughters();
480 for ( std::vector<ControlFlowNode*>::const_iterator itr = dth.begin(); itr != dth.end(); ++itr ) {
481 dumpControlFlow( ost, *itr, indent + 1 );
482 }
483 } else if ( an != 0 ) {
484 ost << node->getNodeName() << " [Alg] ";
485 if ( an != 0 ) {
486 auto ar = an->getAlgorithm();
487 ost << " [n= " << ar->cardinality() << "]";
488 ost << ( ( !ar->isClonable() ) ? " [unclonable] " : "" );
489 }
490 ost << "\n";
491 }
492 }
concurrency::PrecedenceRulesGraph::node
PRVertexDesc node(const std::string &) const
BGL-based facilities.
Definition: PrecedenceRulesGraph.cpp:424
std::vector::end
T end(T...args)
std::string
STL class.
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph
Definition: PrecedenceRulesGraph.h:662
std::vector
STL class.
std::vector::begin
T begin(T...args)
concurrency::PrecedenceRulesGraph::dumpControlFlow
std::string dumpControlFlow() const
Print out control flow of Algorithms and Sequences.
Definition: PrecedenceRulesGraph.cpp:458

std::string concurrency::PrecedenceRulesGraph::dumpDataFlow | ( |  | ) | const

Print out all data origins and destinations, as reflected in the EF graph.

Definition at line 495 of file PrecedenceRulesGraph.cpp.

496 {
497
498 const char idt[] = " ";
499 std::ostringstream ost;
500
501 ost << "\n" << idt << "====================================\n";
502 ost << idt << "Data origins and destinations:\n";
503 ost << idt << "====================================\n";
504
505 for ( auto& pair : m_dataPathToDataNodeMap ) {
506
507 for ( auto algoNode : pair.second->getProducers() ) ost << idt << " " << algoNode->getNodeName() << "\n";
508
509 ost << idt << " V\n";
510 ost << idt << " o " << pair.first << "\n";
511 ost << idt << " V\n";
512
513 for ( auto algoNode : pair.second->getConsumers() ) ost << idt << " " << algoNode->getNodeName() << "\n";
514
515 ost << idt << "====================================\n";
516 }
517
518 return ost.str();
519 }
std::ostringstream
STL class.
std::ostringstream::str
T str(T...args)
concurrency::PrecedenceRulesGraph::m_dataPathToDataNodeMap
DataNodesMap m_dataPathToDataNodeMap
Index: map of data path to DataNode.
Definition: PrecedenceRulesGraph.h:668

void concurrency::PrecedenceRulesGraph::dumpPrecRules | ( | const boost::filesystem::path & | fileName,
|  | const EventSlot & | slot
| ) |  |

dump to file the precedence rules

Definition at line 523 of file PrecedenceRulesGraph.cpp.

524 {
525 boost::filesystem::ofstream myfile;
526 myfile.open( fileName, std::ios::app );
527
528 // Declare properties to dump
529 boost::dynamic_properties dp;
530
531 using boost::make_transform_value_property_map;
532 using boost::apply_visitor;
533 using boost::get;
534 using boost::vertex_bundle;
535
536 dp.property( "Entity", make_transform_value_property_map(
537 []( VariantVertexProps const& v ) { return boost::lexical_cast<std::string>( v ); },
538 get( vertex_bundle, m_PRGraph ) ) );
539
540 dp.property( "Name", make_transform_value_property_map(
541 []( VariantVertexProps const& v ) { return apply_visitor( precedence::VertexName(), v ); },
542 get( vertex_bundle, m_PRGraph ) ) );
543
544 dp.property( "Mode", make_transform_value_property_map(
545 []( VariantVertexProps const& v ) { return apply_visitor( precedence::GroupMode(), v ); },
546 get( vertex_bundle, m_PRGraph ) ) );
547
548 dp.property( "Logic",
549 make_transform_value_property_map(
550 []( VariantVertexProps const& v ) { return apply_visitor( precedence::GroupLogic(), v ); },
551 get( vertex_bundle, m_PRGraph ) ) );
552
553 dp.property( "Decision Negation",
554 make_transform_value_property_map(
555 []( VariantVertexProps const& v ) { return apply_visitor( precedence::DecisionNegation(), v ); },
556 get( vertex_bundle, m_PRGraph ) ) );
557
558 dp.property( "Negative Decision Inversion",
559 make_transform_value_property_map(
560 []( VariantVertexProps const& v ) { return apply_visitor( precedence::AllPass(), v ); },
561 get( vertex_bundle, m_PRGraph ) ) );
562
563 dp.property( "Exit Policy",
564 make_transform_value_property_map(
565 []( VariantVertexProps const& v ) { return apply_visitor( precedence::GroupExit(), v ); },
566 get( vertex_bundle, m_PRGraph ) ) );
567
568 dp.property( "Operations",
569 make_transform_value_property_map(
570 []( VariantVertexProps const& v ) { return apply_visitor( precedence::Operations(), v ); },
571 get( vertex_bundle, m_PRGraph ) ) );
572
573 dp.property( "CF Decision", make_transform_value_property_map(
574 [&slot]( VariantVertexProps const& v ) {
575 return apply_visitor( precedence::CFDecision( slot ), v );
576 },
577 get( vertex_bundle, m_PRGraph ) ) );
578
579 dp.property( "Algorithm State", make_transform_value_property_map(
580 [&slot]( VariantVertexProps const& v ) {
581 return apply_visitor( precedence::FSMState( slot ), v );
582 },
583 get( vertex_bundle, m_PRGraph ) ) );
584
585 SmartIF<ITimelineSvc> timelineSvc = m_svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
586 if ( timelineSvc.isValid() ) {
587 dp.property( "Start Time (epoch ns)", make_transform_value_property_map(
588 [&timelineSvc]( VariantVertexProps const& v ) {
589 return apply_visitor( precedence::StartTime( timelineSvc ), v );
590 },
591 get( vertex_bundle, m_PRGraph ) ) );
592 dp.property( "End Time (epoch ns)", make_transform_value_property_map(
593 [&timelineSvc]( VariantVertexProps const& v ) {
594 return apply_visitor( precedence::EndTime( timelineSvc ), v );
595 },
596 get( vertex_bundle, m_PRGraph ) ) );
597 dp.property( "Runtime (ns)", make_transform_value_property_map(
598 [&timelineSvc]( VariantVertexProps const& v ) {
599 return apply_visitor( precedence::Duration( timelineSvc ), v );
600 },
601 get( vertex_bundle, m_PRGraph ) ) );
602 } else {
603 warning() << "Failed to get the TimelineSvc, timing will not be added to "
604 << "the task precedence rules dump" << endmsg;
605 }
606
607 boost::write_graphml( myfile, m_PRGraph, dp );
608
609 myfile.close();
610 }
precedence::CFDecision
Definition: PrecedenceRulesGraph.h:163
SmartIF< ITimelineSvc >
precedence::GroupMode
Definition: PrecedenceRulesGraph.h:117
precedence::Duration
Definition: PrecedenceRulesGraph.h:267
precedence::FSMState
Definition: PrecedenceRulesGraph.h:181
std::string
STL class.
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
precedence::VariantVertexProps
boost::variant< AlgoProps, DecisionHubProps, DataProps > VariantVertexProps
Definition: PrecedenceRulesGraph.h:307
precedence::GroupExit
Definition: PrecedenceRulesGraph.h:136
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:688
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:109
precedence::EndTime
Definition: PrecedenceRulesGraph.h:240
ITimelineSvc
Definition: ITimelineSvc.h:24
precedence::VertexName
Definition: PrecedenceRulesGraph.h:109
precedence::StartTime
Definition: PrecedenceRulesGraph.h:213
GaudiPython.Persistency.get
def get(type_)
Definition: Persistency.py:29
precedence::DecisionNegation
Definition: PrecedenceRulesGraph.h:147
SmartIF::isValid
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:68
precedence::Operations
Definition: PrecedenceRulesGraph.h:293
BrunelScenarioForwardScheduler.app
app
Definition: BrunelScenarioForwardScheduler.py:147
precedence::GroupLogic
Definition: PrecedenceRulesGraph.h:128
precedence::AllPass
Definition: PrecedenceRulesGraph.h:155
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
concurrency::PrecedenceRulesGraph::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service locator (needed to access the MessageSvc)
Definition: PrecedenceRulesGraph.h:679

void concurrency::PrecedenceRulesGraph::dumpPrecTrace | ( | const boost::filesystem::path & | fileName | ) |

dump to file the precedence trace

Definition at line 613 of file PrecedenceRulesGraph.cpp.

614 {
615 boost::filesystem::ofstream myfile;
616 myfile.open( fileName, std::ios::app );
617
618 // Fill runtimes (as this could not be done on the fly during trace assembling)
619 SmartIF<ITimelineSvc> timelineSvc = m_svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
620 if ( !timelineSvc.isValid() ) {
621 warning() << "Failed to get the TimelineSvc, timing will not be added to "
622 << "the task precedence trace dump" << endmsg;
623 } else {
624
625 typedef boost::graph_traits<precedence::PRGraph>::vertex_iterator vertex_iter;
626 std::pair<vertex_iter, vertex_iter> vp;
627 for ( vp = vertices( m_precTrace ); vp.first != vp.second; ++vp.first ) {
628 TimelineEvent te{};
629 te.algorithm = m_precTrace[*vp.first].m_name;
630 timelineSvc->getTimelineEvent( te );
631 int runtime = std::chrono::duration_cast<std::chrono::nanoseconds>( te.end - te.start ).count();
632 m_precTrace[*vp.first].m_runtime = runtime;
633 }
634 }
635
636 // Declare properties to dump
637 boost::dynamic_properties dp;
638 using boost::get;
639 using precedence::AlgoTraceProps;
640 dp.property( "Name", get( &AlgoTraceProps::m_name, m_precTrace ) );
641 dp.property( "Rank", get( &AlgoTraceProps::m_rank, m_precTrace ) );
642 dp.property( "Runtime", get( &AlgoTraceProps::m_runtime, m_precTrace ) );
643
644 boost::write_graphml( myfile, m_precTrace, dp );
645
646 myfile.close();
647 }
std::chrono::nanoseconds
SmartIF< ITimelineSvc >
concurrency::PrecedenceRulesGraph::m_precTrace
precedence::PrecTrace m_precTrace
facilities for algorithm precedence tracing
Definition: PrecedenceRulesGraph.h:685
TimelineEvent::algorithm
std::string algorithm
Definition: ITimelineSvc.h:18
precedence::AlgoTraceProps
Definition: PrecedenceRulesGraph.h:30
std::chrono::duration_cast
T duration_cast(T...args)
TimelineEvent
Definition: ITimelineSvc.h:13
ITimelineSvc::getTimelineEvent
virtual void getTimelineEvent(TimelineEvent &) const =0
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:109
ITimelineSvc
Definition: ITimelineSvc.h:24
std::count
T count(T...args)
std::pair
GaudiPython.Persistency.get
def get(type_)
Definition: Persistency.py:29
SmartIF::isValid
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:68
BrunelScenarioForwardScheduler.app
app
Definition: BrunelScenarioForwardScheduler.py:147
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
concurrency::PrecedenceRulesGraph::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service locator (needed to access the MessageSvc)
Definition: PrecedenceRulesGraph.h:679

AlgorithmNode * concurrency::PrecedenceRulesGraph::getAlgorithmNode | ( | const std::string & | algoName | ) | const

Get the AlgorithmNode from by algorithm name using graph index.

Definition at line 302 of file PrecedenceRulesGraph.cpp.

303 {
304
305 return m_algoNameToAlgoNodeMap.at( algoName );
306 }
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
AlgoNodesMap m_algoNameToAlgoNodeMap
Index: map of algorithm&#39;s name to AlgorithmNode.
Definition: PrecedenceRulesGraph.h:664
std::unordered_map::at
T at(T...args)

unsigned int concurrency::PrecedenceRulesGraph::getControlFlowNodeCounter | ( |  | ) | const
| inline

Get total number of control flow graph nodes.

Definition at line 625 of file PrecedenceRulesGraph.h.

625 { return m_nodeCounter; }
concurrency::PrecedenceRulesGraph::m_nodeCounter
unsigned int m_nodeCounter
Total number of nodes in the graph.
Definition: PrecedenceRulesGraph.h:674

DataNode * concurrency::PrecedenceRulesGraph::getDataNode | ( | const DataObjID & | dataPath | ) | const

Get DataNode by DataObject path using graph index.

Definition at line 347 of file PrecedenceRulesGraph.cpp.

348 {
349
350 return m_dataPathToDataNodeMap.at( dataPath );
351 }
std::unordered_map::at
T at(T...args)
concurrency::PrecedenceRulesGraph::m_dataPathToDataNodeMap
DataNodesMap m_dataPathToDataNodeMap
Index: map of data path to DataNode.
Definition: PrecedenceRulesGraph.h:668

DecisionNode* concurrency::PrecedenceRulesGraph::getHeadNode | ( |  | ) | const
| inline

Get head node.

Definition at line 616 of file PrecedenceRulesGraph.h.

616 { return m_headNode; };
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph
Definition: PrecedenceRulesGraph.h:662

const std::chrono::system_clock::time_point concurrency::PrecedenceRulesGraph::getInitTime | ( |  | ) | const
| inline

Definition at line 635 of file PrecedenceRulesGraph.h.

635 { return m_initTime; }
concurrency::PrecedenceRulesGraph::m_initTime
const std::chrono::system_clock::time_point m_initTime
Definition: PrecedenceRulesGraph.h:682

StatusCode concurrency::PrecedenceRulesGraph::initialize | ( |  | ) |

Initialize graph.

Definition at line 142 of file PrecedenceRulesGraph.cpp.

143 {
144 if ( serviceLocator()->existsService( "CondSvc" ) ) {
145 SmartIF<ICondSvc> condSvc{serviceLocator()->service( "CondSvc" )};
146 if ( condSvc.isValid() ) {
147 info() << "CondSvc found. DF precedence rules will be augmented with 'Conditions'" << endmsg;
148 m_conditionsRealmEnabled = true;
149 }
150 }
151
152 // Detach condition algorithms from the CF realm
153 if ( m_conditionsRealmEnabled ) {
154 SmartIF<ICondSvc> condSvc{serviceLocator()->service( "CondSvc", false )};
155 auto& condAlgs = condSvc->condAlgs();
156 for ( const auto algo : condAlgs ) {
157 auto itA = m_algoNameToAlgoNodeMap.find( algo->name() );
158 concurrency::AlgorithmNode* algoNode;
159 if ( itA != m_algoNameToAlgoNodeMap.end() ) {
160 algoNode = itA->second;
161 debug() << "Detaching condition algorithm '" << algo->name() << "' from the CF realm.." << endmsg;
162 for ( auto parent : algoNode->getParentDecisionHubs() ) {
163 parent->m_children.erase( std::remove( parent->m_children.begin(), parent->m_children.end(), algoNode ),
164 parent->m_children.end() );
165 }
166 algoNode->m_parents.clear();
167
168 } else {
169 warning() << "Algorithm '" << algo->name() << "' is not registered in the graph" << endmsg;
170 }
171 }
172 }
173
174 StatusCode sc = buildDataDependenciesRealm();
175
176 if ( !sc.isSuccess() ) error() << "Could not build the data dependency realm." << endmsg;
177
178 ON_DEBUG debug() << dumpDataFlow() << endmsg;
179
180 return sc;
181 }
SmartIF< ICondSvc >
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:112
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
concurrency::PrecedenceRulesGraph::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: PrecedenceRulesGraph.h:633
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
AlgoNodesMap m_algoNameToAlgoNodeMap
Index: map of algorithm&#39;s name to AlgorithmNode.
Definition: PrecedenceRulesGraph.h:664
concurrency::AlgorithmNode::m_parents
std::vector< DecisionNode * > m_parents
Control flow parents of an AlgorithmNode (DecisionNodes)
Definition: PrecedenceRulesGraph.h:473
std::unordered_map::end
T end(T...args)
ON_DEBUG
#define ON_DEBUG
Definition: PrecedenceRulesGraph.cpp:9
concurrency::AlgorithmNode::getParentDecisionHubs
const std::vector< DecisionNode * > & getParentDecisionHubs() const
Get all parent decision hubs.
Definition: PrecedenceRulesGraph.h:436
std::remove
T remove(T...args)
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:106
concurrency::PrecedenceRulesGraph::m_conditionsRealmEnabled
bool m_conditionsRealmEnabled
Enable conditions realm of precedence rules.
Definition: PrecedenceRulesGraph.h:691
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:109
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
concurrency::PrecedenceRulesGraph::dumpDataFlow
std::string dumpDataFlow() const
Print out all data origins and destinations, as reflected in the EF graph.
Definition: PrecedenceRulesGraph.cpp:495
std::unordered_map::find
T find(T...args)
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
concurrency::AlgorithmNode
Definition: PrecedenceRulesGraph.h:413
concurrency::PrecedenceRulesGraph::buildDataDependenciesRealm
StatusCode buildDataDependenciesRealm()
Build data dependency realm WITH data object nodes participating.
Definition: PrecedenceRulesGraph.cpp:205
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

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

Retrieve name of the service.

Definition at line 631 of file PrecedenceRulesGraph.h.

631 { return m_name; }
concurrency::PrecedenceRulesGraph::m_name
const std::string m_name
Definition: PrecedenceRulesGraph.h:680

PRVertexDesc concurrency::PrecedenceRulesGraph::node | ( | const std::string & | name | ) | const

BGL-based facilities.

Definition at line 424 of file PrecedenceRulesGraph.cpp.

425 {
426
427 PRVertexDesc target{};
428
429 for ( auto vp = vertices( m_PRGraph ); vp.first != vp.second; ++vp.first ) {
430 PRVertexDesc v = *vp.first;
431 if ( boost::apply_visitor( precedence::VertexName(), m_PRGraph[v] ) == name ) {
432 target = v;
433 break;
434 }
435 }
436
437 return target;
438 }
precedence::PRVertexDesc
boost::graph_traits< PRGraph >::vertex_descriptor PRVertexDesc
Definition: PrecedenceRulesGraph.h:309
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:688
precedence::VertexName
Definition: PrecedenceRulesGraph.h:109

void concurrency::PrecedenceRulesGraph::printState | ( | std::stringstream & | output,
|  | AlgsExecutionStates & | states,
|  | const std::vector< int > & | node_decisions,
|  | const unsigned int & | recursionLevel
| ) |  | const
| inline

Print a string representing the control flow state.

Definition at line 638 of file PrecedenceRulesGraph.h.

640 {
641 m_headNode->printState( output, states, node_decisions, recursionLevel );
642 }
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph
Definition: PrecedenceRulesGraph.h:662
concurrency::DecisionNode::printState
void printState(std::stringstream &output, AlgsExecutionStates &states, const std::vector< int > &node_decisions, const unsigned int &recursionLevel) const override
Print a string representing the control flow state.
Definition: PrecedenceRulesGraph.cpp:49

void concurrency::PrecedenceRulesGraph::rankAlgorithms | ( | IGraphVisitor & | ranker | ) | const

Rank Algorithm nodes by the number of data outputs.

Definition at line 447 of file PrecedenceRulesGraph.cpp.

448 {
449
450 info() << "Starting ranking by data outputs .. " << endmsg;
451 for ( auto& pair : m_algoNameToAlgoNodeMap ) {
452 ON_DEBUG debug() << " Ranking " << pair.first << "... " << endmsg;
453 pair.second->accept( ranker );
454 ON_DEBUG debug() << " ... rank of " << pair.first << ": " << pair.second->getRank() << endmsg;
455 }
456 }
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:112
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
AlgoNodesMap m_algoNameToAlgoNodeMap
Index: map of algorithm&#39;s name to AlgorithmNode.
Definition: PrecedenceRulesGraph.h:664
ON_DEBUG
#define ON_DEBUG
Definition: PrecedenceRulesGraph.cpp:9
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:115
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

void concurrency::PrecedenceRulesGraph::registerIODataObjects | ( | const Algorithm * | algo | ) |

Register algorithm in the Data Dependency index.

Definition at line 184 of file PrecedenceRulesGraph.cpp.

185 {
186
187 const std::string& algoName = algo->name();
188
189 m_algoNameToAlgoInputsMap[algoName] = algo->inputDataObjs();
190 m_algoNameToAlgoOutputsMap[algoName] = algo->outputDataObjs();
191
192 ON_VERBOSE
193 {
194 verbose() << " Inputs of " << algoName << ": ";
195 for ( auto tag : algo->inputDataObjs() ) verbose() << tag << " | ";
196 verbose() << endmsg;
197
198 verbose() << " Outputs of " << algoName << ": ";
199 for ( auto tag : algo->outputDataObjs() ) verbose() << tag << " | ";
200 verbose() << endmsg;
201 }
202 }
Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:731
DataHandleHolderBase::outputDataObjs
const DataObjIDColl & outputDataObjs() const override
Definition: DataHandleHolderBase.h:62
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:118
std::string
STL class.
DataHandleHolderBase::inputDataObjs
const DataObjIDColl & inputDataObjs() const override
Definition: DataHandleHolderBase.h:61
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoOutputsMap
AlgoOutputsMap m_algoNameToAlgoOutputsMap
Definition: PrecedenceRulesGraph.h:671
ON_VERBOSE
#define ON_VERBOSE
Definition: PrecedenceRulesGraph.cpp:10
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoInputsMap
AlgoInputsMap m_algoNameToAlgoInputsMap
Indexes: maps of algorithm&#39;s name to algorithm&#39;s inputs/outputs.
Definition: PrecedenceRulesGraph.h:670

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

Retrieve pointer to service locator.

Definition at line 633 of file PrecedenceRulesGraph.h.

633 { return m_svcLocator; }
concurrency::PrecedenceRulesGraph::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service locator (needed to access the MessageSvc)
Definition: PrecedenceRulesGraph.h:679

## Member Data Documentation

unsigned int concurrency::PrecedenceRulesGraph::m_algoCounter
| private

Total number of algorithm nodes in the graph.

Definition at line 676 of file PrecedenceRulesGraph.h.

AlgoInputsMap concurrency::PrecedenceRulesGraph::m_algoNameToAlgoInputsMap
| private

Indexes: maps of algorithm's name to algorithm's inputs/outputs.

Definition at line 670 of file PrecedenceRulesGraph.h.

AlgoNodesMap concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
| private

Index: map of algorithm's name to AlgorithmNode.

Definition at line 664 of file PrecedenceRulesGraph.h.

AlgoOutputsMap concurrency::PrecedenceRulesGraph::m_algoNameToAlgoOutputsMap
| private

Definition at line 671 of file PrecedenceRulesGraph.h.

bool concurrency::PrecedenceRulesGraph::m_conditionsRealmEnabled {false}
| private

Enable conditions realm of precedence rules.

Definition at line 691 of file PrecedenceRulesGraph.h.

DataNodesMap concurrency::PrecedenceRulesGraph::m_dataPathToDataNodeMap
| private

Index: map of data path to DataNode.

Definition at line 668 of file PrecedenceRulesGraph.h.

DecisionHubsMap concurrency::PrecedenceRulesGraph::m_decisionNameToDecisionHubMap
| private

Index: map of decision's name to DecisionHub.

Definition at line 666 of file PrecedenceRulesGraph.h.

DecisionNode* concurrency::PrecedenceRulesGraph::m_headNode
| private

the head node of the control flow graph

Definition at line 662 of file PrecedenceRulesGraph.h.

const std::chrono::system_clock::time_point concurrency::PrecedenceRulesGraph::m_initTime
| private

Definition at line 682 of file PrecedenceRulesGraph.h.

const std::string concurrency::PrecedenceRulesGraph::m_name
| private

Definition at line 680 of file PrecedenceRulesGraph.h.

unsigned int concurrency::PrecedenceRulesGraph::m_nodeCounter
| private

Total number of nodes in the graph.

Definition at line 674 of file PrecedenceRulesGraph.h.

std::map<std::string, precedence::AlgoTraceVertex> concurrency::PrecedenceRulesGraph::m_prec_trace_map
| private

Definition at line 686 of file PrecedenceRulesGraph.h.

precedence::PrecTrace concurrency::PrecedenceRulesGraph::m_precTrace
| private

facilities for algorithm precedence tracing

Definition at line 685 of file PrecedenceRulesGraph.h.

precedence::PRGraph concurrency::PrecedenceRulesGraph::m_PRGraph
| private

BGL-based graph of precedence rules.

Definition at line 688 of file PrecedenceRulesGraph.h.

SmartIF<ISvcLocator> concurrency::PrecedenceRulesGraph::m_svcLocator
| mutable private

Service locator (needed to access the MessageSvc)

Definition at line 679 of file PrecedenceRulesGraph.h.

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

- GaudiHive/src/PrecedenceRulesGraph.h
- GaudiHive/src/PrecedenceRulesGraph.cpp