The Gaudi Framework  master (37c0b60a)
concurrency::AlgorithmNode Class Referencefinal

#include </builds/gaudi/Gaudi/GaudiHive/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)
 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...
 
float getRank () const
 Get Algorithm rank. More...
 
Gaudi::AlgorithmgetAlgorithm () const
 get Algorithm representatives More...
 
unsigned int getAlgoIndex () const
 Get algorithm index. More...
 
void setAsynchronous (bool value)
 Set the asynchronous flag. More...
 
bool isAsynchronous () const
 Check if algorithm is asynchronous. 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...
 
float m_rank = -1
 Algorithm rank of any kind. More...
 
bool m_isAsynchronous
 If an algorithm is asynchronous. 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 484 of file PrecedenceRulesGraph.h.

Constructor & Destructor Documentation

◆ AlgorithmNode()

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

Constructor.

Definition at line 487 of file PrecedenceRulesGraph.h.

489  : ControlFlowNode( graph, nodeIndex, algoPtr->name() )
490  , m_algorithm( algoPtr )
491  , m_algoIndex( algoIndex )
492  , m_algoName( algoPtr->name() )
493  , m_isAsynchronous( algoPtr->isAsynchronous() ) {}

Member Function Documentation

◆ accept()

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

Visitor entry point.

Implements concurrency::ControlFlowNode.

Definition at line 191 of file PrecedenceRulesGraph.cpp.

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

◆ addInputDataNode()

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

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

Definition at line 214 of file PrecedenceRulesGraph.cpp.

214  {
215 
216  if ( std::find( m_inputs.begin(), m_inputs.end(), node ) == m_inputs.end() ) m_inputs.push_back( node );
217  }

◆ addOutputDataNode()

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

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

Definition at line 208 of file PrecedenceRulesGraph.cpp.

208  {
209 
210  if ( std::find( m_outputs.begin(), m_outputs.end(), node ) == m_outputs.end() ) m_outputs.push_back( node );
211  }

◆ addParentNode()

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

Add a parent node.

Definition at line 202 of file PrecedenceRulesGraph.cpp.

202  {
203 
204  if ( std::find( m_parents.begin(), m_parents.end(), node ) == m_parents.end() ) m_parents.push_back( node );
205  }

◆ getAlgoIndex()

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

Get algorithm index.

Definition at line 520 of file PrecedenceRulesGraph.h.

520 { return m_algoIndex; }

◆ getAlgorithm()

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

get Algorithm representatives

Definition at line 518 of file PrecedenceRulesGraph.h.

518 { return m_algorithm; }

◆ getInputDataNodes()

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

Get all consumer nodes.

Definition at line 510 of file PrecedenceRulesGraph.h.

510 { return m_inputs; }

◆ getOutputDataNodes()

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

Get all supplier nodes.

Definition at line 508 of file PrecedenceRulesGraph.h.

508 { return m_outputs; }

◆ getParentDecisionHubs()

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

Get all parent decision hubs.

Definition at line 501 of file PrecedenceRulesGraph.h.

501 { return m_parents; }

◆ getRank()

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

Get Algorithm rank.

Definition at line 515 of file PrecedenceRulesGraph.h.

515 { return m_rank; }

◆ isAsynchronous()

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

Check if algorithm is asynchronous.

Definition at line 525 of file PrecedenceRulesGraph.h.

525 { return m_isAsynchronous; }

◆ 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 77 of file PrecedenceRulesGraph.cpp.

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

◆ setAsynchronous()

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

Set the asynchronous flag.

Definition at line 523 of file PrecedenceRulesGraph.h.

523 { m_isAsynchronous = value; }

◆ setRank()

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

Set Algorithm rank.

Definition at line 513 of file PrecedenceRulesGraph.h.

513 { m_rank = rank; }

Member Data Documentation

◆ m_algoIndex

unsigned int concurrency::AlgorithmNode::m_algoIndex
private

The index of the algorithm.

Definition at line 538 of file PrecedenceRulesGraph.h.

◆ m_algoName

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

The name of the algorithm.

Definition at line 540 of file PrecedenceRulesGraph.h.

◆ m_algorithm

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

Algorithm representative behind the AlgorithmNode.

Definition at line 536 of file PrecedenceRulesGraph.h.

◆ m_inputs

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

Algorithm inputs (DataNodes)

Definition at line 549 of file PrecedenceRulesGraph.h.

◆ m_isAsynchronous

bool concurrency::AlgorithmNode::m_isAsynchronous
private

If an algorithm is asynchronous.

Definition at line 544 of file PrecedenceRulesGraph.h.

◆ m_outputs

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

Algorithm outputs (DataNodes)

Definition at line 547 of file PrecedenceRulesGraph.h.

◆ m_parents

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

Control flow parents of an AlgorithmNode (DecisionNodes)

Definition at line 532 of file PrecedenceRulesGraph.h.

◆ m_rank

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

Algorithm rank of any kind.

Definition at line 542 of file PrecedenceRulesGraph.h.


The documentation for this class was generated from the following files:
EventSlot::eventContext
std::unique_ptr< EventContext > eventContext
Cache for the eventContext.
Definition: EventSlot.h:83
concurrency::AlgorithmNode::m_rank
float m_rank
Algorithm rank of any kind.
Definition: PrecedenceRulesGraph.h:542
concurrency::AlgorithmNode::m_parents
std::vector< DecisionNode * > m_parents
Control flow parents of an AlgorithmNode (DecisionNodes)
Definition: PrecedenceRulesGraph.h:532
std::string
STL class.
Gaudi::Algorithm::acceptDHVisitor
void acceptDHVisitor(IDataHandleVisitor *) const override
Definition: Algorithm.cpp:186
EventSlot::subSlotsByNode
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
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:526
EventContext::eventID
const EventIDBase & eventID() const
Definition: EventContext.h:55
concurrency::AlgorithmNode::getInputDataNodes
const std::vector< DataNode * > & getInputDataNodes() const
Get all consumer nodes.
Definition: PrecedenceRulesGraph.h:510
std::vector
STL class.
std::find
T find(T... args)
EventSlot
Class representing an event slot.
Definition: EventSlot.h:24
concurrency::ControlFlowNode::name
const std::string & name() const
Get node name.
Definition: PrecedenceRulesGraph.h:429
concurrency::AlgorithmNode::m_outputs
std::vector< DataNode * > m_outputs
Algorithm outputs (DataNodes)
Definition: PrecedenceRulesGraph.h:547
concurrency::AlgorithmNode::m_algoName
std::string m_algoName
The name of the algorithm.
Definition: PrecedenceRulesGraph.h:540
concurrency::AlgorithmNode::m_algoIndex
unsigned int m_algoIndex
The index of the algorithm.
Definition: PrecedenceRulesGraph.h:538
Gaudi::Algorithm::isAsynchronous
bool isAsynchronous() const
Definition: Algorithm.h:396
gaudirun.output
output
Definition: gaudirun.py:521
concurrency::ControlFlowNode::m_nodeIndex
unsigned int m_nodeIndex
Definition: PrecedenceRulesGraph.h:435
plotSpeedupsPyRoot.graph
graph
Definition: plotSpeedupsPyRoot.py:168
std::vector::at
T at(T... args)
EventSlot::parentSlot
EventSlot * parentSlot
Pointer to parent slot (null for top level)
Definition: EventSlot.h:96
EventSlot::allSubSlots
std::vector< EventSlot > allSubSlots
Actual sub-slot instances.
Definition: EventSlot.h:100
concurrency::ControlFlowNode::ControlFlowNode
ControlFlowNode(PrecedenceRulesGraph &graph, unsigned int nodeIndex, const std::string &name)
Constructor.
Definition: PrecedenceRulesGraph.h:417
concurrency::AlgorithmNode::m_algorithm
Gaudi::Algorithm * m_algorithm
Algorithm representative behind the AlgorithmNode.
Definition: PrecedenceRulesGraph.h:536
concurrency::AlgorithmNode::m_inputs
std::vector< DataNode * > m_inputs
Algorithm inputs (DataNodes)
Definition: PrecedenceRulesGraph.h:549
concurrency::ControlFlowNode::m_nodeName
std::string m_nodeName
Definition: PrecedenceRulesGraph.h:436
std::endl
T endl(T... args)
concurrency::AlgorithmNode::m_isAsynchronous
bool m_isAsynchronous
If an algorithm is asynchronous.
Definition: PrecedenceRulesGraph.h:544
EventIDBase
This class provides a unique identification for each event, in terms of run/event number and/or a tim...
Definition: EventIDBase.h:66
EventSlot::controlFlowState
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:87
EventSlot::algsStates
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:85
concurrency::AlgorithmNode::getAlgorithm
Gaudi::Algorithm * getAlgorithm() const
get Algorithm representatives
Definition: PrecedenceRulesGraph.h:518
Gaudi::Functional::details::zip::range
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Definition: details.h:97
DataHandleFinder
Definition: DataHandleFinder.h:31