The Gaudi Framework  v30r3 (a5ef0a68)
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"
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
230  std::ostringstream oss;
231  oss << m_slot.algsStates[props.m_algoIndex];
232  return oss.str();
233  }
234 
235  std::string operator()( const DecisionHubProps& ) const { return ""; }
236 
237  std::string operator()( const DataProps& props ) const
238  {
240 
241  if ( m_whiteboard.isValid() && m_slot.eventContext->valid() )
242  if ( m_whiteboard->selectStore( m_slot.eventContext->slot() ).isSuccess() )
243  state = m_whiteboard->exists( props.m_id ) ? "Produced" : "Missing";
244 
245  return state;
246  }
247 
248  std::string operator()( const CondDataProps& props ) const
249  {
251 
252  if ( m_condSvc.isValid() && m_slot.eventContext->valid() )
253  state = m_condSvc->isValidID( *( m_slot.eventContext ), props.m_id ) ? "Produced" : "Missing";
254 
255  return state;
256  }
257 
259 
262  bool m_conditionsEnabled{false};
263  };
264 
265  struct StartTime : static_visitor<std::string> {
266  StartTime( const EventSlot& slot, SmartIF<ISvcLocator>& svcLocator ) : m_slot( slot )
267  {
268  SmartIF<IMessageSvc> msgSvc{svcLocator};
269  MsgStream log{msgSvc, "StartTime.Getter"};
270 
271  // Figure if we can discover the algorithm timings
272  m_timelineSvc = svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
273  if ( !m_timelineSvc.isValid() ) {
274  log << MSG::WARNING << "Failed to locate the TimelineSvc: no way to "
275  << "add algorithm start time to the TTT dumps" << endmsg;
276  }
277  }
278 
279  std::string operator()( const AlgoProps& props ) const
280  {
281 
282  std::string startTime;
283 
284  if ( m_timelineSvc.isValid() ) {
285 
286  TimelineEvent te{};
287  te.algorithm = props.m_name;
288  te.slot = m_slot.eventContext->slot();
289  te.event = m_slot.eventContext->evt();
290 
291  m_timelineSvc->getTimelineEvent( te );
292  startTime = std::to_string(
293  std::chrono::duration_cast<std::chrono::nanoseconds>( te.start.time_since_epoch() ).count() );
294  }
295 
296  return startTime;
297  }
298 
299  std::string operator()( const DecisionHubProps& ) const { return ""; }
300 
301  std::string operator()( const DataProps& ) const { return ""; }
302 
305  };
306 
307  struct EndTime : static_visitor<std::string> {
308  EndTime( const EventSlot& slot, SmartIF<ISvcLocator>& svcLocator ) : m_slot( slot )
309  {
310  SmartIF<IMessageSvc> msgSvc{svcLocator};
311  MsgStream log{msgSvc, "EndTime.Getter"};
312 
313  // Figure if we can discover the algorithm timings
314  m_timelineSvc = svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
315  if ( !m_timelineSvc.isValid() )
316  log << MSG::WARNING << "Failed to locate the TimelineSvc: no way to add "
317  << "algorithm completion time to the TTT dumps" << endmsg;
318  }
319 
320  std::string operator()( const AlgoProps& props ) const
321  {
322 
323  std::string endTime;
324 
325  if ( m_timelineSvc.isValid() ) {
326 
327  TimelineEvent te{};
328  te.algorithm = props.m_name;
329  te.slot = m_slot.eventContext->slot();
330  te.event = m_slot.eventContext->evt();
331 
332  m_timelineSvc->getTimelineEvent( te );
333  endTime =
334  std::to_string( std::chrono::duration_cast<std::chrono::nanoseconds>( te.end.time_since_epoch() ).count() );
335  }
336 
337  return endTime;
338  }
339 
340  std::string operator()( const DecisionHubProps& ) const { return ""; }
341 
342  std::string operator()( const DataProps& ) const { return ""; }
343 
346  };
347 
348  struct Duration : static_visitor<std::string> {
349  Duration( const EventSlot& slot, SmartIF<ISvcLocator>& svcLocator ) : m_slot( slot )
350  {
351  SmartIF<IMessageSvc> msgSvc{svcLocator};
352  MsgStream log{msgSvc, "Duration.Getter"};
353 
354  // Figure if we can discover the algorithm timings
355  m_timelineSvc = svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
356  if ( !m_timelineSvc.isValid() )
357  log << MSG::WARNING << "Failed to locate the TimelineSvc: no way to add "
358  << "algorithm's runtimes to the TTT dumps" << endmsg;
359  }
360 
361  std::string operator()( const AlgoProps& props ) const
362  {
363 
365 
366  if ( m_timelineSvc.isValid() ) {
367 
368  TimelineEvent te;
369  te.algorithm = props.m_name;
370  te.slot = m_slot.eventContext->slot();
371  te.event = m_slot.eventContext->evt();
372 
373  m_timelineSvc->getTimelineEvent( te );
374  time = std::to_string( std::chrono::duration_cast<std::chrono::nanoseconds>( te.end - te.start ).count() );
375  }
376 
377  return time;
378  }
379 
380  std::string operator()( const DecisionHubProps& ) const { return ""; }
381 
382  std::string operator()( const DataProps& ) const { return ""; }
383 
386  };
387 
388  struct Operations : static_visitor<std::string> {
389  std::string operator()( const AlgoProps& props ) const { return props.m_isIOBound ? "IO-bound" : "CPU-bound"; }
390 
391  std::string operator()( const DecisionHubProps& ) const { return ""; }
392 
393  std::string operator()( const DataProps& ) const { return ""; }
394  };
395 
396  static inline std::ostream& operator<<( std::ostream& os, const AlgoProps& ) { return os << "Algorithm"; }
397  static inline std::ostream& operator<<( std::ostream& os, const DecisionHubProps& ) { return os << "DecisionHub"; }
398  static inline std::ostream& operator<<( std::ostream& os, const DataProps& ) { return os << "Data"; }
399  static inline std::ostream& operator<<( std::ostream& os, const CondDataProps& ) { return os << "ConditionData"; }
400 
401  //=========================================================================
402 
403  using VariantVertexProps = boost::variant<AlgoProps, DecisionHubProps, DataProps, CondDataProps>;
404  using PRGraph = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, VariantVertexProps>;
405  using PRVertexDesc = boost::graph_traits<PRGraph>::vertex_descriptor;
406 
407 } // namespace prules
408 
409 struct Cause final {
410  enum class source { Root, Task };
411 
414 };
415 
416 namespace concurrency
417 {
418  class PrecedenceRulesGraph;
419 
421  using precedence::AlgoProps;
423  using precedence::DataProps;
426 
427  // ==========================================================================
429  {
430  public:
432  ControlFlowNode( PrecedenceRulesGraph& graph, unsigned int nodeIndex, const std::string& name )
433  : m_graph( &graph ), m_nodeIndex( nodeIndex ), m_nodeName( name )
434  {
435  }
437  virtual ~ControlFlowNode() = default;
438 
440  virtual bool accept( IGraphVisitor& visitor ) = 0;
442  virtual void printState( std::stringstream& output, AlgsExecutionStates& states,
443  const std::vector<int>& node_decisions, const unsigned int& recursionLevel ) const = 0;
445  const unsigned int& getNodeIndex() const { return m_nodeIndex; }
447  const std::string& getNodeName() const { return m_nodeName; }
448 
449  public:
451 
452  protected:
453  unsigned int m_nodeIndex;
455  };
456 
457  class DecisionNode final : public ControlFlowNode
458  {
459  public:
461  DecisionNode( PrecedenceRulesGraph& graph, unsigned int nodeIndex, const std::string& name,
462  Concurrent modeConcurrent, PromptDecision modePromptDecision, ModeOr modeOR, AllPass allPass,
463  Inverted isInverted )
464  : ControlFlowNode( graph, nodeIndex, name )
465  , m_modeConcurrent( modeConcurrent )
466  , m_modePromptDecision( modePromptDecision )
467  , m_modeOR( modeOR )
468  , m_allPass( allPass )
469  , m_inverted( isInverted )
470  {
471  }
472 
474  bool accept( IGraphVisitor& visitor ) override;
476  void addParentNode( DecisionNode* node );
478  void addDaughterNode( ControlFlowNode* node );
480  const std::vector<ControlFlowNode*>& getDaughters() const { return m_children; }
482  void printState( std::stringstream& output, AlgsExecutionStates& states, const std::vector<int>& node_decisions,
483  const unsigned int& recursionLevel ) const override;
484 
485  public:
492  bool m_modeOR;
494  bool m_allPass;
496  bool m_inverted{false};
501  };
502 
503  // ==========================================================================
504  class DataNode;
505 
506  class AlgorithmNode final : public ControlFlowNode
507  {
508  public:
510  AlgorithmNode( PrecedenceRulesGraph& graph, Algorithm* algoPtr, unsigned int nodeIndex, unsigned int algoIndex,
511  bool inverted, bool allPass )
512  : ControlFlowNode( graph, nodeIndex, algoPtr->name() )
513  , m_algorithm( algoPtr )
514  , m_algoIndex( algoIndex )
515  , m_algoName( algoPtr->name() )
516  , m_inverted( inverted )
517  , m_allPass( allPass )
518  , m_isIOBound( algoPtr->isIOBound() ){};
519 
521  bool accept( IGraphVisitor& visitor ) override;
522 
524  void addParentNode( DecisionNode* node );
526  const std::vector<DecisionNode*>& getParentDecisionHubs() const { return m_parents; }
527 
529  void addOutputDataNode( DataNode* node );
531  void addInputDataNode( DataNode* node );
533  const std::vector<DataNode*>& getOutputDataNodes() const { return m_outputs; }
536 
538  void setRank( float& rank ) { m_rank = rank; }
540  const float& getRank() const { return m_rank; }
541 
543  Algorithm* getAlgorithm() const { return m_algorithm; }
545  const unsigned int& getAlgoIndex() const { return m_algoIndex; }
546 
548  void setIOBound( bool value ) { m_isIOBound = value; }
550  bool isIOBound() const { return m_isIOBound; }
551 
553  bool isOptimist() const { return m_allPass; };
555  bool isLiar() const { return m_inverted; };
556 
558  void printState( std::stringstream& output, AlgsExecutionStates& states, const std::vector<int>& node_decisions,
559  const unsigned int& recursionLevel ) const override;
560 
561  public:
564 
565  private:
569  unsigned int m_algoIndex;
575  bool m_allPass;
577  float m_rank = -1;
580 
585  };
586 
587  // ==========================================================================
588  class DataNode
589  {
590  public:
592  DataNode( PrecedenceRulesGraph& graph, const DataObjID& path ) : m_graph( &graph ), m_data_object_path( path ) {}
593 
595  virtual ~DataNode() = default;
596 
597  const DataObjID& getPath() { return m_data_object_path; }
598 
600  virtual bool accept( IGraphVisitor& visitor )
601  {
602  return visitor.visitEnter( *this ) ? visitor.visit( *this ) : true;
603  }
606  {
607  if ( std::find( m_producers.begin(), m_producers.end(), node ) == m_producers.end() )
608  m_producers.push_back( node );
609  }
612  {
613  if ( std::find( m_consumers.begin(), m_consumers.end(), node ) == m_consumers.end() )
614  m_consumers.push_back( node );
615  }
617  const std::vector<AlgorithmNode*>& getProducers() const { return m_producers; }
619  const std::vector<AlgorithmNode*>& getConsumers() const { return m_consumers; }
620 
621  public:
623 
624  private:
628  };
629 
630  class ConditionNode final : public DataNode
631  {
632  public:
635  : DataNode( graph, path ), m_condSvc( condSvc )
636  {
637  }
638 
642  bool accept( IGraphVisitor& visitor ) override
643  {
644  return visitor.visitEnter( *this ) ? visitor.visit( *this ) : true;
645  }
646 
647  public:
648  // Service for Conditions handling
650  };
651 
652  // ==========================================================================
653 
655  virtual ~IPrecedenceRulesGraph() = default;
656  };
657 
658  class PrecedenceRulesGraph : public CommonMessaging<IPrecedenceRulesGraph>
659  {
660  public:
662  PrecedenceRulesGraph( const std::string& name, SmartIF<ISvcLocator> svc ) : m_svcLocator( svc ), m_name( name )
663  {
664  // make sure that CommonMessaging is initialized
665  setUpMessaging();
666  }
667 
669  StatusCode initialize();
670 
672  void accept( IGraphVisitor& visitor ) const;
673 
675  StatusCode addDataNode( const DataObjID& dataPath );
677  DataNode* getDataNode( const DataObjID& dataPath ) const { return m_dataPathToDataNodeMap.at( dataPath ).get(); }
679  void registerIODataObjects( const Algorithm* algo );
681  StatusCode buildDataDependenciesRealm();
682 
684  void addHeadNode( const std::string& headName, concurrency::Concurrent, concurrency::PromptDecision,
687  DecisionNode* getHeadNode() const { return m_headNode; };
689  StatusCode addAlgorithmNode( Algorithm* daughterAlgo, const std::string& parentName, bool inverted, bool allPass );
691  AlgorithmNode* getAlgorithmNode( const std::string& algoName ) const
692  {
693  return m_algoNameToAlgoNodeMap.at( algoName ).get();
694  }
696  StatusCode addDecisionHubNode( Algorithm* daughterAlgo, const std::string& parentName, concurrency::Concurrent,
700  unsigned int getControlFlowNodeCounter() const { return m_nodeCounter; }
701 
703  void rankAlgorithms( IGraphVisitor& ranker ) const;
704 
706  const std::string& name() const override { return m_name; }
708  SmartIF<ISvcLocator>& serviceLocator() const override { return m_svcLocator; }
712  const unsigned int& recursionLevel ) const
713  {
714  m_headNode->printState( output, states, node_decisions, recursionLevel );
715  }
716 
718  void enableAnalysis() { m_enableAnalysis = true; };
719  PRVertexDesc node( const std::string& ) const;
720 
722  std::string dumpDataFlow() const;
724  std::string dumpControlFlow() const;
726  void dumpPrecRules( const boost::filesystem::path&, const EventSlot& slot );
728  void dumpPrecTrace( const boost::filesystem::path& );
730  void addEdgeToPrecTrace( const AlgorithmNode* u, const AlgorithmNode* v );
732  void dumpControlFlow( std::ostringstream&, ControlFlowNode*, const int& ) const;
733 
734  private:
736  DecisionNode* m_headNode = nullptr;
746 
748  unsigned int m_nodeCounter = 0;
750  unsigned int m_algoCounter = 0;
751 
755 
759  bool m_enableAnalysis{false};
762 
764  bool m_conditionsRealmEnabled{false};
765  };
766 
767 } // namespace concurrency
768 #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.
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
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
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: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.
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
virtual bool visitEnter(DecisionNode &) const
Definition: IGraphVisitor.h:17
STL class.
Algorithm * getAlgorithm() const
get Algorithm representatives
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:79
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:51
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
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.
Algorithm * m_algorithm
Algorithm representative behind the AlgorithmNode.
time_point start
Definition: ITimelineSvc.h:23
std::string operator()(const DecisionHubProps &) const
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
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.
std::vector< AlgorithmNode * > m_producers
std::string operator()(const DataProps &) const
std::string operator()(const AlgoProps &props) const
std::string operator()(const DataProps &) const
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.
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:99
AlgorithmNode * getAlgorithmNode(const std::string &algoName) const
Get the AlgorithmNode from by algorithm name using graph index.
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".
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.