The Gaudi Framework  v30r3 (a5ef0a68)
PrecedenceRulesGraph.cpp
Go to the documentation of this file.
1 #include "PrecedenceRulesGraph.h"
2 #include "PRGraphVisitors.h"
3 
4 #include <boost/property_map/transform_value_property_map.hpp>
5 #include <fstream>
6 
8 
9 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) )
10 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) )
11 
12 namespace
13 {
14  //---------------------------------------------------------------------------
16  const char* stateToString( const int& stateId )
17  {
18  switch ( stateId ) {
19  case 0:
20  return "FALSE";
21  case 1:
22  return "TRUE";
23  default:
24  return "UNDEFINED";
25  }
26  }
27 }
28 
29 namespace concurrency
30 {
31 
32  //---------------------------------------------------------------------------
34  {
35 
36  if ( std::find( m_parents.begin(), m_parents.end(), node ) == m_parents.end() ) m_parents.push_back( node );
37  }
38 
39  //--------------------------------------------------------------------------
41  {
42 
43  if ( std::find( m_children.begin(), m_children.end(), node ) == m_children.end() ) m_children.push_back( node );
44  }
45 
46  //---------------------------------------------------------------------------
48  const std::vector<int>& node_decisions, const unsigned int& recursionLevel ) const
49  {
50 
51  output << std::string( recursionLevel, ' ' ) << m_nodeName << " (" << m_nodeIndex << ")"
52  << ", w/ decision: " << stateToString( node_decisions[m_nodeIndex] ) << "(" << node_decisions[m_nodeIndex]
53  << ")" << std::endl;
54 
55  for ( auto daughter : m_children ) daughter->printState( output, states, node_decisions, recursionLevel + 2 );
56  }
57 
58  //---------------------------------------------------------------------------
60  {
61 
62  if ( visitor.visitEnter( *this ) ) {
63  // try to aggregate a decision
64  bool result = visitor.visit( *this );
65  return !result;
66  }
67 
68  return false; // visitor was rejected (since the decision node has an aggregated decision already)
69  }
70 
71  //---------------------------------------------------------------------------
73  const std::vector<int>& node_decisions, const unsigned int& recursionLevel ) const
74  {
75  output << std::string( recursionLevel, ' ' ) << m_nodeName << " (" << m_nodeIndex << ")"
76  << ", w/ decision: " << stateToString( node_decisions[m_nodeIndex] ) << "(" << node_decisions[m_nodeIndex]
77  << ")"
78  << ", in state: " << states[m_algoIndex] << std::endl;
79  }
80 
81  //---------------------------------------------------------------------------
83  {
84 
85  if ( visitor.visitEnter( *this ) ) {
86  visitor.visit( *this );
87  return true; // visitor was accepted to promote the algorithm
88  }
89 
90  return false; // visitor was rejected (since the algorithm already produced a decision)
91  }
92 
93  //---------------------------------------------------------------------------
95  {
96 
97  if ( std::find( m_parents.begin(), m_parents.end(), node ) == m_parents.end() ) m_parents.push_back( node );
98  }
99 
100  //---------------------------------------------------------------------------
102  {
103 
104  if ( std::find( m_outputs.begin(), m_outputs.end(), node ) == m_outputs.end() ) m_outputs.push_back( node );
105  }
106 
107  //---------------------------------------------------------------------------
109  {
110 
111  if ( std::find( m_inputs.begin(), m_inputs.end(), node ) == m_inputs.end() ) m_inputs.push_back( node );
112  }
113 
114  //---------------------------------------------------------------------------
116  {
117  if ( serviceLocator()->existsService( "CondSvc" ) ) {
118  SmartIF<ICondSvc> condSvc{serviceLocator()->service( "CondSvc" )};
119  if ( condSvc.isValid() ) {
120  info() << "CondSvc found. DF precedence rules will be augmented with 'Conditions'" << endmsg;
121  m_conditionsRealmEnabled = true;
122  }
123  }
124 
125  // Detach condition algorithms from the CF realm
126  if ( m_conditionsRealmEnabled ) {
127  SmartIF<ICondSvc> condSvc{serviceLocator()->service( "CondSvc", false )};
128  auto& condAlgs = condSvc->condAlgs();
129  for ( const auto algo : condAlgs ) {
130  auto itA = m_algoNameToAlgoNodeMap.find( algo->name() );
131  if ( itA != m_algoNameToAlgoNodeMap.end() ) {
132  concurrency::AlgorithmNode* algoNode = itA->second.get();
133  debug() << "Detaching condition algorithm '" << algo->name() << "' from the CF realm.." << endmsg;
134  for ( auto parent : algoNode->getParentDecisionHubs() ) {
135  parent->m_children.erase( std::remove( parent->m_children.begin(), parent->m_children.end(), algoNode ),
136  parent->m_children.end() );
137  // clean up also auxiliary BGL-based graph of precedence rules
138  if ( m_enableAnalysis )
139  boost::remove_edge( node( algoNode->getNodeName() ), node( parent->getNodeName() ), m_PRGraph );
140  }
141  algoNode->m_parents.clear();
142 
143  } else {
144  warning() << "Algorithm '" << algo->name() << "' is not registered in the graph" << endmsg;
145  }
146  }
147  }
148 
149  StatusCode sc = buildDataDependenciesRealm();
150 
151  if ( !sc.isSuccess() ) error() << "Could not build the data dependency realm." << endmsg;
152 
153  ON_DEBUG debug() << dumpDataFlow() << endmsg;
154 
155  return sc;
156  }
157 
158  //---------------------------------------------------------------------------
160  {
161 
162  const std::string& algoName = algo->name();
163 
164  m_algoNameToAlgoInputsMap[algoName] = algo->inputDataObjs();
165  m_algoNameToAlgoOutputsMap[algoName] = algo->outputDataObjs();
166 
167  ON_VERBOSE
168  {
169  verbose() << " Inputs of " << algoName << ": ";
170  for ( auto tag : algo->inputDataObjs() ) verbose() << tag << " | ";
171  verbose() << endmsg;
172 
173  verbose() << " Outputs of " << algoName << ": ";
174  for ( auto tag : algo->outputDataObjs() ) verbose() << tag << " | ";
175  verbose() << endmsg;
176  }
177  }
178 
179  //---------------------------------------------------------------------------
181  {
182 
183  StatusCode global_sc( StatusCode::SUCCESS, true );
184 
185  // Production of DataNodes by AlgorithmNodes (DataNodes are created here)
186  for ( auto& algo : m_algoNameToAlgoNodeMap ) {
187 
188  auto& outputs = m_algoNameToAlgoOutputsMap[algo.first];
189  for ( auto output : outputs ) {
190  const auto sc = addDataNode( output );
191  if ( !sc.isSuccess() ) {
192  error() << "Extra producer (" << algo.first << ") for DataObject @ " << output
193  << " has been detected: this is not allowed." << endmsg;
194  global_sc = sc;
195  }
196  auto dataNode = getDataNode( output );
197  dataNode->addProducerNode( algo.second.get() );
198  algo.second->addOutputDataNode( dataNode );
199 
200  // Mirror the action above in the BGL-based graph
201  if ( m_enableAnalysis )
202  boost::add_edge( node( algo.second->getNodeName() ), node( output.fullKey() ), m_PRGraph );
203  }
204  }
205 
206  // Consumption of DataNodes by AlgorithmNodes
207  for ( auto& algo : m_algoNameToAlgoNodeMap ) {
208 
209  for ( auto input : m_algoNameToAlgoInputsMap[algo.first] ) {
210 
211  auto itP = m_dataPathToDataNodeMap.find( input );
212 
213  DataNode* dataNode = ( itP != m_dataPathToDataNodeMap.end() ? getDataNode( input ) : nullptr );
214  if ( dataNode ) {
215  dataNode->addConsumerNode( algo.second.get() );
216  algo.second->addInputDataNode( dataNode );
217 
218  // Mirror the action above in the BGL-based graph
219  if ( m_enableAnalysis )
220  boost::add_edge( node( input.fullKey() ), node( algo.second->getNodeName() ), m_PRGraph );
221  }
222  }
223  }
224 
225  return global_sc;
226  }
227 
228  //---------------------------------------------------------------------------
229  StatusCode PrecedenceRulesGraph::addAlgorithmNode( Algorithm* algo, const std::string& parentName, bool inverted,
230  bool allPass )
231  {
232 
234 
236 
237  auto& algoName = algo->name();
238 
239  concurrency::AlgorithmNode* algoNode;
240 
241  auto itA = m_algoNameToAlgoNodeMap.find( algoName );
242  if ( itA != m_algoNameToAlgoNodeMap.end() ) {
243  algoNode = itA->second.get();
244  } else {
245  auto r = m_algoNameToAlgoNodeMap.emplace(
246  algoName, std::make_unique<concurrency::AlgorithmNode>( *this, algo, m_nodeCounter, m_algoCounter, inverted,
247  allPass ) );
248  algoNode = r.first->second.get();
249 
250  // Mirror AlgorithmNode in the BGL-based graph
251  if ( m_enableAnalysis ) {
252  boost::add_vertex( AlgoProps( algo, m_nodeCounter, m_algoCounter, inverted, allPass ), m_PRGraph );
253  }
254  ++m_nodeCounter;
255  ++m_algoCounter;
256  ON_VERBOSE verbose() << "AlgorithmNode '" << algoName << "' added @ " << algoNode << endmsg;
257 
258  registerIODataObjects( algo );
259  }
260 
262  auto itP = m_decisionNameToDecisionHubMap.find( parentName );
263  if ( itP != m_decisionNameToDecisionHubMap.end() ) {
264  auto parentNode = itP->second.get();
265 
266  parentNode->addDaughterNode( algoNode );
267  algoNode->addParentNode( parentNode );
268 
269  // Mirror algorithm to CF parent relationship in the BGL-based graph
270  if ( m_enableAnalysis ) boost::add_edge( node( algo->name() ), node( parentName ), m_PRGraph );
271 
272  ON_VERBOSE verbose() << "Attached AlgorithmNode '" << algo->name() << "' to parent DecisionNode '" << parentName
273  << "'" << endmsg;
274  } else {
275  sc = StatusCode::FAILURE;
276  error() << "Parent DecisionNode '" << parentName << "' was not found" << endmsg;
277  }
278 
279  return sc;
280  }
281 
282  //---------------------------------------------------------------------------
284  {
285 
286  auto itD = m_dataPathToDataNodeMap.find( dataPath );
287  if ( itD != m_dataPathToDataNodeMap.end() ) return StatusCode::SUCCESS;
288 
290  if ( !m_conditionsRealmEnabled ) {
291  dataNode = std::make_unique<concurrency::DataNode>( *this, dataPath );
292  ON_VERBOSE verbose() << " DataNode " << dataPath << " added @ " << dataNode.get() << endmsg;
293  // Mirror the action above in the BGL-based graph
294  if ( m_enableAnalysis ) boost::add_vertex( DataProps( dataPath ), m_PRGraph );
295  } else {
296  SmartIF<ICondSvc> condSvc{serviceLocator()->service( "CondSvc", false )};
297  if ( condSvc->isRegistered( dataPath ) ) {
298  dataNode = std::make_unique<concurrency::ConditionNode>( *this, dataPath, condSvc );
299  ON_VERBOSE verbose() << " ConditionNode " << dataPath << " added @ " << dataNode.get() << endmsg;
300  // Mirror the action above in the BGL-based graph
301  if ( m_enableAnalysis ) boost::add_vertex( CondDataProps( dataPath ), m_PRGraph );
302  } else {
303  dataNode = std::make_unique<concurrency::DataNode>( *this, dataPath );
304  ON_VERBOSE verbose() << " DataNode " << dataPath << " added @ " << dataNode.get() << endmsg;
305  // Mirror the action above in the BGL-based graph
306  if ( m_enableAnalysis ) boost::add_vertex( DataProps( dataPath ), m_PRGraph );
307  }
308  }
309  m_dataPathToDataNodeMap.emplace( dataPath, std::move( dataNode ) );
310  return StatusCode::SUCCESS;
311  }
312 
313  //---------------------------------------------------------------------------
315  Concurrent modeConcurrent, PromptDecision modePromptDecision,
316  ModeOr modeOR, AllPass allPass, Inverted isInverted )
317  {
318 
320 
322 
323  auto& decisionHubName = decisionHubAlgo->name();
324 
325  auto itA = m_decisionNameToDecisionHubMap.find( decisionHubName );
326  concurrency::DecisionNode* decisionHubNode;
327  if ( itA != m_decisionNameToDecisionHubMap.end() ) {
328  decisionHubNode = itA->second.get();
329  } else {
330  auto r = m_decisionNameToDecisionHubMap.emplace(
331  decisionHubName,
332  std::make_unique<concurrency::DecisionNode>( *this, m_nodeCounter, decisionHubName, modeConcurrent,
333  modePromptDecision, modeOR, allPass, isInverted ) );
334  decisionHubNode = r.first->second.get();
335  // Mirror DecisionNode in the BGL-based graph
336  if ( m_enableAnalysis ) {
337  boost::add_vertex( DecisionHubProps( decisionHubName, m_nodeCounter, modeConcurrent, modePromptDecision, modeOR,
338  allPass, isInverted ),
339  m_PRGraph );
340  }
341 
342  ++m_nodeCounter;
343 
344  ON_VERBOSE verbose() << "DecisionNode '" << decisionHubName << "' added @ " << decisionHubNode << endmsg;
345  }
346 
348  auto itP = m_decisionNameToDecisionHubMap.find( parentName );
349  if ( itP != m_decisionNameToDecisionHubMap.end() ) {
350  auto parentNode = itP->second.get();
351  parentNode->addDaughterNode( decisionHubNode );
352  decisionHubNode->addParentNode( parentNode );
353 
354  // Mirror DecisionNode-to-DecisionNode relationship in the BGL-based graph
355  if ( m_enableAnalysis ) boost::add_edge( node( decisionHubName ), node( parentName ), m_PRGraph );
356 
357  ON_VERBOSE verbose() << "Attached DecisionNode '" << decisionHubName << "' to parent DecisionNode '" << parentName
358  << "'" << endmsg;
359  } else {
360  sc = StatusCode::FAILURE;
361  error() << "Parent DecisionNode '" << parentName << "' was not found" << endmsg;
362  }
363 
364  return sc;
365  }
366 
367  //---------------------------------------------------------------------------
369  concurrency::PromptDecision modePromptDecision, concurrency::ModeOr modeOR,
370  concurrency::AllPass allPass, concurrency::Inverted isInverted )
371  {
372 
373  auto itH = m_decisionNameToDecisionHubMap.find( headName );
374  if ( itH != m_decisionNameToDecisionHubMap.end() ) {
375  m_headNode = itH->second.get();
376  } else {
377  auto r = m_decisionNameToDecisionHubMap.emplace(
378  headName, std::make_unique<concurrency::DecisionNode>( *this, m_nodeCounter, headName, modeConcurrent,
379  modePromptDecision, modeOR, allPass, isInverted ) );
380  m_headNode = r.first->second.get();
381 
382  // Mirror the action above in the BGL-based graph
383  if ( m_enableAnalysis ) {
384  boost::add_vertex( DecisionHubProps( headName, m_nodeCounter, modeConcurrent, modePromptDecision, modeOR,
385  allPass, isInverted ),
386  m_PRGraph );
387  }
388 
389  ++m_nodeCounter;
390  }
391  }
392 
393  //---------------------------------------------------------------------------
395  {
396  auto vp = vertices( m_PRGraph );
397  auto i = std::find_if( vp.first, vp.second, [&]( const PRVertexDesc& v ) {
398  return boost::apply_visitor( precedence::VertexName(), m_PRGraph[v] ) == name;
399  } );
400  return i != vp.second ? *i : PRVertexDesc{};
401  }
402 
403  //---------------------------------------------------------------------------
405  {
406  // iterate through Algorithm nodes
407  for ( auto& pr : m_algoNameToAlgoNodeMap ) pr.second->accept( visitor );
408 
409  // iterate through DecisionHub nodes
410  for ( auto& pr : m_decisionNameToDecisionHubMap ) pr.second->accept( visitor );
411 
412  // iterate through Data [and Conditions] nodes
413  for ( auto& pr : m_dataPathToDataNodeMap ) pr.second->accept( visitor );
414  }
415 
416  //---------------------------------------------------------------------------
418  {
419 
420  info() << "Starting ranking by data outputs .. " << endmsg;
421  for ( auto& pair : m_algoNameToAlgoNodeMap ) {
422  ON_DEBUG debug() << " Ranking " << pair.first << "... " << endmsg;
423  pair.second->accept( ranker );
424  ON_DEBUG debug() << " ... rank of " << pair.first << ": " << pair.second->getRank() << endmsg;
425  }
426  }
427 
429  {
430  std::ostringstream ost;
431  dumpControlFlow( ost, m_headNode, 0 );
432  return ost.str();
433  }
434 
435  void PrecedenceRulesGraph::dumpControlFlow( std::ostringstream& ost, ControlFlowNode* node, const int& indent ) const
436  {
437  ost << std::string( indent * 2, ' ' );
438  DecisionNode* dn = dynamic_cast<DecisionNode*>( node );
439  AlgorithmNode* an = dynamic_cast<AlgorithmNode*>( node );
440  if ( dn != 0 ) {
441  if ( node != m_headNode ) {
442  ost << node->getNodeName() << " [Seq] ";
443  ost << ( ( dn->m_modeConcurrent ) ? " [Concurrent] " : " [Sequential] " );
444  ost << ( ( dn->m_modePromptDecision ) ? " [Prompt] " : "" );
445  ost << ( ( dn->m_modeOR ) ? " [OR] " : "" );
446  ost << ( ( dn->m_allPass ) ? " [PASS] " : "" );
447  ost << "\n";
448  }
449  for ( const auto& i : dn->getDaughters() ) dumpControlFlow( ost, i, indent + 1 );
450  } else if ( an != 0 ) {
451  ost << node->getNodeName() << " [Alg] ";
452  if ( an != 0 ) {
453  auto ar = an->getAlgorithm();
454  ost << " [n= " << ar->cardinality() << "]";
455  ost << ( ( !ar->isClonable() ) ? " [unclonable] " : "" );
456  }
457  ost << "\n";
458  }
459  }
460 
461  //---------------------------------------------------------------------------
463  {
464 
465  const char idt[] = " ";
466  std::ostringstream ost;
467 
468  ost << "\n" << idt << "====================================\n";
469  ost << idt << "Data origins and destinations:\n";
470  ost << idt << "====================================\n";
471 
472  for ( auto& pair : m_dataPathToDataNodeMap ) {
473 
474  for ( auto algoNode : pair.second->getProducers() ) ost << idt << " " << algoNode->getNodeName() << "\n";
475 
476  ost << idt << " V\n";
477  ost << idt << " o " << pair.first << "\n";
478  ost << idt << " V\n";
479 
480  for ( auto algoNode : pair.second->getConsumers() ) ost << idt << " " << algoNode->getNodeName() << "\n";
481 
482  ost << idt << "====================================\n";
483  }
484 
485  return ost.str();
486  }
487 
488  //---------------------------------------------------------------------------
489 
491  {
492  boost::filesystem::ofstream myfile;
493  myfile.open( fileName, std::ios::app );
494 
495  // Declare properties to dump
496  boost::dynamic_properties dp;
497 
498  dp.property( "Entity", boost::make_transform_value_property_map(
499  []( const VariantVertexProps& v ) { return boost::lexical_cast<std::string>( v ); },
500  boost::get( boost::vertex_bundle, m_PRGraph ) ) );
501 
502  auto add_prop = [&]( auto name, auto&& vis ) {
503  dp.property( name,
504  boost::make_transform_value_property_map( [vis = std::forward<decltype( vis )>( vis )](
505  const VariantVertexProps&
506  v ) { return boost::apply_visitor( vis, v ); },
507  boost::get( boost::vertex_bundle, m_PRGraph ) ) );
508  };
509 
510  add_prop( "Name", precedence::VertexName() );
511  add_prop( "Mode", precedence::GroupMode() );
512  add_prop( "Logic", precedence::GroupLogic() );
513  add_prop( "Decision Negation", precedence::DecisionNegation() );
514  add_prop( "Negative Decision Inversion", precedence::AllPass() );
515  add_prop( "Exit Policy", precedence::GroupExit() );
516  add_prop( "Operations", precedence::Operations() );
517  add_prop( "CF Decision", precedence::CFDecision( slot ) );
518  add_prop( "State", precedence::EntityState( slot, serviceLocator(), m_conditionsRealmEnabled ) );
519  add_prop( "Start Time (Epoch ns)", precedence::StartTime( slot, serviceLocator() ) );
520  add_prop( "End Time (Epoch ns)", precedence::EndTime( slot, serviceLocator() ) );
521  add_prop( "Runtime (ns)", precedence::Duration( slot, serviceLocator() ) );
522 
523  boost::write_graphml( myfile, m_PRGraph, dp );
524 
525  myfile.close();
526  }
527 
528  //---------------------------------------------------------------------------
530  {
531  boost::filesystem::ofstream myfile;
532  myfile.open( fileName, std::ios::app );
533 
534  // Fill runtimes (as this could not be done on the fly during trace assembling)
535  SmartIF<ITimelineSvc> timelineSvc = m_svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
536  if ( !timelineSvc.isValid() ) {
537  warning() << "Failed to get the TimelineSvc, timing will not be added to "
538  << "the task precedence trace dump" << endmsg;
539  } else {
540 
541  for ( auto vp = vertices( m_precTrace ); vp.first != vp.second; ++vp.first ) {
542  TimelineEvent te{};
543  te.algorithm = m_precTrace[*vp.first].m_name;
544  timelineSvc->getTimelineEvent( te );
545  int runtime = std::chrono::duration_cast<std::chrono::nanoseconds>( te.end - te.start ).count();
546  m_precTrace[*vp.first].m_runtime = runtime;
547  }
548  }
549 
550  // Declare properties to dump
551  boost::dynamic_properties dp;
552  using boost::get;
554  dp.property( "Name", get( &AlgoTraceProps::m_name, m_precTrace ) );
555  dp.property( "Rank", get( &AlgoTraceProps::m_rank, m_precTrace ) );
556  dp.property( "Runtime", get( &AlgoTraceProps::m_runtime, m_precTrace ) );
557 
558  boost::write_graphml( myfile, m_precTrace, dp );
559 
560  myfile.close();
561  }
562 
564  {
565 
566  std::string u_name = u == nullptr ? "ENTRY" : u->getNodeName();
567  std::string v_name = v->getNodeName();
568 
570 
571  if ( !u ) {
572  auto itT = m_prec_trace_map.find( "ENTRY" );
573  if ( itT != m_prec_trace_map.end() ) {
574  source = itT->second;
575  } else {
576  source = boost::add_vertex( precedence::AlgoTraceProps( "ENTRY", -1, -1, -1.0 ), m_precTrace );
577  m_prec_trace_map["ENTRY"] = source;
578  }
579  } else {
580  auto itS = m_prec_trace_map.find( u_name );
581  if ( itS != m_prec_trace_map.end() ) {
582  source = itS->second;
583  } else {
584 
585  source =
586  boost::add_vertex( precedence::AlgoTraceProps( u_name, u->getAlgoIndex(), u->getRank(), -1 ), m_precTrace );
587  m_prec_trace_map[u_name] = source;
588  }
589  }
590 
592 
593  auto itP = m_prec_trace_map.find( v_name );
594  if ( itP != m_prec_trace_map.end() ) {
595  target = itP->second;
596  } else {
597 
598  target =
599  boost::add_vertex( precedence::AlgoTraceProps( v_name, v->getAlgoIndex(), v->getRank(), -1 ), m_precTrace );
600  m_prec_trace_map[v_name] = target;
601  }
602 
603  boost::add_edge( source, target, m_precTrace );
604 
605  ON_DEBUG debug() << u_name << "-->" << v_name << " precedence trait added" << endmsg;
606  }
607 
608 } // namespace
constexpr static const auto FAILURE
Definition: StatusCode.h:88
PRVertexDesc node(const std::string &) const
const unsigned int & getAlgoIndex() const
Get algorithm index.
std::vector< DecisionNode * > m_parents
Direct parent nodes.
StatusCode addAlgorithmNode(Algorithm *daughterAlgo, const std::string &parentName, bool inverted, bool allPass)
Add algorithm node.
void accept(IGraphVisitor &visitor) const
An entry point to visit all graph nodes.
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:765
void addDaughterNode(ControlFlowNode *node)
Add a daughter node.
boost::graph_traits< PrecTrace >::vertex_descriptor AlgoTraceVertex
boost::graph_traits< PRGraph >::vertex_descriptor PRVertexDesc
const DataObjIDColl & outputDataObjs() const override
bool isSuccess() const
Definition: StatusCode.h:287
virtual bool visit(DecisionNode &)
Definition: IGraphVisitor.h:18
std::vector< ControlFlowNode * > m_children
All direct daughter nodes in the tree.
void dumpPrecRules(const boost::filesystem::path &, const EventSlot &slot)
dump to file the precedence rules
T endl(T...args)
std::vector< DecisionNode * > m_parents
Control flow parents of an AlgorithmNode (DecisionNodes)
std::string algorithm
Definition: ITimelineSvc.h:21
T duration_cast(T...args)
StatusCode addDataNode(const DataObjID &dataPath)
Add DataNode that represents DataObject.
void rankAlgorithms(IGraphVisitor &ranker) const
Rank Algorithm nodes by the number of data outputs.
#define ON_DEBUG
bool m_allPass
Whether always passing regardless of daughter results.
const std::vector< DecisionNode * > & getParentDecisionHubs() const
Get all parent decision hubs.
T remove(T...args)
Gaudi::tagged_bool< class ModeOr_tag > ModeOr
virtual bool visitEnter(DecisionNode &) const
Definition: IGraphVisitor.h:17
STL class.
Algorithm * getAlgorithm() const
get Algorithm representatives
bool m_modeOR
Whether acting as "and" (false) or "or" node (true)
void addInputDataNode(DataNode *node)
Associate an AlgorithmNode, which is a data consumer of this one.
bool accept(IGraphVisitor &visitor) override
Visitor entry point.
StatusCode initialize()
Initialize graph.
void dumpPrecTrace(const boost::filesystem::path &)
dump to file the precedence trace
const float & getRank() const
Get Algorithm rank.
The AlgsExecutionStates encodes the state machine for the execution of algorithms within a single eve...
virtual const std::set< IAlgorithm * > & condAlgs() const =0
get list of all registered condition Algorithms
Gaudi::tagged_bool< class Inverted_tag > Inverted
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
const DataObjIDColl & inputDataObjs() const override
std::string dumpDataFlow() const
Print out all data origins and destinations, as reflected in the EF graph.
const std::vector< ControlFlowNode * > & getDaughters() const
Get children nodes.
T move(T...args)
Gaudi::tagged_bool< class Concurrent_tag > Concurrent
constexpr static const auto SUCCESS
Definition: StatusCode.h:87
bool m_modePromptDecision
Whether to evaluate the hub decision ASA its child decisions allow to do that.
virtual bool getTimelineEvent(TimelineEvent &) const =0
void addEdgeToPrecTrace(const AlgorithmNode *u, const AlgorithmNode *v)
set cause-effect connection between two algorithms in the precedence trace
T get(T...args)
void addOutputDataNode(DataNode *node)
Associate an AlgorithmNode, which is a data supplier for this one.
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
T find(T...args)
std::vector< InputHandle_t< In > > m_inputs
Gaudi::tagged_bool< class PromptDecision_tag > PromptDecision
void addParentNode(DecisionNode *node)
Add a parent node.
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:68
void registerIODataObjects(const Algorithm *algo)
Register algorithm in the Data Dependency index.
bool m_modeConcurrent
Whether all daughters will be evaluated concurrently or sequentially.
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.
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.
Class representing the event slot.
Definition: EventSlot.h:10
Gaudi::tagged_bool< class AllPass_tag > AllPass
void addParentNode(DecisionNode *node)
Add a parent node.
bool accept(IGraphVisitor &visitor) override
Visitor entry point.
const std::string & getNodeName() const
Get node name.
#define ON_VERBOSE
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.
StatusCode buildDataDependenciesRealm()
Build data dependency realm WITH data object nodes participating.
std::string dumpControlFlow() const
Print out control flow of Algorithms and Sequences.
T forward(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
void addHeadNode(const std::string &headName, concurrency::Concurrent, concurrency::PromptDecision, concurrency::ModeOr, concurrency::AllPass, concurrency::Inverted)
Add a node, which has no parents.
boost::variant< AlgoProps, DecisionHubProps, DataProps, CondDataProps > VariantVertexProps
void addConsumerNode(AlgorithmNode *node)
Add relationship to consumer AlgorithmNode.