The Gaudi Framework  master (ff829712)
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::AlgorithmgetAlgorithm () 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
PrecedenceRulesGraphm_graph
 

Private Attributes

Gaudi::Algorithmm_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 485 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 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_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 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 }
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 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 }
std::vector< DataNode * > m_outputs
Algorithm outputs (DataNodes)

◆ 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 }
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 521 of file PrecedenceRulesGraph.h.

521{ return m_algoIndex; }

◆ getAlgorithm()

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

get Algorithm representatives

Definition at line 519 of file PrecedenceRulesGraph.h.

519{ return m_algorithm; }

◆ getInputDataNodes()

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

Get all consumer nodes.

Definition at line 511 of file PrecedenceRulesGraph.h.

511{ return m_inputs; }

◆ getOutputDataNodes()

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

Get all supplier nodes.

Definition at line 509 of file PrecedenceRulesGraph.h.

509{ return m_outputs; }

◆ getParentDecisionHubs()

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

Get all parent decision hubs.

Definition at line 502 of file PrecedenceRulesGraph.h.

502{ return m_parents; }

◆ getRank()

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

Get Algorithm rank.

Definition at line 516 of file PrecedenceRulesGraph.h.

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

526{ 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
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 }
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 details.h:86
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 524 of file PrecedenceRulesGraph.h.

524{ m_isAsynchronous = value; }

◆ setRank()

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

Set Algorithm rank.

Definition at line 514 of file PrecedenceRulesGraph.h.

514{ m_rank = rank; }

Member Data Documentation

◆ m_algoIndex

unsigned int concurrency::AlgorithmNode::m_algoIndex
private

The index of the algorithm.

Definition at line 539 of file PrecedenceRulesGraph.h.

◆ m_algoName

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

The name of the algorithm.

Definition at line 541 of file PrecedenceRulesGraph.h.

◆ m_algorithm

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

Algorithm representative behind the AlgorithmNode.

Definition at line 537 of file PrecedenceRulesGraph.h.

◆ m_inputs

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

Algorithm inputs (DataNodes)

Definition at line 550 of file PrecedenceRulesGraph.h.

◆ m_isAsynchronous

bool concurrency::AlgorithmNode::m_isAsynchronous
private

If an algorithm is asynchronous.

Definition at line 545 of file PrecedenceRulesGraph.h.

◆ m_outputs

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

Algorithm outputs (DataNodes)

Definition at line 548 of file PrecedenceRulesGraph.h.

◆ m_parents

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

Control flow parents of an AlgorithmNode (DecisionNodes)

Definition at line 533 of file PrecedenceRulesGraph.h.

◆ m_rank

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

Algorithm rank of any kind.

Definition at line 543 of file PrecedenceRulesGraph.h.


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