1 #ifndef GAUDIHIVE_AVALANCHESCHEDULERSVC_H 2 #define GAUDIHIVE_AVALANCHESCHEDULERSVC_H 23 #include <unordered_map> 27 #include "tbb/concurrent_queue.h" 104 using extends::extends;
134 "Maximum number of event processed simultaneously"};
136 "Size of the threadpool initialised by TBB; a value of -1 gives TBB the freedom to choose"};
138 "The whiteboard name"};
140 "IOBoundAlgSchedulerSvc"};
142 "[[deprecated]] Taken from the whiteboard"};
144 "Maximum number of simultaneous I/O-bound algorithms"};
146 "Flag to perform single-pass simulation of execution flow before the actual execution"};
148 "The following modes are currently available: PCE, COD, DRE, E"};
150 "Dump intra-event concurrency dynamics to csv file"};
152 "Turn on preemptive way of scheduling of I/O-bound algorithms"};
252 m_closure(_closure), m_scheduler(scheduler) {}
311 #endif // GAUDIHIVE_AVALANCHESCHEDULERSVC_H
StatusCode tryPopFinishedEvent(EventContext *&eventContext) override
Try to fetch an event from the scheduler.
Gaudi::Property< std::string > m_whiteboardSvcName
unsigned int m_IOBoundAlgosInFlight
Number of algoritms presently in flight.
const std::string & name() const override
The identifying name of the algorithm object.
SmartIF< AvalancheSchedulerSvc > m_scheduler
Implementation of property with value of concrete type.
Gaudi::Property< bool > m_dumpIntraEventDynamics
bool operator==(const SchedulerState &ss) const
StatusCode initialize() override
Initialise.
void dumpSchedulerState(int iSlot)
Dump the state of the scheduler.
StatusCode promoteToScheduled(unsigned int iAlgo, int si)
Algorithm promotion.
enqueueSchedulerActionTask(AvalancheSchedulerSvc *scheduler, std::function< StatusCode()> _closure)
StatusCode isStalled(int si)
Check if the scheduling is in a stall.
void activate()
Activate scheduler.
Gaudi::Property< std::vector< std::vector< std::string > > > m_algosDependencies
Gaudi::Property< std::string > m_optimizationMode
friend std::ostream & operator<<(std::ostream &os, const SchedulerState &ss)
StatusCode promoteToAsyncScheduled(unsigned int iAlgo, int si)
This class represents an entry point to all the event specific data.
unsigned int algname2index(const std::string &algoname)
Convert a name to an integer.
AlgsExecutionStates::State State
void addAlg(Algorithm *, EventContext *, pthread_t)
std::atomic< ActivationState > m_isActive
Flag to track if the scheduler is active or not.
std::unordered_map< std::string, unsigned int > m_algname_index_map
Map to bookkeep the information necessary to the name2index conversion.
Gaudi::Property< bool > m_checkDeps
Gaudi::Property< bool > m_useIOBoundAlgScheduler
bool operator<(const SchedulerState &rhs) const
std::atomic_int m_freeSlots
Atomic to account for asyncronous updates by the scheduler wrt the rest.
StatusCode pushNewEvents(std::vector< EventContext * > &eventContexts) override
unsigned int m_algosInFlight
Number of algoritms presently in flight.
static std::list< SchedulerState > m_sState
SmartIF< IAlgResourcePool > m_algResourcePool
Cache for the algorithm resource pool.
Manage the execution flow using a graph of task precedence rules Once initialized, the graph is const and can be shared across events.
tbb::task * execute() override
StatusCode popFinishedEvent(EventContext *&eventContext) override
Blocks until an event is availble.
This class is used for returning status codes from appropriate routines.
SmartIF< IHiveWhiteBoard > m_whiteboard
A shortcut to the whiteboard.
tbb::concurrent_bounded_queue< EventContext * > m_finishedEvents
Queue of finished events.
std::vector< std::string > m_algname_vect
Vector to bookkeep the information necessary to the index2name conversion.
SchedulerState(Algorithm *a, EventContext *e, pthread_t t)
Gaudi::Property< std::string > m_IOBoundAlgSchedulerSvcName
std::function< StatusCode()> action
StatusCode finalize() override
Finalise.
static std::mutex m_ssMut
~AvalancheSchedulerSvc() override=default
Destructor.
concurrency::ExecutionFlowManager m_efManager
Member to take care of the control flow.
Gaudi::Property< int > m_threadPoolSize
SmartIF< IThreadPoolSvc > m_threadPoolSvc
SmartIF< IAccelerator > m_IOBoundAlgScheduler
A shortcut to IO-bound algorithm scheduler.
The IAlgorithm is the interface implemented by the Algorithm base class.
bool m_updateNeeded
Keep track of update actions scheduled.
Gaudi::Property< int > m_maxEventsInFlight
Base class from which all concrete algorithm classes should be derived.
StatusCode promoteToFinished(unsigned int iAlgo, int si)
StatusCode pushNewEvent(EventContext *eventContext) override
Make an event available to the scheduler.
Gaudi::Property< unsigned int > m_maxAlgosInFlight
Gaudi::Property< bool > m_simulateExecution
Base class used to extend a class implementing other interfaces.
StatusCode eventFailed(EventContext *eventContext)
Method to check if an event failed and take appropriate actions.
const std::string & index2algname(unsigned int index)
Convert an integer to a name.
StatusCode promoteToExecuted(unsigned int iAlgo, int si, IAlgorithm *algo, EventContext *)
The call to this method is triggered only from within the AlgoExecutionTask.
std::function< StatusCode()> m_closure
unsigned int freeSlots() override
Get free slots number.
std::vector< EventSlot > m_eventSlots
Vector of events slots.
StatusCode promoteToAsyncExecuted(unsigned int iAlgo, int si, IAlgorithm *algo, EventContext *)
The call to this method is triggered only from within the IOBoundAlgTask.
bool operator==(Algorithm *a) const
StatusCode deactivate()
Deactivate scheduler.
void dumpState() override
StatusCode updateStates(int si=-1, const std::string &algo_name=std::string())
Loop on algorithm in the slots and promote them to successive states (-1 means all slots...
State
Execution states of the algorithms.
SmartIF< IAlgExecStateSvc > m_algExecStateSvc
Algorithm execution state manager.
Gaudi::Property< unsigned int > m_maxIOBoundAlgosInFlight
tbb::concurrent_bounded_queue< action > m_actionsQueue
Queue where closures are stored and picked for execution.
std::thread m_thread
The thread in which the activate function runs.
StatusCode m_drain()
Drain the actions present in the queue.