The Gaudi Framework  master (37c0b60a)
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. More...
 
bool visitEnter (DecisionNode &) const override
 
bool visit (DecisionNode &) override
 
bool visitEnter (AlgorithmNode &) const override
 
bool visit (AlgorithmNode &) override
 
void reset () override
 
virtual bool visit (DecisionNode &)
 
virtual bool visit (AlgorithmNode &)
 
virtual bool visit (DataNode &)
 
virtual bool visit (ConditionNode &)
 
virtual bool visitEnter (DecisionNode &) const
 
virtual bool visitEnter (AlgorithmNode &) const
 
virtual bool visitEnter (DataNode &) const
 
virtual bool visitEnter (ConditionNode &) const
 
- Public Member Functions inherited from concurrency::IGraphVisitor
virtual ~IGraphVisitor ()=default
 
virtual bool visitEnter (DataNode &) const
 
virtual bool visit (DataNode &)
 
virtual bool visitEnter (ConditionNode &) const
 
virtual bool visit (ConditionNode &)
 

Public Attributes

EventSlotm_slot
 
Cause m_cause
 
int m_nodesSucceeded { 0 }
 

Detailed Description

Definition at line 87 of file Promoters.h.

Constructor & Destructor Documentation

◆ RunSimulator()

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

Constructor.

Definition at line 90 of file Promoters.h.

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

Member Function Documentation

◆ reset()

void concurrency::RunSimulator::reset ( )
inlineoverridevirtual

Reimplemented from concurrency::IGraphVisitor.

Definition at line 103 of file Promoters.h.

103 { m_nodesSucceeded = 0; }

◆ visit() [1/6]

virtual bool concurrency::IGraphVisitor::visit
inline

Definition at line 29 of file IGraphVisitor.h.

29 { return true; }

◆ visit() [2/6]

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() [3/6]

virtual bool concurrency::IGraphVisitor::visit
inline

Definition at line 35 of file IGraphVisitor.h.

35 { return true; }

◆ visit() [4/6]

virtual bool concurrency::IGraphVisitor::visit
inline

Definition at line 32 of file IGraphVisitor.h.

32 { return true; }

◆ visit() [5/6]

virtual bool concurrency::IGraphVisitor::visit
inline

Definition at line 26 of file IGraphVisitor.h.

26 { return true; }

◆ visit() [6/6]

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/6]

virtual bool concurrency::IGraphVisitor::visitEnter
inline

Definition at line 28 of file IGraphVisitor.h.

28 { return true; }

◆ visitEnter() [2/6]

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() [3/6]

virtual bool concurrency::IGraphVisitor::visitEnter
inline

Definition at line 34 of file IGraphVisitor.h.

34 { return true; }

◆ visitEnter() [4/6]

virtual bool concurrency::IGraphVisitor::visitEnter
inline

Definition at line 31 of file IGraphVisitor.h.

31 { return true; }

◆ visitEnter() [5/6]

virtual bool concurrency::IGraphVisitor::visitEnter
inline

Definition at line 25 of file IGraphVisitor.h.

25 { return true; }

◆ visitEnter() [6/6]

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 106 of file Promoters.h.

◆ m_nodesSucceeded

int concurrency::RunSimulator::m_nodesSucceeded { 0 }

Definition at line 107 of file Promoters.h.

◆ m_slot

EventSlot* concurrency::RunSimulator::m_slot

Definition at line 105 of file Promoters.h.


The documentation for this class was generated from the following files:
concurrency::RunSimulator::m_nodesSucceeded
int m_nodesSucceeded
Definition: Promoters.h:107
concurrency::RunSimulator::m_slot
EventSlot * m_slot
Definition: Promoters.h:105
EventSlot::controlFlowState
std::vector< int > controlFlowState
State of the control flow.
Definition: EventSlot.h:87
concurrency::RunSimulator::m_cause
Cause m_cause
Definition: Promoters.h:106
EventSlot::algsStates
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:85