The Gaudi Framework  v33r1 (b1225454)
PrecedenceRulesGraph.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIHIVE_PRECEDENCERULESGRAPH_H
12 #define GAUDIHIVE_PRECEDENCERULESGRAPH_H
13 
14 // std includes
15 #include <algorithm>
16 #include <memory>
17 #include <sstream>
18 #include <unordered_map>
19 #include <variant>
20 #include <vector>
21 
22 #include <boost/filesystem.hpp>
23 #include <boost/graph/adjacency_list.hpp>
24 #include <boost/graph/graphml.hpp>
25 
26 // fwk includes
27 #include "../AlgsExecutionStates.h"
28 #include "../EventSlot.h"
30 #include "GaudiKernel/DataObject.h"
31 #include "GaudiKernel/ICondSvc.h"
34 #include "GaudiKernel/TaggedBool.h"
35 #include "Visitors/IGraphVisitor.h"
36 #include <Gaudi/Algorithm.h>
37 
38 namespace concurrency {
39  using Concurrent = Gaudi::tagged_bool<class Concurrent_tag>;
40  using PromptDecision = Gaudi::tagged_bool<class PromptDecision_tag>;
41  using ModeOr = Gaudi::tagged_bool<class ModeOr_tag>;
42  using AllPass = Gaudi::tagged_bool<class AllPass_tag>;
43  using Inverted = Gaudi::tagged_bool<class Inverted_tag>;
44 } // namespace concurrency
45 
46 namespace precedence {
47 
48  // Precedence trace utilities ==============================================
49  struct AlgoTraceProps {
51  AlgoTraceProps( const std::string& name, int index, int rank, double runtime )
52  : m_name( name ), m_index( index ), m_rank( rank ), m_runtime( runtime ) {}
54  int m_index{-1};
55  int m_rank{-1};
56  int m_runtime{-1}; // ns
57  int m_eccentricity{-1};
58  };
59 
60  using PrecTrace = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, AlgoTraceProps>;
61  using AlgoTraceVertex = boost::graph_traits<PrecTrace>::vertex_descriptor;
62 
63  // Precedence rules utilities ==============================================
64  struct AlgoProps {
65  AlgoProps() {}
66  AlgoProps( Gaudi::Algorithm* algo, uint nodeIndex, uint algoIndex, bool inverted, bool allPass )
67  : m_name( algo->name() )
68  , m_nodeIndex( nodeIndex )
69  , m_algoIndex( algoIndex )
70  , m_algorithm( algo )
71  , m_inverted( inverted )
72  , m_allPass( allPass )
73  , m_isIOBound( algo->isIOBound() ) {}
74 
76  int m_nodeIndex{-1};
77  int m_algoIndex{-1};
78  int m_rank{-1};
81 
83  bool m_inverted{false};
85  bool m_allPass{false};
87  bool m_isIOBound{false};
88  };
89 
91  DecisionHubProps( const std::string& name, uint nodeIndex, concurrency::Concurrent modeConcurrent,
92  concurrency::PromptDecision modePromptDecision, concurrency::ModeOr modeOR,
93  concurrency::AllPass allPass, concurrency::Inverted isInverted )
94  : m_name( name )
95  , m_nodeIndex( nodeIndex )
96  , m_modeConcurrent( modeConcurrent )
97  , m_modePromptDecision( modePromptDecision )
98  , m_inverted( isInverted )
99  , m_modeOR( modeOR )
100  , m_allPass( allPass ) {}
101 
104 
111  bool m_inverted{false};
113  bool m_modeOR;
115  bool m_allPass;
116  };
117 
118  struct DataProps {
119  DataProps( const DataObjID& id ) : m_id( id ) {}
120 
122  };
123 
125  CondDataProps( const DataObjID& id ) : DataProps( id ) {}
126  };
127 
128  // Vertex unpacking ========================================================
129 
130  struct VertexName {
131  std::string operator()( const AlgoProps& props ) const { return props.m_name; }
132 
133  std::string operator()( const DecisionHubProps& props ) const { return props.m_name; }
134 
135  std::string operator()( const DataProps& props ) const { return props.m_id.fullKey(); }
136  };
137 
138  struct GroupMode {
139  std::string operator()( const AlgoProps& ) const { return ""; }
140 
141  std::string operator()( const DecisionHubProps& props ) const {
142  return props.m_modeConcurrent ? "Concurrent" : "Sequential";
143  }
144 
145  std::string operator()( const DataProps& ) const { return ""; }
146  };
147 
148  struct GroupLogic {
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 {
157  std::string operator()( const AlgoProps& ) const { return ""; }
158 
159  std::string operator()( const DecisionHubProps& props ) const {
160  return props.m_modePromptDecision ? "Early" : "Late";
161  }
162 
163  std::string operator()( const DataProps& ) const { return ""; }
164  };
165 
167  std::string operator()( const AlgoProps& props ) const { return props.m_inverted ? "Inverted" : "Non-inverted"; }
168 
169  std::string operator()( const DecisionHubProps& ) const { return ""; }
170 
171  std::string operator()( const DataProps& ) const { return ""; }
172  };
173 
174  struct AllPass {
175  std::string operator()( const AlgoProps& props ) const { return props.m_allPass ? "Optimist" : "Realist"; }
176 
177  std::string operator()( const DecisionHubProps& props ) const { return props.m_allPass ? "Optimist" : "Realist"; }
178 
179  std::string operator()( const DataProps& ) const { return ""; }
180  };
181 
182  struct CFDecision {
183  CFDecision( const EventSlot& slot ) : m_slot( slot ) {}
184 
185  std::string operator()( const AlgoProps& props ) const {
187  }
188 
189  std::string operator()( const DecisionHubProps& props ) const {
191  }
192 
193  std::string operator()( const DataProps& ) const { return ""; }
194 
196  };
197 
198  struct EntityState {
199  EntityState( const EventSlot& slot, SmartIF<ISvcLocator>& svcLocator, bool conditionsEnabled )
200  : m_slot( slot ), m_conditionsEnabled( conditionsEnabled ) {
202  MsgStream log{msgSvc, "EntityState.Getter"};
203 
204  // Figure if we can discover the data object states
205  m_whiteboard = svcLocator->service<IHiveWhiteBoard>( "EventDataSvc", false );
206  if ( !m_whiteboard.isValid() ) {
207  log << MSG::WARNING << "Failed to locate EventDataSvc: no way to add DO "
208  << "states to the TTT dump " << endmsg;
209  }
210 
211  if ( m_conditionsEnabled ) {
212  // Figure if we can discover Condition data object states
213  m_condSvc = svcLocator->service<ICondSvc>( "CondSvc", false );
214  if ( !m_condSvc.isValid() )
215  log << MSG::WARNING << "Failed to locate CondSvc: no way to add Condition DO "
216  << "states to the TTT dump " << endmsg;
217  }
218 
219  if ( !m_slot.eventContext->valid() )
220  log << MSG::WARNING << "Event context is invalid: no way to add DO states"
221  << " in the TTT dump" << endmsg;
222  }
223 
224  // Returns algorithm's FSM state
225  std::string operator()( const AlgoProps& props ) const {
226  std::ostringstream oss;
227  oss << m_slot.algsStates[props.m_algoIndex];
228  return oss.str();
229  }
230 
231  std::string operator()( const DecisionHubProps& ) const { return ""; }
232 
233  std::string operator()( const DataProps& props ) const {
235 
237  if ( m_whiteboard->selectStore( m_slot.eventContext->slot() ).isSuccess() )
238  state = m_whiteboard->exists( props.m_id ) ? "Produced" : "Missing";
239 
240  return state;
241  }
242 
243  std::string operator()( const CondDataProps& props ) const {
245 
246  if ( m_condSvc.isValid() && m_slot.eventContext->valid() )
247  state = m_condSvc->isValidID( *( m_slot.eventContext ), props.m_id ) ? "Produced" : "Missing";
248 
249  return state;
250  }
251 
253 
256  bool m_conditionsEnabled{false};
257  };
258 
259  struct StartTime {
262  MsgStream log{msgSvc, "StartTime.Getter"};
263 
264  // Figure if we can discover the algorithm timings
265  m_timelineSvc = svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
266  if ( !m_timelineSvc.isValid() ) {
267  log << MSG::WARNING << "Failed to locate the TimelineSvc: no way to "
268  << "add algorithm start time to the TTT dumps" << endmsg;
269  }
270  }
271 
272  std::string operator()( const AlgoProps& props ) const {
273 
274  std::string startTime;
275 
276  if ( m_timelineSvc.isValid() ) {
277 
278  TimelineEvent te{};
279  te.algorithm = props.m_name;
280  te.slot = m_slot.eventContext->slot();
281  te.event = m_slot.eventContext->evt();
282 
284  startTime = std::to_string(
285  std::chrono::duration_cast<std::chrono::nanoseconds>( te.start.time_since_epoch() ).count() );
286  }
287 
288  return startTime;
289  }
290 
291  std::string operator()( const DecisionHubProps& ) const { return ""; }
292 
293  std::string operator()( const DataProps& ) const { return ""; }
294 
297  };
298 
299  struct EndTime {
302  MsgStream log{msgSvc, "EndTime.Getter"};
303 
304  // Figure if we can discover the algorithm timings
305  m_timelineSvc = svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
306  if ( !m_timelineSvc.isValid() )
307  log << MSG::WARNING << "Failed to locate the TimelineSvc: no way to add "
308  << "algorithm completion time to the TTT dumps" << endmsg;
309  }
310 
311  std::string operator()( const AlgoProps& props ) const {
312 
313  std::string endTime;
314 
315  if ( m_timelineSvc.isValid() ) {
316 
317  TimelineEvent te{};
318  te.algorithm = props.m_name;
319  te.slot = m_slot.eventContext->slot();
320  te.event = m_slot.eventContext->evt();
321 
323  endTime =
324  std::to_string( std::chrono::duration_cast<std::chrono::nanoseconds>( te.end.time_since_epoch() ).count() );
325  }
326 
327  return endTime;
328  }
329 
330  std::string operator()( const DecisionHubProps& ) const { return ""; }
331 
332  std::string operator()( const DataProps& ) const { return ""; }
333 
336  };
337 
338  struct Duration {
341  MsgStream log{msgSvc, "Duration.Getter"};
342 
343  // Figure if we can discover the algorithm timings
344  m_timelineSvc = svcLocator->service<ITimelineSvc>( "TimelineSvc", false );
345  if ( !m_timelineSvc.isValid() )
346  log << MSG::WARNING << "Failed to locate the TimelineSvc: no way to add "
347  << "algorithm's runtimes to the TTT dumps" << endmsg;
348  }
349 
350  std::string operator()( const AlgoProps& props ) const {
351 
353 
354  if ( m_timelineSvc.isValid() ) {
355 
356  TimelineEvent te;
357  te.algorithm = props.m_name;
358  te.slot = m_slot.eventContext->slot();
359  te.event = m_slot.eventContext->evt();
360 
362  time = std::to_string( std::chrono::duration_cast<std::chrono::nanoseconds>( te.end - te.start ).count() );
363  }
364 
365  return time;
366  }
367 
368  std::string operator()( const DecisionHubProps& ) const { return ""; }
369 
370  std::string operator()( const DataProps& ) const { return ""; }
371 
374  };
375 
376  struct Operations {
377  std::string operator()( const AlgoProps& props ) const { return props.m_isIOBound ? "IO-bound" : "CPU-bound"; }
378 
379  std::string operator()( const DecisionHubProps& ) const { return ""; }
380 
381  std::string operator()( const DataProps& ) const { return ""; }
382  };
383 
384  static inline std::ostream& operator<<( std::ostream& os, const AlgoProps& ) { return os << "Algorithm"; }
385  static inline std::ostream& operator<<( std::ostream& os, const DecisionHubProps& ) { return os << "DecisionHub"; }
386  static inline std::ostream& operator<<( std::ostream& os, const DataProps& ) { return os << "Data"; }
387  static inline std::ostream& operator<<( std::ostream& os, const CondDataProps& ) { return os << "ConditionData"; }
388 
389  //=========================================================================
390 
391  using VariantVertexProps = std::variant<AlgoProps, DecisionHubProps, DataProps, CondDataProps>;
392  using PRGraph = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, VariantVertexProps>;
393  using PRVertexDesc = boost::graph_traits<PRGraph>::vertex_descriptor;
394 
395 } // namespace precedence
396 
397 struct Cause final {
398  enum class source { Root, Task };
399 
402 };
403 
404 namespace concurrency {
405  class PrecedenceRulesGraph;
406 
407  using precedence::AlgoProps;
409  using precedence::DataProps;
413 
414  // ==========================================================================
416  public:
418  ControlFlowNode( PrecedenceRulesGraph& graph, unsigned int nodeIndex, const std::string& name )
419  : m_graph( &graph ), m_nodeIndex( nodeIndex ), m_nodeName( name ) {}
421  virtual ~ControlFlowNode() = default;
422 
424  virtual bool accept( IGraphVisitor& visitor ) = 0;
426  virtual void printState( std::stringstream& output, EventSlot& slot, const unsigned int& recursionLevel ) const = 0;
428  const unsigned int& getNodeIndex() const { return m_nodeIndex; }
430  const std::string& name() const { return m_nodeName; }
431 
432  public:
434 
435  protected:
436  unsigned int m_nodeIndex;
438  };
439 
440  class DecisionNode final : public ControlFlowNode {
441  public:
443  DecisionNode( PrecedenceRulesGraph& graph, unsigned int nodeIndex, const std::string& name,
444  Concurrent modeConcurrent, PromptDecision modePromptDecision, ModeOr modeOR, AllPass allPass,
445  Inverted isInverted )
446  : ControlFlowNode( graph, nodeIndex, name )
447  , m_modeConcurrent( modeConcurrent )
448  , m_modePromptDecision( modePromptDecision )
449  , m_modeOR( modeOR )
450  , m_allPass( allPass )
451  , m_inverted( isInverted ) {}
452 
454  bool accept( IGraphVisitor& visitor ) override;
456  void addParentNode( DecisionNode* node );
458  void addDaughterNode( ControlFlowNode* node );
462  void printState( std::stringstream& output, EventSlot& slot, const unsigned int& recursionLevel ) const override;
463 
464  public:
471  bool m_modeOR;
473  bool m_allPass;
475  bool m_inverted{false};
480  };
481 
482  // ==========================================================================
483  class DataNode;
484 
485  class AlgorithmNode final : public ControlFlowNode {
486  public:
488  AlgorithmNode( PrecedenceRulesGraph& graph, Gaudi::Algorithm* algoPtr, unsigned int nodeIndex,
489  unsigned int algoIndex, bool inverted, bool allPass )
490  : ControlFlowNode( graph, nodeIndex, algoPtr->name() )
491  , m_algorithm( algoPtr )
492  , m_algoIndex( algoIndex )
493  , m_algoName( algoPtr->name() )
494  , m_inverted( inverted )
495  , m_allPass( allPass )
496  , m_isIOBound( algoPtr->isIOBound() ){};
497 
499  bool accept( IGraphVisitor& visitor ) override;
500 
502  void addParentNode( DecisionNode* node );
505 
507  void addOutputDataNode( DataNode* node );
509  void addInputDataNode( DataNode* node );
514 
516  void setRank( float& rank ) { m_rank = rank; }
518  const float& getRank() const { return m_rank; }
519 
523  const unsigned int& getAlgoIndex() const { return m_algoIndex; }
524 
526  void setIOBound( bool value ) { m_isIOBound = value; }
528  bool isIOBound() const { return m_isIOBound; }
529 
531  bool isOptimist() const { return m_allPass; };
533  bool isLiar() const { return m_inverted; };
534 
536  void printState( std::stringstream& output, EventSlot& slot, const unsigned int& recursionLevel ) const override;
537 
538  public:
541 
542  private:
546  unsigned int m_algoIndex;
552  bool m_allPass;
554  float m_rank = -1;
557 
562  };
563 
564  // ==========================================================================
565  class DataNode {
566  public:
569 
571  virtual ~DataNode() = default;
572 
573  const DataObjID& name() const { return m_data_object_path; }
574 
576  virtual bool accept( IGraphVisitor& visitor ) {
577  return visitor.visitEnter( *this ) ? visitor.visit( *this ) : true;
578  }
581  if ( std::find( m_producers.begin(), m_producers.end(), node ) == m_producers.end() )
582  m_producers.push_back( node );
583  }
586  if ( std::find( m_consumers.begin(), m_consumers.end(), node ) == m_consumers.end() )
587  m_consumers.push_back( node );
588  }
593 
594  public:
596 
597  private:
601  };
602 
603  class ConditionNode final : public DataNode {
604  public:
607  : DataNode( graph, path ), m_condSvc( condSvc ) {}
608 
612  bool accept( IGraphVisitor& visitor ) override {
613  return visitor.visitEnter( *this ) ? visitor.visit( *this ) : true;
614  }
615 
616  public:
617  // Service for Conditions handling
619  };
620 
621  // ==========================================================================
622 
624  virtual ~IPrecedenceRulesGraph() = default;
625  };
626 
627  template <typename T>
628  struct CompareNodes {
629  bool operator()( const T& a, const T& b ) const { return a->name() < b->name(); }
630  };
631 
632  class PrecedenceRulesGraph : public CommonMessaging<IPrecedenceRulesGraph> {
633  public:
636  // make sure that CommonMessaging is initialized
637  setUpMessaging();
638  }
639 
642 
644  void accept( IGraphVisitor& visitor ) const;
645 
647  StatusCode addDataNode( const DataObjID& dataPath );
649  DataNode* getDataNode( const DataObjID& dataPath ) const { return m_dataPathToDataNodeMap.at( dataPath ).get(); }
651  void registerIODataObjects( const Gaudi::Algorithm* algo );
654 
659  DecisionNode* getHeadNode() const { return m_headNode; };
661  StatusCode addAlgorithmNode( Gaudi::Algorithm* daughterAlgo, const std::string& parentName, bool inverted,
662  bool allPass );
664  AlgorithmNode* getAlgorithmNode( const std::string& algoName ) const {
665  return m_algoNameToAlgoNodeMap.at( algoName ).get();
666  }
668  StatusCode addDecisionHubNode( Gaudi::Algorithm* daughterAlgo, const std::string& parentName,
672  unsigned int getControlFlowNodeCounter() const { return m_nodeCounter; }
673 
675  void rankAlgorithms( IGraphVisitor& ranker ) const;
676 
678  const std::string& name() const override { return m_name; }
680  SmartIF<ISvcLocator>& serviceLocator() const override { return m_svcLocator; }
683  void printState( std::stringstream& output, EventSlot& slot, const unsigned int& recursionLevel ) const {
684  if ( slot.parentSlot ) {
685  // Start at sub-slot entry point
686  m_decisionNameToDecisionHubMap.at( slot.entryPoint )->printState( output, slot, recursionLevel );
687  } else {
688  // Start at the head node for whole-event slots
689  m_headNode->printState( output, slot, recursionLevel );
690  }
691  }
692 
694  void enableAnalysis() { m_enableAnalysis = true; };
695  PRVertexDesc node( const std::string& ) const;
696 
698  std::string dumpDataFlow() const;
702  void dumpPrecRules( const boost::filesystem::path&, const EventSlot& slot );
704  void dumpPrecTrace( const boost::filesystem::path& );
706  void addEdgeToPrecTrace( const AlgorithmNode* u, const AlgorithmNode* v );
708  void dumpControlFlow( std::ostringstream&, ControlFlowNode*, const int& ) const;
709 
710  private:
722 
724  unsigned int m_nodeCounter = 0;
726  unsigned int m_algoCounter = 0;
727 
731 
735  bool m_enableAnalysis{false};
738 
741  };
742 
743 } // namespace concurrency
744 #endif
std::unordered_map< std::string, DataObjIDColl > m_algoNameToAlgoInputsMap
Indexes: maps of algorithm's name to algorithm's inputs/outputs.
std::string operator()(const DecisionHubProps &) const
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:34
std::string operator()(const DataProps &) const
std::string entryPoint
Event Views bookkeeping (TODO: optimize view bookkeeping)
Definition: EventSlot.h:94
Class representing an event slot.
Definition: EventSlot.h:24
ContextID_t slot() const
Definition: EventContext.h:51
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.
unsigned int m_algoIndex
The index of the algorithm.
bool m_inverted
Whether the selection result is negated or not.
AlgorithmNode * getAlgorithmNode(const std::string &algoName) const
Get the AlgorithmNode from by algorithm name using graph index.
std::string operator()(const AlgoProps &props) const
std::string operator()(const DataProps &) 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)
ContextEvt_t evt() const
Definition: EventContext.h:50
void addDaughterNode(ControlFlowNode *node)
Add a daughter node.
boost::graph_traits< PrecTrace >::vertex_descriptor AlgoTraceVertex
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
const std::vector< DecisionNode * > & getParentDecisionHubs() const
Get all parent decision hubs.
std::string operator()(const AlgoProps &props) const
std::string operator()(const AlgoProps &props) const
boost::graph_traits< PRGraph >::vertex_descriptor PRVertexDesc
std::string operator()(const DataProps &props) const
std::string m_algoName
The name of the algorithm.
StatusCode addAlgorithmNode(Gaudi::Algorithm *daughterAlgo, const std::string &parentName, bool inverted, bool allPass)
Add algorithm node.
std::string operator()(const DecisionHubProps &props) const
std::string operator()(const AlgoProps &props) const
std::string operator()(const AlgoProps &props) const
std::string operator()(const AlgoProps &props) const
virtual bool visit(DecisionNode &)
Definition: IGraphVisitor.h:26
std::string operator()(const DecisionHubProps &props) const
void setRank(float &rank)
Set Algorithm rank.
std::vector< ControlFlowNode * > m_children
All direct daughter nodes in the tree.
virtual bool visitEnter(DecisionNode &) const
Definition: IGraphVisitor.h:25
Gaudi::Algorithm * getAlgorithm() const
get Algorithm representatives
void dumpPrecRules(const boost::filesystem::path &, const EventSlot &slot)
dump to file the precedence rules
EntityState(const EventSlot &slot, SmartIF< ISvcLocator > &svcLocator, bool conditionsEnabled)
std::string operator()(const CondDataProps &props) const
T to_string(T... args)
DataProps(const DataObjID &id)
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:72
std::string operator()(const DecisionHubProps &props) const
std::map< std::string, precedence::AlgoTraceVertex > m_prec_trace_map
std::vector< DecisionNode * > m_parents
Control flow parents of an AlgorithmNode (DecisionNodes)
std::string operator()(const DecisionHubProps &) const
virtual bool getTimelineEvent(TimelineEvent &) const =0
bool m_isIOBound
If an algorithm is blocking.
SmartIF< ITimelineSvc > m_timelineSvc
std::string algorithm
Definition: ITimelineSvc.h:31
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:87
unsigned int m_algoCounter
Total number of algorithm nodes in the graph.
bool m_allPass
Whether always passing regardless of daughter results.
virtual bool accept(IGraphVisitor &visitor)=0
Visitor entry point.
virtual bool exists(const DataObjID &)=0
Check if a data object exists in store.
std::string operator()(const DataProps &) const
StatusCode addDataNode(const DataObjID &dataPath)
Add DataNode that represents DataObject.
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 AlgoProps &props) const
bool valid() const
Definition: EventContext.h:54
std::string operator()(const AlgoProps &props) const
std::string operator()(const AlgoProps &props) const
std::unordered_map< DataObjID, std::unique_ptr< DataNode >, DataObjID_Hasher > m_dataPathToDataNodeMap
Index: map of data path to DataNode.
std::string fullKey() const
Definition: DataObjID.cpp:99
virtual ~IPrecedenceRulesGraph()=default
bool isOptimist() const
Check if positive control flow decision is enforced.
Gaudi::tagged_bool< class ModeOr_tag > ModeOr
MSG::Level setUpMessaging() const
Set up local caches.
const std::vector< AlgorithmNode * > & getConsumers() const
Get all data object consumers.
SmartIF< ITimelineSvc > m_timelineSvc
Gaudi::Algorithm * m_algorithm
Algorithm representative behind the AlgorithmNode.
std::string operator()(const DataProps &) const
STL class.
const unsigned int & getAlgoIndex() const
Get algorithm index.
bool m_modeOR
Whether acting as "and" (false) or "or" node (true)
T at(T... args)
std::string operator()(const DecisionHubProps &props) const
time_point end
Definition: ITimelineSvc.h:34
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:86
void addInputDataNode(DataNode *node)
Associate an AlgorithmNode, which is a data consumer of this one.
bool accept(IGraphVisitor &visitor) override
Visitor entry point.
StatusCode initialize()
Initialize graph.
std::unordered_map< std::string, std::unique_ptr< AlgorithmNode > > m_algoNameToAlgoNodeMap
Index: map of algorithm's name to AlgorithmNode.
const std::vector< AlgorithmNode * > & getProducers() const
Get all data object producers.
SmartIF< ITimelineSvc > m_timelineSvc
void dumpPrecTrace(const boost::filesystem::path &)
dump to file the precedence trace
Duration(const EventSlot &slot, SmartIF< ISvcLocator > &svcLocator)
bool m_conditionsRealmEnabled
Enable conditions realm of precedence rules.
std::string operator()(const DecisionHubProps &props) const
virtual StatusCode selectStore(size_t partitionIndex)=0
Activate an given 'slot' for all subsequent calls within the same thread id.
std::string operator()(const AlgoProps &) const
precedence::PRGraph m_PRGraph
BGL-based graph of precedence rules.
bool isIOBound() const
Check if algorithm is I/O-bound.
void printState(std::stringstream &output, EventSlot &slot, const unsigned int &recursionLevel) const
Print a string representing the control flow state.
GAUDI_API ISvcLocator * svcLocator()
PrecedenceRulesGraph * m_graph
Gaudi::tagged_bool< class Inverted_tag > Inverted
void enableAnalysis()
BGL-based facilities.
DecisionNode * m_headNode
the head node of the control flow graph
std::string operator()(const DataProps &) 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:61
std::string dumpControlFlow() const
Print out control flow of Algorithms and Sequences.
virtual bool accept(IGraphVisitor &visitor)
Entry point for a visitor.
virtual bool isValidID(const EventContext &ctx, const DataObjID &id) const =0
check to see if a specific condition object ID is valid for this event
std::string operator()(const DecisionHubProps &) const
std::string operator()(const DecisionHubProps &) const
const EventSlot & m_slot
boost::adjacency_list< boost::vecS, boost::vecS, boost::bidirectionalS, AlgoTraceProps > PrecTrace
T str(T... args)
EndTime(const EventSlot &slot, SmartIF< ISvcLocator > &svcLocator)
const float & getRank() const
Get Algorithm rank.
DataNode(PrecedenceRulesGraph &graph, const DataObjID &path)
Constructor.
unsigned int getControlFlowNodeCounter() const
Get total number of control flow graph nodes.
bool m_modePromptDecision
Whether to evaluate the hub decision ASA its child decisions allow to do that.
void registerIODataObjects(const Gaudi::Algorithm *algo)
Register algorithm in the Data Dependency index.
Interface for the Condition Service.
Definition: ICondSvc.h:39
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.
std::string operator()(const DataProps &props) const
PrecedenceRulesGraph(const std::string &name, SmartIF< ISvcLocator > svc)
Constructor.
const std::vector< ControlFlowNode * > & getDaughters() const
Get children nodes.
const DataObjID & name() const
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:33
PRVertexDesc node(const std::string &) const
void addEdgeToPrecTrace(const AlgorithmNode *u, const AlgorithmNode *v)
set cause-effect connection between two algorithms in the precedence trace
float m_rank
Algorithm rank of any kind.
std::string operator()(const DataProps &) const
virtual ~ControlFlowNode()=default
Destructor.
void addOutputDataNode(DataNode *node)
Associate an AlgorithmNode, which is a data supplier for this one.
Gaudi::Algorithm * m_algorithm
Algorithm representative behind the AlgorithmNode.
T find(T... args)
std::unordered_map< std::string, std::unique_ptr< DecisionNode > > m_decisionNameToDecisionHubMap
Index: map of decision's name to DecisionHub.
std::string operator()(const DataProps &) const
STL class.
StatusCode addDecisionHubNode(Gaudi::Algorithm *daughterAlgo, const std::string &parentName, concurrency::Concurrent, concurrency::PromptDecision, concurrency::ModeOr, concurrency::AllPass, concurrency::Inverted)
Add a node, which aggregates decisions of direct daughter nodes.
void accept(IGraphVisitor &visitor) const
An entry point to visit all graph nodes.
SmartIF< IHiveWhiteBoard > m_whiteboard
std::string operator()(const DecisionHubProps &) const
Gaudi::tagged_bool< class PromptDecision_tag > PromptDecision
bool operator()(const T &a, const T &b) const
std::vector< DataNode * > m_inputs
Algorithm inputs (DataNodes)
void addParentNode(DecisionNode *node)
Add a parent node.
bool m_modeConcurrent
Whether all daughters will be evaluated concurrently or sequentially.
const std::vector< DataNode * > & getInputDataNodes() const
Get all consumer nodes.
AlgoProps(Gaudi::Algorithm *algo, uint nodeIndex, uint algoIndex, bool inverted, bool allPass)
DecisionNode * getHeadNode() const
Get head node.
const std::string & name() const override
Retrieve name of the service.
std::string operator()(const AlgoProps &) const
std::vector< AlgorithmNode * > m_producers
virtual ~DataNode()=default
Destructor.
unsigned int m_nodeCounter
Total number of nodes in the graph.
const std::vector< DataNode * > & getOutputDataNodes() const
Get all supplier nodes.
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:89
std::string operator()(const AlgoProps &) const
void printState(std::stringstream &output, EventSlot &slot, const unsigned int &recursionLevel) const override
Print a string representing the control flow state.
DataNode * getDataNode(const DataObjID &dataPath) const
Get DataNode by DataObject path using graph index.
Gaudi::tagged_bool< class AllPass_tag > AllPass
EventSlot * parentSlot
Pointer to parent slot (null for top level)
Definition: EventSlot.h:96
void addParentNode(DecisionNode *node)
Add a parent node.
bool m_inverted
Whether the selection result is negated or not.
DecisionHubProps(const std::string &name, uint nodeIndex, concurrency::Concurrent modeConcurrent, concurrency::PromptDecision modePromptDecision, concurrency::ModeOr modeOR, concurrency::AllPass allPass, concurrency::Inverted isInverted)
std::string operator()(const DecisionHubProps &) const
bool accept(IGraphVisitor &visitor) override
Visitor entry point.
std::string dumpDataFlow() const
Print out all data origins and destinations, as reflected in the EF graph.
PrecedenceRulesGraph * m_graph
bool isLiar() const
Check if control flow logic is always inverted.
std::string operator()(const DataProps &) const
bool m_modeOR
Whether acting as "and" (false) or "or" node (true)
std::string operator()(const DataProps &) const
std::string operator()(const DataProps &) const
bool m_modeConcurrent
Whether all daughters will be evaluated concurrently or sequentially.
const unsigned int & getNodeIndex() const
Get node index.
StatusCode buildDataDependenciesRealm()
Build data dependency realm WITH data object nodes participating.
void printState(std::stringstream &output, EventSlot &slot, const unsigned int &recursionLevel) const override
Print a string representing the control flow state.
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...
bool m_isIOBound
If an algorithm is blocking.
StartTime(const EventSlot &slot, SmartIF< ISvcLocator > &svcLocator)
virtual void printState(std::stringstream &output, EventSlot &slot, const unsigned int &recursionLevel) const =0
Print a string representing the control flow state.
std::variant< AlgoProps, DecisionHubProps, DataProps, CondDataProps > VariantVertexProps
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
std::unique_ptr< EventContext > eventContext
Cache for the eventContext.
Definition: EventSlot.h:83
std::string m_sourceName
const std::string & name() const
Get node name.
bool m_allPass
Whether the selection result is relevant or always "pass".
void addProducerNode(AlgorithmNode *node)
Add relationship to producer AlgorithmNode.
void addHeadNode(const std::string &headName, concurrency::Concurrent, concurrency::PromptDecision, concurrency::ModeOr, concurrency::AllPass, concurrency::Inverted)
Add a node, which has no parents.
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:85
std::ostream & operator<<(std::ostream &str, const GaudiAlg::ID &id)
Operator overloading for ostream.
Definition: GaudiHistoID.h:142
SmartIF< ISvcLocator > m_svcLocator
Service locator (needed to access the MessageSvc)
ConditionNode(PrecedenceRulesGraph &graph, const DataObjID &path, SmartIF< ICondSvc > condSvc)
Constructor.
void rankAlgorithms(IGraphVisitor &ranker) const
Rank Algorithm nodes by the number of data outputs.
CFDecision(const EventSlot &slot)
void addConsumerNode(AlgorithmNode *node)
Add relationship to consumer AlgorithmNode.