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;
177 std::map<std::string, DataObjIDColl> algosOutputDependenciesMap;
181 fatal() <<
"Could not convert IAlgorithm into Gaudi::Algorithm: this will result in a crash." <<
endmsg;
187 globalOutp.insert(
id );
188 algoOutputs.insert(
id );
190 algosOutputDependenciesMap[algoPtr->
name()] = algoOutputs;
193 std::ostringstream ostdd;
194 ostdd <<
"Data Dependencies for Algorithms:";
196 std::map<std::string, DataObjIDColl> algosInputDependenciesMap;
199 if (
nullptr == algoPtr ) {
200 fatal() <<
"Could not convert IAlgorithm into Gaudi::Algorithm for " << ialgoPtr->name()
201 <<
": this will result in a crash." <<
endmsg;
209 ostdd <<
"\n " << algoPtr->
name();
211 auto write_owners = [&avis, &ostdd](
const DataObjID& id ) {
220 ostdd <<
"\n o INPUT " << id;
222 algoDependencies.insert(
id );
223 globalInp.insert(
id );
226 ostdd <<
"\n o OUTPUT " << *id;
228 if ( id->key().find(
":" ) != std::string::npos ) {
229 error() <<
" in Alg " << algoPtr->
name() <<
" alternatives are NOT allowed for outputs! id: " << *
id
237 algosInputDependenciesMap[algoPtr->
name()] = algoDependencies;
253 std::set<std::string> requiredInputKeys;
254 for (
auto o : globalInp ) {
257 requiredInputKeys.insert( o.key() );
258 if ( globalOutp.find( o ) == globalOutp.end() ) unmetDepInp.insert( o );
261 for (
auto o : globalOutp ) {
262 if ( globalInp.find( o ) == globalInp.end() && requiredInputKeys.find( o.key() ) == requiredInputKeys.end() ) {
266 auto it = algosOutputDependenciesMap.find( algoName );
267 if ( it != algosOutputDependenciesMap.end() ) {
268 if ( it->second.find( o ) != it->second.end() ) {
274 if ( !ignored ) { unusedOutp.insert( o ); }
281 if ( unmetDepInp.size() > 0 ) {
283 auto printUnmet = [&](
auto msg ) {
284 for (
const DataObjID* o : sortedDataObjIDColl( unmetDepInp ) ) {
285 msg <<
" o " << *o <<
" required by Algorithm: " <<
endmsg;
287 for (
const auto& p : algosInputDependenciesMap )
288 if ( p.second.find( *o ) != p.second.end() )
msg <<
" * " << p.first <<
endmsg;
298 dataLoaderAlg = algo;
302 if ( dataLoaderAlg ==
nullptr ) {
304 <<
"\" found, and unmet INPUT dependencies "
306 printUnmet(
fatal() );
310 info() <<
"Will attribute the following unmet INPUT dependencies to \"" << dataLoaderAlg->
type() <<
"/"
311 << dataLoaderAlg->name() <<
"\" Algorithm" <<
endmsg;
312 printUnmet(
info() );
317 fatal() <<
"Unable to dcast DataLoader \"" <<
m_useDataLoader.value() <<
"\" IAlg to Gaudi::Algorithm"
322 for (
auto&
id : unmetDepInp ) {
323 ON_DEBUG debug() <<
"adding OUTPUT dep \"" <<
id <<
"\" to " << dataLoaderAlg->
type() <<
"/"
324 << dataLoaderAlg->name() <<
endmsg;
329 fatal() <<
"Auto DataLoading not requested, "
330 <<
"and the following unmet INPUT dependencies were found:" <<
endmsg;
331 printUnmet(
fatal() );
336 info() <<
"No unmet INPUT data dependencies were found" <<
endmsg;
341 if ( unusedOutp.size() > 0 ) {
343 auto printUnusedOutp = [&](
auto msg ) {
344 for (
const DataObjID* o : sortedDataObjIDColl( unusedOutp ) ) {
345 msg <<
" o " << *o <<
" produced by Algorithm: " <<
endmsg;
347 for (
const auto& p : algosOutputDependenciesMap )
348 if ( p.second.find( *o ) != p.second.end() )
msg <<
" * " << p.first <<
endmsg;
352 fatal() <<
"The following unused OUTPUT items were found:" <<
endmsg;
353 printUnusedOutp(
fatal() );
356 info() <<
"No unused OUTPUT items were found" <<
endmsg;
363 fatal() <<
"Error retrieving PrecedenceSvc" <<
endmsg;
368 fatal() <<
"Unable to dcast PrecedenceSvc" <<
endmsg;
375 const std::string&
name = algo->name();
383 if ( !messageSvc.
isValid() )
error() <<
"Error retrieving MessageSvc interface IMessageSvc." <<
endmsg;
392 info() <<
"Concurrency level information:" <<
endmsg;
398 info() <<
"Task scheduling settings:" <<
endmsg;
399 info() <<
" o Avalanche generation mode: "
428 info() <<
"Joining Scheduler thread" <<
endmsg;
433 error() <<
"problems in scheduler thread" <<
endmsg;
456 error() <<
"problems initializing ThreadPoolSvc" <<
endmsg;
474 verbose() <<
"Action did not succeed (which is not bad per se)." <<
endmsg;
485 verbose() <<
"Iteration did not succeed (which is not bad per se)." <<
endmsg;
495 error() <<
"Problems terminating thread pool" <<
endmsg;
541 if ( !eventContext ) {
556 const unsigned int thisSlotNum = eventContext->
slot();
559 fatal() <<
"The slot " << thisSlotNum <<
" is supposed to be a finished event but it's not" <<
endmsg;
564 thisSlot.
reset( eventContext );
571 if (
m_precSvc->iterate( thisSlot, cs ).isFailure() ) {
572 error() <<
"Failed to call IPrecedenceSvc::iterate for slot " << thisSlotNum <<
endmsg;
576 if ( this->
iterate().isFailure() ) {
577 error() <<
"Failed to call AvalancheSchedulerSvc::updateStates for slot " << thisSlotNum <<
endmsg;
586 verbose() <<
"Pushing the action to update the scheduler for slot " << eventContext->
slot() <<
endmsg;
599 for (
auto context : eventContexts ) {
642 ON_DEBUG debug() <<
"Try Pop successful slot " << eventContext->
slot() <<
"(event " << eventContext->
evt() <<
")"
665 for (
unsigned int retryIndex = 0; retryIndex < retries; ++retryIndex ) {
668 global_sc =
schedule( std::move( retryTS ) );
672 OccupancySnapshot nextSnap;
673 auto now = std::chrono::system_clock::now();
677 if ( !thisSlot.eventContext )
continue;
679 int iSlot = thisSlot.eventContext->slot();
691 if ( nextSnap.states.empty() ) {
697 std::vector<int>& slotStateTotals = nextSnap.states[iSlot];
698 slotStateTotals.resize( AState::MAXVALUE );
699 for ( uint8_t state = 0; state < AState::MAXVALUE; ++state ) {
700 slotStateTotals[state] = thisSlot.algsStates.sizeOfSubset(
AState( state ) );
704 for (
auto& subslot : thisSlot.allSubSlots ) {
705 for ( uint8_t state = 0; state < AState::MAXVALUE; ++state ) {
706 slotStateTotals[state] += subslot.algsStates.sizeOfSubset(
AState( state ) );
712 const auto& drAlgs = thisAlgsStates.
algsInState( AState::DATAREADY );
713 for ( uint algIndex : drAlgs ) {
716 bool asynchronous{
m_precSvc->isAsynchronous( algName ) };
719 schedule(
TaskSpec(
nullptr, algIndex, algName, rank, asynchronous, iSlot, thisSlot.eventContext.get() ) );
722 <<
"Could not apply transition from " << AState::DATAREADY <<
" for algorithm " << algName
723 <<
" on processing slot " << iSlot <<
endmsg;
727 for (
auto& subslot : thisSlot.allSubSlots ) {
728 const auto& drAlgsSubSlot = subslot.algsStates.algsInState( AState::DATAREADY );
729 for ( uint algIndex : drAlgsSubSlot ) {
732 bool asynchronous{
m_precSvc->isAsynchronous( algName ) };
734 schedule(
TaskSpec(
nullptr, algIndex, algName, rank, asynchronous, iSlot, subslot.eventContext.get() ) );
740 s <<
"START, " << thisAlgsStates.
sizeOfSubset( AState::CONTROLREADY ) <<
", "
742 <<
", " << std::chrono::high_resolution_clock::now().time_since_epoch().count() <<
"\n";
744 : std::to_string( std::thread::hardware_concurrency() );
745 std::ofstream myfile;
746 myfile.open(
"IntraEventFSMOccupancy_" + threads +
"T.csv", std::ios::app );
752 if (
m_precSvc->CFRulesResolved( thisSlot ) &&
753 !thisSlot.algsStates.containsAny(
754 { AState::CONTROLREADY, AState::DATAREADY, AState::SCHEDULED, AState::RESOURCELESS } ) &&
755 !subSlotAlgsInStates( thisSlot,
756 { AState::CONTROLREADY, AState::DATAREADY, AState::SCHEDULED, AState::RESOURCELESS } ) &&
757 !thisSlot.complete ) {
759 thisSlot.complete =
true;
763 ON_DEBUG debug() <<
"Event " << thisSlot.eventContext->evt() <<
" finished (slot "
764 << thisSlot.eventContext->slot() <<
")." <<
endmsg;
771 thisSlot.eventContext.reset(
nullptr );
781 if ( !nextSnap.states.empty() ) {
795 auto slotIndex = contextPtr->
slot();
801 auto subSlotIndex = contextPtr->
subSlot();
808 <<
", subslot:" << subSlotIndex <<
", event:" << contextPtr->
evt() <<
"]" <<
endmsg;
818 <<
", event:" << contextPtr->
evt() <<
"]" <<
endmsg;
836 if ( !slot.
algsStates.
containsAny( { AState::DATAREADY, AState::SCHEDULED, AState::RESOURCELESS } ) &&
837 !subSlotAlgsInStates( slot, { AState::DATAREADY, AState::SCHEDULED, AState::RESOURCELESS } ) ) {
853 const uint slotIdx = eventContext->
slot();
855 error() <<
"Event " << eventContext->
evt() <<
" on slot " << slotIdx <<
" failed" <<
endmsg;
876 std::ostringstream outputMS;
878 outputMS <<
"Dumping scheduler state\n"
879 <<
"=========================================================================================\n"
880 <<
"++++++++++++++++++++++++++++++++++++ SCHEDULER STATE ++++++++++++++++++++++++++++++++++++\n"
881 <<
"=========================================================================================\n\n";
885 outputMS <<
"------------------ Last schedule: Task/Event/Slot/Thread/State Mapping "
886 <<
"------------------\n\n";
890 if ( !timelineSvc.isValid() || !timelineSvc->isEnabled() ) {
891 outputMS <<
"WARNING Enable TimelineSvc in record mode (RecordTimeline = True) to trace the mapping\n";
898 const auto& schedAlgs = slot.algsStates.algsInState( AState::SCHEDULED );
899 for ( uint algIndex : schedAlgs ) {
907 const auto& schedAlgs = slot.algsStates.algsInState( AState::SCHEDULED );
908 for ( uint algIndex : schedAlgs ) {
912 outputMS <<
" task: " << std::setw( indt ) << algoName <<
" evt/slot: " << slot.eventContext->evt() <<
"/"
913 << slot.eventContext->slot();
916 if ( timelineSvc.isValid() ) {
919 te.
slot = slot.eventContext->slot();
920 te.
event = slot.eventContext->evt();
922 if ( timelineSvc->getTimelineEvent( te ) )
923 outputMS <<
" thread.id: 0x" << std::hex << te.
thread << std::dec;
925 outputMS <<
" thread.id: [unknown]";
930 outputMS <<
" state: [" <<
m_algExecStateSvc->algExecState( algoName, *( slot.eventContext ) ) <<
"]\n";
937 outputMS <<
"\n---------------------------- Task/CF/FSM Mapping "
938 << ( 0 > iSlot ?
"[all slots] --" :
"[target slot] " ) <<
"--------------------------\n\n";
941 bool wasAlgError = ( iSlot >= 0 ) ?
m_eventSlots[iSlot].algsStates.containsAny( { AState::ERROR } ) ||
942 subSlotAlgsInStates(
m_eventSlots[iSlot], { AState::ERROR } )
947 if ( slot.complete )
continue;
949 outputMS <<
"[ slot: "
950 << ( slot.eventContext->valid() ? std::to_string( slot.eventContext->slot() ) :
"[ctx invalid]" )
952 << ( slot.eventContext->valid() ? std::to_string( slot.eventContext->evt() ) :
"[ctx invalid]" );
954 if ( slot.eventContext->eventID().isValid() ) { outputMS <<
", eventID: " << slot.eventContext->eventID(); }
955 outputMS <<
" ]:\n\n";
957 if ( 0 > iSlot || iSlot == slotCount ) {
961 outputMS <<
"ERROR alg(s):";
963 const auto& errorAlgs = slot.algsStates.algsInState( AState::ERROR );
964 for ( uint algIndex : errorAlgs ) {
968 if ( errorCount == 0 ) outputMS <<
" in subslot(s)";
972 outputMS <<
m_precSvc->printState( slot ) <<
"\n";
977 outputMS <<
"\nNumber of sub-slots: " << slot.allSubSlots.size() <<
"\n\n";
978 auto slotID = slot.eventContext->valid() ? std::to_string( slot.eventContext->slot() ) :
"[ctx invalid]";
979 for (
auto& ss : slot.allSubSlots ) {
980 outputMS <<
"[ slot: " << slotID <<
", sub-slot: "
981 << ( ss.eventContext->valid() ? std::to_string( ss.eventContext->subSlot() ) :
"[ctx invalid]" )
982 <<
", entry: " << ss.entryPoint <<
", event: "
983 << ( ss.eventContext->valid() ? std::to_string( ss.eventContext->evt() ) :
"[ctx invalid]" )
986 outputMS <<
"ERROR alg(s):";
987 const auto& errorAlgs = ss.algsStates.algsInState( AState::ERROR );
988 for ( uint algIndex : errorAlgs ) { outputMS <<
" " <<
index2algname( algIndex ); }
992 outputMS <<
m_precSvc->printState( ss ) <<
"\n";
1001 if ( 0 <= iSlot && !wasAlgError ) {
1002 outputMS <<
"\n------------------------------ Algorithm Execution States -----------------------------\n\n";
1006 outputMS <<
"\n=========================================================================================\n"
1007 <<
"++++++++++++++++++++++++++++++++++++++ END OF DUMP ++++++++++++++++++++++++++++++++++++++\n"
1008 <<
"=========================================================================================\n\n";
1028 unsigned int algIndex{ ts.algIndex };
1029 std::string_view algName( ts.algName );
1030 unsigned int algRank{ ts.algRank };
1031 bool asynchronous{ ts.asynchronous };
1032 int slotIndex{ ts.slotIndex };
1035 if ( asynchronous ) {
1043 if ( !asynchronous ) {
1051 sc =
revise( algIndex, contextPtr, AState::SCHEDULED );
1053 ON_DEBUG debug() <<
"Scheduled " << algName <<
" [slot:" << slotIndex <<
", event:" << contextPtr->
evt()
1054 <<
", rank:" << algRank <<
", asynchronous:" << ( asynchronous ?
"yes" :
"no" )
1060 sc =
revise( ts.algIndex, ts.contextPtr, AState::SCHEDULED );
1066 sc =
revise( ts.algIndex, ts.contextPtr, AState::RESOURCELESS );
1089 ? ( algstate.
filterPassed() ? AState::EVTACCEPTED : AState::EVTREJECTED )
1093 auto sc =
revise( ts.algIndex, ts.contextPtr, state,
true );
1095 ON_DEBUG debug() <<
"Executed " << ts.algName <<
" [slot:" << ts.slotIndex <<
", event:" << ts.contextPtr->evt()
1096 <<
", rank:" << ts.algRank <<
", asynchronous:" << ( ts.asynchronous ?
"yes" :
"no" )
1109 std::unique_ptr<EventContext> viewContext ) {
1112 fatal() <<
"Attempted to nest EventViews at node " << nodeName <<
": this is not supported" <<
endmsg;
1120 auto action = [
this, slotIndex = sourceContext->
slot(), viewContextPtr = viewContext.release(),
1125 if ( viewContextPtr ) {
1127 auto viewContext = std::unique_ptr<EventContext>( viewContextPtr );
1128 topSlot.
addSubSlot( std::move( viewContext ), nodeName );
1150 auto action = [
this, samplePeriod, callback = std::move( callback )]() ->
StatusCode {
1151 if ( samplePeriod < 0 ) {
1154 this->
m_snapshotInterval = std::chrono::duration<int64_t, std::milli>( samplePeriod );
1164 const std::map<std::string, DataObjIDColl>& outDeps )
const {
1166 assert( inDeps.size() == outDeps.size() );
1169 info() <<
"Dumping data dependencies graph to file: " << g.fileName() <<
endmsg;
1172 std::set<std::size_t> definedObjects;
1179 std::size_t algoIndex = 0ul;
1180 for (
const auto& [algName, ideps] : inDeps ) {
1181 if ( not std::regex_search( algName, algNameRegex ) )
continue;
1182 std::string algIndex =
"Alg_" + std::to_string( algoIndex );
1183 g.addNode( algIndex, algName );
1186 for (
const auto& dep : ideps ) {
1187 if ( not std::regex_search( dep.fullKey(), objNameRegex ) )
continue;
1189 const auto [itr, inserted] = definedObjects.insert( dep.hash() );
1190 std::string objIndex =
"obj_" + std::to_string( dep.hash() );
1191 if ( inserted ) g.addNode( objIndex, dep.key() );
1193 g.addEdge( objIndex, algIndex );
1196 const auto& odeps = outDeps.at( algName );
1197 for (
const auto& dep : odeps ) {
1198 if ( not std::regex_search( dep.fullKey(), objNameRegex ) )
continue;
1200 const auto [itr, inserted] = definedObjects.insert( dep.hash() );
1201 std::string objIndex =
"obj_" + std::to_string( dep.hash() );
1202 if ( inserted ) g.addNode( objIndex, dep.key() );
1204 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.
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.