The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
concurrency::RunSimulator Class Reference

#include </builds/gaudi/Gaudi/GaudiHive/src/PRGraph/Visitors/Promoters.h>

Inheritance diagram for concurrency::RunSimulator:
Collaboration diagram for concurrency::RunSimulator:

Public Member Functions

 RunSimulator (EventSlot &slot, const Cause &cause)
 Constructor.
 
bool visitEnter (DecisionNode &) const override
 
bool visit (DecisionNode &) override
 
bool visitEnter (AlgorithmNode &) const override
 
bool visit (AlgorithmNode &) override
 
void reset () override
 
virtual bool visit (DataNode &)
 
virtual bool visit (ConditionNode &)
 
virtual bool visitEnter (DataNode &) const
 
virtual bool visitEnter (ConditionNode &) const
 
- Public Member Functions inherited from concurrency::IGraphVisitor
virtual ~IGraphVisitor ()=default
 

Public Attributes

EventSlotm_slot
 
Cause m_cause
 
int m_nodesSucceeded { 0 }
 

Detailed Description

Definition at line 86 of file Promoters.h.

Constructor & Destructor Documentation

◆ RunSimulator()

concurrency::RunSimulator::RunSimulator ( EventSlot & slot,
const Cause & cause )
inline

Constructor.

Definition at line 89 of file Promoters.h.

89: m_slot( &slot ), m_cause( cause ) {}

Member Function Documentation

◆ reset()

void concurrency::RunSimulator::reset ( )
inlineoverridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 102 of file Promoters.h.

◆ visit() [1/4]

bool concurrency::RunSimulator::visit ( AlgorithmNode & node)
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 402 of file Promoters.cpp.

402 {
403
404 auto& states = m_slot->algsStates;
405 int& decision = m_slot->controlFlowState[node.getNodeIndex()];
406
407 auto dataPromoter = DataReadyPromoter( *m_slot, m_cause );
408
409 if ( AState::INITIAL == states[node.getAlgoIndex()] ) {
410 states.set( node.getAlgoIndex(), AState::CONTROLREADY ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
411 if ( dataPromoter.visit( node ) ) {
412 states.set( node.getAlgoIndex(), AState::SCHEDULED ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
413 states.set( node.getAlgoIndex(), AState::EVTACCEPTED ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
414 decision = 1;
416 // std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
417 return true;
418 }
419 } else if ( AState::CONTROLREADY == states[node.getAlgoIndex()] && dataPromoter.visit( node ) ) {
420 states.set( node.getAlgoIndex(), AState::SCHEDULED ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
421 states.set( node.getAlgoIndex(), AState::EVTACCEPTED ).ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
422 decision = 1;
424 // std::cout << "Algorithm decided: " << node.getNodeName() << std::endl;
425 return true;
426 }
427
428 return false;
429 }

◆ visit() [2/4]

virtual bool concurrency::IGraphVisitor::visit ( ConditionNode & )
inlinevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 34 of file IGraphVisitor.h.

34{ return true; }

◆ visit() [3/4]

virtual bool concurrency::IGraphVisitor::visit ( DataNode & )
inlinevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 31 of file IGraphVisitor.h.

31{ return true; }

◆ visit() [4/4]

bool concurrency::RunSimulator::visit ( DecisionNode & node)
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 361 of file Promoters.cpp.

361 {
362
363 bool allChildDecisionsResolved = true;
364
365 for ( const auto& child : node.getDaughters() ) {
366
367 child->accept( *this );
368
369 int childDecision = m_slot->controlFlowState[child->getNodeIndex()];
370 if ( childDecision == -1 ) allChildDecisionsResolved = false;
371
372 // process children sequentially if their decision hub is sequential
373 if ( !node.m_modeConcurrent && childDecision == -1 ) return false;
374
375 if ( childDecision == 1 && node.m_modeOR && node.m_modePromptDecision ) {
376 m_slot->controlFlowState[node.getNodeIndex()] = 1;
377
378 // if a decision was made for this node, propagate the result upwards
379 for ( auto parent : node.m_parents ) { parent->accept( *this ); }
380 return true;
381 }
382 }
383
384 if ( allChildDecisionsResolved ) {
385 m_slot->controlFlowState[node.getNodeIndex()] = 1;
386
387 // if a decision was made for this node, propagate the result upwards
388 for ( auto parent : node.m_parents ) { parent->accept( *this ); }
389 }
390
391 return allChildDecisionsResolved;
392 }

◆ visitEnter() [1/4]

bool concurrency::RunSimulator::visitEnter ( AlgorithmNode & node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 395 of file Promoters.cpp.

395 {
396
397 if ( m_slot->controlFlowState[node.getNodeIndex()] != 1 ) return true;
398 return false;
399 }

◆ visitEnter() [2/4]

virtual bool concurrency::IGraphVisitor::visitEnter ( ConditionNode & ) const
inlinevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 33 of file IGraphVisitor.h.

33{ return true; }

◆ visitEnter() [3/4]

virtual bool concurrency::IGraphVisitor::visitEnter ( DataNode & ) const
inlinevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 30 of file IGraphVisitor.h.

30{ return true; }

◆ visitEnter() [4/4]

bool concurrency::RunSimulator::visitEnter ( DecisionNode & node) const
overridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 354 of file Promoters.cpp.

354 {
355
356 if ( m_slot->controlFlowState[node.getNodeIndex()] != 1 ) return true;
357 return false;
358 }

Member Data Documentation

◆ m_cause

Cause concurrency::RunSimulator::m_cause

Definition at line 105 of file Promoters.h.

◆ m_nodesSucceeded

int concurrency::RunSimulator::m_nodesSucceeded { 0 }

Definition at line 106 of file Promoters.h.

106{ 0 };

◆ m_slot

EventSlot* concurrency::RunSimulator::m_slot

Definition at line 104 of file Promoters.h.


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