Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 <memory>
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"
20 #include "GaudiKernel/DataObject.h"
21 #include "GaudiKernel/ICondSvc.h"
24 #include "GaudiKernel/TaggedBool.h"
25 #include "IGraphVisitor.h"
26 #include <Gaudi/Algorithm.h>
27 
28 namespace concurrency {
29  using Concurrent = Gaudi::tagged_bool<class Concurrent_tag>;
30  using PromptDecision = Gaudi::tagged_bool<class PromptDecision_tag>;
31  using ModeOr = Gaudi::tagged_bool<class ModeOr_tag>;
32  using AllPass = Gaudi::tagged_bool<class AllPass_tag>;
33  using Inverted = Gaudi::tagged_bool<class Inverted_tag>;
34 } // namespace concurrency
35 
36 namespace precedence {
37  using boost::static_visitor;
38 
39  // Precedence trace utilities ==============================================
40  struct AlgoTraceProps {
42  AlgoTraceProps( const std::string& name, int index, int rank, double runtime )
43  : m_name( name ), m_index( index ), m_rank( rank ), m_runtime( runtime ) {}
45  int m_index{-1};
46  int m_rank{-1};
47  int m_runtime{-1}; // ns
48  int m_eccentricity{-1};
49  };
50 
51  using PrecTrace = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, AlgoTraceProps>;
52  using AlgoTraceVertex = boost::graph_traits<PrecTrace>::vertex_descriptor;
53 
54  // Precedence rules utilities ==============================================
55  struct AlgoProps {
56  AlgoProps() {}
57  AlgoProps( Gaudi::Algorithm* algo, uint nodeIndex, uint algoIndex, bool inverted, bool allPass )
58  : m_name( algo->name() )
59  , m_nodeIndex( nodeIndex )
60  , m_algoIndex( algoIndex )
61  , m_algorithm( algo )
62  , m_inverted( inverted )
63  , m_allPass( allPass )
64  , m_isIOBound( algo->isIOBound() ) {}
65 
66  std::string m_name{""};
67  int m_nodeIndex{-1};
68  int m_algoIndex{-1};
69  int m_rank{-1};
71  Gaudi::Algorithm* m_algorithm{nullptr};
72 
74  bool m_inverted{false};
76  bool m_allPass{false};
78  bool m_isIOBound{false};
79  };
80 
82  DecisionHubProps( const std::string& name, uint nodeIndex, concurrency::Concurrent modeConcurrent,
83  concurrency::PromptDecision modePromptDecision, concurrency::ModeOr modeOR,
84  concurrency::AllPass allPass, concurrency::Inverted isInverted )
85  : m_name( name )
86  , m_nodeIndex( nodeIndex )
87  , m_modeConcurrent( modeConcurrent )
88  , m_modePromptDecision( modePromptDecision )
89  , m_inverted( isInverted )
90  , m_modeOR( modeOR )
91  , m_allPass( allPass ) {}
92 
95 
102  bool m_inverted{false};
104  bool m_modeOR;
106  bool m_allPass;
107  };
108 
109  struct DataProps {
110  DataProps( const DataObjID& id ) : m_id( id ) {}
111 
113  };
114 
116  CondDataProps( const DataObjID& id ) : DataProps( id ) {}
117  };
118 
119  // Vertex unpacking ========================================================
120 
121  struct VertexName : static_visitor<std::string> {
122  std::string operator()( const AlgoProps& props ) const { return props.m_name; }
123 
124  std::string operator()( const DecisionHubProps& props ) const { return props.m_name; }
125 
126  std::string operator()( const DataProps& props ) const { return props.m_id.fullKey(); }
127  };
128 
129  struct GroupMode : static_visitor<std::string> {
130  std::string operator()( const AlgoProps& ) const { return ""; }
131 
132  std::string operator()( const DecisionHubProps& props ) const {
133  return props.m_modeConcurrent ? "Concurrent" : "Sequential";
134  }
135 
136  std::string operator()( const DataProps& ) const { return ""; }
137  };
138 
139  struct GroupLogic : static_visitor<std::string> {
140  std::string operator()( const AlgoProps& ) const { return ""; }
141 
142  std::string operator()( const DecisionHubProps& props ) const { return props.m_modeOR ? "OR" : "AND"; }
143 
144  std::string operator()( const DataProps& ) const { return ""; }
145  };
146 
147  struct GroupExit : static_visitor<std::string> {
148  std::string operator()( const AlgoProps& ) const { return ""; }
149 
150  std::string operator()( const DecisionHubProps& props ) const {
151  return props.m_modePromptDecision ? "Early" : "Late";
152  }
153 
154  std::string operator()( const DataProps& ) const { return ""; }
155  };
156 
157  struct DecisionNegation : static_visitor<std::string> {
158  std::string operator()( const AlgoProps& props ) const { return props.m_inverted ? "Inverted" : "Non-inverted"; }
159 
160  std::string operator()( const DecisionHubProps& ) const { return ""; }
161 
162  std::string operator()( const DataProps& ) const { return ""; }
163  };
164 
165  struct AllPass : static_visitor<std::string> {
166  std::string operator()( const AlgoProps& props ) const { return props.m_allPass ? "Optimist" : "Realist"; }
167 
168  std::string operator()( const DecisionHubProps& props ) const { return props.m_allPass ? "Optimist" : "Realist"; }
169 
170  std::string operator()( const DataProps& ) const { return ""; }
171  };
172 
173  struct CFDecision : static_visitor<std::string> {
174  CFDecision( const EventSlot& slot ) : m_slot( slot ) {}
175 
176  std::string operator()( const AlgoProps& props ) const {
177  return std::to_string( m_slot.controlFlowState.at( props.m_nodeIndex ) );
178  }
179 
180  std::string operator()( const DecisionHubProps& props ) const {
181  return std::to_string( m_slot.controlFlowState.at( props.m_nodeIndex ) );
182  }
183 
184  std::string operator()( const DataProps& ) const { return ""; }
185 
187  };
188 
189  struct EntityState : static_visitor<std::string> {
190  EntityState( const EventSlot& slot, SmartIF<ISvcLocator>& svcLocator, bool conditionsEnabled )
191  : m_slot( slot ), m_conditionsEnabled( conditionsEnabled ) {
192  SmartIF<IMessageSvc> msgSvc{svcLocator};
193  MsgStream log{msgSvc, "EntityState.Getter"};
194 
195  // Figure if we can discover the data object states
196  m_whiteboard = svcLocator->service<IHiveWhiteBoard>( "EventDataSvc", false );
197  if ( !m_whiteboard.isValid() ) {
198  log << MSG::WARNING << "Failed to locate EventDataSvc: no way to add DO "
199  << "states to the TTT dump " << endmsg;
200  }
201 
202  if ( m_conditionsEnabled ) {
203  // Figure if we can discover Condition data object states
204  m_condSvc = svcLocator->service<ICondSvc>( "CondSvc", false );
205  if ( !m_condSvc.isValid() )
206  log << MSG::WARNING << "Failed to locate CondSvc: no way to add Condition DO "
207  << "states to the TTT dump " << endmsg;
208  }
209 
210  if ( !m_slot.eventContext->valid() )
211  log << MSG::WARNING << "Event context is invalid: no way to add DO states"
212  << " in the TTT dump" << endmsg;
213  }
214 
215  // Returns algorithm's FSM state
216  std::string operator()( const AlgoProps& props ) const {
217  std::ostringstream oss;
218  oss << m_slot.algsStates[props.m_algoIndex];
219  return oss.str();
220  }
221 
222  std::string operator()( const DecisionHubProps& ) const { return ""; }
223 
224  std::string operator()( const DataProps& props ) const {
226 
227  if ( m_whiteboard.isValid() && m_slot.eventContext->valid() )
228  if ( m_whiteboard->selectStore( m_slot.eventContext->slot() ).isSuccess() )
229  state = m_whiteboard->exists( props.m_id ) ? "Produced" : "Missing";
230 
231  return state;
232  }
233 
234  std::string operator()( const CondDataProps& props ) const {
236 
237  if ( m_condSvc.isValid() && m_slot.eventContext->valid() )
238  state = m_condSvc->isValidID( *( m_slot.eventContext ), props.m_id ) ? "Produced" : "Missing";
239 
240  return state;
241  }
242 
244 
247  bool m_conditionsEnabled{false};
248  };
249 
250  struct StartTime : static_visitor<std::string> {
251  StartTime( const EventSlot& slot, SmartIF<ISvcLocator>& svcLocator ) : m_slot( slot ) {
252  SmartIF<IMessageSvc> msgSvc{svcLocator};
253  MsgStream log{msgSvc, "StartTime.Getter"};
254 
255  // Figure if we can discover the algorithm timings
256  m_timelineSvc = svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
257  if ( !m_timelineSvc.isValid() ) {
258  log << MSG::WARNING << "Failed to locate the TimelineSvc: no way to "
259  << "add algorithm start time to the TTT dumps" << endmsg;
260  }
261  }
262 
263  std::string operator()( const AlgoProps& props ) const {
264 
265  std::string startTime;
266 
267  if ( m_timelineSvc.isValid() ) {
268 
269  TimelineEvent te{};
270  te.algorithm = props.m_name;
271  te.slot = m_slot.eventContext->slot();
272  te.event = m_slot.eventContext->evt();
273 
274  m_timelineSvc->getTimelineEvent( te );
275  startTime = std::to_string(
276  std::chrono::duration_cast<std::chrono::nanoseconds>( te.start.time_since_epoch() ).count() );
277  }
278 
279  return startTime;
280  }
281 
282  std::string operator()( const DecisionHubProps& ) const { return ""; }
283 
284  std::string operator()( const DataProps& ) const { return ""; }
285 
288  };
289 
290  struct EndTime : static_visitor<std::string> {
291  EndTime( const EventSlot& slot, SmartIF<ISvcLocator>& svcLocator ) : m_slot( slot ) {
292  SmartIF<IMessageSvc> msgSvc{svcLocator};
293  MsgStream log{msgSvc, "EndTime.Getter"};
294 
295  // Figure if we can discover the algorithm timings
296  m_timelineSvc = svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
297  if ( !m_timelineSvc.isValid() )
298  log << MSG::WARNING << "Failed to locate the TimelineSvc: no way to add "
299  << "algorithm completion time to the TTT dumps" << endmsg;
300  }
301 
302  std::string operator()( const AlgoProps& props ) const {
303 
304  std::string endTime;
305 
306  if ( m_timelineSvc.isValid() ) {
307 
308  TimelineEvent te{};
309  te.algorithm = props.m_name;
310  te.slot = m_slot.eventContext->slot();
311  te.event = m_slot.eventContext->evt();
312 
313  m_timelineSvc->getTimelineEvent( te );
314  endTime =
315  std::to_string( std::chrono::duration_cast<std::chrono::nanoseconds>( te.end.time_since_epoch() ).count() );
316  }
317 
318  return endTime;
319  }
320 
321  std::string operator()( const DecisionHubProps& ) const { return ""; }
322 
323  std::string operator()( const DataProps& ) const { return ""; }
324 
327  };
328 
329  struct Duration : static_visitor<std::string> {
330  Duration( const EventSlot& slot, SmartIF<ISvcLocator>& svcLocator ) : m_slot( slot ) {
331  SmartIF<IMessageSvc> msgSvc{svcLocator};
332  MsgStream log{msgSvc, "Duration.Getter"};
333 
334  // Figure if we can discover the algorithm timings
335  m_timelineSvc = svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
336  if ( !m_timelineSvc.isValid() )
337  log << MSG::WARNING << "Failed to locate the TimelineSvc: no way to add "
338  << "algorithm's runtimes to the TTT dumps" << endmsg;
339  }
340 
341  std::string operator()( const AlgoProps& props ) const {
342 
344 
345  if ( m_timelineSvc.isValid() ) {
346 
347  TimelineEvent te;
348  te.algorithm = props.m_name;
349  te.slot = m_slot.eventContext->slot();
350  te.event = m_slot.eventContext->evt();
351 
352  m_timelineSvc->getTimelineEvent( te );
353  time = std::to_string( std::chrono::duration_cast<std::chrono::nanoseconds>( te.end - te.start ).count() );
354  }
355 
356  return time;
357  }
358 
359  std::string operator()( const DecisionHubProps& ) const { return ""; }
360 
361  std::string operator()( const DataProps& ) const { return ""; }
362 
365  };
366 
367  struct Operations : static_visitor<std::string> {
368  std::string operator()( const AlgoProps& props ) const { return props.m_isIOBound ? "IO-bound" : "CPU-bound"; }
369 
370  std::string operator()( const DecisionHubProps& ) const { return ""; }
371 
372  std::string operator()( const DataProps& ) const { return ""; }
373  };
374 
375  static inline std::ostream& operator<<( std::ostream& os, const AlgoProps& ) { return os << "Algorithm"; }
376  static inline std::ostream& operator<<( std::ostream& os, const DecisionHubProps& ) { return os << "DecisionHub"; }
377  static inline std::ostream& operator<<( std::ostream& os, const DataProps& ) { return os << "Data"; }
378  static inline std::ostream& operator<<( std::ostream& os, const CondDataProps& ) { return os << "ConditionData"; }
379 
380  //=========================================================================
381 
382  using VariantVertexProps = boost::variant<AlgoProps, DecisionHubProps, DataProps, CondDataProps>;
383  using PRGraph = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, VariantVertexProps>;
384  using PRVertexDesc = boost::graph_traits<PRGraph>::vertex_descriptor;
385 
386 } // namespace precedence
387 
388 struct Cause final {
389  enum class source { Root, Task };
390 
393 };
394 
395 namespace concurrency {
396  class PrecedenceRulesGraph;
397 
398  using precedence::AlgoProps;
400  using precedence::DataProps;
404 
405  // ==========================================================================
407  public:
409  ControlFlowNode( PrecedenceRulesGraph& graph, unsigned int nodeIndex, const std::string& name )
410  : m_graph( &graph ), m_nodeIndex( nodeIndex ), m_nodeName( name ) {}
412  virtual ~ControlFlowNode() = default;
413 
415  virtual bool accept( IGraphVisitor& visitor ) = 0;
417  virtual void printState( std::stringstream& output, AlgsExecutionStates& states,
418  const std::vector<int>& node_decisions, const unsigned int& recursionLevel ) const = 0;
420  const unsigned int& getNodeIndex() const { return m_nodeIndex; }
422  const std::string& getNodeName() const { return m_nodeName; }
423 
424  public:
426 
427  protected:
428  unsigned int m_nodeIndex;
430  };
431 
432  class DecisionNode final : public ControlFlowNode {
433  public:
435  DecisionNode( PrecedenceRulesGraph& graph, unsigned int nodeIndex, const std::string& name,
436  Concurrent modeConcurrent, PromptDecision modePromptDecision, ModeOr modeOR, AllPass allPass,
437  Inverted isInverted )
438  : ControlFlowNode( graph, nodeIndex, name )
439  , m_modeConcurrent( modeConcurrent )
440  , m_modePromptDecision( modePromptDecision )
441  , m_modeOR( modeOR )
442  , m_allPass( allPass )
443  , m_inverted( isInverted ) {}
444 
446  bool accept( IGraphVisitor& visitor ) override;
448  void addParentNode( DecisionNode* node );
450  void addDaughterNode( ControlFlowNode* node );
452  const std::vector<ControlFlowNode*>& getDaughters() const { return m_children; }
454  void printState( std::stringstream& output, AlgsExecutionStates& states, const std::vector<int>& node_decisions,
455  const unsigned int& recursionLevel ) const override;
456 
457  public:
464  bool m_modeOR;
466  bool m_allPass;
468  bool m_inverted{false};
473  };
474 
475  // ==========================================================================
476  class DataNode;
477 
478  class AlgorithmNode final : public ControlFlowNode {
479  public:
481  AlgorithmNode( PrecedenceRulesGraph& graph, Gaudi::Algorithm* algoPtr, unsigned int nodeIndex,
482  unsigned int algoIndex, bool inverted, bool allPass )
483  : ControlFlowNode( graph, nodeIndex, algoPtr->name() )
484  , m_algorithm( algoPtr )
485  , m_algoIndex( algoIndex )
486  , m_algoName( algoPtr->name() )
487  , m_inverted( inverted )
488  , m_allPass( allPass )
489  , m_isIOBound( algoPtr->isIOBound() ){};
490 
492  bool accept( IGraphVisitor& visitor ) override;
493 
495  void addParentNode( DecisionNode* node );
497  const std::vector<DecisionNode*>& getParentDecisionHubs() const { return m_parents; }
498 
500  void addOutputDataNode( DataNode* node );
502  void addInputDataNode( DataNode* node );
504  const std::vector<DataNode*>& getOutputDataNodes() const { return m_outputs; }
507 
509  void setRank( float& rank ) { m_rank = rank; }
511  const float& getRank() const { return m_rank; }
512 
514  Gaudi::Algorithm* getAlgorithm() const { return m_algorithm; }
516  const unsigned int& getAlgoIndex() const { return m_algoIndex; }
517 
519  void setIOBound( bool value ) { m_isIOBound = value; }
521  bool isIOBound() const { return m_isIOBound; }
522 
524  bool isOptimist() const { return m_allPass; };
526  bool isLiar() const { return m_inverted; };
527 
529  void printState( std::stringstream& output, AlgsExecutionStates& states, const std::vector<int>& node_decisions,
530  const unsigned int& recursionLevel ) const override;
531 
532  public:
535 
536  private:
540  unsigned int m_algoIndex;
546  bool m_allPass;
548  float m_rank = -1;
551 
556  };
557 
558  // ==========================================================================
559  class DataNode {
560  public:
562  DataNode( PrecedenceRulesGraph& graph, const DataObjID& path ) : m_graph( &graph ), m_data_object_path( path ) {}
563 
565  virtual ~DataNode() = default;
566 
567  const DataObjID& getPath() { return m_data_object_path; }
568 
570  virtual bool accept( IGraphVisitor& visitor ) {
571  return visitor.visitEnter( *this ) ? visitor.visit( *this ) : true;
572  }
575  if ( std::find( m_producers.begin(), m_producers.end(), node ) == m_producers.end() )
576  m_producers.push_back( node );
577  }
580  if ( std::find( m_consumers.begin(), m_consumers.end(), node ) == m_consumers.end() )
581  m_consumers.push_back( node );
582  }
584  const std::vector<AlgorithmNode*>& getProducers() const { return m_producers; }
586  const std::vector<AlgorithmNode*>& getConsumers() const { return m_consumers; }
587 
588  public:
590 
591  private:
595  };
596 
597  class ConditionNode final : public DataNode {
598  public:
601  : DataNode( graph, path ), m_condSvc( condSvc ) {}
602 
606  bool accept( IGraphVisitor& visitor ) override {
607  return visitor.visitEnter( *this ) ? visitor.visit( *this ) : true;
608  }
609 
610  public:
611  // Service for Conditions handling
613  };
614 
615  // ==========================================================================
616 
618  virtual ~IPrecedenceRulesGraph() = default;
619  };
620 
621  class PrecedenceRulesGraph : public CommonMessaging<IPrecedenceRulesGraph> {
622  public:
624  PrecedenceRulesGraph( const std::string& name, SmartIF<ISvcLocator> svc ) : m_svcLocator( svc ), m_name( name ) {
625  // make sure that CommonMessaging is initialized
626  setUpMessaging();
627  }
628 
630  StatusCode initialize();
631 
633  void accept( IGraphVisitor& visitor ) const;
634 
636  StatusCode addDataNode( const DataObjID& dataPath );
638  DataNode* getDataNode( const DataObjID& dataPath ) const { return m_dataPathToDataNodeMap.at( dataPath ).get(); }
640  void registerIODataObjects( const Gaudi::Algorithm* algo );
642  StatusCode buildDataDependenciesRealm();
643 
645  void addHeadNode( const std::string& headName, concurrency::Concurrent, concurrency::PromptDecision,
648  DecisionNode* getHeadNode() const { return m_headNode; };
650  StatusCode addAlgorithmNode( Gaudi::Algorithm* daughterAlgo, const std::string& parentName, bool inverted,
651  bool allPass );
653  AlgorithmNode* getAlgorithmNode( const std::string& algoName ) const {
654  return m_algoNameToAlgoNodeMap.at( algoName ).get();
655  }
657  StatusCode addDecisionHubNode( Gaudi::Algorithm* daughterAlgo, const std::string& parentName,
661  unsigned int getControlFlowNodeCounter() const { return m_nodeCounter; }
662 
664  void rankAlgorithms( IGraphVisitor& ranker ) const;
665 
667  const std::string& name() const override { return m_name; }
669  SmartIF<ISvcLocator>& serviceLocator() const override { return m_svcLocator; }
673  const unsigned int& recursionLevel ) const {
674  m_headNode->printState( output, states, node_decisions, recursionLevel );
675  }
676 
678  void enableAnalysis() { m_enableAnalysis = true; };
679  PRVertexDesc node( const std::string& ) const;
680 
682  std::string dumpDataFlow() const;
684  std::string dumpControlFlow() const;
686  void dumpPrecRules( const boost::filesystem::path&, const EventSlot& slot );
688  void dumpPrecTrace( const boost::filesystem::path& );
690  void addEdgeToPrecTrace( const AlgorithmNode* u, const AlgorithmNode* v );
692  void dumpControlFlow( std::ostringstream&, ControlFlowNode*, const int& ) const;
693 
694  private:
696  DecisionNode* m_headNode = nullptr;
706 
708  unsigned int m_nodeCounter = 0;
710  unsigned int m_algoCounter = 0;
711 
715 
719  bool m_enableAnalysis{false};
722 
724  bool m_conditionsRealmEnabled{false};
725  };
726 
727 } // namespace concurrency
728 #endif
std::unordered_map< std::string, DataObjIDColl > m_algoNameToAlgoInputsMap
Indexes: maps of algorithm&#39;s name to algorithm&#39;s inputs/outputs.
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.
Class representing an event slot.
Definition: EventSlot.h:14
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.
std::string operator()(const AlgoProps &props) const
precedence::PrecTrace m_precTrace
facilities for algorithm precedence tracing
AlgorithmNode(PrecedenceRulesGraph &graph, Gaudi::Algorithm *algoPtr, unsigned int nodeIndex, unsigned int algoIndex, bool inverted, bool allPass)
Constructor.
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
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.
virtual bool visit(DecisionNode &)
Definition: IGraphVisitor.h:16
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
Gaudi::Algorithm * getAlgorithm() const
get Algorithm representatives
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.
SmartIF< ITimelineSvc > m_timelineSvc
const std::vector< DataNode * > & getOutputDataNodes() const
Get all supplier nodes.
std::string algorithm
Definition: ITimelineSvc.h:21
std::string operator()(const DataProps &) const
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.
std::unordered_map< DataObjID, std::unique_ptr< DataNode >, DataObjID_Hasher > m_dataPathToDataNodeMap
Index: map of data path to DataNode.
Gaudi::tagged_bool< class ModeOr_tag > ModeOr
std::string operator()(const DataProps &props) const
SmartIF< ITimelineSvc > m_timelineSvc
Gaudi::Algorithm * m_algorithm
Algorithm representative behind the AlgorithmNode.
virtual bool visitEnter(DecisionNode &) const
Definition: IGraphVisitor.h:15
STL class.
std::string operator()(const DecisionHubProps &) const
std::string operator()(const DataProps &) const
bool m_modeOR
Whether acting as "and" (false) or "or" node (true)
time_point end
Definition: ITimelineSvc.h:24
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:76
std::string operator()(const DataProps &) const
std::unordered_map< std::string, std::unique_ptr< AlgorithmNode > > m_algoNameToAlgoNodeMap
Index: map of algorithm&#39;s name to AlgorithmNode.
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()
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:50
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
const EventSlot & m_slot
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
std::unordered_map< std::string, DataObjIDColl > m_algoNameToAlgoOutputsMap
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.
time_point start
Definition: ITimelineSvc.h:23
std::string operator()(const DecisionHubProps &) const
std::string operator()(const DecisionHubProps &) const
T find(T...args)
std::unordered_map< std::string, std::unique_ptr< DecisionNode > > m_decisionNameToDecisionHubMap
Index: map of decision&#39;s name to DecisionHub.
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.
AlgoProps(Gaudi::Algorithm *algo, uint nodeIndex, uint algoIndex, bool inverted, bool allPass)
std::vector< AlgorithmNode * > m_producers
std::string operator()(const DataProps &) const
std::string operator()(const AlgoProps &props) const
std::string operator()(const DataProps &) const
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
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
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.
DataNode * getDataNode(const DataObjID &dataPath) const
Get DataNode by DataObject path using graph index.
std::string operator()(const DecisionHubProps &props) const
std::string fullKey() const
Definition: DataObjID.cpp:88
AlgorithmNode * getAlgorithmNode(const std::string &algoName) const
Get the AlgorithmNode from by algorithm name using graph index.
const EventSlot & m_slot
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:192
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".
void addProducerNode(AlgorithmNode *node)
Add relationship to producer AlgorithmNode.
const std::vector< AlgorithmNode * > & getProducers() const
Get all data object producers.
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.