| The Gaudi Framework v32r1 (f65d50dc)

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

`#include <src/PRGraph/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...
StatusCode | initialize ()
| Initialize graph. More...
void | accept (IGraphVisitor &visitor) const
| An entry point to visit all graph nodes. 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 Gaudi::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, concurrency::Concurrent, concurrency::PromptDecision, concurrency::ModeOr, concurrency::AllPass, concurrency::Inverted)
| Add a node, which has no parents. More...
DecisionNode * | getHeadNode () const
| Get head node. More...
StatusCode | addAlgorithmNode (Gaudi::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 (Gaudi::Algorithm *daughterAlgo, const std::string &parentName, concurrency::Concurrent, concurrency::PromptDecision, concurrency::ModeOr, concurrency::AllPass, concurrency::Inverted)
| 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...
void | printState (std::stringstream &output, EventSlot &slot, const unsigned int &recursionLevel) const
| Print a string representing the control flow state. More...
void | enableAnalysis ()
| BGL-based facilities. More...
PRVertexDesc | node (const std::string &) const
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 CommonMessaging< IPrecedenceRulesGraph >
MSG::Level | msgLevel () const
| get the cached level (originally extracted from the embedded MsgStream) More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const
| Backward compatibility function for getting the output level. More...
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...

## Private Attributes
DecisionNode * | m_headNode = nullptr
| the head node of the control flow graph More...
std::unordered_map< std::string, std::unique_ptr< AlgorithmNode > > | m_algoNameToAlgoNodeMap
| Index: map of algorithm's name to AlgorithmNode. More...
std::unordered_map< std::string, std::unique_ptr< DecisionNode > > | m_decisionNameToDecisionHubMap
| Index: map of decision's name to DecisionHub. More...
std::unordered_map< DataObjID, std::unique_ptr< DataNode >, DataObjID_Hasher > | m_dataPathToDataNodeMap
| Index: map of data path to DataNode. More...
std::unordered_map< std::string, DataObjIDColl > | m_algoNameToAlgoInputsMap
| Indexes: maps of algorithm's name to algorithm's inputs/outputs. More...
std::unordered_map< std::string, DataObjIDColl > | m_algoNameToAlgoOutputsMap
unsigned int | m_nodeCounter = 0
| Total number of nodes in the graph. More...
unsigned int | m_algoCounter = 0
| 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
precedence::PrecTrace | m_precTrace
| facilities for algorithm precedence tracing More...
std::map< std::string, precedence::AlgoTraceVertex > | m_prec_trace_map
bool | m_enableAnalysis {false}
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 () const
| 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 617 of file PrecedenceRulesGraph.h.

## Constructor & Destructor Documentation

## ◆ PrecedenceRulesGraph()

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

Constructor.

Definition at line 620 of file PrecedenceRulesGraph.h.

620 : m_svcLocator( svc ), m_name( name ) {
621 // make sure that CommonMessaging is initialized
622 setUpMessaging();
623 }
CommonMessaging< IPrecedenceRulesGraph >::setUpMessaging
MSG::Level setUpMessaging() const
Set up local caches.
Definition: CommonMessaging.h:169
concurrency::PrecedenceRulesGraph::m_name
const std::string m_name
Definition: PrecedenceRulesGraph.h:715
concurrency::PrecedenceRulesGraph::name
const std::string & name() const override
Retrieve name of the service.
Definition: PrecedenceRulesGraph.h:663
concurrency::PrecedenceRulesGraph::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service locator (needed to access the MessageSvc)
Definition: PrecedenceRulesGraph.h:714

## Member Function Documentation

## ◆ accept()

void concurrency::PrecedenceRulesGraph::accept | ( | IGraphVisitor & | visitor | ) | const

An entry point to visit all graph nodes.

Definition at line 479 of file PrecedenceRulesGraph.cpp.

479 {
480 // iterate through Algorithm nodes
481 for ( auto& pr : m_algoNameToAlgoNodeMap ) pr.second->accept( visitor );
482
483 // iterate through DecisionHub nodes
484 for ( auto& pr : m_decisionNameToDecisionHubMap ) pr.second->accept( visitor );
485
486 // iterate through Data [and Conditions] nodes
487 for ( auto& pr : m_dataPathToDataNodeMap ) pr.second->accept( visitor );
488 }
concurrency::PrecedenceRulesGraph::m_dataPathToDataNodeMap
std::unordered_map< DataObjID, std::unique_ptr< DataNode >, DataObjID_Hasher > m_dataPathToDataNodeMap
Index: map of data path to DataNode.
Definition: PrecedenceRulesGraph.h:703
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
std::unordered_map< std::string, std::unique_ptr< AlgorithmNode > > m_algoNameToAlgoNodeMap
Index: map of algorithm's name to AlgorithmNode.
Definition: PrecedenceRulesGraph.h:699
concurrency::PrecedenceRulesGraph::m_decisionNameToDecisionHubMap
std::unordered_map< std::string, std::unique_ptr< DecisionNode > > m_decisionNameToDecisionHubMap
Index: map of decision's name to DecisionHub.
Definition: PrecedenceRulesGraph.h:701

## ◆ addAlgorithmNode()

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

Add algorithm node.

Create new, or fetch existent, AlgorithmNode

Attach AlgorithmNode to its parent DecisionNode

Definition at line 309 of file PrecedenceRulesGraph.cpp.

310 {
311
312 StatusCode sc = StatusCode::SUCCESS;
313
315
316 auto& algoName = algo->name();
317
318 concurrency::AlgorithmNode* algoNode;
319
320 auto itA = m_algoNameToAlgoNodeMap.find( algoName );
321 if ( itA != m_algoNameToAlgoNodeMap.end() ) {
322 algoNode = itA->second.get();
323 } else {
324 auto r = m_algoNameToAlgoNodeMap.emplace(
325 algoName, std::make_unique<concurrency::AlgorithmNode>( *this, algo, m_nodeCounter, m_algoCounter, inverted,
326 allPass ) );
327 algoNode = r.first->second.get();
328
329 // Mirror AlgorithmNode in the BGL-based graph
330 if ( m_enableAnalysis ) {
331 boost::add_vertex( AlgoProps( algo, m_nodeCounter, m_algoCounter, inverted, allPass ), m_PRGraph );
332 }
333 ++m_nodeCounter;
334 ++m_algoCounter;
335 ON_VERBOSE verbose() << "AlgorithmNode '" << algoName << "' added @ " << algoNode << endmsg;
336
337 registerIODataObjects( algo );
338 }
339
341 auto itP = m_decisionNameToDecisionHubMap.find( parentName );
342 if ( itP != m_decisionNameToDecisionHubMap.end() ) {
343 auto parentNode = itP->second.get();
344
345 parentNode->addDaughterNode( algoNode );
346 algoNode->addParentNode( parentNode );
347
348 // Mirror algorithm to CF parent relationship in the BGL-based graph
349 if ( m_enableAnalysis ) boost::add_edge( node( algo->name() ), node( parentName ), m_PRGraph );
350
351 ON_VERBOSE verbose() << "Attached AlgorithmNode '" << algo->name() << "' to parent DecisionNode '" << parentName
352 << "'" << endmsg;
353 } else {
354 sc = StatusCode::FAILURE;
355 error() << "Parent DecisionNode '" << parentName << "' was not found" << endmsg;
356 }
357
358 return sc;
359 }
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
concurrency::PrecedenceRulesGraph::m_algoCounter
unsigned int m_algoCounter
Total number of algorithm nodes in the graph.
Definition: PrecedenceRulesGraph.h:711
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
std::unordered_map< std::string, std::unique_ptr< AlgorithmNode > > m_algoNameToAlgoNodeMap
Index: map of algorithm's name to AlgorithmNode.
Definition: PrecedenceRulesGraph.h:699
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:722
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:110
concurrency::PrecedenceRulesGraph::registerIODataObjects
void registerIODataObjects(const Gaudi::Algorithm *algo)
Register algorithm in the Data Dependency index.
Definition: PrecedenceRulesGraph.cpp:242
concurrency::PrecedenceRulesGraph::node
PRVertexDesc node(const std::string &) const
Definition: PrecedenceRulesGraph.cpp:470
concurrency::PrecedenceRulesGraph::m_decisionNameToDecisionHubMap
std::unordered_map< std::string, std::unique_ptr< DecisionNode > > m_decisionNameToDecisionHubMap
Index: map of decision's name to DecisionHub.
Definition: PrecedenceRulesGraph.h:701
concurrency::PrecedenceRulesGraph::m_nodeCounter
unsigned int m_nodeCounter
Total number of nodes in the graph.
Definition: PrecedenceRulesGraph.h:709
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
concurrency::AlgorithmNode
Definition: PrecedenceRulesGraph.h:475
concurrency::AlgorithmNode::addParentNode
void addParentNode(DecisionNode *node)
Add a parent node.
Definition: PrecedenceRulesGraph.cpp:181
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:192
concurrency::PrecedenceRulesGraph::m_enableAnalysis
bool m_enableAnalysis
Definition: PrecedenceRulesGraph.h:720

## ◆ addDataNode()

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

Add DataNode that represents DataObject.

Definition at line 362 of file PrecedenceRulesGraph.cpp.

362 {
363
364 auto itD = m_dataPathToDataNodeMap.find( dataPath );
365 if ( itD != m_dataPathToDataNodeMap.end() ) return StatusCode::SUCCESS;
366
367 std::unique_ptr<concurrency::DataNode> dataNode;
368 if ( !m_conditionsRealmEnabled ) {
369 dataNode = std::make_unique<concurrency::DataNode>( *this, dataPath );
370 ON_VERBOSE verbose() << " DataNode " << dataPath << " added @ " << dataNode.get() << endmsg;
371 // Mirror the action above in the BGL-based graph
372 if ( m_enableAnalysis ) boost::add_vertex( DataProps( dataPath ), m_PRGraph );
373 } else {
374 SmartIF<ICondSvc> condSvc{serviceLocator()->service( "CondSvc", false )};
375 if ( condSvc->isRegistered( dataPath ) ) {
376 dataNode = std::make_unique<concurrency::ConditionNode>( *this, dataPath, condSvc );
377 ON_VERBOSE verbose() << " ConditionNode " << dataPath << " added @ " << dataNode.get() << endmsg;
378 // Mirror the action above in the BGL-based graph
379 if ( m_enableAnalysis ) boost::add_vertex( CondDataProps( dataPath ), m_PRGraph );
380 } else {
381 dataNode = std::make_unique<concurrency::DataNode>( *this, dataPath );
382 ON_VERBOSE verbose() << " DataNode " << dataPath << " added @ " << dataNode.get() << endmsg;
383 // Mirror the action above in the BGL-based graph
384 if ( m_enableAnalysis ) boost::add_vertex( DataProps( dataPath ), m_PRGraph );
385 }
386 }
387 m_dataPathToDataNodeMap.emplace( dataPath, std::move( dataNode ) );
388 return StatusCode::SUCCESS;
389 }
SmartIF< ICondSvc >
concurrency::PrecedenceRulesGraph::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: PrecedenceRulesGraph.h:665
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
concurrency::PrecedenceRulesGraph::m_dataPathToDataNodeMap
std::unordered_map< DataObjID, std::unique_ptr< DataNode >, DataObjID_Hasher > m_dataPathToDataNodeMap
Index: map of data path to DataNode.
Definition: PrecedenceRulesGraph.h:703
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:76
concurrency::PrecedenceRulesGraph::m_conditionsRealmEnabled
bool m_conditionsRealmEnabled
Enable conditions realm of precedence rules.
Definition: PrecedenceRulesGraph.h:725
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:722
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:110
std::move
T move(T... args)
std::unique_ptr::get
T get(T... args)
std::unique_ptr< concurrency::DataNode >
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:192
concurrency::PrecedenceRulesGraph::m_enableAnalysis
bool m_enableAnalysis
Definition: PrecedenceRulesGraph.h:720

## ◆ addDecisionHubNode()

StatusCode concurrency::PrecedenceRulesGraph::addDecisionHubNode | ( | Gaudi::Algorithm * | daughterAlgo,
|  | const std::string & | parentName,
|  | concurrency::Concurrent | modeConcurrent,
|  | concurrency::PromptDecision | modePromptDecision,
|  | concurrency::ModeOr | modeOR,
|  | concurrency::AllPass | allPass,
|  | concurrency::Inverted | isInverted
| ) |  |

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

Create new, or fetch existent, DecisionNode

Attach DecisionNode to its parent DecisionNode

Definition at line 392 of file PrecedenceRulesGraph.cpp.

394 {
395
396 StatusCode sc = StatusCode::SUCCESS;
397
399
400 auto& decisionHubName = decisionHubAlgo->name();
401
402 auto itA = m_decisionNameToDecisionHubMap.find( decisionHubName );
403 concurrency::DecisionNode* decisionHubNode;
404 if ( itA != m_decisionNameToDecisionHubMap.end() ) {
405 decisionHubNode = itA->second.get();
406 } else {
407 auto r = m_decisionNameToDecisionHubMap.emplace(
408 decisionHubName,
409 std::make_unique<concurrency::DecisionNode>( *this, m_nodeCounter, decisionHubName, modeConcurrent,
410 modePromptDecision, modeOR, allPass, isInverted ) );
411 decisionHubNode = r.first->second.get();
412 // Mirror DecisionNode in the BGL-based graph
413 if ( m_enableAnalysis ) {
414 boost::add_vertex( DecisionHubProps( decisionHubName, m_nodeCounter, modeConcurrent, modePromptDecision, modeOR,
415 allPass, isInverted ),
416 m_PRGraph );
417 }
418
419 ++m_nodeCounter;
420
421 ON_VERBOSE verbose() << "DecisionNode '" << decisionHubName << "' added @ " << decisionHubNode << endmsg;
422 }
423
425 auto itP = m_decisionNameToDecisionHubMap.find( parentName );
426 if ( itP != m_decisionNameToDecisionHubMap.end() ) {
427 auto parentNode = itP->second.get();
428 parentNode->addDaughterNode( decisionHubNode );
429 decisionHubNode->addParentNode( parentNode );
430
431 // Mirror DecisionNode-to-DecisionNode relationship in the BGL-based graph
432 if ( m_enableAnalysis ) boost::add_edge( node( decisionHubName ), node( parentName ), m_PRGraph );
433
434 ON_VERBOSE verbose() << "Attached DecisionNode '" << decisionHubName << "' to parent DecisionNode '" << parentName
435 << "'" << endmsg;
436 } else {
437 sc = StatusCode::FAILURE;
438 error() << "Parent DecisionNode '" << parentName << "' was not found" << endmsg;
439 }
440
441 return sc;
442 }
concurrency::DecisionNode
Definition: PrecedenceRulesGraph.h:430
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:722
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:110
concurrency::PrecedenceRulesGraph::node
PRVertexDesc node(const std::string &) const
Definition: PrecedenceRulesGraph.cpp:470
concurrency::PrecedenceRulesGraph::m_decisionNameToDecisionHubMap
std::unordered_map< std::string, std::unique_ptr< DecisionNode > > m_decisionNameToDecisionHubMap
Index: map of decision's name to DecisionHub.
Definition: PrecedenceRulesGraph.h:701
concurrency::DecisionNode::addParentNode
void addParentNode(DecisionNode *node)
Add a parent node.
Definition: PrecedenceRulesGraph.cpp:30
concurrency::PrecedenceRulesGraph::m_nodeCounter
unsigned int m_nodeCounter
Total number of nodes in the graph.
Definition: PrecedenceRulesGraph.h:709
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
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:192
concurrency::PrecedenceRulesGraph::m_enableAnalysis
bool m_enableAnalysis
Definition: PrecedenceRulesGraph.h:720

## ◆ addEdgeToPrecTrace()

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

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

Definition at line 635 of file PrecedenceRulesGraph.cpp.

635 {
636
637 std::string u_name = u == nullptr ? "ENTRY" : u->getNodeName();
638 std::string v_name = v->getNodeName();
639
640 precedence::AlgoTraceVertex source;
641
642 if ( !u ) {
643 auto itT = m_prec_trace_map.find( "ENTRY" );
644 if ( itT != m_prec_trace_map.end() ) {
645 source = itT->second;
646 } else {
647 source = boost::add_vertex( precedence::AlgoTraceProps( "ENTRY", -1, -1, -1.0 ), m_precTrace );
648 m_prec_trace_map["ENTRY"] = source;
649 }
650 } else {
651 auto itS = m_prec_trace_map.find( u_name );
652 if ( itS != m_prec_trace_map.end() ) {
653 source = itS->second;
654 } else {
655
656 source =
657 boost::add_vertex( precedence::AlgoTraceProps( u_name, u->getAlgoIndex(), u->getRank(), -1 ), m_precTrace );
658 m_prec_trace_map[u_name] = source;
659 }
660 }
661
662 precedence::AlgoTraceVertex target;
663
664 auto itP = m_prec_trace_map.find( v_name );
665 if ( itP != m_prec_trace_map.end() ) {
666 target = itP->second;
667 } else {
668
669 target =
670 boost::add_vertex( precedence::AlgoTraceProps( v_name, v->getAlgoIndex(), v->getRank(), -1 ), m_precTrace );
671 m_prec_trace_map[v_name] = target;
672 }
673
674 boost::add_edge( source, target, m_precTrace );
675
676 ON_DEBUG debug() << u_name << "-->" << v_name << " precedence trait added" << endmsg;
677 }
concurrency::PrecedenceRulesGraph::m_precTrace
precedence::PrecTrace m_precTrace
facilities for algorithm precedence tracing
Definition: PrecedenceRulesGraph.h:718
precedence::AlgoTraceVertex
boost::graph_traits< PrecTrace >::vertex_descriptor AlgoTraceVertex
Definition: PrecedenceRulesGraph.h:51
concurrency::PrecedenceRulesGraph::m_prec_trace_map
std::map< std::string, precedence::AlgoTraceVertex > m_prec_trace_map
Definition: PrecedenceRulesGraph.h:719
precedence::AlgoTraceProps
Definition: PrecedenceRulesGraph.h:39
std::map::end
T end(T... args)
ON_DEBUG
#define ON_DEBUG
Definition: PrecedenceRulesGraph.cpp:9
std::string
STL class.
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:107
std::map::find
T find(T... args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ addHeadNode()

void concurrency::PrecedenceRulesGraph::addHeadNode | ( | const std::string & | headName,
|  | concurrency::Concurrent | modeConcurrent,
|  | concurrency::PromptDecision | modePromptDecision,
|  | concurrency::ModeOr | modeOR,
|  | concurrency::AllPass | allPass,
|  | concurrency::Inverted | isInverted
| ) |  |

Add a node, which has no parents.

Definition at line 445 of file PrecedenceRulesGraph.cpp.

447 {
448
449 auto itH = m_decisionNameToDecisionHubMap.find( headName );
450 if ( itH != m_decisionNameToDecisionHubMap.end() ) {
451 m_headNode = itH->second.get();
452 } else {
453 auto r = m_decisionNameToDecisionHubMap.emplace(
454 headName, std::make_unique<concurrency::DecisionNode>( *this, m_nodeCounter, headName, modeConcurrent,
455 modePromptDecision, modeOR, allPass, isInverted ) );
456 m_headNode = r.first->second.get();
457
458 // Mirror the action above in the BGL-based graph
459 if ( m_enableAnalysis ) {
460 boost::add_vertex( DecisionHubProps( headName, m_nodeCounter, modeConcurrent, modePromptDecision, modeOR,
461 allPass, isInverted ),
462 m_PRGraph );
463 }
464
465 ++m_nodeCounter;
466 }
467 }
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:722
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph
Definition: PrecedenceRulesGraph.h:697
concurrency::PrecedenceRulesGraph::m_decisionNameToDecisionHubMap
std::unordered_map< std::string, std::unique_ptr< DecisionNode > > m_decisionNameToDecisionHubMap
Index: map of decision's name to DecisionHub.
Definition: PrecedenceRulesGraph.h:701
concurrency::PrecedenceRulesGraph::m_nodeCounter
unsigned int m_nodeCounter
Total number of nodes in the graph.
Definition: PrecedenceRulesGraph.h:709
concurrency::PrecedenceRulesGraph::m_enableAnalysis
bool m_enableAnalysis
Definition: PrecedenceRulesGraph.h:720

## ◆ buildDataDependenciesRealm()

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

Build data dependency realm WITH data object nodes participating.

Definition at line 261 of file PrecedenceRulesGraph.cpp.

261 {
262
263 StatusCode global_sc( StatusCode::SUCCESS, true );
264
265 // Production of DataNodes by AlgorithmNodes (DataNodes are created here)
266 for ( auto& algo : m_algoNameToAlgoNodeMap ) {
267
268 auto& outputs = m_algoNameToAlgoOutputsMap[algo.first];
269 for ( auto output : outputs ) {
270 const auto sc = addDataNode( output );
271 if ( !sc.isSuccess() ) {
272 error() << "Extra producer (" << algo.first << ") for DataObject @ " << output
273 << " has been detected: this is not allowed." << endmsg;
274 global_sc = sc;
275 }
276 auto dataNode = getDataNode( output );
277 dataNode->addProducerNode( algo.second.get() );
278 algo.second->addOutputDataNode( dataNode );
279
280 // Mirror the action above in the BGL-based graph
281 if ( m_enableAnalysis )
282 boost::add_edge( node( algo.second->getNodeName() ), node( output.fullKey() ), m_PRGraph );
283 }
284 }
285
286 // Consumption of DataNodes by AlgorithmNodes
287 for ( auto& algo : m_algoNameToAlgoNodeMap ) {
288
289 for ( auto input : m_algoNameToAlgoInputsMap[algo.first] ) {
290
291 auto itP = m_dataPathToDataNodeMap.find( input );
292
293 DataNode* dataNode = ( itP != m_dataPathToDataNodeMap.end() ? getDataNode( input ) : nullptr );
294 if ( dataNode ) {
295 dataNode->addConsumerNode( algo.second.get() );
296 algo.second->addInputDataNode( dataNode );
297
298 // Mirror the action above in the BGL-based graph
299 if ( m_enableAnalysis )
300 boost::add_edge( node( input.fullKey() ), node( algo.second->getNodeName() ), m_PRGraph );
301 }
302 }
303 }
304
305 return global_sc;
306 }
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoInputsMap
std::unordered_map< std::string, DataObjIDColl > m_algoNameToAlgoInputsMap
Indexes: maps of algorithm's name to algorithm's inputs/outputs.
Definition: PrecedenceRulesGraph.h:705
gaudirun.output
output
Definition: gaudirun.py:484
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
concurrency::PrecedenceRulesGraph::addDataNode
StatusCode addDataNode(const DataObjID &dataPath)
Add DataNode that represents DataObject.
Definition: PrecedenceRulesGraph.cpp:362
concurrency::PrecedenceRulesGraph::m_dataPathToDataNodeMap
std::unordered_map< DataObjID, std::unique_ptr< DataNode >, DataObjID_Hasher > m_dataPathToDataNodeMap
Index: map of data path to DataNode.
Definition: PrecedenceRulesGraph.h:703
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
std::unordered_map< std::string, std::unique_ptr< AlgorithmNode > > m_algoNameToAlgoNodeMap
Index: map of algorithm's name to AlgorithmNode.
Definition: PrecedenceRulesGraph.h:699
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:722
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoOutputsMap
std::unordered_map< std::string, DataObjIDColl > m_algoNameToAlgoOutputsMap
Definition: PrecedenceRulesGraph.h:706
concurrency::PrecedenceRulesGraph::node
PRVertexDesc node(const std::string &) const
Definition: PrecedenceRulesGraph.cpp:470
concurrency::PrecedenceRulesGraph::getDataNode
DataNode * getDataNode(const DataObjID &dataPath) const
Get DataNode by DataObject path using graph index.
Definition: PrecedenceRulesGraph.h:634
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
concurrency::PrecedenceRulesGraph::m_enableAnalysis
bool m_enableAnalysis
Definition: PrecedenceRulesGraph.h:720

## ◆ dumpControlFlow() [1/2]

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

Print out control flow of Algorithms and Sequences.

Definition at line 501 of file PrecedenceRulesGraph.cpp.

501 {
502 std::ostringstream ost;
503 dumpControlFlow( ost, m_headNode, 0 );
504 return ost.str();
505 }
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph
Definition: PrecedenceRulesGraph.h:697
concurrency::PrecedenceRulesGraph::dumpControlFlow
std::string dumpControlFlow() const
Print out control flow of Algorithms and Sequences.
Definition: PrecedenceRulesGraph.cpp:501
std::ostringstream
STL class.
std::ostringstream::str
T str(T... args)

## ◆ dumpControlFlow() [2/2]

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

Definition at line 507 of file PrecedenceRulesGraph.cpp.

508 {
509 ost << std::string( indent * 2, ' ' );
510 DecisionNode* dn = dynamic_cast<DecisionNode*>( node );
511 AlgorithmNode* an = dynamic_cast<AlgorithmNode*>( node );
512 if ( dn != 0 ) {
513 if ( node != m_headNode ) {
514 ost << node->getNodeName() << " [Seq] ";
515 ost << ( ( dn->m_modeConcurrent ) ? " [Concurrent] " : " [Sequential] " );
516 ost << ( ( dn->m_modePromptDecision ) ? " [Prompt] " : "" );
517 ost << ( ( dn->m_modeOR ) ? " [OR] " : "" );
518 ost << ( ( dn->m_allPass ) ? " [PASS] " : "" );
519 ost << "\n";
520 }
521 for ( const auto& i : dn->getDaughters() ) dumpControlFlow( ost, i, indent + 1 );
522 } else if ( an != 0 ) {
523 ost << node->getNodeName() << " [Alg] ";
524 if ( an != 0 ) {
525 auto ar = an->getAlgorithm();
526 ost << " [n= " << ar->cardinality() << "]";
527 ost << ( ( !ar->isClonable() ) ? " [unclonable] " : "" );
528 }
529 ost << "\n";
530 }
531 }
std::string
STL class.
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph
Definition: PrecedenceRulesGraph.h:697
concurrency::PrecedenceRulesGraph::dumpControlFlow
std::string dumpControlFlow() const
Print out control flow of Algorithms and Sequences.
Definition: PrecedenceRulesGraph.cpp:501
concurrency::PrecedenceRulesGraph::node
PRVertexDesc node(const std::string &) const
Definition: PrecedenceRulesGraph.cpp:470

## ◆ dumpDataFlow()

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

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

Definition at line 534 of file PrecedenceRulesGraph.cpp.

534 {
535
536 const char idt[] = " ";
537 std::ostringstream ost;
538
539 ost << "\n" << idt << "====================================\n";
540 ost << idt << "Data origins and destinations:\n";
541 ost << idt << "====================================\n";
542
543 for ( auto& pair : m_dataPathToDataNodeMap ) {
544
545 for ( auto algoNode : pair.second->getProducers() ) ost << idt << " " << algoNode->getNodeName() << "\n";
546
547 ost << idt << " V\n";
548 ost << idt << " o " << pair.first << "\n";
549 ost << idt << " V\n";
550
551 for ( auto algoNode : pair.second->getConsumers() ) ost << idt << " " << algoNode->getNodeName() << "\n";
552
553 ost << idt << "====================================\n";
554 }
555
556 return ost.str();
557 }
concurrency::PrecedenceRulesGraph::m_dataPathToDataNodeMap
std::unordered_map< DataObjID, std::unique_ptr< DataNode >, DataObjID_Hasher > m_dataPathToDataNodeMap
Index: map of data path to DataNode.
Definition: PrecedenceRulesGraph.h:703
std::ostringstream
STL class.
std::ostringstream::str
T str(T... args)

## ◆ dumpPrecRules()

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

dump to file the precedence rules

Definition at line 561 of file PrecedenceRulesGraph.cpp.

561 {
562 boost::filesystem::ofstream myfile;
563 myfile.open( fileName, std::ios::app );
564
565 // Declare properties to dump
566 boost::dynamic_properties dp;
567
568 dp.property( "Entity",
569 boost::make_transform_value_property_map(
570 []( const VariantVertexProps& v ) {
571 return std::visit( []( const auto& w ) { return boost::lexical_cast<std::string>( w ); }, v );
572 },
573 boost::get( boost::vertex_bundle, m_PRGraph ) ) );
574
575 auto add_prop = [&]( auto name, auto&& vis ) {
576 dp.property( name, boost::make_transform_value_property_map(
577 [vis = std::forward<decltype( vis )>( vis )]( const VariantVertexProps& v ) {
578 return std::visit( vis, v );
579 },
580 boost::get( boost::vertex_bundle, m_PRGraph ) ) );
581 };
582
583 add_prop( "Name", precedence::VertexName() );
584 add_prop( "Mode", precedence::GroupMode() );
585 add_prop( "Logic", precedence::GroupLogic() );
586 add_prop( "Decision Negation", precedence::DecisionNegation() );
587 add_prop( "Negative Decision Inversion", precedence::AllPass() );
588 add_prop( "Exit Policy", precedence::GroupExit() );
589 add_prop( "Operations", precedence::Operations() );
590 add_prop( "CF Decision", precedence::CFDecision( slot ) );
591 add_prop( "State", precedence::EntityState( slot, serviceLocator(), m_conditionsRealmEnabled ) );
592 add_prop( "Start Time (Epoch ns)", precedence::StartTime( slot, serviceLocator() ) );
593 add_prop( "End Time (Epoch ns)", precedence::EndTime( slot, serviceLocator() ) );
594 add_prop( "Runtime (ns)", precedence::Duration( slot, serviceLocator() ) );
595
596 boost::write_graphml( myfile, m_PRGraph, dp );
597
598 myfile.close();
599 }
precedence::CFDecision
Definition: PrecedenceRulesGraph.h:172
precedence::GroupMode
Definition: PrecedenceRulesGraph.h:128
precedence::Duration
Definition: PrecedenceRulesGraph.h:328
concurrency::PrecedenceRulesGraph::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: PrecedenceRulesGraph.h:665
concurrency::PrecedenceRulesGraph::m_conditionsRealmEnabled
bool m_conditionsRealmEnabled
Enable conditions realm of precedence rules.
Definition: PrecedenceRulesGraph.h:725
precedence::GroupExit
Definition: PrecedenceRulesGraph.h:146
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:722
precedence::EndTime
Definition: PrecedenceRulesGraph.h:289
precedence::VertexName
Definition: PrecedenceRulesGraph.h:120
precedence::EntityState
Definition: PrecedenceRulesGraph.h:188
precedence::StartTime
Definition: PrecedenceRulesGraph.h:249
Gaudi::Functional::details::get
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
Definition: FunctionalDetails.h:332
precedence::DecisionNegation
Definition: PrecedenceRulesGraph.h:156
precedence::Operations
Definition: PrecedenceRulesGraph.h:366
concurrency::PrecedenceRulesGraph::name
const std::string & name() const override
Retrieve name of the service.
Definition: PrecedenceRulesGraph.h:663
precedence::GroupLogic
Definition: PrecedenceRulesGraph.h:138
precedence::AllPass
Definition: PrecedenceRulesGraph.h:164
std::forward
T forward(T... args)
precedence::VariantVertexProps
std::variant< AlgoProps, DecisionHubProps, DataProps, CondDataProps > VariantVertexProps
Definition: PrecedenceRulesGraph.h:381

## ◆ dumpPrecTrace()

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

dump to file the precedence trace

Definition at line 602 of file PrecedenceRulesGraph.cpp.

602 {
603 boost::filesystem::ofstream myfile;
604 myfile.open( fileName, std::ios::app );
605
606 // Fill runtimes (as this could not be done on the fly during trace assembling)
607 SmartIF<ITimelineSvc> timelineSvc = m_svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
608 if ( !timelineSvc.isValid() ) {
609 warning() << "Failed to get the TimelineSvc, timing will not be added to "
610 << "the task precedence trace dump" << endmsg;
611 } else {
612
613 for ( auto vp = vertices( m_precTrace ); vp.first != vp.second; ++vp.first ) {
614 TimelineEvent te{};
615 te.algorithm = m_precTrace[*vp.first].m_name;
616 timelineSvc->getTimelineEvent( te );
617 int runtime = std::chrono::duration_cast<std::chrono::microseconds>( te.end - te.start ).count();
618 m_precTrace[*vp.first].m_runtime = runtime;
619 }
620 }
621
622 // Declare properties to dump
623 boost::dynamic_properties dp;
624 using boost::get;
625 using precedence::AlgoTraceProps;
626 dp.property( "Name", get( &AlgoTraceProps::m_name, m_precTrace ) );
627 dp.property( "Rank", get( &AlgoTraceProps::m_rank, m_precTrace ) );
628 dp.property( "Runtime", get( &AlgoTraceProps::m_runtime, m_precTrace ) );
629
630 boost::write_graphml( myfile, m_precTrace, dp );
631
632 myfile.close();
633 }
SmartIF< ITimelineSvc >
concurrency::PrecedenceRulesGraph::m_precTrace
precedence::PrecTrace m_precTrace
facilities for algorithm precedence tracing
Definition: PrecedenceRulesGraph.h:718
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:101
SmartIF::isValid
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:62
ITimelineSvc::getTimelineEvent
virtual bool getTimelineEvent(TimelineEvent &) const =0
TimelineEvent::algorithm
std::string algorithm
Definition: ITimelineSvc.h:21
precedence::AlgoTraceProps
Definition: PrecedenceRulesGraph.h:39
TimelineEvent
Definition: ITimelineSvc.h:13
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:76
ITimelineSvc
Definition: ITimelineSvc.h:27
Gaudi::Functional::details::get
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
Definition: FunctionalDetails.h:332
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
concurrency::PrecedenceRulesGraph::m_svcLocator
SmartIF< ISvcLocator > m_svcLocator
Service locator (needed to access the MessageSvc)
Definition: PrecedenceRulesGraph.h:714

## ◆ enableAnalysis()

void concurrency::PrecedenceRulesGraph::enableAnalysis | ( |  | ) |
| inline

BGL-based facilities.

Definition at line 679 of file PrecedenceRulesGraph.h.

679 { m_enableAnalysis = true; };
concurrency::PrecedenceRulesGraph::m_enableAnalysis
bool m_enableAnalysis
Definition: PrecedenceRulesGraph.h:720

## ◆ getAlgorithmNode()

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

Get the AlgorithmNode from by algorithm name using graph index.

Definition at line 649 of file PrecedenceRulesGraph.h.

649 {
650 return m_algoNameToAlgoNodeMap.at( algoName ).get();
651 }
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
std::unordered_map< std::string, std::unique_ptr< AlgorithmNode > > m_algoNameToAlgoNodeMap
Index: map of algorithm's name to AlgorithmNode.
Definition: PrecedenceRulesGraph.h:699

## ◆ getControlFlowNodeCounter()

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

Get total number of control flow graph nodes.

Definition at line 657 of file PrecedenceRulesGraph.h.

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

## ◆ getDataNode()

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

Get DataNode by DataObject path using graph index.

Definition at line 634 of file PrecedenceRulesGraph.h.

634 { return m_dataPathToDataNodeMap.at( dataPath ).get(); }
concurrency::PrecedenceRulesGraph::m_dataPathToDataNodeMap
std::unordered_map< DataObjID, std::unique_ptr< DataNode >, DataObjID_Hasher > m_dataPathToDataNodeMap
Index: map of data path to DataNode.
Definition: PrecedenceRulesGraph.h:703

## ◆ getHeadNode()

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

Get head node.

Definition at line 644 of file PrecedenceRulesGraph.h.

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

## ◆ initialize()

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

Initialize graph.

Definition at line 199 of file PrecedenceRulesGraph.cpp.

199 {
200 if ( serviceLocator()->existsService( "CondSvc" ) ) {
201 SmartIF<ICondSvc> condSvc{serviceLocator()->service( "CondSvc" )};
202 if ( condSvc.isValid() ) {
203 info() << "CondSvc found. DF precedence rules will be augmented with 'Conditions'" << endmsg;
204 m_conditionsRealmEnabled = true;
205 }
206 }
207
208 // Detach condition algorithms from the CF realm
209 if ( m_conditionsRealmEnabled ) {
210 SmartIF<ICondSvc> condSvc{serviceLocator()->service( "CondSvc", false )};
211 auto& condAlgs = condSvc->condAlgs();
212 for ( const auto algo : condAlgs ) {
213 auto itA = m_algoNameToAlgoNodeMap.find( algo->name() );
214 if ( itA != m_algoNameToAlgoNodeMap.end() ) {
215 concurrency::AlgorithmNode* algoNode = itA->second.get();
216 debug() << "Detaching condition algorithm '" << algo->name() << "' from the CF realm.." << endmsg;
217 for ( auto parent : algoNode->getParentDecisionHubs() ) {
218 parent->m_children.erase( std::remove( parent->m_children.begin(), parent->m_children.end(), algoNode ),
219 parent->m_children.end() );
220 // clean up also auxiliary BGL-based graph of precedence rules
221 if ( m_enableAnalysis )
222 boost::remove_edge( node( algoNode->getNodeName() ), node( parent->getNodeName() ), m_PRGraph );
223 }
224 algoNode->m_parents.clear();
225
226 } else {
227 warning() << "Algorithm '" << algo->name() << "' is not registered in the graph" << endmsg;
228 }
229 }
230 }
231
232 StatusCode sc = buildDataDependenciesRealm();
233
234 if ( !sc.isSuccess() ) error() << "Could not build the data dependency realm." << endmsg;
235
236 ON_DEBUG debug() << dumpDataFlow() << endmsg;
237
238 return sc;
239 }
SmartIF< ICondSvc >
concurrency::ControlFlowNode::getNodeName
const std::string & getNodeName() const
Get node name.
Definition: PrecedenceRulesGraph.h:420
concurrency::PrecedenceRulesGraph::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: PrecedenceRulesGraph.h:665
concurrency::AlgorithmNode::getParentDecisionHubs
const std::vector< DecisionNode * > & getParentDecisionHubs() const
Get all parent decision hubs.
Definition: PrecedenceRulesGraph.h:494
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:101
concurrency::AlgorithmNode::m_parents
std::vector< DecisionNode * > m_parents
Control flow parents of an AlgorithmNode (DecisionNodes)
Definition: PrecedenceRulesGraph.h:530
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:104
ON_DEBUG
#define ON_DEBUG
Definition: PrecedenceRulesGraph.cpp:9
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:76
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
std::unordered_map< std::string, std::unique_ptr< AlgorithmNode > > m_algoNameToAlgoNodeMap
Index: map of algorithm's name to AlgorithmNode.
Definition: PrecedenceRulesGraph.h:699
concurrency::PrecedenceRulesGraph::m_conditionsRealmEnabled
bool m_conditionsRealmEnabled
Enable conditions realm of precedence rules.
Definition: PrecedenceRulesGraph.h:725
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:98
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:722
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:107
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
concurrency::PrecedenceRulesGraph::node
PRVertexDesc node(const std::string &) const
Definition: PrecedenceRulesGraph.cpp:470
concurrency::AlgorithmNode
Definition: PrecedenceRulesGraph.h:475
concurrency::PrecedenceRulesGraph::dumpDataFlow
std::string dumpDataFlow() const
Print out all data origins and destinations, as reflected in the EF graph.
Definition: PrecedenceRulesGraph.cpp:534
concurrency::PrecedenceRulesGraph::buildDataDependenciesRealm
StatusCode buildDataDependenciesRealm()
Build data dependency realm WITH data object nodes participating.
Definition: PrecedenceRulesGraph.cpp:261
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
concurrency::PrecedenceRulesGraph::m_enableAnalysis
bool m_enableAnalysis
Definition: PrecedenceRulesGraph.h:720

## ◆ name()

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

Retrieve name of the service.

Definition at line 663 of file PrecedenceRulesGraph.h.

663 { return m_name; }
concurrency::PrecedenceRulesGraph::m_name
const std::string m_name
Definition: PrecedenceRulesGraph.h:715

## ◆ node()

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

Definition at line 470 of file PrecedenceRulesGraph.cpp.

470 {
471 auto vp = vertices( m_PRGraph );
472 auto i = std::find_if( vp.first, vp.second, [&]( const PRVertexDesc& v ) {
473 return std::visit( precedence::VertexName(), m_PRGraph[v] ) == name;
474 } );
475 return i != vp.second ? *i : PRVertexDesc{};
476 }
precedence::PRVertexDesc
boost::graph_traits< PRGraph >::vertex_descriptor PRVertexDesc
Definition: PrecedenceRulesGraph.h:383
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:722
std::find_if
T find_if(T... args)

## ◆ printState()

void concurrency::PrecedenceRulesGraph::printState | ( | std::stringstream & | output,
|  | EventSlot & | slot,
|  | const unsigned int & | recursionLevel
| ) |  | const
| inline

Print a string representing the control flow state.

Definition at line 668 of file PrecedenceRulesGraph.h.

668 {
669 if ( slot.parentSlot ) {
670 // Start at sub-slot entry point
671 m_decisionNameToDecisionHubMap.at( slot.entryPoint )->printState( output, slot, recursionLevel );
672 } else {
673 // Start at the head node for whole-event slots
674 m_headNode->printState( output, slot, recursionLevel );
675 }
676 }
EventSlot::entryPoint
std::string entryPoint
Event Views bookkeeping (TODO: optimize view bookkeeping)
Definition: EventSlot.h:84
gaudirun.output
output
Definition: gaudirun.py:484
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph
Definition: PrecedenceRulesGraph.h:697
concurrency::PrecedenceRulesGraph::m_decisionNameToDecisionHubMap
std::unordered_map< std::string, std::unique_ptr< DecisionNode > > m_decisionNameToDecisionHubMap
Index: map of decision's name to DecisionHub.
Definition: PrecedenceRulesGraph.h:701
concurrency::DecisionNode::printState
void printState(std::stringstream &output, EventSlot &slot, const unsigned int &recursionLevel) const override
Print a string representing the control flow state.
Definition: PrecedenceRulesGraph.cpp:42
EventSlot::parentSlot
EventSlot * parentSlot
Pointer to parent slot (null for top level)
Definition: EventSlot.h:86

## ◆ rankAlgorithms()

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

Rank Algorithm nodes by the number of data outputs.

Definition at line 491 of file PrecedenceRulesGraph.cpp.

491 {
492
493 info() << "Starting ranking by data outputs .. " << endmsg;
494 for ( auto& pair : m_algoNameToAlgoNodeMap ) {
495 ON_DEBUG debug() << " Ranking " << pair.first << "... " << endmsg;
496 pair.second->accept( ranker );
497 ON_DEBUG debug() << " ... rank of " << pair.first << ": " << pair.second->getRank() << endmsg;
498 }
499 }
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:104
ON_DEBUG
#define ON_DEBUG
Definition: PrecedenceRulesGraph.cpp:9
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
std::unordered_map< std::string, std::unique_ptr< AlgorithmNode > > m_algoNameToAlgoNodeMap
Index: map of algorithm's name to AlgorithmNode.
Definition: PrecedenceRulesGraph.h:699
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:107
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

## ◆ registerIODataObjects()

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

Register algorithm in the Data Dependency index.

Definition at line 242 of file PrecedenceRulesGraph.cpp.

242 {
243
244 const std::string& algoName = algo->name();
245
246 m_algoNameToAlgoInputsMap[algoName] = algo->inputDataObjs();
247 m_algoNameToAlgoOutputsMap[algoName] = algo->outputDataObjs();
248
249 ON_VERBOSE {
250 verbose() << " Inputs of " << algoName << ": ";
251 for ( auto tag : algo->inputDataObjs() ) verbose() << tag << " | ";
252 verbose() << endmsg;
253
254 verbose() << " Outputs of " << algoName << ": ";
255 for ( auto tag : algo->outputDataObjs() ) verbose() << tag << " | ";
256 verbose() << endmsg;
257 }
258 }
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoInputsMap
std::unordered_map< std::string, DataObjIDColl > m_algoNameToAlgoInputsMap
Indexes: maps of algorithm's name to algorithm's inputs/outputs.
Definition: PrecedenceRulesGraph.h:705
std::string
STL class.
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:110
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoOutputsMap
std::unordered_map< std::string, DataObjIDColl > m_algoNameToAlgoOutputsMap
Definition: PrecedenceRulesGraph.h:706
DataHandleHolderBase::outputDataObjs
const DataObjIDColl & outputDataObjs() const override
Definition: DataHandleHolderBase.h:56
ON_VERBOSE
#define ON_VERBOSE
Definition: PrecedenceRulesGraph.cpp:10
DataHandleHolderBase::inputDataObjs
const DataObjIDColl & inputDataObjs() const override
Definition: DataHandleHolderBase.h:55
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:645

## ◆ serviceLocator()

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

Retrieve pointer to service locator.

Definition at line 665 of file PrecedenceRulesGraph.h.

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

## Member Data Documentation

## ◆ m_algoCounter

unsigned int concurrency::PrecedenceRulesGraph::m_algoCounter = 0
| private

Total number of algorithm nodes in the graph.

Definition at line 711 of file PrecedenceRulesGraph.h.

## ◆ m_algoNameToAlgoInputsMap

std::unordered_map<std::string, DataObjIDColl> concurrency::PrecedenceRulesGraph::m_algoNameToAlgoInputsMap
| private

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

Definition at line 705 of file PrecedenceRulesGraph.h.

## ◆ m_algoNameToAlgoNodeMap

std::unordered_map<std::string, std::unique_ptr<AlgorithmNode> > concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
| private

Index: map of algorithm's name to AlgorithmNode.

Definition at line 699 of file PrecedenceRulesGraph.h.

## ◆ m_algoNameToAlgoOutputsMap

std::unordered_map<std::string, DataObjIDColl> concurrency::PrecedenceRulesGraph::m_algoNameToAlgoOutputsMap
| private

Definition at line 706 of file PrecedenceRulesGraph.h.

## ◆ m_conditionsRealmEnabled

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

Enable conditions realm of precedence rules.

Definition at line 725 of file PrecedenceRulesGraph.h.

## ◆ m_dataPathToDataNodeMap

std::unordered_map<DataObjID, std::unique_ptr<DataNode>, DataObjID_Hasher> concurrency::PrecedenceRulesGraph::m_dataPathToDataNodeMap
| private

Index: map of data path to DataNode.

Definition at line 703 of file PrecedenceRulesGraph.h.

## ◆ m_decisionNameToDecisionHubMap

std::unordered_map<std::string, std::unique_ptr<DecisionNode> > concurrency::PrecedenceRulesGraph::m_decisionNameToDecisionHubMap
| private

Index: map of decision's name to DecisionHub.

Definition at line 701 of file PrecedenceRulesGraph.h.

## ◆ m_enableAnalysis

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

Definition at line 720 of file PrecedenceRulesGraph.h.

## ◆ m_headNode

DecisionNode* concurrency::PrecedenceRulesGraph::m_headNode = nullptr
| private

the head node of the control flow graph

Definition at line 697 of file PrecedenceRulesGraph.h.

## ◆ m_name

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

Definition at line 715 of file PrecedenceRulesGraph.h.

## ◆ m_nodeCounter

unsigned int concurrency::PrecedenceRulesGraph::m_nodeCounter = 0
| private

Total number of nodes in the graph.

Definition at line 709 of file PrecedenceRulesGraph.h.

## ◆ m_prec_trace_map

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

Definition at line 719 of file PrecedenceRulesGraph.h.

## ◆ m_precTrace

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

facilities for algorithm precedence tracing

Definition at line 718 of file PrecedenceRulesGraph.h.

## ◆ m_PRGraph

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

BGL-based graph of precedence rules.

Definition at line 722 of file PrecedenceRulesGraph.h.

## ◆ m_svcLocator

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

Service locator (needed to access the MessageSvc)

Definition at line 714 of file PrecedenceRulesGraph.h.

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

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