The Gaudi Framework  master (9f3f8895)
Loading...
Searching...
No Matches
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.
bool accept (IGraphVisitor &visitor) override
 Visitor entry point.
void addParentNode (DecisionNode *node)
 Add a parent node.
const std::vector< DecisionNode * > & getParentDecisionHubs () const
 Get all parent decision hubs.
void addOutputDataNode (DataNode *node)
 Associate an AlgorithmNode, which is a data supplier for this one.
void addInputDataNode (DataNode *node)
 Associate an AlgorithmNode, which is a data consumer of this one.
const std::vector< DataNode * > & getOutputDataNodes () const
 Get all supplier nodes.
const std::vector< DataNode * > & getInputDataNodes () const
 Get all consumer nodes.
void setRank (float rank)
 Set Algorithm rank.
float getRank () const
 Get Algorithm rank.
Gaudi::Algorithm * getAlgorithm () const
 get Algorithm representatives
unsigned int getAlgoIndex () const
 Get algorithm index.
void setAsynchronous (bool value)
 Set the asynchronous flag.
bool isAsynchronous () const
 Check if algorithm is asynchronous.
void printState (std::stringstream &output, EventSlot &slot, const unsigned int &recursionLevel) const override
 Print a string representing the control flow state.
Public Member Functions inherited from concurrency::ControlFlowNode
 ControlFlowNode (PrecedenceRulesGraph &graph, unsigned int nodeIndex, const std::string &name)
 Constructor.
virtual ~ControlFlowNode ()=default
 Destructor.
const unsigned int & getNodeIndex () const
 Get node index.
const std::string & name () const
 Get node name.

Public Attributes

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

Private Attributes

Gaudi::Algorithm * m_algorithm
 Algorithm representative behind the AlgorithmNode.
unsigned int m_algoIndex
 The index of the algorithm.
std::string m_algoName
 The name of the algorithm.
float m_rank = -1
 Algorithm rank of any kind.
bool m_isAsynchronous
 If an algorithm is asynchronous.
std::vector< DataNode * > m_outputs
 Algorithm outputs (DataNodes).
std::vector< DataNode * > m_inputs
 Algorithm inputs (DataNodes).

Additional Inherited Members

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

Detailed Description

Definition at line 494 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 497 of file PrecedenceRulesGraph.h.

499 : ControlFlowNode( graph, nodeIndex, algoPtr->name() )
500 , m_algorithm( algoPtr )
501 , m_algoIndex( algoIndex )
502 , m_algoName( algoPtr->name() )
503 , m_isAsynchronous( algoPtr->isAsynchronous() ) {}
const std::string & name() const override
The identifying name of the algorithm object.
bool isAsynchronous() const
Definition Algorithm.h:376
bool m_isAsynchronous
If an algorithm is asynchronous.
std::string m_algoName
The name of the algorithm.
Gaudi::Algorithm * m_algorithm
Algorithm representative behind the AlgorithmNode.
unsigned int m_algoIndex
The index of the algorithm.
ControlFlowNode(PrecedenceRulesGraph &graph, unsigned int nodeIndex, const std::string &name)
Constructor.

Member Function Documentation

◆ accept()

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

Visitor entry point.

Implements concurrency::ControlFlowNode.

Definition at line 197 of file PrecedenceRulesGraph.cpp.

197 {
198
199 if ( visitor.visitEnter( *this ) ) {
200 visitor.visit( *this );
201 return true; // visitor was accepted to promote the algorithm
202 }
203
204 return false; // visitor was rejected (since the algorithm already produced a decision)
205 }

◆ addInputDataNode()

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

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

Definition at line 220 of file PrecedenceRulesGraph.cpp.

220 {
221
222 if ( std::find( m_inputs.begin(), m_inputs.end(), node ) == m_inputs.end() ) m_inputs.push_back( node );
223 }
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 214 of file PrecedenceRulesGraph.cpp.

214 {
215
216 if ( std::find( m_outputs.begin(), m_outputs.end(), node ) == m_outputs.end() ) m_outputs.push_back( node );
217 }
std::vector< DataNode * > m_outputs
Algorithm outputs (DataNodes).

◆ addParentNode()

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

Add a parent node.

Definition at line 208 of file PrecedenceRulesGraph.cpp.

208 {
209
210 if ( std::find( m_parents.begin(), m_parents.end(), node ) == m_parents.end() ) m_parents.push_back( node );
211 }
std::vector< DecisionNode * > m_parents
Control flow parents of an AlgorithmNode (DecisionNodes).

◆ getAlgoIndex()

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

Get algorithm index.

Definition at line 530 of file PrecedenceRulesGraph.h.

530{ return m_algoIndex; }

◆ getAlgorithm()

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

get Algorithm representatives

Definition at line 528 of file PrecedenceRulesGraph.h.

528{ return m_algorithm; }

◆ getInputDataNodes()

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

Get all consumer nodes.

Definition at line 520 of file PrecedenceRulesGraph.h.

520{ return m_inputs; }

◆ getOutputDataNodes()

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

Get all supplier nodes.

Definition at line 518 of file PrecedenceRulesGraph.h.

518{ return m_outputs; }

◆ getParentDecisionHubs()

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

Get all parent decision hubs.

Definition at line 511 of file PrecedenceRulesGraph.h.

511{ return m_parents; }

◆ getRank()

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

Get Algorithm rank.

Definition at line 525 of file PrecedenceRulesGraph.h.

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

◆ isAsynchronous()

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

Check if algorithm is asynchronous.

Definition at line 535 of file PrecedenceRulesGraph.h.

535{ 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 83 of file PrecedenceRulesGraph.cpp.

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

◆ setAsynchronous()

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

Set the asynchronous flag.

Definition at line 533 of file PrecedenceRulesGraph.h.

533{ m_isAsynchronous = value; }

◆ setRank()

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

Set Algorithm rank.

Definition at line 523 of file PrecedenceRulesGraph.h.

523{ m_rank = rank; }

Member Data Documentation

◆ m_algoIndex

unsigned int concurrency::AlgorithmNode::m_algoIndex
private

The index of the algorithm.

Definition at line 548 of file PrecedenceRulesGraph.h.

◆ m_algoName

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

The name of the algorithm.

Definition at line 550 of file PrecedenceRulesGraph.h.

◆ m_algorithm

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

Algorithm representative behind the AlgorithmNode.

Definition at line 546 of file PrecedenceRulesGraph.h.

◆ m_inputs

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

Algorithm inputs (DataNodes).

Definition at line 559 of file PrecedenceRulesGraph.h.

◆ m_isAsynchronous

bool concurrency::AlgorithmNode::m_isAsynchronous
private

If an algorithm is asynchronous.

Definition at line 554 of file PrecedenceRulesGraph.h.

◆ m_outputs

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

Algorithm outputs (DataNodes).

Definition at line 557 of file PrecedenceRulesGraph.h.

◆ m_parents

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

Control flow parents of an AlgorithmNode (DecisionNodes).

Definition at line 542 of file PrecedenceRulesGraph.h.

◆ m_rank

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

Algorithm rank of any kind.

Definition at line 552 of file PrecedenceRulesGraph.h.


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