36#include <unordered_set>
39#include <boost/algorithm/string.hpp>
40#include <boost/thread.hpp>
41#include <boost/tokenizer.hpp>
46#define ON_DEBUG if ( msgLevel( MSG::DEBUG ) )
47#define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) )
50 struct DataObjIDSorter {
56 std::vector<const DataObjID*> sortedDataObjIDColl(
const DataObjIDColl& coll ) {
57 std::vector<const DataObjID*> v;
58 v.reserve( coll.size() );
59 for (
const DataObjID&
id : coll ) v.push_back( &
id );
60 std::sort( v.begin(), v.end(), DataObjIDSorter() );
64 bool subSlotAlgsInStates(
const EventSlot& slot, std::initializer_list<AlgsExecutionStates::State> testStates ) {
66 [testStates](
const EventSlot& ss ) { return ss.algsStates.containsAny( testStates ); } );
87 fatal() <<
"Error retrieving ThreadPoolSvc" <<
endmsg;
97 fatal() <<
"Cannot find valid TBB task_arena" <<
endmsg;
102 info() <<
"Activating scheduler in a separate thread" <<
endmsg;
103 std::binary_semaphore fiber_manager_initalized{ 0 };
104 m_thread = std::thread( [
this, &fiber_manager_initalized]() {
107 fiber_manager_initalized.release();
111 fiber_manager_initalized.acquire();
127 warning() <<
"No CondSvc found, or not enabled. "
128 <<
"Will not manage CondAlgorithms" <<
endmsg;
136 fatal() <<
"Error retrieving AlgoResourcePool" <<
endmsg;
142 fatal() <<
"Error retrieving AlgExecStateSvc" <<
endmsg;
149 fatal() <<
"Error retrieving EventDataSvc interface IHiveWhiteBoard." <<
endmsg;
161 const unsigned int algsNumber = algos.size();
162 if ( algsNumber != 0 ) {
163 info() <<
"Found " << algsNumber <<
" algorithms" <<
endmsg;
176 auto hasAsynchronousAlgorithms =
false;
179 std::map<std::string, DataObjIDColl> algosOutputDependenciesMap;
183 fatal() <<
"Could not convert IAlgorithm into Gaudi::Algorithm: this will result in a crash." <<
endmsg;
189 globalOutp.insert(
id );
190 algoOutputs.insert(
id );
192 algosOutputDependenciesMap[algoPtr->
name()] = algoOutputs;
194 hasAsynchronousAlgorithms = hasAsynchronousAlgorithms || algoPtr->
isAsynchronous();
199 <<
"; no fiber pool threads will be available to execute them." <<
endmsg;
203 std::ostringstream ostdd;
204 ostdd <<
"Data Dependencies for Algorithms:";
206 std::map<std::string, DataObjIDColl> algosInputDependenciesMap;
209 if (
nullptr == algoPtr ) {
210 fatal() <<
"Could not convert IAlgorithm into Gaudi::Algorithm for " << ialgoPtr->name()
211 <<
": this will result in a crash." <<
endmsg;
219 ostdd <<
"\n " << algoPtr->
name();
221 auto write_owners = [&avis, &ostdd](
const DataObjID& id ) {
230 ostdd <<
"\n o INPUT " << id;
232 algoDependencies.insert(
id );
233 globalInp.insert(
id );
236 ostdd <<
"\n o OUTPUT " << *id;
238 if ( id->key().find(
":" ) != std::string::npos ) {
239 error() <<
" in Alg " << algoPtr->
name() <<
" alternatives are NOT allowed for outputs! id: " << *
id
247 algosInputDependenciesMap[algoPtr->
name()] = algoDependencies;
263 std::set<std::string> requiredInputKeys;
264 for (
auto o : globalInp ) {
267 requiredInputKeys.insert( o.key() );
268 if ( globalOutp.find( o ) == globalOutp.end() ) unmetDepInp.insert( o );
271 for (
auto o : globalOutp ) {
272 if ( globalInp.find( o ) == globalInp.end() && requiredInputKeys.find( o.key() ) == requiredInputKeys.end() ) {
276 auto it = algosOutputDependenciesMap.find( algoName );
277 if ( it != algosOutputDependenciesMap.end() ) {
278 if ( it->second.find( o ) != it->second.end() ) {
284 if ( !ignored ) { unusedOutp.insert( o ); }
291 if ( unmetDepInp.size() > 0 ) {
293 auto printUnmet = [&](
auto msg ) {
294 for (
const DataObjID* o : sortedDataObjIDColl( unmetDepInp ) ) {
295 msg <<
" o " << *o <<
" required by Algorithm: " <<
endmsg;
297 for (
const auto& p : algosInputDependenciesMap )
298 if ( p.second.find( *o ) != p.second.end() )
msg <<
" * " << p.first <<
endmsg;
308 dataLoaderAlg = algo;
312 if ( dataLoaderAlg ==
nullptr ) {
314 <<
"\" found, and unmet INPUT dependencies "
316 printUnmet(
fatal() );
320 info() <<
"Will attribute the following unmet INPUT dependencies to \"" << dataLoaderAlg->
type() <<
"/"
321 << dataLoaderAlg->name() <<
"\" Algorithm" <<
endmsg;
322 printUnmet(
info() );
327 fatal() <<
"Unable to dcast DataLoader \"" <<
m_useDataLoader.value() <<
"\" IAlg to Gaudi::Algorithm"
332 for (
auto&
id : unmetDepInp ) {
333 ON_DEBUG debug() <<
"adding OUTPUT dep \"" <<
id <<
"\" to " << dataLoaderAlg->
type() <<
"/"
334 << dataLoaderAlg->name() <<
endmsg;
339 fatal() <<
"Auto DataLoading not requested, "
340 <<
"and the following unmet INPUT dependencies were found:" <<
endmsg;
341 printUnmet(
fatal() );
346 info() <<
"No unmet INPUT data dependencies were found" <<
endmsg;
351 if ( unusedOutp.size() > 0 ) {
353 auto printUnusedOutp = [&](
auto msg ) {
354 for (
const DataObjID* o : sortedDataObjIDColl( unusedOutp ) ) {
355 msg <<
" o " << *o <<
" produced by Algorithm: " <<
endmsg;
357 for (
const auto& p : algosOutputDependenciesMap )
358 if ( p.second.find( *o ) != p.second.end() )
msg <<
" * " << p.first <<
endmsg;
362 fatal() <<
"The following unused OUTPUT items were found:" <<
endmsg;
363 printUnusedOutp(
fatal() );
366 info() <<
"No unused OUTPUT items were found" <<
endmsg;
373 fatal() <<
"Error retrieving PrecedenceSvc" <<
endmsg;
378 fatal() <<
"Unable to dcast PrecedenceSvc" <<
endmsg;
385 const std::string&
name = algo->name();
393 if ( !messageSvc.
isValid() )
error() <<
"Error retrieving MessageSvc interface IMessageSvc." <<
endmsg;
402 info() <<
"Concurrency level information:" <<
endmsg;
408 info() <<
"Task scheduling settings:" <<
endmsg;
409 info() <<
" o Avalanche generation mode: "
438 info() <<
"Joining Scheduler thread" <<
endmsg;
443 error() <<
"problems in scheduler thread" <<
endmsg;
466 error() <<
"problems initializing ThreadPoolSvc" <<
endmsg;
484 verbose() <<
"Action did not succeed (which is not bad per se)." <<
endmsg;
495 verbose() <<
"Iteration did not succeed (which is not bad per se)." <<
endmsg;
505 error() <<
"Problems terminating thread pool" <<
endmsg;
551 if ( !eventContext ) {
566 const unsigned int thisSlotNum = eventContext->
slot();
569 fatal() <<
"The slot " << thisSlotNum <<
" is supposed to be a finished event but it's not" <<
endmsg;
574 thisSlot.
reset( eventContext );
581 if (
m_precSvc->iterate( thisSlot, cs ).isFailure() ) {
582 error() <<
"Failed to call IPrecedenceSvc::iterate for slot " << thisSlotNum <<
endmsg;
586 if ( this->
iterate().isFailure() ) {
587 error() <<
"Failed to call AvalancheSchedulerSvc::updateStates for slot " << thisSlotNum <<
endmsg;
596 verbose() <<
"Pushing the action to update the scheduler for slot " << eventContext->
slot() <<
endmsg;
609 for (
auto context : eventContexts ) {
652 ON_DEBUG debug() <<
"Try Pop successful slot " << eventContext->
slot() <<
"(event " << eventContext->
evt() <<
")"
675 for (
unsigned int retryIndex = 0; retryIndex < retries; ++retryIndex ) {
678 global_sc =
schedule( std::move( retryTS ) );
682 OccupancySnapshot nextSnap;
683 auto now = std::chrono::system_clock::now();
687 if ( !thisSlot.eventContext )
continue;
689 int iSlot = thisSlot.eventContext->slot();
701 if ( nextSnap.states.empty() ) {
707 std::vector<int>& slotStateTotals = nextSnap.states[iSlot];
708 slotStateTotals.resize( AState::MAXVALUE );
709 for ( uint8_t state = 0; state < AState::MAXVALUE; ++state ) {
710 slotStateTotals[state] = thisSlot.algsStates.sizeOfSubset(
AState( state ) );
714 for (
auto& subslot : thisSlot.allSubSlots ) {
715 for ( uint8_t state = 0; state < AState::MAXVALUE; ++state ) {
716 slotStateTotals[state] += subslot.algsStates.sizeOfSubset(
AState( state ) );
722 const auto& drAlgs = thisAlgsStates.
algsInState( AState::DATAREADY );
723 for ( uint algIndex : drAlgs ) {
726 bool asynchronous{
m_precSvc->isAsynchronous( algName ) };
729 schedule(
TaskSpec(
nullptr, algIndex, algName, rank, asynchronous, iSlot, thisSlot.eventContext.get() ) );
732 <<
"Could not apply transition from " << AState::DATAREADY <<
" for algorithm " << algName
733 <<
" on processing slot " << iSlot <<
endmsg;
737 for (
auto& subslot : thisSlot.allSubSlots ) {
738 const auto& drAlgsSubSlot = subslot.algsStates.algsInState( AState::DATAREADY );
739 for ( uint algIndex : drAlgsSubSlot ) {
742 bool asynchronous{
m_precSvc->isAsynchronous( algName ) };
744 schedule(
TaskSpec(
nullptr, algIndex, algName, rank, asynchronous, iSlot, subslot.eventContext.get() ) );
750 s <<
"START, " << thisAlgsStates.
sizeOfSubset( AState::CONTROLREADY ) <<
", "
752 <<
", " << std::chrono::high_resolution_clock::now().time_since_epoch().count() <<
"\n";
754 : std::to_string( std::thread::hardware_concurrency() );
755 std::ofstream myfile;
756 myfile.open(
"IntraEventFSMOccupancy_" + threads +
"T.csv", std::ios::app );
762 if (
m_precSvc->CFRulesResolved( thisSlot ) &&
763 !thisSlot.algsStates.containsAny(
764 { AState::CONTROLREADY, AState::DATAREADY, AState::SCHEDULED, AState::RESOURCELESS } ) &&
765 !subSlotAlgsInStates( thisSlot,
766 { AState::CONTROLREADY, AState::DATAREADY, AState::SCHEDULED, AState::RESOURCELESS } ) &&
767 !thisSlot.complete ) {
769 thisSlot.complete =
true;
773 ON_DEBUG debug() <<
"Event " << thisSlot.eventContext->evt() <<
" finished (slot "
774 << thisSlot.eventContext->slot() <<
")." <<
endmsg;
781 thisSlot.eventContext.reset(
nullptr );
791 if ( !nextSnap.states.empty() ) {
805 auto slotIndex = contextPtr->
slot();
811 auto subSlotIndex = contextPtr->
subSlot();
818 <<
", subslot:" << subSlotIndex <<
", event:" << contextPtr->
evt() <<
"]" <<
endmsg;
828 <<
", event:" << contextPtr->
evt() <<
"]" <<
endmsg;
846 if ( !slot.
algsStates.
containsAny( { AState::DATAREADY, AState::SCHEDULED, AState::RESOURCELESS } ) &&
847 !subSlotAlgsInStates( slot, { AState::DATAREADY, AState::SCHEDULED, AState::RESOURCELESS } ) ) {
863 const uint slotIdx = eventContext->
slot();
865 error() <<
"Event " << eventContext->
evt() <<
" on slot " << slotIdx <<
" failed" <<
endmsg;
886 std::ostringstream outputMS;
888 outputMS <<
"Dumping scheduler state\n"
889 <<
"=========================================================================================\n"
890 <<
"++++++++++++++++++++++++++++++++++++ SCHEDULER STATE ++++++++++++++++++++++++++++++++++++\n"
891 <<
"=========================================================================================\n\n";
895 outputMS <<
"------------------ Last schedule: Task/Event/Slot/Thread/State Mapping "
896 <<
"------------------\n\n";
900 if ( !timelineSvc.isValid() || !timelineSvc->isEnabled() ) {
901 outputMS <<
"WARNING Enable TimelineSvc in record mode (RecordTimeline = True) to trace the mapping\n";
908 const auto& schedAlgs = slot.algsStates.algsInState( AState::SCHEDULED );
909 for ( uint algIndex : schedAlgs ) {
917 const auto& schedAlgs = slot.algsStates.algsInState( AState::SCHEDULED );
918 for ( uint algIndex : schedAlgs ) {
922 outputMS <<
" task: " << std::setw( indt ) << algoName <<
" evt/slot: " << slot.eventContext->evt() <<
"/"
923 << slot.eventContext->slot();
926 if ( timelineSvc.isValid() ) {
929 te.
slot = slot.eventContext->slot();
930 te.
event = slot.eventContext->evt();
932 if ( timelineSvc->getTimelineEvent( te ) )
933 outputMS <<
" thread.id: 0x" << std::hex << te.
thread << std::dec;
935 outputMS <<
" thread.id: [unknown]";
940 outputMS <<
" state: [" <<
m_algExecStateSvc->algExecState( algoName, *( slot.eventContext ) ) <<
"]\n";
947 outputMS <<
"\n---------------------------- Task/CF/FSM Mapping "
948 << ( 0 > iSlot ?
"[all slots] --" :
"[target slot] " ) <<
"--------------------------\n\n";
951 bool wasAlgError = ( iSlot >= 0 ) ?
m_eventSlots[iSlot].algsStates.containsAny( { AState::ERROR } ) ||
952 subSlotAlgsInStates(
m_eventSlots[iSlot], { AState::ERROR } )
957 if ( slot.complete )
continue;
959 outputMS <<
"[ slot: "
960 << ( slot.eventContext->valid() ? std::to_string( slot.eventContext->slot() ) :
"[ctx invalid]" )
962 << ( slot.eventContext->valid() ? std::to_string( slot.eventContext->evt() ) :
"[ctx invalid]" );
964 if ( slot.eventContext->eventID().isValid() ) { outputMS <<
", eventID: " << slot.eventContext->eventID(); }
965 outputMS <<
" ]:\n\n";
967 if ( 0 > iSlot || iSlot == slotCount ) {
971 outputMS <<
"ERROR alg(s):";
973 const auto& errorAlgs = slot.algsStates.algsInState( AState::ERROR );
974 for ( uint algIndex : errorAlgs ) {
978 if ( errorCount == 0 ) outputMS <<
" in subslot(s)";
982 outputMS <<
m_precSvc->printState( slot ) <<
"\n";
987 outputMS <<
"\nNumber of sub-slots: " << slot.allSubSlots.size() <<
"\n\n";
988 auto slotID = slot.eventContext->valid() ? std::to_string( slot.eventContext->slot() ) :
"[ctx invalid]";
989 for (
auto& ss : slot.allSubSlots ) {
990 outputMS <<
"[ slot: " << slotID <<
", sub-slot: "
991 << ( ss.eventContext->valid() ? std::to_string( ss.eventContext->subSlot() ) :
"[ctx invalid]" )
992 <<
", entry: " << ss.entryPoint <<
", event: "
993 << ( ss.eventContext->valid() ? std::to_string( ss.eventContext->evt() ) :
"[ctx invalid]" )
996 outputMS <<
"ERROR alg(s):";
997 const auto& errorAlgs = ss.algsStates.algsInState( AState::ERROR );
998 for ( uint algIndex : errorAlgs ) { outputMS <<
" " <<
index2algname( algIndex ); }
1002 outputMS <<
m_precSvc->printState( ss ) <<
"\n";
1011 if ( 0 <= iSlot && !wasAlgError ) {
1012 outputMS <<
"\n------------------------------ Algorithm Execution States -----------------------------\n\n";
1016 outputMS <<
"\n=========================================================================================\n"
1017 <<
"++++++++++++++++++++++++++++++++++++++ END OF DUMP ++++++++++++++++++++++++++++++++++++++\n"
1018 <<
"=========================================================================================\n\n";
1038 unsigned int algIndex{ ts.algIndex };
1039 std::string_view algName( ts.algName );
1040 unsigned int algRank{ ts.algRank };
1041 bool asynchronous{ ts.asynchronous };
1042 int slotIndex{ ts.slotIndex };
1045 if ( asynchronous ) {
1053 if ( !asynchronous ) {
1061 sc =
revise( algIndex, contextPtr, AState::SCHEDULED );
1063 ON_DEBUG debug() <<
"Scheduled " << algName <<
" [slot:" << slotIndex <<
", event:" << contextPtr->
evt()
1064 <<
", rank:" << algRank <<
", asynchronous:" << ( asynchronous ?
"yes" :
"no" )
1070 sc =
revise( ts.algIndex, ts.contextPtr, AState::SCHEDULED );
1076 sc =
revise( ts.algIndex, ts.contextPtr, AState::RESOURCELESS );
1099 ? ( algstate.
filterPassed() ? AState::EVTACCEPTED : AState::EVTREJECTED )
1103 auto sc =
revise( ts.algIndex, ts.contextPtr, state,
true );
1105 ON_DEBUG debug() <<
"Executed " << ts.algName <<
" [slot:" << ts.slotIndex <<
", event:" << ts.contextPtr->evt()
1106 <<
", rank:" << ts.algRank <<
", asynchronous:" << ( ts.asynchronous ?
"yes" :
"no" )
1119 std::unique_ptr<EventContext> viewContext ) {
1122 fatal() <<
"Attempted to nest EventViews at node " << nodeName <<
": this is not supported" <<
endmsg;
1130 auto action = [
this, slotIndex = sourceContext->
slot(), viewContextPtr = viewContext.release(),
1135 if ( viewContextPtr ) {
1137 auto viewContext = std::unique_ptr<EventContext>( viewContextPtr );
1138 topSlot.
addSubSlot( std::move( viewContext ), nodeName );
1160 auto action = [
this, samplePeriod, callback = std::move( callback )]() ->
StatusCode {
1161 if ( samplePeriod < 0 ) {
1164 this->
m_snapshotInterval = std::chrono::duration<int64_t, std::milli>( samplePeriod );
1174 const std::map<std::string, DataObjIDColl>& outDeps )
const {
1176 assert( inDeps.size() == outDeps.size() );
1179 info() <<
"Dumping data dependencies graph to file: " << g.fileName() <<
endmsg;
1182 std::set<std::size_t> definedObjects;
1189 std::size_t algoIndex = 0ul;
1190 for (
const auto& [algName, ideps] : inDeps ) {
1191 if ( not std::regex_search( algName, algNameRegex ) )
continue;
1192 std::string algIndex =
"Alg_" + std::to_string( algoIndex );
1193 g.addNode( algIndex, algName );
1196 for (
const auto& dep : ideps ) {
1197 if ( not std::regex_search( dep.fullKey(), objNameRegex ) )
continue;
1199 const auto [itr, inserted] = definedObjects.insert( dep.hash() );
1200 std::string objIndex =
"obj_" + std::to_string( dep.hash() );
1201 if ( inserted ) g.addNode( objIndex, dep.key() );
1203 g.addEdge( objIndex, algIndex );
1206 const auto& odeps = outDeps.at( algName );
1207 for (
const auto& dep : odeps ) {
1208 if ( not std::regex_search( dep.fullKey(), objNameRegex ) )
continue;
1210 const auto [itr, inserted] = definedObjects.insert( dep.hash() );
1211 std::string objIndex =
"obj_" + std::to_string( dep.hash() );
1212 if ( inserted ) g.addNode( objIndex, dep.key() );
1214 g.addEdge( algIndex, objIndex );
std::unordered_set< DataObjID, DataObjID_Hasher > DataObjIDColl
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
#define DECLARE_COMPONENT(type)
Provide serialization function (output only) for some common STL classes (vectors,...
wrapper on an Algorithm state.
const StatusCode & execStatus() const
bool filterPassed() const
The AlgsExecutionStates encodes the state machine for the execution of algorithms within a single eve...
const boost::container::flat_set< int > algsInState(State state) const
size_t sizeOfSubset(State state) const
bool containsAny(std::initializer_list< State > l) const
check if the collection contains at least one state of any listed types
StatusCode set(unsigned int iAlgo, State newState)
StatusCode pushNewEvent(EventContext *eventContext) override
Make an event available to the scheduler.
Gaudi::Property< std::vector< std::string > > m_checkOutputIgnoreList
SmartIF< IThreadPoolSvc > m_threadPoolSvc
Gaudi::Property< std::string > m_useDataLoader
void dumpState() override
Dump scheduler state for all slots.
void activate()
Activate scheduler.
Gaudi::Property< std::string > m_optimizationMode
StatusCode popFinishedEvent(EventContext *&eventContext) override
Blocks until an event is available.
Gaudi::Property< bool > m_dumpIntraEventDynamics
std::chrono::system_clock::time_point m_lastSnapshot
std::vector< std::string > m_algname_vect
Vector to bookkeep the information necessary to the index2name conversion.
Gaudi::Property< int > m_threadPoolSize
StatusCode finalize() override
Finalise.
tbb::concurrent_priority_queue< TaskSpec, AlgQueueSort > m_scheduledQueue
Queues for scheduled algorithms.
std::function< void(OccupancySnapshot)> m_snapshotCallback
std::queue< TaskSpec > m_retryQueue
Gaudi::Property< bool > m_verboseSubSlots
tbb::concurrent_bounded_queue< action > m_actionsQueue
Queue where closures are stored and picked for execution.
SmartIF< ICondSvc > m_condSvc
A shortcut to service for Conditions handling.
AlgsExecutionStates::State AState
bool isStalled(const EventSlot &) const
Check if scheduling in a particular slot is in a stall.
SmartIF< IAlgExecStateSvc > m_algExecStateSvc
Algorithm execution state manager.
StatusCode pushNewEvents(std::vector< EventContext * > &eventContexts) override
StatusCode revise(unsigned int iAlgo, EventContext *contextPtr, AState state, bool iterate=false)
tbb::concurrent_bounded_queue< EventContext * > m_finishedEvents
Queue of finished events.
StatusCode deactivate()
Deactivate scheduler.
size_t m_maxEventsInFlight
unsigned int m_algosInFlight
Number of algorithms presently in flight.
Gaudi::Property< std::string > m_dataDepsGraphObjectPattern
Gaudi::Property< bool > m_showDataFlow
StatusCode schedule(TaskSpec &&)
SmartIF< IPrecedenceSvc > m_precSvc
A shortcut to the Precedence Service.
Gaudi::Property< bool > m_checkDeps
std::chrono::duration< int64_t, std::milli > m_snapshotInterval
Gaudi::Property< std::string > m_dataDepsGraphFile
SmartIF< IAlgResourcePool > m_algResourcePool
Cache for the algorithm resource pool.
Gaudi::Property< bool > m_showControlFlow
Gaudi::Property< bool > m_simulateExecution
Gaudi::Property< std::string > m_whiteboardSvcName
StatusCode tryPopFinishedEvent(EventContext *&eventContext) override
Try to fetch an event from the scheduler.
std::unordered_map< std::string, unsigned int > m_algname_index_map
Map to bookkeep the information necessary to the name2index conversion.
std::atomic< bool > m_needsUpdate
virtual StatusCode scheduleEventView(const EventContext *sourceContext, const std::string &nodeName, std::unique_ptr< EventContext > viewContext) override
Method to inform the scheduler about event views.
Gaudi::Property< int > m_maxParallelismExtra
StatusCode signoff(const TaskSpec &)
The call to this method is triggered only from within the AlgTask.
std::function< StatusCode()> action
Gaudi::Property< std::string > m_dataDepsGraphAlgoPattern
Gaudi::Property< int > m_numOffloadThreads
Gaudi::Property< bool > m_checkOutput
std::atomic< ActivationState > m_isActive
Flag to track if the scheduler is active or not.
StatusCode initialize() override
Initialise.
Gaudi::Property< bool > m_enableCondSvc
virtual void recordOccupancy(int samplePeriod, std::function< void(OccupancySnapshot)> callback) override
Sample occupancy at fixed interval (ms) Negative value to deactivate, 0 to snapshot every change Each...
void eventFailed(EventContext *eventContext)
Method to execute if an event failed.
std::atomic_int m_freeSlots
Atomic to account for asyncronous updates by the scheduler wrt the rest.
tbb::task_arena * m_arena
StatusCode dumpDataDepsGraphFile(const std::map< std::string, DataObjIDColl > &inDeps, const std::map< std::string, DataObjIDColl > &outDeps) const
unsigned int freeSlots() override
Get free slots number.
void dumpSchedulerState(int iSlot)
Dump the state of the scheduler.
std::unique_ptr< FiberManager > m_fiberManager
SmartIF< IHiveWhiteBoard > m_whiteboard
A shortcut to the whiteboard.
tbb::concurrent_priority_queue< TaskSpec, AlgQueueSort > m_scheduledAsynchronousQueue
StatusCode iterate()
Loop on all slots to schedule DATAREADY algorithms and sign off ready events.
Gaudi::Property< bool > m_showDataDeps
std::thread m_thread
The thread in which the activate function runs.
const std::string & index2algname(unsigned int index)
Convert an integer to a name.
std::vector< EventSlot > m_eventSlots
Vector of events slots.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
std::vector< std::string > owners_names_of(const DataObjID &id, bool with_main=false) const
const DataObjIDColl & outputDataObjs() const override
void addDependency(const DataObjID &id, const Gaudi::DataHandle::Mode &mode) override
const DataObjIDColl & inputDataObjs() const override
std::string fullKey() const
combination of the key and the ClassName, mostly for debugging
This class represents an entry point to all the event specific data.
ContextID_t subSlot() const
Base class from which all concrete algorithm classes should be derived.
void acceptDHVisitor(IDataHandleVisitor *) const override
const std::string & name() const override
The identifying name of the algorithm object.
bool isAsynchronous() const
utilities to dump graphs in different formats
The IAlgorithm is the interface implemented by the Algorithm base class.
virtual const std::string & type() const =0
The type of the algorithm.
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
A service to resolve the task execution precedence.
const concurrency::PrecedenceRulesGraph * getRules() const
Precedence rules accessor.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
StatusCode finalize() override
const std::string & name() const override
Retrieve name of the service.
StatusCode initialize() override
Small smart pointer class with automatic reference counting for IInterface.
bool isValid() const
Allow for check if smart pointer is valid.
This class is used for returning status codes from appropriate routines.
void ignore() const
Allow discarding a StatusCode without warning.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
A service which initializes a TBB thread pool.
unsigned int getAlgoIndex() const
Get algorithm index.
unsigned int getControlFlowNodeCounter() const
Get total number of control flow graph nodes.
AlgorithmNode * getAlgorithmNode(const std::string &algoName) const
Get the AlgorithmNode from by algorithm name using graph index.
GAUDI_API void setCurrentContext(const EventContext *ctx)
std::ostream & operator<<(std::ostream &s, const std::pair< T1, T2 > &p)
Serialize an std::pair in a python like format. E.g. "(1, 2)".
Struct to hold entries in the alg queues.
Class representing an event slot.
std::unique_ptr< EventContext > eventContext
Cache for the eventContext.
std::vector< EventSlot > allSubSlots
Actual sub-slot instances.
bool complete
Flags completion of the event.
void addSubSlot(std::unique_ptr< EventContext > viewContext, const std::string &nodeName)
Add a subslot to the slot (this constructs a new slot and registers it with the parent one).
void reset(EventContext *theeventContext)
Reset all resources in order to reuse the slot (thread-unsafe).
AlgsExecutionStates algsStates
Vector of algorithms states.
void disableSubSlots(const std::string &nodeName)
Disable event views for a given CF view node by registering an empty container Contact B.