The Gaudi Framework  master (37c0b60a)
AlgsExecutionStates Class Referencefinal

#include <GaudiKernel/AlgsExecutionStates.h>

Collaboration diagram for AlgsExecutionStates:

Public Types

enum  State : uint8_t {
  INITIAL = 0, CONTROLREADY = 1, DATAREADY = 2, RESOURCELESS = 3,
  SCHEDULED = 4, EVTACCEPTED = 5, EVTREJECTED = 6, ERROR = 7,
  MAXVALUE = 8
}
 Execution states of the algorithms Must have contiguous integer values 0, 1... More...
 

Public Member Functions

 AlgsExecutionStates (unsigned int algsNumber, SmartIF< IMessageSvc > MS)
 
StatusCode set (unsigned int iAlgo, State newState)
 
void reset ()
 
bool contains (State state) const
 check if the collection contains at least one state of requested type More...
 
bool containsAny (std::initializer_list< State > l) const
 check if the collection contains at least one state of any listed types More...
 
const boost::container::flat_set< int > algsInState (State state) const
 
const Stateoperator[] (unsigned int i) const
 
size_t size () const
 
size_t sizeOfSubset (State state) const
 

Private Member Functions

MsgStream log ()
 

Private Attributes

std::vector< Statem_states
 
std::vector< boost::container::flat_set< int > > m_algsInState
 
SmartIF< IMessageSvcm_MS
 

Detailed Description

The AlgsExecutionStates encodes the state machine for the execution of algorithms within a single event. It is used by the concurrent schedulers

Author
Benedikt Hegner
Danilo Piparo
Version
1.0

Definition at line 38 of file AlgsExecutionStates.h.

Member Enumeration Documentation

◆ State

Execution states of the algorithms Must have contiguous integer values 0, 1...

N

Enumerator
INITIAL 
CONTROLREADY 
DATAREADY 
RESOURCELESS 
SCHEDULED 
EVTACCEPTED 
EVTREJECTED 
ERROR 
MAXVALUE 

Definition at line 42 of file AlgsExecutionStates.h.

42  : uint8_t {
43  INITIAL = 0,
44  CONTROLREADY = 1,
45  DATAREADY = 2,
46  RESOURCELESS = 3,
47  SCHEDULED = 4,
48  EVTACCEPTED = 5,
49  EVTREJECTED = 6,
50  ERROR = 7,
51  MAXVALUE = 8 // Allows loop over all states
52  };

Constructor & Destructor Documentation

◆ AlgsExecutionStates()

AlgsExecutionStates::AlgsExecutionStates ( unsigned int  algsNumber,
SmartIF< IMessageSvc MS 
)
inline

Definition at line 54 of file AlgsExecutionStates.h.

55  : m_states( algsNumber, INITIAL ), m_algsInState( MAXVALUE ), m_MS( std::move( MS ) ) {
56 
57  m_algsInState[INITIAL].reserve( algsNumber );
58  for ( unsigned int i = 0; i < algsNumber; ++i ) m_algsInState[INITIAL].insert( i );
59  }

Member Function Documentation

◆ algsInState()

const boost::container::flat_set<int> AlgsExecutionStates::algsInState ( State  state) const
inline

Definition at line 83 of file AlgsExecutionStates.h.

83 { return m_algsInState[state]; }

◆ contains()

bool AlgsExecutionStates::contains ( State  state) const
inline

check if the collection contains at least one state of requested type

Definition at line 72 of file AlgsExecutionStates.h.

72 { return m_algsInState[state].size() > 0; }

◆ containsAny()

bool AlgsExecutionStates::containsAny ( std::initializer_list< State l) const
inline

check if the collection contains at least one state of any listed types

Definition at line 75 of file AlgsExecutionStates.h.

75  {
76  for ( auto state : l )
77  if ( m_algsInState[state].size() > 0 ) return true;
78  return false;
79  }

◆ log()

MsgStream AlgsExecutionStates::log ( )
inlineprivate

Definition at line 96 of file AlgsExecutionStates.h.

96 { return { m_MS, "AlgsExecutionStates" }; }

◆ operator[]()

const State& AlgsExecutionStates::operator[] ( unsigned int  i) const
inline

Definition at line 85 of file AlgsExecutionStates.h.

85 { return m_states.at( i ); }

◆ reset()

void AlgsExecutionStates::reset ( )
inline

Definition at line 63 of file AlgsExecutionStates.h.

63  {
65 
66  for ( auto& algs : m_algsInState ) algs.clear();
68  for ( unsigned int i = 0; i < m_states.size(); ++i ) m_algsInState[INITIAL].insert( i );
69  }

◆ set()

StatusCode AlgsExecutionStates::set ( unsigned int  iAlgo,
State  newState 
)

Definition at line 23 of file AlgsExecutionStates.cpp.

23  {
24  if ( iAlgo >= m_states.size() ) {
25  log() << MSG::ERROR << "Index out of bound (" << iAlgo << " / " << m_states.size() << ")" << endmsg;
26  return StatusCode::FAILURE;
27  }
28 
29  State oldState = m_states[iAlgo];
30 
31  // Allow cycling of a single state
32  if ( oldState == newState ) return StatusCode::SUCCESS;
33 
34  switch ( transition( oldState, newState ) ) {
35  case transition( INITIAL, CONTROLREADY ):
36  [[fallthrough]];
37  case transition( CONTROLREADY, DATAREADY ):
38  [[fallthrough]];
39  case transition( DATAREADY, SCHEDULED ):
40  [[fallthrough]];
41  case transition( DATAREADY, RESOURCELESS ):
42  [[fallthrough]];
43  case transition( RESOURCELESS, SCHEDULED ):
44  [[fallthrough]];
45  case transition( SCHEDULED, ERROR ):
46  [[fallthrough]];
47  case transition( SCHEDULED, EVTACCEPTED ):
48  [[fallthrough]];
49  case transition( SCHEDULED, EVTREJECTED ):
50  m_states[iAlgo] = newState;
51  m_algsInState[oldState].erase( iAlgo );
52  m_algsInState[newState].insert( iAlgo );
53  return StatusCode::SUCCESS;
54  default:
55  log() << MSG::ERROR << "[AlgIndex " << iAlgo << "] Transition from " << m_states[iAlgo] << " to " << newState
56  << " is not allowed" << endmsg;
57  m_states[iAlgo] = ERROR;
58  m_algsInState[oldState].erase( iAlgo );
59  m_algsInState[ERROR].insert( iAlgo );
60  return StatusCode::FAILURE;
61  }
62 }

◆ size()

size_t AlgsExecutionStates::size ( ) const
inline

Definition at line 87 of file AlgsExecutionStates.h.

87 { return m_states.size(); }

◆ sizeOfSubset()

size_t AlgsExecutionStates::sizeOfSubset ( State  state) const
inline

Definition at line 89 of file AlgsExecutionStates.h.

89 { return m_algsInState[state].size(); }

Member Data Documentation

◆ m_algsInState

std::vector<boost::container::flat_set<int> > AlgsExecutionStates::m_algsInState
private

Definition at line 93 of file AlgsExecutionStates.h.

◆ m_MS

SmartIF<IMessageSvc> AlgsExecutionStates::m_MS
private

Definition at line 94 of file AlgsExecutionStates.h.

◆ m_states

std::vector<State> AlgsExecutionStates::m_states
private

Definition at line 92 of file AlgsExecutionStates.h.


The documentation for this class was generated from the following files:
AlgsExecutionStates::m_algsInState
std::vector< boost::container::flat_set< int > > m_algsInState
Definition: AlgsExecutionStates.h:93
std::move
T move(T... args)
std::vector::reserve
T reserve(T... args)
AlgsExecutionStates::MAXVALUE
@ MAXVALUE
Definition: AlgsExecutionStates.h:51
std::vector::size
T size(T... args)
AlgsExecutionStates::CONTROLREADY
@ CONTROLREADY
Definition: AlgsExecutionStates.h:44
std::fill
T fill(T... args)
AlgsExecutionStates::RESOURCELESS
@ RESOURCELESS
Definition: AlgsExecutionStates.h:46
AlgsExecutionStates::m_MS
SmartIF< IMessageSvc > m_MS
Definition: AlgsExecutionStates.h:94
AlgsExecutionStates::log
MsgStream log()
Definition: AlgsExecutionStates.h:96
AlgsExecutionStates::ERROR
@ ERROR
Definition: AlgsExecutionStates.h:50
std::vector::at
T at(T... args)
AlgsExecutionStates::m_states
std::vector< State > m_states
Definition: AlgsExecutionStates.h:92
AlgsExecutionStates::SCHEDULED
@ SCHEDULED
Definition: AlgsExecutionStates.h:47
std::vector::erase
T erase(T... args)
AlgsExecutionStates::EVTREJECTED
@ EVTREJECTED
Definition: AlgsExecutionStates.h:49
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
gaudirun.l
dictionary l
Definition: gaudirun.py:583
std::vector::begin
T begin(T... args)
std::vector::insert
T insert(T... args)
MSG::ERROR
@ ERROR
Definition: IMessageSvc.h:25
AlgsExecutionStates::DATAREADY
@ DATAREADY
Definition: AlgsExecutionStates.h:45
AlgsExecutionStates::State
State
Execution states of the algorithms Must have contiguous integer values 0, 1...
Definition: AlgsExecutionStates.h:42
AlgsExecutionStates::EVTACCEPTED
@ EVTACCEPTED
Definition: AlgsExecutionStates.h:48
std::vector::end
T end(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
compareRootHistos.state
state
Definition: compareRootHistos.py:496
AlgsExecutionStates::INITIAL
@ INITIAL
Definition: AlgsExecutionStates.h:43
Gaudi::Functional::details::insert
constexpr struct Gaudi::Functional::details::insert_t insert
CollWrite.algs
algs
Definition: CollWrite.py:33
AlgsExecutionStates::size
size_t size() const
Definition: AlgsExecutionStates.h:87