The Gaudi Framework  v30r0 (c919700c)
PrecedenceRulesGraph.h
Go to the documentation of this file.
1 #ifndef GAUDIHIVE_PRECEDENCERULESGRAPH_H
2 #define GAUDIHIVE_PRECEDENCERULESGRAPH_H
3 
4 // std includes
5 #include <algorithm>
6 #include <chrono>
7 #include <sstream>
8 #include <unordered_map>
9 #include <vector>
10 
11 #include <boost/filesystem.hpp>
12 #include <boost/graph/adjacency_list.hpp>
13 #include <boost/graph/graphml.hpp>
14 #include <boost/variant.hpp>
15 
16 // fwk includes
17 #include "AlgsExecutionStates.h"
18 #include "EventSlot.h"
19 #include "GaudiKernel/Algorithm.h"
21 #include "GaudiKernel/DataObject.h"
22 #include "GaudiKernel/ICondSvc.h"
25 #include "GaudiKernel/TaggedBool.h"
26 #include "IGraphVisitor.h"
27 
28 namespace concurrency
29 {
30  using Concurrent = Gaudi::tagged_bool<class Concurrent_tag>;
31  using PromptDecision = Gaudi::tagged_bool<class PromptDecision_tag>;
32  using ModeOr = Gaudi::tagged_bool<class ModeOr_tag>;
33  using AllPass = Gaudi::tagged_bool<class AllPass_tag>;
34  using Inverted = Gaudi::tagged_bool<class Inverted_tag>;
35 }
36 
37 namespace precedence
38 {
39  using boost::static_visitor;
40 
41  // Precedence trace utilities ==============================================
42  struct AlgoTraceProps {
44  AlgoTraceProps( const std::string& name, int index, int rank, double runtime )
45  : m_name( name ), m_index( index ), m_rank( rank ), m_runtime( runtime )
46  {
47  }
49  int m_index{-1};
50  int m_rank{-1};
51  int m_runtime{-1}; // ns
52  int m_eccentricity{-1};
53  };
54 
55  using PrecTrace = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, AlgoTraceProps>;
56  using AlgoTraceVertex = boost::graph_traits<PrecTrace>::vertex_descriptor;
57 
58  // Precedence rules utilities ==============================================
59  struct AlgoProps {
60  AlgoProps() {}
61  AlgoProps( Algorithm* algo, uint nodeIndex, uint algoIndex, bool inverted, bool allPass )
62  : m_name( algo->name() )
63  , m_nodeIndex( nodeIndex )
64  , m_algoIndex( algoIndex )
65  , m_algorithm( algo )
66  , m_inverted( inverted )
67  , m_allPass( allPass )
68  , m_isIOBound( algo->isIOBound() )
69  {
70  }
71 
72  std::string m_name{""};
73  int m_nodeIndex{-1};
74  int m_algoIndex{-1};
75  int m_rank{-1};
77  Algorithm* m_algorithm{nullptr};
78 
80  bool m_inverted{false};
82  bool m_allPass{false};
84  bool m_isIOBound{false};
85  };
86 
88  DecisionHubProps( const std::string& name, uint nodeIndex, concurrency::Concurrent modeConcurrent,
89  concurrency::PromptDecision modePromptDecision, concurrency::ModeOr modeOR,
90  concurrency::AllPass allPass, concurrency::Inverted isInverted )
91  : m_name( name )
92  , m_nodeIndex( nodeIndex )
93  , m_modeConcurrent( modeConcurrent )
94  , m_modePromptDecision( modePromptDecision )
95  , m_inverted( isInverted )
96  , m_modeOR( modeOR )
97  , m_allPass( allPass )
98  {
99  }
100 
103 
110  bool m_inverted{false};
112  bool m_modeOR;
114  bool m_allPass;
115  };
116 
117  struct DataProps {
118  DataProps( const DataObjID& id ) : m_id( id ) {}
119 
121  };
122 
124  CondDataProps( const DataObjID& id ) : DataProps( id ) {}
125  };
126 
127  // Vertex unpacking ========================================================
128 
129  struct VertexName : static_visitor<std::string> {
130  std::string operator()( const AlgoProps& props ) const { return props.m_name; }
131 
132  std::string operator()( const DecisionHubProps& props ) const { return props.m_name; }
133 
134  std::string operator()( const DataProps& props ) const { return props.m_id.fullKey(); }
135  };
136 
137  struct GroupMode : static_visitor<std::string> {
138  std::string operator()( const AlgoProps& ) const { return ""; }
139 
141  {
142  return props.m_modeConcurrent ? "Concurrent" : "Sequential";
143  }
144 
145  std::string operator()( const DataProps& ) const { return ""; }
146  };
147 
148  struct GroupLogic : static_visitor<std::string> {
149  std::string operator()( const AlgoProps& ) const { return ""; }
150 
151  std::string operator()( const DecisionHubProps& props ) const { return props.m_modeOR ? "OR" : "AND"; }
152 
153  std::string operator()( const DataProps& ) const { return ""; }
154  };
155 
156  struct GroupExit : static_visitor<std::string> {
157  std::string operator()( const AlgoProps& ) const { return ""; }
158 
160  {
161  return props.m_modePromptDecision ? "Early" : "Late";
162  }
163 
164  std::string operator()( const DataProps& ) const { return ""; }
165  };
166 
167  struct DecisionNegation : static_visitor<std::string> {
168  std::string operator()( const AlgoProps& props ) const { return props.m_inverted ? "Inverted" : "Non-inverted"; }
169 
170  std::string operator()( const DecisionHubProps& ) const { return ""; }
171 
172  std::string operator()( const DataProps& ) const { return ""; }
173  };
174 
175  struct AllPass : static_visitor<std::string> {
176  std::string operator()( const AlgoProps& props ) const { return props.m_allPass ? "Optimist" : "Realist"; }
177 
178  std::string operator()( const DecisionHubProps& props ) const { return props.m_allPass ? "Optimist" : "Realist"; }
179 
180  std::string operator()( const DataProps& ) const { return ""; }
181  };
182 
183  struct CFDecision : static_visitor<std::string> {
184  CFDecision( const EventSlot& slot ) : m_slot( slot ) {}
185 
186  std::string operator()( const AlgoProps& props ) const
187  {
188  return std::to_string( m_slot.controlFlowState.at( props.m_nodeIndex ) );
189  }
190 
192  {
193  return std::to_string( m_slot.controlFlowState.at( props.m_nodeIndex ) );
194  }
195 
196  std::string operator()( const DataProps& ) const { return ""; }
197 
199  };
200 
201  struct EntityState : static_visitor<std::string> {
202  EntityState( const EventSlot& slot, SmartIF<ISvcLocator>& svcLocator, bool conditionsEnabled )
203  : m_slot( slot ), m_conditionsEnabled( conditionsEnabled )
204  {
205  SmartIF<IMessageSvc> msgSvc{svcLocator};
206  MsgStream log{msgSvc, "EntityState.Getter"};
207 
208  // Figure if we can discover the data object states
209  m_whiteboard = svcLocator->service<IHiveWhiteBoard>( "EventDataSvc", false );
210  if ( !m_whiteboard.isValid() ) {
211  log << MSG::WARNING << "Failed to locate EventDataSvc: no way to add DO "
212  << "states to the TTT dump " << endmsg;
213  }
214 
215  if ( m_conditionsEnabled ) {
216  // Figure if we can discover Condition data object states
217  m_condSvc = svcLocator->service<ICondSvc>( "CondSvc", false );
218  if ( !m_condSvc.isValid() )
219  log << MSG::WARNING << "Failed to locate CondSvc: no way to add Condition DO "
220  << "states to the TTT dump " << endmsg;
221  }
222 
223  if ( !m_slot.eventContext->valid() )
224  log << MSG::WARNING << "Event context is invalid: no way to add DO states"
225  << " in the TTT dump" << endmsg;
226  }
227 
228  std::string operator()( const AlgoProps& props ) const
229  { // Returns algorithm's FSM state
231  State state = m_slot.algsStates[props.m_algoIndex];
232  switch ( state ) {
233  case State::INITIAL:
234  return "INITIAL";
235  case State::CONTROLREADY:
236  return "CONTROLREADY";
237  case State::DATAREADY:
238  return "DATAREADY";
239  case State::SCHEDULED:
240  return "SCHEDULED";
241  case State::EVTACCEPTED:
242  return "EVTACCEPTED";
243  case State::EVTREJECTED:
244  return "EVTREJECTED";
245  case State::ERROR:
246  return "ERROR";
247  default:
248  return "UNKNOWN";
249  }
250  }
251 
252  std::string operator()( const DecisionHubProps& ) const { return ""; }
253 
254  std::string operator()( const DataProps& props ) const
255  {
257 
258  if ( m_whiteboard.isValid() && m_slot.eventContext->valid() )
259  if ( m_whiteboard->selectStore( m_slot.eventContext->slot() ).isSuccess() )
260  state = m_whiteboard->exists( props.m_id.fullKey() ) ? "Produced" : "Missing";
261 
262  return state;
263  }
264 
265  std::string operator()( const CondDataProps& props ) const
266  {
268 
269  if ( m_condSvc.isValid() && m_slot.eventContext->valid() )
270  state = m_condSvc->isValidID( *( m_slot.eventContext ), props.m_id.fullKey() ) ? "Produced" : "Missing";
271 
272  return state;
273  }
274 
276 
279  bool m_conditionsEnabled{false};
280  };
281 
282  struct StartTime : static_visitor<std::string> {
283  StartTime( const EventSlot& slot, SmartIF<ISvcLocator>& svcLocator ) : m_slot( slot )
284  {
285  SmartIF<IMessageSvc> msgSvc{svcLocator};
286  MsgStream log{msgSvc, "StartTime.Getter"};
287 
288  // Figure if we can discover the algorithm timings
289  m_timelineSvc = svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
290  if ( !m_timelineSvc.isValid() ) {
291  log << MSG::WARNING << "Failed to locate the TimelineSvc: no way to "
292  << "add algorithm start time to the TTT dumps" << endmsg;
293  }
294  }
295 
296  std::string operator()( const AlgoProps& props ) const
297  {
298 
299  std::string startTime;
300 
301  if ( m_timelineSvc.isValid() ) {
302 
303  TimelineEvent te{};
304  te.algorithm = props.m_name;
305  te.slot = m_slot.eventContext->slot();
306  te.event = m_slot.eventContext->evt();
307 
308  m_timelineSvc->getTimelineEvent( te );
309  startTime = std::to_string(
310  std::chrono::duration_cast<std::chrono::nanoseconds>( te.start.time_since_epoch() ).count() );
311  }
312 
313  return startTime;
314  }
315 
316  std::string operator()( const DecisionHubProps& ) const { return ""; }
317 
318  std::string operator()( const DataProps& ) const { return ""; }
319 
322  };
323 
324  struct EndTime : static_visitor<std::string> {
325  EndTime( const EventSlot& slot, SmartIF<ISvcLocator>& svcLocator ) : m_slot( slot )
326  {
327  SmartIF<IMessageSvc> msgSvc{svcLocator};
328  MsgStream log{msgSvc, "EndTime.Getter"};
329 
330  // Figure if we can discover the algorithm timings
331  m_timelineSvc = svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
332  if ( !m_timelineSvc.isValid() )
333  log << MSG::WARNING << "Failed to locate the TimelineSvc: no way to add "
334  << "algorithm completion time to the TTT dumps" << endmsg;
335  }
336 
337  std::string operator()( const AlgoProps& props ) const
338  {
339 
340  std::string endTime;
341 
342  if ( m_timelineSvc.isValid() ) {
343 
344  TimelineEvent te{};
345  te.algorithm = props.m_name;
346  te.slot = m_slot.eventContext->slot();
347  te.event = m_slot.eventContext->evt();
348 
349  m_timelineSvc->getTimelineEvent( te );
350  endTime =
351  std::to_string( std::chrono::duration_cast<std::chrono::nanoseconds>( te.end.time_since_epoch() ).count() );
352  }
353 
354  return endTime;
355  }
356 
357  std::string operator()( const DecisionHubProps& ) const { return ""; }
358 
359  std::string operator()( const DataProps& ) const { return ""; }
360 
363  };
364 
365  struct Duration : static_visitor<std::string> {
366  Duration( const EventSlot& slot, SmartIF<ISvcLocator>& svcLocator ) : m_slot( slot )
367  {
368  SmartIF<IMessageSvc> msgSvc{svcLocator};
369  MsgStream log{msgSvc, "Duration.Getter"};
370 
371  // Figure if we can discover the algorithm timings
372  m_timelineSvc = svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
373  if ( !m_timelineSvc.isValid() )
374  log << MSG::WARNING << "Failed to locate the TimelineSvc: no way to add "
375  << "algorithm's runtimes to the TTT dumps" << endmsg;
376  }
377 
378  std::string operator()( const AlgoProps& props ) const
379  {
380 
382 
383  if ( m_timelineSvc.isValid() ) {
384 
385  TimelineEvent te;
386  te.algorithm = props.m_name;
387  te.slot = m_slot.eventContext->slot();
388  te.event = m_slot.eventContext->evt();
389 
390  m_timelineSvc->getTimelineEvent( te );
391  time = std::to_string( std::chrono::duration_cast<std::chrono::nanoseconds>( te.end - te.start ).count() );
392  }
393 
394  return time;
395  }
396 
397  std::string operator()( const DecisionHubProps& ) const { return ""; }
398 
399  std::string operator()( const DataProps& ) const { return ""; }
400 
403  };
404 
405  struct Operations : static_visitor<std::string> {
406  std::string operator()( const AlgoProps& props ) const { return props.m_isIOBound ? "IO-bound" : "CPU-bound"; }
407 
408  std::string operator()( const DecisionHubProps& ) const { return ""; }
409 
410  std::string operator()( const DataProps& ) const { return ""; }
411  };
412 
413  static inline std::ostream& operator<<( std::ostream& os, const AlgoProps& ) { return os << "Algorithm"; }
414  static inline std::ostream& operator<<( std::ostream& os, const DecisionHubProps& ) { return os << "DecisionHub"; }
415  static inline std::ostream& operator<<( std::ostream& os, const DataProps& ) { return os << "Data"; }
416  static inline std::ostream& operator<<( std::ostream& os, const CondDataProps& ) { return os << "ConditionData"; }
417 
418  //=========================================================================
419 
420  using VariantVertexProps = boost::variant<AlgoProps, DecisionHubProps, DataProps, CondDataProps>;
421  using PRGraph = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, VariantVertexProps>;
422  using PRVertexDesc = boost::graph_traits<PRGraph>::vertex_descriptor;
423 
424 } // namespace prules
425 
426 struct Cause {
427  enum class source { Root, Task };
428 
431 };
432 
433 namespace concurrency
434 {
435 
437  class PrecedenceRulesGraph;
438 
440  using precedence::AlgoProps;
442  using precedence::DataProps;
445 
446  // ==========================================================================
448  {
449  public:
451  ControlFlowNode( PrecedenceRulesGraph& graph, unsigned int nodeIndex, const std::string& name )
452  : m_graph( &graph ), m_nodeIndex( nodeIndex ), m_nodeName( name )
453  {
454  }
456  virtual ~ControlFlowNode() {}
457 
459  virtual bool accept( IGraphVisitor& visitor ) = 0;
461  virtual void printState( std::stringstream& output, AlgsExecutionStates& states,
462  const std::vector<int>& node_decisions, const unsigned int& recursionLevel ) const = 0;
464  const unsigned int& getNodeIndex() const { return m_nodeIndex; }
466  const std::string& getNodeName() const { return m_nodeName; }
467 
468  public:
470 
471  protected:
473  std::string stateToString( const int& stateId ) const;
474  unsigned int m_nodeIndex;
476  };
477 
479  {
480  public:
482  DecisionNode( PrecedenceRulesGraph& graph, unsigned int nodeIndex, const std::string& name,
483  Concurrent modeConcurrent, PromptDecision modePromptDecision, ModeOr modeOR, AllPass allPass,
484  Inverted isInverted )
485  : ControlFlowNode( graph, nodeIndex, name )
486  , m_modeConcurrent( modeConcurrent )
487  , m_modePromptDecision( modePromptDecision )
488  , m_modeOR( modeOR )
489  , m_allPass( allPass )
490  , m_inverted( isInverted )
491  , m_children()
492  {
493  }
494 
496  ~DecisionNode() override;
497 
499  bool accept( IGraphVisitor& visitor ) override;
501  void addParentNode( DecisionNode* node );
503  void addDaughterNode( ControlFlowNode* node );
505  const std::vector<ControlFlowNode*>& getDaughters() const { return m_children; }
507  void printState( std::stringstream& output, AlgsExecutionStates& states, const std::vector<int>& node_decisions,
508  const unsigned int& recursionLevel ) const override;
509 
510  public:
517  bool m_modeOR;
519  bool m_allPass;
521  bool m_inverted{false};
526  };
527 
528  // ==========================================================================
529  class DataNode;
530 
532  {
533  public:
535  AlgorithmNode( PrecedenceRulesGraph& graph, Algorithm* algoPtr, unsigned int nodeIndex, unsigned int algoIndex,
536  bool inverted, bool allPass )
537  : ControlFlowNode( graph, nodeIndex, algoPtr->name() )
538  , m_algorithm( algoPtr )
539  , m_algoIndex( algoIndex )
540  , m_algoName( algoPtr->name() )
541  , m_inverted( inverted )
542  , m_allPass( allPass )
543  , m_rank( -1 )
544  , m_isIOBound( algoPtr->isIOBound() ){};
546  ~AlgorithmNode();
547 
549  bool accept( IGraphVisitor& visitor ) override;
550 
552  void addParentNode( DecisionNode* node );
554  const std::vector<DecisionNode*>& getParentDecisionHubs() const { return m_parents; }
555 
557  void addOutputDataNode( DataNode* node );
559  void addInputDataNode( DataNode* node );
561  const std::vector<DataNode*>& getOutputDataNodes() const { return m_outputs; }
564 
566  void setRank( float& rank ) { m_rank = rank; }
568  const float& getRank() const { return m_rank; }
569 
571  Algorithm* getAlgorithm() const { return m_algorithm; }
573  const unsigned int& getAlgoIndex() const { return m_algoIndex; }
574 
576  void setIOBound( bool value ) { m_isIOBound = value; }
578  bool isIOBound() const { return m_isIOBound; }
579 
581  bool isOptimist() const { return m_allPass; };
583  bool isLiar() const { return m_inverted; };
584 
586  void printState( std::stringstream& output, AlgsExecutionStates& states, const std::vector<int>& node_decisions,
587  const unsigned int& recursionLevel ) const override;
588 
589  public:
592 
593  private:
597  unsigned int m_algoIndex;
603  bool m_allPass;
605  float m_rank;
608 
613  };
614 
615  // ==========================================================================
616  class DataNode
617  {
618  public:
620  DataNode( PrecedenceRulesGraph& graph, const DataObjID& path ) : m_graph( &graph ), m_data_object_path( path ) {}
621 
623  virtual ~DataNode() = default;
624 
625  const DataObjID& getPath() { return m_data_object_path; }
626 
628  virtual bool accept( IGraphVisitor& visitor )
629  {
630  if ( visitor.visitEnter( *this ) ) return visitor.visit( *this );
631  return true;
632  }
635  {
636  if ( std::find( m_producers.begin(), m_producers.end(), node ) == m_producers.end() )
637  m_producers.push_back( node );
638  }
641  {
642  if ( std::find( m_consumers.begin(), m_consumers.end(), node ) == m_consumers.end() )
643  m_consumers.push_back( node );
644  }
646  const std::vector<AlgorithmNode*>& getProducers() const { return m_producers; }
648  const std::vector<AlgorithmNode*>& getConsumers() const { return m_consumers; }
649 
650  public:
652 
653  private:
657  };
658 
659  class ConditionNode : public DataNode
660  {
661  public:
664  : DataNode( graph, path ), m_condSvc( condSvc )
665  {
666  }
667 
671  bool accept( IGraphVisitor& visitor ) override
672  {
673  if ( visitor.visitEnter( *this ) ) return visitor.visit( *this );
674  return true;
675  }
676 
677  public:
678  // Service for Conditions handling
680  };
681 
682  // ==========================================================================
686 
689 
691  virtual ~IPrecedenceRulesGraph() = default;
692  };
693 
694  class PrecedenceRulesGraph : public CommonMessaging<IPrecedenceRulesGraph>
695  {
696  public:
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  }
711  {
712  if ( m_headNode != 0 ) delete m_headNode;
713  }
714 
716  StatusCode initialize();
717 
719  void accept( const std::string& algo_name, IGraphVisitor& visitor ) const;
720 
722  StatusCode addDataNode( const DataObjID& dataPath );
724  DataNode* getDataNode( const DataObjID& dataPath ) const;
726  void registerIODataObjects( const Algorithm* algo );
728  StatusCode buildDataDependenciesRealm();
729 
731  void addHeadNode( const std::string& headName, concurrency::Concurrent, concurrency::PromptDecision,
734  DecisionNode* getHeadNode() const { return m_headNode; };
736  StatusCode addAlgorithmNode( Algorithm* daughterAlgo, const std::string& parentName, bool inverted, bool allPass );
738  AlgorithmNode* getAlgorithmNode( const std::string& algoName ) const;
740  StatusCode addDecisionHubNode( Algorithm* daughterAlgo, const std::string& parentName, concurrency::Concurrent,
744  unsigned int getControlFlowNodeCounter() const { return m_nodeCounter; }
745 
747  void rankAlgorithms( IGraphVisitor& ranker ) const;
748 
750  const std::string& name() const override { return m_name; }
752  SmartIF<ISvcLocator>& serviceLocator() const override { return m_svcLocator; }
754  const std::chrono::system_clock::time_point getInitTime() const { return m_initTime; }
755 
758  const unsigned int& recursionLevel ) const
759  {
760  m_headNode->printState( output, states, node_decisions, recursionLevel );
761  }
762 
764  void enableAnalysis() { m_enableAnalysis = true; };
765  PRVertexDesc node( const std::string& ) const;
766 
768  std::string dumpDataFlow() const;
770  std::string dumpControlFlow() const;
772  void dumpPrecRules( const boost::filesystem::path&, const EventSlot& slot );
774  void dumpPrecTrace( const boost::filesystem::path& );
776  void addEdgeToPrecTrace( const AlgorithmNode* u, const AlgorithmNode* v );
778  void dumpControlFlow( std::ostringstream&, ControlFlowNode*, const int& ) const;
779 
780  private:
792 
794  unsigned int m_nodeCounter;
796  unsigned int m_algoCounter;
797 
801 
803 
807  bool m_enableAnalysis{false};
810 
812  bool m_conditionsRealmEnabled{false};
813  };
814 
815 } // namespace concurrency
816 #endif
std::vector< DataNode * > m_outputs
Algorithm outputs (DataNodes)
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, VariantVertexProps > PRGraph
std::string operator()(const DecisionHubProps &props) const
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
const unsigned int & getAlgoIndex() const
Get algorithm index.
std::string operator()(const DecisionHubProps &) const
std::vector< DecisionNode * > m_parents
Direct parent nodes.
AlgoTraceProps(const std::string &name, int index, int rank, double runtime)
ControlFlowNode(PrecedenceRulesGraph &graph, unsigned int nodeIndex, const std::string &name)
Constructor.
std::string operator()(const AlgoProps &props) const
unsigned int m_algoIndex
The index of the algorithm.
const std::chrono::system_clock::time_point getInitTime() const
std::string operator()(const AlgoProps &props) const
AlgoProps(Algorithm *algo, uint nodeIndex, uint algoIndex, bool inverted, bool allPass)
precedence::PrecTrace m_precTrace
facilities for algorithm precedence tracing
void setIOBound(bool value)
Set the I/O-boundness flag.
CondDataProps(const DataObjID &id)
std::string operator()(const AlgoProps &props) const
boost::graph_traits< PrecTrace >::vertex_descriptor AlgoTraceVertex
boost::graph_traits< PRGraph >::vertex_descriptor PRVertexDesc
const std::chrono::system_clock::time_point m_initTime
std::string m_algoName
The name of the algorithm.
const std::vector< DataNode * > & getInputDataNodes() const
Get all consumer nodes.
bool isOptimist() const
Check if positive control flow decision is enforced.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
AlgoNodesMap m_algoNameToAlgoNodeMap
Index: map of algorithm&#39;s name to AlgorithmNode.
virtual bool visit(DecisionNode &)
Definition: IGraphVisitor.h:18
void setRank(float &rank)
Set Algorithm rank.
std::vector< ControlFlowNode * > m_children
All direct daughter nodes in the tree.
std::string operator()(const CondDataProps &props) const
EntityState(const EventSlot &slot, SmartIF< ISvcLocator > &svcLocator, bool conditionsEnabled)
std::string operator()(const AlgoProps &) const
T to_string(T...args)
std::string operator()(const DecisionHubProps &props) const
DataProps(const DataObjID &id)
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.
std::map< std::string, precedence::AlgoTraceVertex > m_prec_trace_map
std::vector< DecisionNode * > m_parents
Control flow parents of an AlgorithmNode (DecisionNodes)
bool m_isIOBound
If an algorithm is blocking.
STL namespace.
SmartIF< ITimelineSvc > m_timelineSvc
const std::vector< DataNode * > & getOutputDataNodes() const
Get all supplier nodes.
std::string algorithm
Definition: ITimelineSvc.h:18
std::string operator()(const DataProps &) const
unsigned int m_algoCounter
Total number of algorithm nodes in the graph.
bool m_allPass
Whether always passing regardless of daughter results.
std::string operator()(const AlgoProps &props) const
std::string operator()(const AlgoProps &props) const
bool m_inverted
Whether the selection result is negated or not.
bool m_allPass
Whether always passing regardless of daughter results.
std::string operator()(const DataProps &) const
const std::vector< DecisionNode * > & getParentDecisionHubs() const
Get all parent decision hubs.
std::string operator()(const DecisionHubProps &props) const
bool isIOBound() const
Check if algorithm is I/O-bound.
Gaudi::tagged_bool< class ModeOr_tag > ModeOr
~PrecedenceRulesGraph() override
Destructor.
std::string operator()(const DataProps &props) const
SmartIF< ITimelineSvc > m_timelineSvc
virtual bool visitEnter(DecisionNode &) const
Definition: IGraphVisitor.h:17
STL class.
Algorithm * getAlgorithm() const
get Algorithm representatives
std::string operator()(const DecisionHubProps &) const
virtual ~ControlFlowNode()
Destructor.
std::string operator()(const DataProps &) const
bool m_modeOR
Whether acting as "and" (false) or "or" node (true)
time_point end
Definition: ITimelineSvc.h:21
std::string operator()(const AlgoProps &) const
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
std::string operator()(const DataProps &) const
SmartIF< ITimelineSvc > m_timelineSvc
Duration(const EventSlot &slot, SmartIF< ISvcLocator > &svcLocator)
const float & getRank() const
Get Algorithm rank.
The AlgsExecutionStates encodes the state machine for the execution of algorithms within a single eve...
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
GAUDI_API ISvcLocator * svcLocator()
PrecedenceRulesGraph * m_graph
Gaudi::tagged_bool< class Inverted_tag > Inverted
std::string operator()(const DataProps &) const
void enableAnalysis()
BGL-based facilities.
const DataObjID & getPath()
DecisionNode * m_headNode
the head node of the control flow graph
std::string operator()(const DecisionHubProps &) const
std::vector< AlgorithmNode * > m_consumers
SmartIF< ICondSvc > m_condSvc
DecisionNode(PrecedenceRulesGraph &graph, unsigned int nodeIndex, const std::string &name, Concurrent modeConcurrent, PromptDecision modePromptDecision, ModeOr modeOR, AllPass allPass, Inverted isInverted)
Constructor.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual bool accept(IGraphVisitor &visitor)
Entry point for a visitor.
const std::vector< ControlFlowNode * > & getDaughters() const
Get children nodes.
std::string operator()(const AlgoProps &props) const
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, AlgoTraceProps > PrecTrace
const std::vector< AlgorithmNode * > & getConsumers() const
Get all data object consumers.
EndTime(const EventSlot &slot, SmartIF< ISvcLocator > &svcLocator)
std::string operator()(const DecisionHubProps &) const
DataNode(PrecedenceRulesGraph &graph, const DataObjID &path)
Constructor.
bool m_modePromptDecision
Whether to evaluate the hub decision ASA its child decisions allow to do that.
std::string operator()(const AlgoProps &props) const
Interface for the Condition Service.
Definition: ICondSvc.h:28
bool m_allPass
Whether the selection result is relevant or always "pass".
bool m_inverted
Whether the selection result is negated or not.
PrecedenceRulesGraph(const std::string &name, SmartIF< ISvcLocator > svc)
Constructor.
Gaudi::tagged_bool< class Concurrent_tag > Concurrent
bool m_modePromptDecision
Whether to evaluate the hub decision ASA its child decisions allow to do that.
Algorithm * m_algorithm
Algorithm representative behind the AlgorithmNode.
time_point start
Definition: ITimelineSvc.h:20
float m_rank
Algorithm rank of any kind.
std::string operator()(const DecisionHubProps &) const
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
std::string operator()(const DecisionHubProps &) const
T find(T...args)
std::vector< InputHandle_t< In > > m_inputs
std::string operator()(const AlgoProps &props) const
SmartIF< IHiveWhiteBoard > m_whiteboard
Gaudi::tagged_bool< class PromptDecision_tag > PromptDecision
std::vector< DataNode * > m_inputs
Algorithm inputs (DataNodes)
bool m_modeConcurrent
Whether all daughters will be evaluated concurrently or sequentially.
Clock::time_point time_point
Definition: ITimelineSvc.h:11
std::vector< AlgorithmNode * > m_producers
std::string operator()(const DataProps &) const
std::string operator()(const AlgoProps &props) const
std::string operator()(const DataProps &) const
unsigned int m_nodeCounter
Total number of nodes in the graph.
Class representing the event slot.
Definition: EventSlot.h:10
Gaudi::tagged_bool< class AllPass_tag > AllPass
std::string operator()(const DecisionHubProps &props) const
bool isLiar() const
Check if control flow logic is always inverted.
DecisionHubProps(const std::string &name, uint nodeIndex, concurrency::Concurrent modeConcurrent, concurrency::PromptDecision modePromptDecision, concurrency::ModeOr modeOR, concurrency::AllPass allPass, concurrency::Inverted isInverted)
PrecedenceRulesGraph * m_graph
AlgorithmNode(PrecedenceRulesGraph &graph, Algorithm *algoPtr, unsigned int nodeIndex, unsigned int algoIndex, bool inverted, bool allPass)
Constructor.
bool m_modeOR
Whether acting as "and" (false) or "or" node (true)
const std::string & getNodeName() const
Get node name.
const unsigned int & getNodeIndex() const
Get node index.
bool m_modeConcurrent
Whether all daughters will be evaluated concurrently or sequentially.
std::string operator()(const DecisionHubProps &props) const
State
Execution states of the algorithms.
std::string fullKey() const
Definition: DataObjID.cpp:54
STL class.
bool accept(IGraphVisitor &visitor) override
Need to hide the (identical) base method with this one so that visitEnter(ConditionNode&) and visit(C...
std::string operator()(const DataProps &) const
const std::string & name() const override
Retrieve name of the service.
bool m_isIOBound
If an algorithm is blocking.
StartTime(const EventSlot &slot, SmartIF< ISvcLocator > &svcLocator)
std::string operator()(const DecisionHubProps &props) const
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
std::string operator()(const AlgoProps &) const
std::string operator()(const DataProps &props) const
std::string m_sourceName
bool m_allPass
Whether the selection result is relevant or always "pass".
AlgoInputsMap m_algoNameToAlgoInputsMap
Indexes: maps of algorithm&#39;s name to algorithm&#39;s inputs/outputs.
void addProducerNode(AlgorithmNode *node)
Add relationship to producer AlgorithmNode.
const std::vector< AlgorithmNode * > & getProducers() const
Get all data object producers.
DataNodesMap m_dataPathToDataNodeMap
Index: map of data path to DataNode.
unsigned int getControlFlowNodeCounter() const
Get total number of control flow graph nodes.
std::string operator()(const DataProps &) const
boost::variant< AlgoProps, DecisionHubProps, DataProps, CondDataProps > VariantVertexProps
SmartIF< ISvcLocator > m_svcLocator
Service locator (needed to access the MessageSvc)
ConditionNode(PrecedenceRulesGraph &graph, const DataObjID &path, SmartIF< ICondSvc > condSvc)
Constructor.
DecisionNode * getHeadNode() const
Get head node.
std::string operator()(const DataProps &) const
CFDecision(const EventSlot &slot)
void addConsumerNode(AlgorithmNode *node)
Add relationship to consumer AlgorithmNode.
DecisionHubsMap m_decisionNameToDecisionHubMap
Index: map of decision&#39;s name to DecisionHub.