The Gaudi Framework  v32r2 (46d42edc)
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::stringgetNodeName () 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 475 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 478 of file PrecedenceRulesGraph.h.

480  : ControlFlowNode( graph, nodeIndex, algoPtr->name() )
481  , m_algorithm( algoPtr )
482  , m_algoIndex( algoIndex )
483  , m_algoName( algoPtr->name() )
484  , m_inverted( inverted )
485  , m_allPass( allPass )
486  , m_isIOBound( algoPtr->isIOBound() ){};
bool isIOBound() const
Definition: Algorithm.h:431
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:645

Member Function Documentation

◆ accept()

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

Visitor entry point.

Implements concurrency::ControlFlowNode.

Definition at line 170 of file PrecedenceRulesGraph.cpp.

170  {
171 
172  if ( visitor.visitEnter( *this ) ) {
173  visitor.visit( *this );
174  return true; // visitor was accepted to promote the algorithm
175  }
176 
177  return false; // visitor was rejected (since the algorithm already produced a decision)
178  }

◆ addInputDataNode()

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

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

Definition at line 193 of file PrecedenceRulesGraph.cpp.

193  {
194 
195  if ( std::find( m_inputs.begin(), m_inputs.end(), node ) == m_inputs.end() ) m_inputs.push_back( node );
196  }
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 187 of file PrecedenceRulesGraph.cpp.

187  {
188 
189  if ( std::find( m_outputs.begin(), m_outputs.end(), node ) == m_outputs.end() ) m_outputs.push_back( node );
190  }
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 181 of file PrecedenceRulesGraph.cpp.

181  {
182 
183  if ( std::find( m_parents.begin(), m_parents.end(), node ) == m_parents.end() ) m_parents.push_back( node );
184  }
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 513 of file PrecedenceRulesGraph.h.

513 { 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 511 of file PrecedenceRulesGraph.h.

511 { 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 503 of file PrecedenceRulesGraph.h.

503 { 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 501 of file PrecedenceRulesGraph.h.

501 { 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 494 of file PrecedenceRulesGraph.h.

494 { 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 508 of file PrecedenceRulesGraph.h.

508 { 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 518 of file PrecedenceRulesGraph.h.

518 { 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 523 of file PrecedenceRulesGraph.h.

523 { 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 521 of file PrecedenceRulesGraph.h.

521 { 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 66 of file PrecedenceRulesGraph.cpp.

67  {
68 
69  auto& node_decisions = slot.controlFlowState;
70  auto& states = slot.algsStates;
71  std::string indent( recursionLevel, ' ' );
72  output << indent << m_nodeName << " (" << m_nodeIndex << ")"
73  << ", w/ decision: " << stateToString( node_decisions[m_nodeIndex] ) << "(" << node_decisions[m_nodeIndex]
74  << ")"
75  << ", in state: " << states[m_algoIndex] << std::endl;
76 
77  // In a stall, CONTROLREADY nodes are interesting
78  if ( states[m_algoIndex] == AlgsExecutionStates::State::CONTROLREADY ) {
79 
80  // Check all data dependencies
81  output << indent << "========" << std::endl;
82  for ( auto dataNode : this->getInputDataNodes() ) {
83 
84  // Was the data produced?
85  ConditionNode* castNode = dynamic_cast<ConditionNode*>( dataNode );
86  DataReadyPromoter visitor( slot, {} );
87  bool wasProduced = false;
88  if ( castNode ) {
89  // ConditionNodes always request data on visit()
90  // Instead take the opposite of visitEnter(), since you may not enter if it already exists
91  wasProduced = !visitor.visitEnter( *castNode );
92  } else {
93  // For DataNodes, the check is done in visit()
94  wasProduced = visitor.visit( *dataNode );
95  }
96 
97  // Print out states of producer algs if data is missing
98  if ( !wasProduced ) {
99 
100  // Say if it's conditions data or not
101  if ( castNode )
102  output << indent << "missing conditions data: " << dataNode->getPath() << std::endl;
103  else
104  output << indent << "missing data: " << dataNode->getPath() << std::endl;
105 
106  // Find out if the algorithm needs it because of a tool
107  DataHandleFinder finder( dataNode->getPath() );
108  this->getAlgorithm()->acceptDHVisitor( &finder );
109  if ( finder.holderNames().size() > 1 ) {
110  output << indent << "required by tool:";
111  for ( auto const& holderName : finder.holderNames() ) {
112  if ( holderName != this->getNodeName() ) output << " " << holderName;
113  }
114  output << std::endl;
115  }
116 
117  // State which algs produce this data
118  output << indent << "can be produced by alg(s): ";
119  for ( auto algoNode : dataNode->getProducers() ) {
120  output << "( " << algoNode->getNodeName() << " in state: " << states[algoNode->getAlgoIndex()] << " ) ";
121  }
122  output << std::endl;
123 
124  // See where data is available (ignore conditions, since these are top-level)
125  if ( !castNode ) {
126  std::vector<EventSlot>* testSubSlots = &slot.allSubSlots;
127  auto* subSlotMap = &slot.subSlotsByNode;
128 
129  // Examine the top-level slot if you did not start there
130  if ( slot.parentSlot ) {
131  visitor.m_slot = slot.parentSlot;
132  testSubSlots = &slot.parentSlot->allSubSlots;
133  subSlotMap = &slot.parentSlot->subSlotsByNode;
134  if ( visitor.visit( *dataNode ) ) {
135  output << indent << "data is available at whole-event level" << std::endl;
136  }
137  }
138 
139  // Examine all sub slots, grouped by entry point
140  for ( auto& pair : *subSlotMap ) {
141  if ( pair.second.size() > 0 ) {
142  bool madeLine = false;
143 
144  // Loop over the slots for this entry point
145  for ( int slotIndex : pair.second ) {
146 
147  EventSlot* subSlot = &testSubSlots->at( slotIndex );
148  visitor.m_slot = subSlot;
149  if ( visitor.visit( *dataNode ) ) {
150 
151  if ( !madeLine ) {
152  // Only mention this set of sub-slots at all if one has the data
153  output << indent << "data is available in sub-slot(s) ";
154  madeLine = true;
155  }
156  output << slotIndex << ", ";
157  }
158  }
159  if ( madeLine ) { output << "entered from " << pair.first << std::endl; }
160  }
161  }
162  }
163  }
164  }
165  output << indent << "========" << std::endl;
166  }
167  }
Class representing an event slot.
Definition: EventSlot.h:14
const std::string & getNodeName() const
Get node name.
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:77
std::vector< EventSlot > allSubSlots
Actual sub-slot instances.
Definition: EventSlot.h:90
STL class.
T at(T... args)
Implements the IDataHandleVisitor interface Class used to explore heirarchy of nested IDataHandleHold...
void acceptDHVisitor(IDataHandleVisitor *) const override
Definition: Algorithm.cpp:194
const std::vector< DataNode * > & getInputDataNodes() const
Get all consumer nodes.
EventSlot * parentSlot
Pointer to parent slot (null for top level)
Definition: EventSlot.h:86
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:88
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:75

◆ setIOBound()

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

Set the I/O-boundness flag.

Definition at line 516 of file PrecedenceRulesGraph.h.

516 { 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 506 of file PrecedenceRulesGraph.h.

506 { 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 536 of file PrecedenceRulesGraph.h.

◆ m_algoName

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

The name of the algorithm.

Definition at line 538 of file PrecedenceRulesGraph.h.

◆ m_algorithm

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

Algorithm representative behind the AlgorithmNode.

Definition at line 534 of file PrecedenceRulesGraph.h.

◆ m_allPass

bool concurrency::AlgorithmNode::m_allPass
private

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

Definition at line 542 of file PrecedenceRulesGraph.h.

◆ m_inputs

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

Algorithm inputs (DataNodes)

Definition at line 551 of file PrecedenceRulesGraph.h.

◆ m_inverted

bool concurrency::AlgorithmNode::m_inverted
private

Whether the selection result is negated or not.

Definition at line 540 of file PrecedenceRulesGraph.h.

◆ m_isIOBound

bool concurrency::AlgorithmNode::m_isIOBound
private

If an algorithm is blocking.

Definition at line 546 of file PrecedenceRulesGraph.h.

◆ m_outputs

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

Algorithm outputs (DataNodes)

Definition at line 549 of file PrecedenceRulesGraph.h.

◆ m_parents

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

Control flow parents of an AlgorithmNode (DecisionNodes)

Definition at line 530 of file PrecedenceRulesGraph.h.

◆ m_rank

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

Algorithm rank of any kind.

Definition at line 544 of file PrecedenceRulesGraph.h.


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