31 declareProperty(
"UseTopAlgList", m_useTopAlgList =
false);
32 declareProperty(
"ThreadPoolSize", m_threadPoolSize = -1);
33 declareProperty(
"WhiteboardSvc", m_whiteboardSvcName =
"EventDataSvc");
46 warning () <<
"Base class could not be initialized" <<
endmsg;
51 error() <<
"Error retrieving AlgResourcePool" <<
endmsg;
62 fatal() <<
"Error retrieving EventDataSvc interface IHiveWhiteBoard." <<
endmsg;
95 const unsigned int algosDependenciesSize=0;
96 info() <<
"Algodependecies size is " << algosDependenciesSize <<
endmsg;
104 if (algosDependenciesSize == 0){
108 if (
"" != rootInTESName &&
'/'!=rootInTESName[rootInTESName.size()-1]){
109 rootInTESName = rootInTESName+
"/";
114 if (
nullptr == algoPtr){
115 fatal() <<
"Could not convert IAlgorithm into Algorithm: this will result in a crash." <<
endmsg;
120 if (!algoHandles.empty()){
121 info() <<
"Algorithm " << algoPtr->
name() <<
" data dependencies:" <<
endmsg;
128 for (
auto id : inputObjs) {
129 const std::string& productName = rootInTESName +
id.key();
130 info() <<
" o Input dep for " << productName <<
endmsg;
131 algoDependencies.
insert(
id);
136 info() <<
"Algorithm " << algoPtr->
name() <<
" has no data dependencies."
169 for(
auto evt : eventContexts){
176 tbb::task* t =
new( tbb::task::allocate_root() )
178 tbb::task::enqueue( *t);
195 debug() <<
"Popped slot " << eventContext->
slot() <<
"(event "
207 debug() <<
"Try Pop successful slot " << eventContext->
slot()
208 <<
"(event " << eventContext->
evt() <<
")" <<
endmsg;
229 MsgStream log(messageSvc,
"SequentialAlgoExecutionTask");
237 std::vector<int> nodeDecisions(algPool->getExecutionFlowGraph()->getControlFlowNodeCounter(), -1);
247 bool eventFailed =
false;
251 while(!eventFailed && algStates.algsPresent(AlgsExecutionStates::State::CONTROLREADY) ){
258 for(
auto it = algStates.begin(AlgsExecutionStates::State::CONTROLREADY); it != algStates.end(AlgsExecutionStates::State::CONTROLREADY); ++it){
273 if(sc.
isFailure() || ialgoPtr ==
nullptr){
294 log <<
MSG::ERROR <<
".executeEvent(): Exception with tag=" << Exception.
tag()
295 <<
" thrown by " << algName <<
endmsg;
298 log <<
MSG::FATAL <<
".executeEvent(): Standard std::exception thrown by "
302 log <<
MSG::FATAL <<
".executeEvent(): UNKNOWN Exception thrown by "
313 << (eventFailed ?
" failed" :
" succeded") <<
endmsg;
317 state = AlgsExecutionStates::State::EVTACCEPTED;
319 state = AlgsExecutionStates::State::EVTREJECTED;
329 algStates.updateState(algIndex,state);
356 if(!algStates.algsPresent(AlgsExecutionStates::State::CONTROLREADY) && !algStates.allAlgsExecuted()){
std::list< IAlgorithm * > m_algList
Cache the list of algs to be executed.
Definition of the MsgStream class used to transmit messages.
StatusCode initialize() override
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
virtual StatusCode acquireAlgorithm(const std::string &name, IAlgorithm *&algo, bool blocking=false)=0
Acquire a certain algorithm using its name.
virtual tbb::task * execute()
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.
StatusCode finalize() override
GAUDI_API void setCurrentContextId(ContextIdType newId)
Used by the framework to change the value of the current context id.
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
bool isSuccess() const
Test for a status code of SUCCESS.
std::unique_ptr< tbb::task_scheduler_init > m_tbb_sched
SmartIF< ParallelSequentialSchedulerSvc > m_scheduler
EventContext * m_eventContext
tbb::concurrent_bounded_queue< EventContext * > m_finishedEvents
Queue of finished events.
virtual size_t getNumberOfStores()=0
Get the number of 'slots'.
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.
virtual StatusCode pushNewEvent(EventContext *eventContext)
Make an event available to the scheduler.
void setContext(EventContext *context)
set the context
const std::string & name() const override
The identifying name of the algorithm object.
constexpr int UnhandledException
TYPE * get() const
Get interface pointer.
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
const std::string & name() const override
Retrieve name of the service.
bool m_useTopAlgList
Decide if the top alglist or its flat version has to be used.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
SmartIF< IHiveWhiteBoard > m_whiteboard
A shortcut to the whiteboard.
int m_threadPoolSize
Size of the threadpool initialised by TBB; a value of -1 gives TBB the freedom to choose...
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...
SmartIF< IAlgResourcePool > m_algPool
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
void promoteToControlReadyState(AlgsExecutionStates &algo_states, std::vector< int > &node_decisions, const int &slotNum=-1) const
XXX: CF tests.
virtual StatusCode pushNewEvents(std::vector< EventContext * > &eventContexts)
This class is used for returning status codes from appropriate routines.
StatusCode sysExecute() override
The actions to be performed by the algorithm on an event.
void setFail(const bool &b=true)
std::string m_whiteboardSvcName
The whiteboard name.
std::atomic_int m_freeSlots
Atomic to account for asyncronous updates by the scheduler wrt the rest.
virtual const std::string & tag() const
name tag for the exception, or exception type
virtual unsigned int freeSlots()
Get free slots number.
virtual concurrency::ExecutionFlowGraph * getExecutionFlowGraph() const
#define DECLARE_SERVICE_FACTORY(x)
~ParallelSequentialSchedulerSvc()
Destructor.
The IAlgorithm is the interface implemented by the Algorithm base class.
virtual const std::string & rootName() const =0
Get Name of root Event.
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.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
bool isValid() const
Allow for check if smart pointer is valid.
virtual void acceptDHVisitor(IDataHandleVisitor *) const override
SmartIF< ISvcLocator > m_serviceLocator
virtual StatusCode finalize()
Finalise.
void activate()
Activate MsgStream.
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
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.
std::vector< std::string > m_algname_vect
Vector to bookkeep the information necessary to the index2name conversion.
concurrency::ExecutionFlowManager m_controlFlow
This SchedulerSvc implements the IScheduler interface.
friend class SequentialTask
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual StatusCode initialize()
Initialise.
SmartIF< IAlgResourcePool > m_algResourcePool
Cache for the algorithm resource pool.
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.
virtual std::vector< Gaudi::DataHandle * > inputHandles() const override
virtual StatusCode popFinishedEvent(EventContext *&eventContext)
Blocks until an event is availble.