| The Gaudi Framework v30r0 (c919700c)

- 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, 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 (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, 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...
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...
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 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
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 ()
| 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 694 of file PrecedenceRulesGraph.h.

## Constructor & Destructor Documentation

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

Constructor.

Definition at line 698 of file PrecedenceRulesGraph.h.

699 : m_headNode( 0 )
700 , m_nodeCounter( 0 )
701 , m_algoCounter( 0 )
702 , m_svcLocator( svc )
703 , m_name( name )
704 , m_initTime( std::chrono::system_clock::now() )
705 {
706 // make sure that CommonMessaging is initialized
707 setUpMessaging();
708 }
concurrency::PrecedenceRulesGraph::m_initTime
const std::chrono::system_clock::time_point m_initTime
Definition: PrecedenceRulesGraph.h:802
concurrency::PrecedenceRulesGraph::m_algoCounter
unsigned int m_algoCounter
Total number of algorithm nodes in the graph.
Definition: PrecedenceRulesGraph.h:796
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph
Definition: PrecedenceRulesGraph.h:782
concurrency::PrecedenceRulesGraph::m_name
const std::string m_name
Definition: PrecedenceRulesGraph.h:800
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:794
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:799

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

Destructor.

Definition at line 710 of file PrecedenceRulesGraph.h.

711 {
712 if ( m_headNode != 0 ) delete m_headNode;
713 }
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph
Definition: PrecedenceRulesGraph.h:782

## 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 447 of file PrecedenceRulesGraph.cpp.

448 {
449 getAlgorithmNode( algo_name )->accept( visitor );
450 }
concurrency::PrecedenceRulesGraph::getAlgorithmNode
AlgorithmNode * getAlgorithmNode(const std::string &algoName) const
Get the AlgorithmNode from by algorithm name using graph index.
Definition: PrecedenceRulesGraph.cpp:305
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 260 of file PrecedenceRulesGraph.cpp.

262 {
263
264 StatusCode sc = StatusCode::SUCCESS;
265
266 // Create new, or fetch existent, AlgorithmNode
267 auto& algoName = algo->name();
268 auto itA = m_algoNameToAlgoNodeMap.find( algoName );
269 concurrency::AlgorithmNode* algoNode;
270 if ( itA != m_algoNameToAlgoNodeMap.end() ) {
271 algoNode = itA->second;
272 } else {
273 algoNode = new concurrency::AlgorithmNode( *this, algo, m_nodeCounter, m_algoCounter, inverted, allPass );
274 // Mirror the action above in the BGL-based graph
275 if ( m_enableAnalysis ) {
276 auto source =
277 boost::add_vertex( AlgoProps( algo, m_nodeCounter, m_algoCounter, inverted, allPass ), m_PRGraph );
278 boost::add_edge( source, node( parentName ), m_PRGraph );
279 }
280 ++m_nodeCounter;
281 ++m_algoCounter;
282 m_algoNameToAlgoNodeMap[algoName] = algoNode;
283 ON_VERBOSE verbose() << "AlgoNode " << algoName << " added @ " << algoNode << endmsg;
284 registerIODataObjects( algo );
285 }
286
287 // Attach AlgorithmNode to its CF decision hub
288 auto itP = m_decisionNameToDecisionHubMap.find( parentName );
289 if ( itP != m_decisionNameToDecisionHubMap.end() ) {
290 auto parentNode = itP->second;
291 ON_VERBOSE verbose() << "Attaching AlgorithmNode '" << algo->name() << "' to DecisionNode '" << parentName << "'"
292 << endmsg;
293
294 parentNode->addDaughterNode( algoNode );
295 algoNode->addParentNode( parentNode );
296 } else {
297 sc = StatusCode::FAILURE;
298 error() << "Requested DecisionNode '" << parentName << "' was not found" << endmsg;
299 }
300
301 return sc;
302 }
StatusCode::SUCCESS
Definition: StatusCode.h:29
concurrency::PrecedenceRulesGraph::node
PRVertexDesc node(const std::string &) const
Definition: PrecedenceRulesGraph.cpp:430
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
AlgoNodesMap m_algoNameToAlgoNodeMap
Index: map of algorithm&#39;s name to AlgorithmNode.
Definition: PrecedenceRulesGraph.h:784
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:796
std::unordered_map::end
T end(T...args)
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:809
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
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:187
concurrency::PrecedenceRulesGraph::m_nodeCounter
unsigned int m_nodeCounter
Total number of nodes in the graph.
Definition: PrecedenceRulesGraph.h:794
concurrency::AlgorithmNode
Definition: PrecedenceRulesGraph.h:531
concurrency::AlgorithmNode::addParentNode
void addParentNode(DecisionNode *node)
Add a parent node.
Definition: PrecedenceRulesGraph.cpp:121
ON_VERBOSE
#define ON_VERBOSE
Definition: PrecedenceRulesGraph.cpp:10
StatusCode::FAILURE
Definition: StatusCode.h:29
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
concurrency::PrecedenceRulesGraph::m_enableAnalysis
bool m_enableAnalysis
Definition: PrecedenceRulesGraph.h:807
concurrency::PrecedenceRulesGraph::m_decisionNameToDecisionHubMap
DecisionHubsMap m_decisionNameToDecisionHubMap
Index: map of decision&#39;s name to DecisionHub.
Definition: PrecedenceRulesGraph.h:786

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

Add DataNode that represents DataObject.

Definition at line 312 of file PrecedenceRulesGraph.cpp.

313 {
314
315 StatusCode sc;
316
317 auto itD = m_dataPathToDataNodeMap.find( dataPath );
318 concurrency::DataNode* dataNode;
319 if ( itD != m_dataPathToDataNodeMap.end() ) {
320 dataNode = itD->second;
321 sc = StatusCode::SUCCESS;
322 } else {
323 if ( !m_conditionsRealmEnabled ) {
324 dataNode = new concurrency::DataNode( *this, dataPath );
325 ON_VERBOSE verbose() << " DataNode for " << dataPath << " added @ " << dataNode << endmsg;
326 // Mirror the action above in the BGL-based graph
327 if ( m_enableAnalysis ) boost::add_vertex( DataProps( dataPath ), m_PRGraph );
328 } else {
329 SmartIF<ICondSvc> condSvc{serviceLocator()->service( "CondSvc", false )};
330 if ( condSvc->isRegistered( dataPath ) ) {
331 dataNode = new concurrency::ConditionNode( *this, dataPath, condSvc );
332 ON_VERBOSE verbose() << " ConditionNode for " << dataPath << " added @ " << dataNode << endmsg;
333 // Mirror the action above in the BGL-based graph
334 if ( m_enableAnalysis ) boost::add_vertex( CondDataProps( dataPath ), m_PRGraph );
335 } else {
336 dataNode = new concurrency::DataNode( *this, dataPath );
337 ON_VERBOSE verbose() << " DataNode for " << dataPath << " added @ " << dataNode << endmsg;
338 // Mirror the action above in the BGL-based graph
339 if ( m_enableAnalysis ) boost::add_vertex( DataProps( dataPath ), m_PRGraph );
340 }
341 }
342
343 m_dataPathToDataNodeMap[dataPath] = dataNode;
344
345 sc = StatusCode::SUCCESS;
346 }
347
348 return sc;
349 }
StatusCode::SUCCESS
Definition: StatusCode.h:29
SmartIF< ICondSvc >
concurrency::DataNode
Definition: PrecedenceRulesGraph.h:616
concurrency::PrecedenceRulesGraph::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: PrecedenceRulesGraph.h:752
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:118
std::unordered_map::end
T end(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
concurrency::PrecedenceRulesGraph::m_conditionsRealmEnabled
bool m_conditionsRealmEnabled
Enable conditions realm of precedence rules.
Definition: PrecedenceRulesGraph.h:812
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:809
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
std::unordered_map::find
T find(T...args)
concurrency::ConditionNode
Definition: PrecedenceRulesGraph.h:659
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_enableAnalysis
bool m_enableAnalysis
Definition: PrecedenceRulesGraph.h:807
concurrency::PrecedenceRulesGraph::m_dataPathToDataNodeMap
DataNodesMap m_dataPathToDataNodeMap
Index: map of data path to DataNode.
Definition: PrecedenceRulesGraph.h:788

StatusCode concurrency::PrecedenceRulesGraph::addDecisionHubNode | ( | 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.

Definition at line 359 of file PrecedenceRulesGraph.cpp.

362 {
363
364 StatusCode sc = StatusCode::SUCCESS;
365
366 auto& decisionHubName = decisionHubAlgo->name();
367
368 auto itP = m_decisionNameToDecisionHubMap.find( parentName );
369 concurrency::DecisionNode* parentNode;
370 if ( itP != m_decisionNameToDecisionHubMap.end() ) {
371 parentNode = itP->second;
372 auto itA = m_decisionNameToDecisionHubMap.find( decisionHubName );
373 concurrency::DecisionNode* decisionHubNode;
374 if ( itA != m_decisionNameToDecisionHubMap.end() ) {
375 decisionHubNode = itA->second;
376 } else {
377 decisionHubNode = new concurrency::DecisionNode( *this, m_nodeCounter, decisionHubName, modeConcurrent,
378 modePromptDecision, modeOR, allPass, isInverted );
379 m_decisionNameToDecisionHubMap[decisionHubName] = decisionHubNode;
380
381 // Mirror the action above in the BGL-based graph
382 if ( m_enableAnalysis ) {
383 auto source = boost::add_vertex( DecisionHubProps( decisionHubName, m_nodeCounter, modeConcurrent,
384 modePromptDecision, modeOR, allPass, isInverted ),
385 m_PRGraph );
386 boost::add_edge( source, node( parentName ), m_PRGraph );
387 }
388
389 ++m_nodeCounter;
390
391 ON_VERBOSE verbose() << "Decision hub node " << decisionHubName << " added @ " << decisionHubNode << endmsg;
392 }
393
394 parentNode->addDaughterNode( decisionHubNode );
395 decisionHubNode->addParentNode( parentNode );
396 } else {
397 sc = StatusCode::FAILURE;
398 error() << "Decision hub node " << parentName << ", requested to be parent, is not registered." << endmsg;
399 }
400
401 return sc;
402 }
StatusCode::SUCCESS
Definition: StatusCode.h:29
concurrency::PrecedenceRulesGraph::node
PRVertexDesc node(const std::string &) const
Definition: PrecedenceRulesGraph.cpp:430
concurrency::DecisionNode
Definition: PrecedenceRulesGraph.h:478
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)
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:809
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
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:794
ON_VERBOSE
#define ON_VERBOSE
Definition: PrecedenceRulesGraph.cpp:10
StatusCode::FAILURE
Definition: StatusCode.h:29
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
concurrency::PrecedenceRulesGraph::m_enableAnalysis
bool m_enableAnalysis
Definition: PrecedenceRulesGraph.h:807
concurrency::PrecedenceRulesGraph::m_decisionNameToDecisionHubMap
DecisionHubsMap m_decisionNameToDecisionHubMap
Index: map of decision&#39;s name to DecisionHub.
Definition: PrecedenceRulesGraph.h:786

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

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

Definition at line 651 of file PrecedenceRulesGraph.cpp.

652 {
653
654 std::string u_name = u == nullptr ? "ENTRY" : u->getNodeName();
655 std::string v_name = v->getNodeName();
656
657 precedence::AlgoTraceVertex source;
658
659 if ( u == nullptr ) {
660 auto itT = m_prec_trace_map.find( "ENTRY" );
661 if ( itT != m_prec_trace_map.end() ) {
662 source = itT->second;
663 } else {
664 source = boost::add_vertex( precedence::AlgoTraceProps( "ENTRY", -1, -1, -1.0 ), m_precTrace );
665 m_prec_trace_map["ENTRY"] = source;
666 }
667 } else {
668 auto itS = m_prec_trace_map.find( u_name );
669 if ( itS != m_prec_trace_map.end() ) {
670 source = itS->second;
671 } else {
672
673 source =
674 boost::add_vertex( precedence::AlgoTraceProps( u_name, u->getAlgoIndex(), u->getRank(), -1 ), m_precTrace );
675 m_prec_trace_map[u_name] = source;
676 }
677 }
678
679 precedence::AlgoTraceVertex target;
680
681 auto itP = m_prec_trace_map.find( v_name );
682 if ( itP != m_prec_trace_map.end() ) {
683 target = itP->second;
684 } else {
685
686 target =
687 boost::add_vertex( precedence::AlgoTraceProps( v_name, v->getAlgoIndex(), v->getRank(), -1 ), m_precTrace );
688 m_prec_trace_map[v_name] = target;
689 }
690
691 boost::add_edge( source, target, m_precTrace );
692
693 ON_DEBUG debug() << u_name << "-->" << v_name << " precedence trait added" << endmsg;
694 }
concurrency::PrecedenceRulesGraph::m_precTrace
precedence::PrecTrace m_precTrace
facilities for algorithm precedence tracing
Definition: PrecedenceRulesGraph.h:805
precedence::AlgoTraceVertex
boost::graph_traits< PrecTrace >::vertex_descriptor AlgoTraceVertex
Definition: PrecedenceRulesGraph.h:56
concurrency::PrecedenceRulesGraph::m_prec_trace_map
std::map< std::string, precedence::AlgoTraceVertex > m_prec_trace_map
Definition: PrecedenceRulesGraph.h:806
precedence::AlgoTraceProps
Definition: PrecedenceRulesGraph.h:42
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,
|  | 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 405 of file PrecedenceRulesGraph.cpp.

408 {
409
410 auto itH = m_decisionNameToDecisionHubMap.find( headName );
411 if ( itH != m_decisionNameToDecisionHubMap.end() ) {
412 m_headNode = itH->second;
413 } else {
414 m_headNode = new concurrency::DecisionNode( *this, m_nodeCounter, headName, modeConcurrent, modePromptDecision,
415 modeOR, allPass, isInverted );
416 m_decisionNameToDecisionHubMap[headName] = m_headNode;
417
418 // Mirror the action above in the BGL-based graph
419 if ( m_enableAnalysis ) {
420 boost::add_vertex( DecisionHubProps( headName, m_nodeCounter, modeConcurrent, modePromptDecision, modeOR,
421 allPass, isInverted ),
422 m_PRGraph );
423 }
424
425 ++m_nodeCounter;
426 }
427 }
concurrency::DecisionNode
Definition: PrecedenceRulesGraph.h:478
std::unordered_map::end
T end(T...args)
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:809
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph
Definition: PrecedenceRulesGraph.h:782
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:794
concurrency::PrecedenceRulesGraph::m_enableAnalysis
bool m_enableAnalysis
Definition: PrecedenceRulesGraph.h:807
concurrency::PrecedenceRulesGraph::m_decisionNameToDecisionHubMap
DecisionHubsMap m_decisionNameToDecisionHubMap
Index: map of decision&#39;s name to DecisionHub.
Definition: PrecedenceRulesGraph.h:786

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

Build data dependency realm WITH data object nodes participating.

Definition at line 208 of file PrecedenceRulesGraph.cpp.

209 {
210
211 StatusCode global_sc( StatusCode::SUCCESS, true );
212
213 // Production of DataNodes by AlgorithmNodes (DataNodes are created here)
214 for ( auto algo : m_algoNameToAlgoNodeMap ) {
215
216 auto& outputs = m_algoNameToAlgoOutputsMap[algo.first];
217 for ( auto output : outputs ) {
218 const auto sc = addDataNode( output );
219 if ( !sc.isSuccess() ) {
220 error() << "Extra producer (" << algo.first << ") for DataObject @ " << output
221 << " has been detected: this is not allowed." << endmsg;
222 global_sc = sc;
223 }
224 auto dataNode = getDataNode( output );
225 dataNode->addProducerNode( algo.second );
226 algo.second->addOutputDataNode( dataNode );
227
228 // Mirror the action above in the BGL-based graph
229 if ( m_enableAnalysis )
230 boost::add_edge( node( algo.second->getNodeName() ), node( output.fullKey() ), m_PRGraph );
231 }
232 }
233
234 // Consumption of DataNodes by AlgorithmNodes
235 for ( auto algo : m_algoNameToAlgoNodeMap ) {
236
237 for ( auto input : m_algoNameToAlgoInputsMap[algo.first] ) {
238
239 DataNode* dataNode = nullptr;
240
241 auto itP = m_dataPathToDataNodeMap.find( input );
242
243 if ( itP != m_dataPathToDataNodeMap.end() ) dataNode = getDataNode( input );
244
245 if ( dataNode ) {
246 dataNode->addConsumerNode( algo.second );
247 algo.second->addInputDataNode( dataNode );
248
249 // Mirror the action above in the BGL-based graph
250 if ( m_enableAnalysis )
251 boost::add_edge( node( input.fullKey() ), node( algo.second->getNodeName() ), m_PRGraph );
252 }
253 }
254 }
255
256 return global_sc;
257 }
StatusCode::SUCCESS
Definition: StatusCode.h:29
concurrency::PrecedenceRulesGraph::node
PRVertexDesc node(const std::string &) const
Definition: PrecedenceRulesGraph.cpp:430
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:784
std::unordered_map::end
T end(T...args)
concurrency::PrecedenceRulesGraph::addDataNode
StatusCode addDataNode(const DataObjID &dataPath)
Add DataNode that represents DataObject.
Definition: PrecedenceRulesGraph.cpp:312
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:809
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoOutputsMap
AlgoOutputsMap m_algoNameToAlgoOutputsMap
Definition: PrecedenceRulesGraph.h:791
concurrency::PrecedenceRulesGraph::getDataNode
DataNode * getDataNode(const DataObjID &dataPath) const
Get DataNode by DataObject path using graph index.
Definition: PrecedenceRulesGraph.cpp:352
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_enableAnalysis
bool m_enableAnalysis
Definition: PrecedenceRulesGraph.h:807
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoInputsMap
AlgoInputsMap m_algoNameToAlgoInputsMap
Indexes: maps of algorithm&#39;s name to algorithm&#39;s inputs/outputs.
Definition: PrecedenceRulesGraph.h:790
concurrency::PrecedenceRulesGraph::m_dataPathToDataNodeMap
DataNodesMap m_dataPathToDataNodeMap
Index: map of data path to DataNode.
Definition: PrecedenceRulesGraph.h:788
concurrency::DataNode::addConsumerNode
void addConsumerNode(AlgorithmNode *node)
Add relationship to consumer AlgorithmNode.
Definition: PrecedenceRulesGraph.h:640

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

Print out control flow of Algorithms and Sequences.

Definition at line 464 of file PrecedenceRulesGraph.cpp.

465 {
466 std::ostringstream ost;
467 dumpControlFlow( ost, m_headNode, 0 );
468 return ost.str();
469 }
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph
Definition: PrecedenceRulesGraph.h:782
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:464

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

Definition at line 471 of file PrecedenceRulesGraph.cpp.

472 {
473 ost << std::string( indent * 2, ' ' );
474 DecisionNode* dn = dynamic_cast<DecisionNode*>( node );
475 AlgorithmNode* an = dynamic_cast<AlgorithmNode*>( node );
476 if ( dn != 0 ) {
477 if ( node != m_headNode ) {
478 ost << node->getNodeName() << " [Seq] ";
479 ost << ( ( dn->m_modeConcurrent ) ? " [Concurrent] " : " [Sequential] " );
480 ost << ( ( dn->m_modePromptDecision ) ? " [Prompt] " : "" );
481 ost << ( ( dn->m_modeOR ) ? " [OR] " : "" );
482 ost << ( ( dn->m_allPass ) ? " [PASS] " : "" );
483 ost << "\n";
484 }
485 const std::vector<ControlFlowNode*>& dth = dn->getDaughters();
486 for ( std::vector<ControlFlowNode*>::const_iterator itr = dth.begin(); itr != dth.end(); ++itr ) {
487 dumpControlFlow( ost, *itr, indent + 1 );
488 }
489 } else if ( an != 0 ) {
490 ost << node->getNodeName() << " [Alg] ";
491 if ( an != 0 ) {
492 auto ar = an->getAlgorithm();
493 ost << " [n= " << ar->cardinality() << "]";
494 ost << ( ( !ar->isClonable() ) ? " [unclonable] " : "" );
495 }
496 ost << "\n";
497 }
498 }
concurrency::PrecedenceRulesGraph::node
PRVertexDesc node(const std::string &) const
Definition: PrecedenceRulesGraph.cpp:430
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:782
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:464

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

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

Definition at line 501 of file PrecedenceRulesGraph.cpp.

502 {
503
504 const char idt[] = " ";
505 std::ostringstream ost;
506
507 ost << "\n" << idt << "====================================\n";
508 ost << idt << "Data origins and destinations:\n";
509 ost << idt << "====================================\n";
510
511 for ( auto& pair : m_dataPathToDataNodeMap ) {
512
513 for ( auto algoNode : pair.second->getProducers() ) ost << idt << " " << algoNode->getNodeName() << "\n";
514
515 ost << idt << " V\n";
516 ost << idt << " o " << pair.first << "\n";
517 ost << idt << " V\n";
518
519 for ( auto algoNode : pair.second->getConsumers() ) ost << idt << " " << algoNode->getNodeName() << "\n";
520
521 ost << idt << "====================================\n";
522 }
523
524 return ost.str();
525 }
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:788

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

dump to file the precedence rules

Definition at line 529 of file PrecedenceRulesGraph.cpp.

530 {
531 boost::filesystem::ofstream myfile;
532 myfile.open( fileName, std::ios::app );
533
534 // Declare properties to dump
535 boost::dynamic_properties dp;
536
537 using boost::make_transform_value_property_map;
538 using boost::apply_visitor;
539 using boost::get;
540 using boost::vertex_bundle;
541
542 dp.property( "Entity", make_transform_value_property_map(
543 []( const VariantVertexProps& v ) { return boost::lexical_cast<std::string>( v ); },
544 get( vertex_bundle, m_PRGraph ) ) );
545
546 auto nameVis = precedence::VertexName();
547 dp.property( "Name", make_transform_value_property_map(
548 [&nameVis]( const VariantVertexProps& v ) { return apply_visitor( nameVis, v ); },
549 get( vertex_bundle, m_PRGraph ) ) );
550
551 auto gMVis = precedence::GroupMode();
552 dp.property( "Mode", make_transform_value_property_map(
553 [&gMVis]( const VariantVertexProps& v ) { return apply_visitor( gMVis, v ); },
554 get( vertex_bundle, m_PRGraph ) ) );
555
556 auto gLVis = precedence::GroupLogic();
557 dp.property( "Logic", make_transform_value_property_map(
558 [&gLVis]( const VariantVertexProps& v ) { return apply_visitor( gLVis, v ); },
559 get( vertex_bundle, m_PRGraph ) ) );
560
561 auto dNVis = precedence::DecisionNegation();
562 dp.property( "Decision Negation", make_transform_value_property_map(
563 [&dNVis]( const VariantVertexProps& v ) { return apply_visitor( dNVis, v ); },
564 get( vertex_bundle, m_PRGraph ) ) );
565
566 auto aPVis = precedence::AllPass();
567 dp.property( "Negative Decision Inversion",
568 make_transform_value_property_map(
569 [&aPVis]( const VariantVertexProps& v ) { return apply_visitor( aPVis, v ); },
570 get( vertex_bundle, m_PRGraph ) ) );
571
572 auto gEVis = precedence::GroupExit();
573 dp.property( "Exit Policy", make_transform_value_property_map(
574 [&gEVis]( const VariantVertexProps& v ) { return apply_visitor( gEVis, v ); },
575 get( vertex_bundle, m_PRGraph ) ) );
576
577 auto opVis = precedence::Operations();
578 dp.property( "Operations", make_transform_value_property_map(
579 [&opVis]( const VariantVertexProps& v ) { return apply_visitor( opVis, v ); },
580 get( vertex_bundle, m_PRGraph ) ) );
581
582 auto cFDVis = precedence::CFDecision( slot );
583 dp.property( "CF Decision", make_transform_value_property_map(
584 [&cFDVis]( const VariantVertexProps& v ) { return apply_visitor( cFDVis, v ); },
585 get( vertex_bundle, m_PRGraph ) ) );
586
587 auto stVis = precedence::EntityState( slot, serviceLocator(), m_conditionsRealmEnabled );
588 dp.property( "State", make_transform_value_property_map(
589 [&stVis]( const VariantVertexProps& v ) { return apply_visitor( stVis, v ); },
590 get( vertex_bundle, m_PRGraph ) ) );
591
592 auto sTVis = precedence::StartTime( slot, serviceLocator() );
593 dp.property( "Start Time (Epoch ns)",
594 make_transform_value_property_map(
595 [&sTVis]( const VariantVertexProps& v ) { return apply_visitor( sTVis, v ); },
596 get( vertex_bundle, m_PRGraph ) ) );
597
598 auto eTVis = precedence::EndTime( slot, serviceLocator() );
599 dp.property( "End Time (Epoch ns)",
600 make_transform_value_property_map(
601 [&eTVis]( const VariantVertexProps& v ) { return apply_visitor( eTVis, v ); },
602 get( vertex_bundle, m_PRGraph ) ) );
603
604 auto durVis = precedence::Duration( slot, serviceLocator() );
605 dp.property( "Runtime (ns)", make_transform_value_property_map(
606 [&durVis]( const VariantVertexProps& v ) { return apply_visitor( durVis, v ); },
607 get( vertex_bundle, m_PRGraph ) ) );
608
609 boost::write_graphml( myfile, m_PRGraph, dp );
610
611 myfile.close();
612 }
precedence::CFDecision
Definition: PrecedenceRulesGraph.h:183
precedence::GroupMode
Definition: PrecedenceRulesGraph.h:137
precedence::Duration
Definition: PrecedenceRulesGraph.h:365
concurrency::PrecedenceRulesGraph::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: PrecedenceRulesGraph.h:752
std::string
STL class.
concurrency::PrecedenceRulesGraph::m_conditionsRealmEnabled
bool m_conditionsRealmEnabled
Enable conditions realm of precedence rules.
Definition: PrecedenceRulesGraph.h:812
precedence::GroupExit
Definition: PrecedenceRulesGraph.h:156
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:809
precedence::EndTime
Definition: PrecedenceRulesGraph.h:324
precedence::VertexName
Definition: PrecedenceRulesGraph.h:129
precedence::EntityState
Definition: PrecedenceRulesGraph.h:201
precedence::StartTime
Definition: PrecedenceRulesGraph.h:282
GaudiPython.Persistency.get
def get(type_)
Definition: Persistency.py:29
precedence::DecisionNegation
Definition: PrecedenceRulesGraph.h:167
precedence::Operations
Definition: PrecedenceRulesGraph.h:405
concurrency::AllPass
Gaudi::tagged_bool< class AllPass_tag > AllPass
Definition: PrecedenceRulesGraph.h:33
precedence::GroupLogic
Definition: PrecedenceRulesGraph.h:148
precedence::VariantVertexProps
boost::variant< AlgoProps, DecisionHubProps, DataProps, CondDataProps > VariantVertexProps
Definition: PrecedenceRulesGraph.h:420

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

dump to file the precedence trace

Definition at line 615 of file PrecedenceRulesGraph.cpp.

616 {
617 boost::filesystem::ofstream myfile;
618 myfile.open( fileName, std::ios::app );
619
620 // Fill runtimes (as this could not be done on the fly during trace assembling)
621 SmartIF<ITimelineSvc> timelineSvc = m_svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
622 if ( !timelineSvc.isValid() ) {
623 warning() << "Failed to get the TimelineSvc, timing will not be added to "
624 << "the task precedence trace dump" << endmsg;
625 } else {
626
627 typedef boost::graph_traits<precedence::PRGraph>::vertex_iterator vertex_iter;
628 std::pair<vertex_iter, vertex_iter> vp;
629 for ( vp = vertices( m_precTrace ); vp.first != vp.second; ++vp.first ) {
630 TimelineEvent te{};
631 te.algorithm = m_precTrace[*vp.first].m_name;
632 timelineSvc->getTimelineEvent( te );
633 int runtime = std::chrono::duration_cast<std::chrono::nanoseconds>( te.end - te.start ).count();
634 m_precTrace[*vp.first].m_runtime = runtime;
635 }
636 }
637
638 // Declare properties to dump
639 boost::dynamic_properties dp;
640 using boost::get;
641 using precedence::AlgoTraceProps;
642 dp.property( "Name", get( &AlgoTraceProps::m_name, m_precTrace ) );
643 dp.property( "Rank", get( &AlgoTraceProps::m_rank, m_precTrace ) );
644 dp.property( "Runtime", get( &AlgoTraceProps::m_runtime, m_precTrace ) );
645
646 boost::write_graphml( myfile, m_precTrace, dp );
647
648 myfile.close();
649 }
std::chrono::nanoseconds
SmartIF< ITimelineSvc >
concurrency::PrecedenceRulesGraph::m_precTrace
precedence::PrecTrace m_precTrace
facilities for algorithm precedence tracing
Definition: PrecedenceRulesGraph.h:805
TimelineEvent::algorithm
std::string algorithm
Definition: ITimelineSvc.h:18
precedence::AlgoTraceProps
Definition: PrecedenceRulesGraph.h:42
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
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:799

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

BGL-based facilities.

Definition at line 764 of file PrecedenceRulesGraph.h.

764 { m_enableAnalysis = true; };
concurrency::PrecedenceRulesGraph::m_enableAnalysis
bool m_enableAnalysis
Definition: PrecedenceRulesGraph.h:807

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

Get the AlgorithmNode from by algorithm name using graph index.

Definition at line 305 of file PrecedenceRulesGraph.cpp.

306 {
307
308 return m_algoNameToAlgoNodeMap.at( algoName );
309 }
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
AlgoNodesMap m_algoNameToAlgoNodeMap
Index: map of algorithm&#39;s name to AlgorithmNode.
Definition: PrecedenceRulesGraph.h:784
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 744 of file PrecedenceRulesGraph.h.

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

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

Get DataNode by DataObject path using graph index.

Definition at line 352 of file PrecedenceRulesGraph.cpp.

353 {
354
355 return m_dataPathToDataNodeMap.at( dataPath );
356 }
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:788

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

Get head node.

Definition at line 734 of file PrecedenceRulesGraph.h.

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

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

Definition at line 754 of file PrecedenceRulesGraph.h.

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

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 // clean up also auxiliary BGL-based graph of precedence rules
166 if ( m_enableAnalysis )
167 boost::remove_edge( node( algoNode->getNodeName() ), node( parent->getNodeName() ), m_PRGraph );
168 }
169 algoNode->m_parents.clear();
170
171 } else {
172 warning() << "Algorithm '" << algo->name() << "' is not registered in the graph" << endmsg;
173 }
174 }
175 }
176
177 StatusCode sc = buildDataDependenciesRealm();
178
179 if ( !sc.isSuccess() ) error() << "Could not build the data dependency realm." << endmsg;
180
181 ON_DEBUG debug() << dumpDataFlow() << endmsg;
182
183 return sc;
184 }
concurrency::PrecedenceRulesGraph::node
PRVertexDesc node(const std::string &) const
Definition: PrecedenceRulesGraph.cpp:430
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:50
concurrency::PrecedenceRulesGraph::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: PrecedenceRulesGraph.h:752
concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
AlgoNodesMap m_algoNameToAlgoNodeMap
Index: map of algorithm&#39;s name to AlgorithmNode.
Definition: PrecedenceRulesGraph.h:784
concurrency::AlgorithmNode::m_parents
std::vector< DecisionNode * > m_parents
Control flow parents of an AlgorithmNode (DecisionNodes)
Definition: PrecedenceRulesGraph.h:591
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:554
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:812
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:809
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:26
concurrency::PrecedenceRulesGraph::dumpDataFlow
std::string dumpDataFlow() const
Print out all data origins and destinations, as reflected in the EF graph.
Definition: PrecedenceRulesGraph.cpp:501
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:531
concurrency::ControlFlowNode::getNodeName
const std::string & getNodeName() const
Get node name.
Definition: PrecedenceRulesGraph.h:466
concurrency::PrecedenceRulesGraph::buildDataDependenciesRealm
StatusCode buildDataDependenciesRealm()
Build data dependency realm WITH data object nodes participating.
Definition: PrecedenceRulesGraph.cpp:208
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
concurrency::PrecedenceRulesGraph::m_enableAnalysis
bool m_enableAnalysis
Definition: PrecedenceRulesGraph.h:807

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

Retrieve name of the service.

Definition at line 750 of file PrecedenceRulesGraph.h.

750 { return m_name; }
concurrency::PrecedenceRulesGraph::m_name
const std::string m_name
Definition: PrecedenceRulesGraph.h:800

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

Definition at line 430 of file PrecedenceRulesGraph.cpp.

431 {
432
433 PRVertexDesc target{};
434
435 for ( auto vp = vertices( m_PRGraph ); vp.first != vp.second; ++vp.first ) {
436 PRVertexDesc v = *vp.first;
437 if ( boost::apply_visitor( precedence::VertexName(), m_PRGraph[v] ) == name ) {
438 target = v;
439 break;
440 }
441 }
442
443 return target;
444 }
precedence::PRVertexDesc
boost::graph_traits< PRGraph >::vertex_descriptor PRVertexDesc
Definition: PrecedenceRulesGraph.h:422
concurrency::PrecedenceRulesGraph::m_PRGraph
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
Definition: PrecedenceRulesGraph.h:809
precedence::VertexName
Definition: PrecedenceRulesGraph.h:129

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 757 of file PrecedenceRulesGraph.h.

759 {
760 m_headNode->printState( output, states, node_decisions, recursionLevel );
761 }
concurrency::PrecedenceRulesGraph::m_headNode
DecisionNode * m_headNode
the head node of the control flow graph
Definition: PrecedenceRulesGraph.h:782
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 453 of file PrecedenceRulesGraph.cpp.

454 {
455
456 info() << "Starting ranking by data outputs .. " << endmsg;
457 for ( auto& pair : m_algoNameToAlgoNodeMap ) {
458 ON_DEBUG debug() << " Ranking " << pair.first << "... " << endmsg;
459 pair.second->accept( ranker );
460 ON_DEBUG debug() << " ... rank of " << pair.first << ": " << pair.second->getRank() << endmsg;
461 }
462 }
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:784
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 187 of file PrecedenceRulesGraph.cpp.

188 {
189
190 const std::string& algoName = algo->name();
191
192 m_algoNameToAlgoInputsMap[algoName] = algo->inputDataObjs();
193 m_algoNameToAlgoOutputsMap[algoName] = algo->outputDataObjs();
194
195 ON_VERBOSE
196 {
197 verbose() << " Inputs of " << algoName << ": ";
198 for ( auto tag : algo->inputDataObjs() ) verbose() << tag << " | ";
199 verbose() << endmsg;
200
201 verbose() << " Outputs of " << algoName << ": ";
202 for ( auto tag : algo->outputDataObjs() ) verbose() << tag << " | ";
203 verbose() << endmsg;
204 }
205 }
Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:737
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:791
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:790

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

Retrieve pointer to service locator.

Definition at line 752 of file PrecedenceRulesGraph.h.

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

## Member Data Documentation

unsigned int concurrency::PrecedenceRulesGraph::m_algoCounter
| private

Total number of algorithm nodes in the graph.

Definition at line 796 of file PrecedenceRulesGraph.h.

AlgoInputsMap concurrency::PrecedenceRulesGraph::m_algoNameToAlgoInputsMap
| private

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

Definition at line 790 of file PrecedenceRulesGraph.h.

AlgoNodesMap concurrency::PrecedenceRulesGraph::m_algoNameToAlgoNodeMap
| private

Index: map of algorithm's name to AlgorithmNode.

Definition at line 784 of file PrecedenceRulesGraph.h.

AlgoOutputsMap concurrency::PrecedenceRulesGraph::m_algoNameToAlgoOutputsMap
| private

Definition at line 791 of file PrecedenceRulesGraph.h.

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

Enable conditions realm of precedence rules.

Definition at line 812 of file PrecedenceRulesGraph.h.

DataNodesMap concurrency::PrecedenceRulesGraph::m_dataPathToDataNodeMap
| private

Index: map of data path to DataNode.

Definition at line 788 of file PrecedenceRulesGraph.h.

DecisionHubsMap concurrency::PrecedenceRulesGraph::m_decisionNameToDecisionHubMap
| private

Index: map of decision's name to DecisionHub.

Definition at line 786 of file PrecedenceRulesGraph.h.

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

Definition at line 807 of file PrecedenceRulesGraph.h.

DecisionNode* concurrency::PrecedenceRulesGraph::m_headNode
| private

the head node of the control flow graph

Definition at line 782 of file PrecedenceRulesGraph.h.

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

Definition at line 802 of file PrecedenceRulesGraph.h.

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

Definition at line 800 of file PrecedenceRulesGraph.h.

unsigned int concurrency::PrecedenceRulesGraph::m_nodeCounter
| private

Total number of nodes in the graph.

Definition at line 794 of file PrecedenceRulesGraph.h.

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

Definition at line 806 of file PrecedenceRulesGraph.h.

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

facilities for algorithm precedence tracing

Definition at line 805 of file PrecedenceRulesGraph.h.

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

BGL-based graph of precedence rules.

Definition at line 809 of file PrecedenceRulesGraph.h.

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

Service locator (needed to access the MessageSvc)

Definition at line 799 of file PrecedenceRulesGraph.h.

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

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