2 #include "GaudiKernel/SvcFactory.h"
3 #include "GaudiKernel/IAlgorithm.h"
4 #include "GaudiKernel/Algorithm.h"
5 #include "GaudiKernel/IProperty.h"
6 #include "GaudiKernel/AppReturnCode.h"
8 #include "GaudiKernel/ContextSpecificPtr.h"
28 declareProperty(
"UseTopAlgList", m_useTopAlgList=
true);
29 declareProperty(
"SimultaneousEvents", m_freeSlots=1);
41 warning () <<
"Base class could not be initialized" <<
endmsg;
46 error() <<
"Error retrieving AlgResourcePool" <<
endmsg;
59 const std::string&
name = algo->name();
81 warning () <<
"Base class could not be finalized" <<
endmsg;
129 std::vector<int> nodeDecisions(algPool->getExecutionFlowGraph()->getControlFlowNodeCounter(), -1);
140 while(algStates.algsPresent(AlgsExecutionStates::State::CONTROLREADY) ){
142 debug() <<
"algorithms left" <<
endmsg;
147 for(
auto it = algStates.begin(AlgsExecutionStates::State::CONTROLREADY); it != algStates.end(AlgsExecutionStates::State::CONTROLREADY); ++it){
153 debug() <<
"Running algorithm [" << algIndex <<
"] " << algName <<
endmsg;
155 std::vector<AlgsExecutionStates::State> algResults(
m_evtCtx_buffer.size());
170 bool eventfailed=
false;
181 warning() <<
"Execution of algorithm " << algName <<
" failed for event " <<
m_evtCtx_buffer[
i]->evt() <<
endmsg;
186 error() <<
".executeEvent(): Exception with tag=" << Exception.
tag()
187 <<
" thrown by " << algName <<
endmsg;
188 error() << Exception <<
endmsg;
189 }
catch (
const std::exception& Exception ) {
190 fatal() <<
".executeEvent(): Standard std::exception thrown by "
192 error() << Exception.what() <<
endmsg;
194 fatal() <<
".executeEvent(): UNKNOWN Exception thrown by "
201 algResults[
i] = AlgsExecutionStates::State::EVTACCEPTED;
203 algResults[
i] = AlgsExecutionStates::State::EVTREJECTED;
211 bool unanimous =
true;
212 for(uint
i = 1;
i < algResults.size(); ++
i)
213 if(result != algResults[
i])
217 algStates.updateState(algIndex,result);
219 fatal() <<
"divergent algorithm execution" <<
endmsg;
220 fatal() <<
"Algorithm results: ";
221 for(uint i =0; i < algResults.size(); ++
i){
222 fatal() << i <<
": " << (algResults[
i] == AlgsExecutionStates::State::EVTACCEPTED ?
"A" :
"R") <<
"\t";
223 if(algResults[i] == AlgsExecutionStates::State::EVTREJECTED){
244 m_evtCtx_buffer.clear();
258 debug() <<
"Popped slot " << eventContext->
slot() <<
"(event "
267 debug() <<
"Try Pop successful slot " << eventContext->
slot()
268 <<
"(event " << eventContext->
evt() <<
")" <<
endmsg;
void resetExecuted() override
Reset the executed state of the Algorithm for the duration of the current event.
StatusCode processEvents()
virtual StatusCode pushNewEvents(std::vector< EventContext * > &eventContexts)
StatusCode initialize() override
virtual StatusCode acquireAlgorithm(const std::string &name, IAlgorithm *&algo, bool blocking=false)=0
Acquire a certain algorithm using its name.
Define general base for Gaudi exception.
Helper class to set the application return code in case of early exit (e.g.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
void updateEventState(AlgsExecutionStates &algo_states, std::vector< int > &node_decisions) const
Update the state of algorithms to controlready, where possible.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
StatusCode finalize() override
virtual unsigned int freeSlots()
Get free slots number.
virtual StatusCode finalize()
Finalise.
std::list< IAlgorithm * > m_algList
Cache the list of algs to be executed.
bool isSuccess() const
Test for a status code of SUCCESS.
virtual StatusCode popFinishedEvent(EventContext *&eventContext)
Blocks until an event is availble.
bool m_useTopAlgList
Decide if the top alglist or its flat version has to be used.
virtual std::list< IAlgorithm * > getFlatAlgList()=0
Get the flat list of algorithms.
The AlgResourcePool is a concrete implementation of the IAlgResourcePool interface.
This class represents an entry point to all the event specific data.
bool isFailure() const
Test for a status code of FAILURE.
GAUDI_API void setCurrentContextId(ContextIdType newId)
Used by the framework to change the value of the current context id.
unsigned int m_freeSlots
The number of free slots (0 or 1)
void setContext(EventContext *context)
set the context
virtual StatusCode sysExecute()=0
System execution. This method invokes the execute() method of a concrete algorithm.
SmartIF< IAlgResourcePool > m_algResourcePool
constexpr int UnhandledException
TYPE * get() const
Get interface pointer.
virtual std::list< IAlgorithm * > getTopAlgList()=0
Get top list of algorithms.
The AlgsExecutionStates encodes the state machine for the execution of algorithms within a single eve...
std::unordered_map< std::string, unsigned int > m_algname_index_map
Map to bookkeep the information necessary to the name2index conversion.
virtual StatusCode tryPopFinishedEvent(EventContext *&eventContext)
Try to fetch an event from the scheduler.
void promoteToControlReadyState(AlgsExecutionStates &algo_states, std::vector< int > &node_decisions, const int &slotNum=-1) const
XXX: CF tests.
This class is used for returning status codes from appropriate routines.
void setFail(const bool &b=true)
std::vector< std::string > m_algname_vect
Vector to bookkeep the information necessary to the index2name conversion.
virtual StatusCode pushNewEvent(EventContext *eventContext)
Make an event available to the scheduler.
virtual const std::string & tag() const
name tag for the exception, or exception type
#define DECLARE_SERVICE_FACTORY(x)
virtual concurrency::ExecutionFlowGraph * getExecutionFlowGraph() const
concurrency::ExecutionFlowManager m_controlFlow
The IAlgorithm is the interface implemented by the Algorithm base class.
virtual bool filterPassed() const =0
Did this algorithm pass or fail its filter criterion for the last event?
Base class from which all concrete algorithm classes should be derived.
virtual StatusCode initialize()
Initialise.
bool isValid() const
Allow for check if smart pointer is valid.
Base class used to extend a class implementing other interfaces.
tbb::concurrent_bounded_queue< EventContext * > m_finishedEvents
Queue of finished events.
StatusCode initialize(ExecutionFlowGraph *CFGraph, const std::unordered_map< std::string, unsigned int > &algname_index_map)
Initialize the control flow manager It greps the topalg list and the index map for the algo names...
State
Execution states of the algorithms.
virtual StatusCode releaseAlgorithm(const std::string &name, IAlgorithm *&algo)=0
Release a certain algorithm.
~RoundRobinSchedulerSvc()
Destructor.
std::vector< EventContext * > m_evtCtx_buffer
The RoundRobinSchedulerSvc implements the IScheduler interface.