The Gaudi Framework  v33r1 (b1225454)
concurrency::AlgorithmNode Class Referencefinal

#include <src/PRGraph/PrecedenceRulesGraph.h>

Inheritance diagram for concurrency::AlgorithmNode:
Collaboration diagram for concurrency::AlgorithmNode:

Public Member Functions

 AlgorithmNode (PrecedenceRulesGraph &graph, Gaudi::Algorithm *algoPtr, unsigned int nodeIndex, unsigned int algoIndex, bool inverted, bool allPass)
 Constructor. More...
 
bool accept (IGraphVisitor &visitor) override
 Visitor entry point. More...
 
void addParentNode (DecisionNode *node)
 Add a parent node. More...
 
const std::vector< DecisionNode * > & getParentDecisionHubs () const
 Get all parent decision hubs. More...
 
void addOutputDataNode (DataNode *node)
 Associate an AlgorithmNode, which is a data supplier for this one. More...
 
void addInputDataNode (DataNode *node)
 Associate an AlgorithmNode, which is a data consumer of this one. More...
 
const std::vector< DataNode * > & getOutputDataNodes () const
 Get all supplier nodes. More...
 
const std::vector< DataNode * > & getInputDataNodes () const
 Get all consumer nodes. More...
 
void setRank (float &rank)
 Set Algorithm rank. More...
 
const float & getRank () const
 Get Algorithm rank. More...
 
Gaudi::AlgorithmgetAlgorithm () const
 get Algorithm representatives More...
 
const unsigned int & getAlgoIndex () const
 Get algorithm index. More...
 
void setIOBound (bool value)
 Set the I/O-boundness flag. More...
 
bool isIOBound () const
 Check if algorithm is I/O-bound. More...
 
bool isOptimist () const
 Check if positive control flow decision is enforced. More...
 
bool isLiar () const
 Check if control flow logic is always inverted. More...
 
void printState (std::stringstream &output, EventSlot &slot, const unsigned int &recursionLevel) const override
 Print a string representing the control flow state. More...
 
- Public Member Functions inherited from concurrency::ControlFlowNode
 ControlFlowNode (PrecedenceRulesGraph &graph, unsigned int nodeIndex, const std::string &name)
 Constructor. More...
 
virtual ~ControlFlowNode ()=default
 Destructor. More...
 
const unsigned int & getNodeIndex () const
 Get node index. More...
 
const std::stringname () const
 Get node name. More...
 

Public Attributes

std::vector< DecisionNode * > m_parents
 Control flow parents of an AlgorithmNode (DecisionNodes) More...
 
- Public Attributes inherited from concurrency::ControlFlowNode
PrecedenceRulesGraphm_graph
 

Private Attributes

Gaudi::Algorithmm_algorithm
 Algorithm representative behind the AlgorithmNode. More...
 
unsigned int m_algoIndex
 The index of the algorithm. More...
 
std::string m_algoName
 The name of the algorithm. More...
 
bool m_inverted
 Whether the selection result is negated or not. More...
 
bool m_allPass
 Whether the selection result is relevant or always "pass". More...
 
float m_rank = -1
 Algorithm rank of any kind. More...
 
bool m_isIOBound
 If an algorithm is blocking. More...
 
std::vector< DataNode * > m_outputs
 Algorithm outputs (DataNodes) More...
 
std::vector< DataNode * > m_inputs
 Algorithm inputs (DataNodes) More...
 

Additional Inherited Members

- Protected Attributes inherited from concurrency::ControlFlowNode
unsigned int m_nodeIndex
 
std::string m_nodeName
 

Detailed Description

Definition at line 485 of file PrecedenceRulesGraph.h.

Constructor & Destructor Documentation

◆ AlgorithmNode()

concurrency::AlgorithmNode::AlgorithmNode ( PrecedenceRulesGraph graph,
Gaudi::Algorithm algoPtr,
unsigned int  nodeIndex,
unsigned int  algoIndex,
bool  inverted,
bool  allPass 
)
inline

Constructor.

Definition at line 488 of file PrecedenceRulesGraph.h.

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() ){};
bool isIOBound() const
Definition: Algorithm.h:404
ControlFlowNode(PrecedenceRulesGraph &graph, unsigned int nodeIndex, const std::string &name)
Constructor.
unsigned int m_algoIndex
The index of the algorithm.
std::string m_algoName
The name of the algorithm.
bool m_inverted
Whether the selection result is negated or not.
Gaudi::Algorithm * m_algorithm
Algorithm representative behind the AlgorithmNode.
bool m_isIOBound
If an algorithm is blocking.
bool m_allPass
Whether the selection result is relevant or always "pass".
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:549

Member Function Documentation

◆ accept()

bool concurrency::AlgorithmNode::accept ( IGraphVisitor visitor)
overridevirtual

Visitor entry point.

Implements concurrency::ControlFlowNode.

Definition at line 190 of file PrecedenceRulesGraph.cpp.

190  {
191 
192  if ( visitor.visitEnter( *this ) ) {
193  visitor.visit( *this );
194  return true; // visitor was accepted to promote the algorithm
195  }
196 
197  return false; // visitor was rejected (since the algorithm already produced a decision)
198  }

◆ addInputDataNode()

void concurrency::AlgorithmNode::addInputDataNode ( DataNode node)

Associate an AlgorithmNode, which is a data consumer of this one.

Definition at line 213 of file PrecedenceRulesGraph.cpp.

213  {
214 
215  if ( std::find( m_inputs.begin(), m_inputs.end(), node ) == m_inputs.end() ) m_inputs.push_back( node );
216  }
T find(T... args)
std::vector< DataNode * > m_inputs
Algorithm inputs (DataNodes)

◆ addOutputDataNode()

void concurrency::AlgorithmNode::addOutputDataNode ( DataNode node)

Associate an AlgorithmNode, which is a data supplier for this one.

Definition at line 207 of file PrecedenceRulesGraph.cpp.

207  {
208 
209  if ( std::find( m_outputs.begin(), m_outputs.end(), node ) == m_outputs.end() ) m_outputs.push_back( node );
210  }
std::vector< DataNode * > m_outputs
Algorithm outputs (DataNodes)
T find(T... args)

◆ addParentNode()

void concurrency::AlgorithmNode::addParentNode ( DecisionNode node)

Add a parent node.

Definition at line 201 of file PrecedenceRulesGraph.cpp.

201  {
202 
203  if ( std::find( m_parents.begin(), m_parents.end(), node ) == m_parents.end() ) m_parents.push_back( node );
204  }
std::vector< DecisionNode * > m_parents
Control flow parents of an AlgorithmNode (DecisionNodes)
T find(T... args)

◆ getAlgoIndex()

const unsigned int& concurrency::AlgorithmNode::getAlgoIndex ( ) const
inline

Get algorithm index.

Definition at line 523 of file PrecedenceRulesGraph.h.

523 { return m_algoIndex; }
unsigned int m_algoIndex
The index of the algorithm.

◆ getAlgorithm()

Gaudi::Algorithm* concurrency::AlgorithmNode::getAlgorithm ( ) const
inline

get Algorithm representatives

Definition at line 521 of file PrecedenceRulesGraph.h.

521 { return m_algorithm; }
Gaudi::Algorithm * m_algorithm
Algorithm representative behind the AlgorithmNode.

◆ getInputDataNodes()

const std::vector<DataNode*>& concurrency::AlgorithmNode::getInputDataNodes ( ) const
inline

Get all consumer nodes.

Definition at line 513 of file PrecedenceRulesGraph.h.

513 { return m_inputs; }
std::vector< DataNode * > m_inputs
Algorithm inputs (DataNodes)

◆ getOutputDataNodes()

const std::vector<DataNode*>& concurrency::AlgorithmNode::getOutputDataNodes ( ) const
inline

Get all supplier nodes.

Definition at line 511 of file PrecedenceRulesGraph.h.

511 { return m_outputs; }
std::vector< DataNode * > m_outputs
Algorithm outputs (DataNodes)

◆ getParentDecisionHubs()

const std::vector<DecisionNode*>& concurrency::AlgorithmNode::getParentDecisionHubs ( ) const
inline

Get all parent decision hubs.

Definition at line 504 of file PrecedenceRulesGraph.h.

504 { return m_parents; }
std::vector< DecisionNode * > m_parents
Control flow parents of an AlgorithmNode (DecisionNodes)

◆ getRank()

const float& concurrency::AlgorithmNode::getRank ( ) const
inline

Get Algorithm rank.

Definition at line 518 of file PrecedenceRulesGraph.h.

518 { return m_rank; }
float m_rank
Algorithm rank of any kind.

◆ isIOBound()

bool concurrency::AlgorithmNode::isIOBound ( ) const
inline

Check if algorithm is I/O-bound.

Definition at line 528 of file PrecedenceRulesGraph.h.

528 { return m_isIOBound; }
bool m_isIOBound
If an algorithm is blocking.

◆ isLiar()

bool concurrency::AlgorithmNode::isLiar ( ) const
inline

Check if control flow logic is always inverted.

Definition at line 533 of file PrecedenceRulesGraph.h.

533 { return m_inverted; };
bool m_inverted
Whether the selection result is negated or not.

◆ isOptimist()

bool concurrency::AlgorithmNode::isOptimist ( ) const
inline

Check if positive control flow decision is enforced.

Definition at line 531 of file PrecedenceRulesGraph.h.

531 { return m_allPass; };
bool m_allPass
Whether the selection result is relevant or always "pass".

◆ printState()

void concurrency::AlgorithmNode::printState ( std::stringstream output,
EventSlot slot,
const unsigned int &  recursionLevel 
) const
overridevirtual

Print a string representing the control flow state.

Implements concurrency::ControlFlowNode.

Definition at line 76 of file PrecedenceRulesGraph.cpp.

77  {
78 
79  auto& node_decisions = slot.controlFlowState;
80  auto& states = slot.algsStates;
81  std::string indent( recursionLevel, ' ' );
82  output << indent << m_nodeName << " (" << m_nodeIndex << ")"
83  << ", w/ decision: " << stateToString( node_decisions[m_nodeIndex] ) << "(" << node_decisions[m_nodeIndex]
84  << ")"
85  << ", in state: " << states[m_algoIndex] << std::endl;
86 
87  // In a stall, CONTROLREADY nodes are interesting
88  if ( states[m_algoIndex] == AlgsExecutionStates::State::CONTROLREADY ) {
89 
90  // Check all data dependencies
91  output << indent << "========" << std::endl;
92  for ( auto dataNode : this->getInputDataNodes() ) {
93 
94  // Was the data produced?
95  ConditionNode* conditionNode = dynamic_cast<ConditionNode*>( dataNode );
96  DataReadyPromoter visitor( slot, {} );
97  bool wasProduced = false;
98  if ( conditionNode ) {
99  // ConditionNodes always request data on visit()
100  // Instead take the opposite of visitEnter(), since you may not enter if it already exists
101  wasProduced = !visitor.visitEnter( *conditionNode );
102  } else {
103  // For DataNodes, the check is done in visit()
104  wasProduced = visitor.visit( *dataNode );
105  }
106 
107  // Print out states of producer algs if data is missing
108  if ( !wasProduced ) {
109 
110  // Say if it's conditions data or not
111  if ( conditionNode )
112  output << indent << "missing conditions data: " << dataNode->name() << std::endl;
113  else
114  output << indent << "missing data: " << dataNode->name() << std::endl;
115 
116  // Find out if the algorithm needs it because of a tool
117  DataHandleFinder finder( dataNode->name() );
118  this->getAlgorithm()->acceptDHVisitor( &finder );
119  if ( finder.holderNames().size() > 1 ) {
120  output << indent << "required by tool:";
121  for ( auto const& holderName : finder.holderNames() ) {
122  if ( holderName != this->name() ) output << " " << holderName;
123  }
124  output << std::endl;
125  }
126 
127  if ( conditionNode ) {
128  // State which IOVs the data exists for
129  output << indent << "current EventID: " << EventIDBase( slot.eventContext->eventID() ) << std::endl;
130  std::vector<EventIDRange> validRanges;
131  conditionNode->m_condSvc->validRanges( validRanges, dataNode->name() )
132  .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
133  for ( auto& range : validRanges ) { output << indent << "interval of validity: " << range << std::endl; }
134  if ( validRanges.empty() ) output << indent << "no interval(s) of validity" << std::endl;
135  } else {
136  // State which algs produce this data
137  output << indent << "can be produced by alg(s): ";
138  for ( auto algoNode : dataNode->getProducers() ) {
139  output << "( " << algoNode->name() << " in state: " << states[algoNode->getAlgoIndex()] << " ) ";
140  }
141  output << std::endl;
142  }
143 
144  // See where data is available (ignore conditions, since these are top-level)
145  if ( !conditionNode ) {
146  std::vector<EventSlot>* testSubSlots = &slot.allSubSlots;
147  auto* subSlotMap = &slot.subSlotsByNode;
148 
149  // Examine the top-level slot if you did not start there
150  if ( slot.parentSlot ) {
151  visitor.m_slot = slot.parentSlot;
152  testSubSlots = &slot.parentSlot->allSubSlots;
153  subSlotMap = &slot.parentSlot->subSlotsByNode;
154  if ( visitor.visit( *dataNode ) ) {
155  output << indent << "data is available at whole-event level" << std::endl;
156  }
157  }
158 
159  // Examine all sub slots, grouped by entry point
160  for ( auto& pair : *subSlotMap ) {
161  if ( pair.second.size() > 0 ) {
162  bool madeLine = false;
163 
164  // Loop over the slots for this entry point
165  for ( int slotIndex : pair.second ) {
166 
167  EventSlot* subSlot = &testSubSlots->at( slotIndex );
168  visitor.m_slot = subSlot;
169  if ( visitor.visit( *dataNode ) ) {
170 
171  if ( !madeLine ) {
172  // Only mention this set of sub-slots at all if one has the data
173  output << indent << "data is available in sub-slot(s) ";
174  madeLine = true;
175  }
176  output << slotIndex << ", ";
177  }
178  }
179  if ( madeLine ) { output << "entered from " << pair.first << std::endl; }
180  }
181  }
182  }
183  }
184  }
185  output << indent << "========" << std::endl;
186  }
187  }
Class representing an event slot.
Definition: EventSlot.h:24
unsigned int m_algoIndex
The index of the algorithm.
Gaudi::Algorithm * getAlgorithm() const
get Algorithm representatives
T endl(T... args)
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:87
std::vector< EventSlot > allSubSlots
Actual sub-slot instances.
Definition: EventSlot.h:100
STL class.
T at(T... args)
Implements the IDataHandleVisitor interface Class used to explore heirarchy of nested IDataHandleHold...
STL class.
void acceptDHVisitor(IDataHandleVisitor *) const override
Definition: Algorithm.cpp:199
const std::vector< DataNode * > & getInputDataNodes() const
Get all consumer nodes.
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventIDBase.h:66
EventSlot * parentSlot
Pointer to parent slot (null for top level)
Definition: EventSlot.h:96
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
std::unordered_map< std::string, std::vector< unsigned int > > subSlotsByNode
Listing of sub-slots by the node (name) they are attached to.
Definition: EventSlot.h:98
std::unique_ptr< EventContext > eventContext
Cache for the eventContext.
Definition: EventSlot.h:83
const std::string & name() const
Get node name.
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:85
const EventIDBase & eventID() const
Definition: EventContext.h:55

◆ setIOBound()

void concurrency::AlgorithmNode::setIOBound ( bool  value)
inline

Set the I/O-boundness flag.

Definition at line 526 of file PrecedenceRulesGraph.h.

526 { m_isIOBound = value; }
bool m_isIOBound
If an algorithm is blocking.

◆ setRank()

void concurrency::AlgorithmNode::setRank ( float &  rank)
inline

Set Algorithm rank.

Definition at line 516 of file PrecedenceRulesGraph.h.

516 { m_rank = rank; }
float m_rank
Algorithm rank of any kind.

Member Data Documentation

◆ m_algoIndex

unsigned int concurrency::AlgorithmNode::m_algoIndex
private

The index of the algorithm.

Definition at line 546 of file PrecedenceRulesGraph.h.

◆ m_algoName

std::string concurrency::AlgorithmNode::m_algoName
private

The name of the algorithm.

Definition at line 548 of file PrecedenceRulesGraph.h.

◆ m_algorithm

Gaudi::Algorithm* concurrency::AlgorithmNode::m_algorithm
private

Algorithm representative behind the AlgorithmNode.

Definition at line 544 of file PrecedenceRulesGraph.h.

◆ m_allPass

bool concurrency::AlgorithmNode::m_allPass
private

Whether the selection result is relevant or always "pass".

Definition at line 552 of file PrecedenceRulesGraph.h.

◆ m_inputs

std::vector<DataNode*> concurrency::AlgorithmNode::m_inputs
private

Algorithm inputs (DataNodes)

Definition at line 561 of file PrecedenceRulesGraph.h.

◆ m_inverted

bool concurrency::AlgorithmNode::m_inverted
private

Whether the selection result is negated or not.

Definition at line 550 of file PrecedenceRulesGraph.h.

◆ m_isIOBound

bool concurrency::AlgorithmNode::m_isIOBound
private

If an algorithm is blocking.

Definition at line 556 of file PrecedenceRulesGraph.h.

◆ m_outputs

std::vector<DataNode*> concurrency::AlgorithmNode::m_outputs
private

Algorithm outputs (DataNodes)

Definition at line 559 of file PrecedenceRulesGraph.h.

◆ m_parents

std::vector<DecisionNode*> concurrency::AlgorithmNode::m_parents

Control flow parents of an AlgorithmNode (DecisionNodes)

Definition at line 540 of file PrecedenceRulesGraph.h.

◆ m_rank

float concurrency::AlgorithmNode::m_rank = -1
private

Algorithm rank of any kind.

Definition at line 554 of file PrecedenceRulesGraph.h.


The documentation for this class was generated from the following files: