The Gaudi Framework  v39r1 (adb068b2)
AvalancheSchedulerSvc.cpp
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #include "AvalancheSchedulerSvc.h"
12 #include "AlgTask.h"
13 #include "FiberManager.h"
14 #include "ThreadPoolSvc.h"
15 
16 // Framework includes
17 #include <Gaudi/Algorithm.h> // can be removed ASA dynamic casts to Algorithm are removed
20 #include <GaudiKernel/IAlgorithm.h>
24 
25 // C++
26 #include <algorithm>
27 #include <fstream>
28 #include <map>
29 #include <queue>
30 #include <regex>
31 #include <sstream>
32 #include <string_view>
33 #include <thread>
34 #include <unordered_set>
35 
36 // External libs
37 #include <boost/algorithm/string.hpp>
38 #include <boost/thread.hpp>
39 #include <boost/tokenizer.hpp>
40 
41 // Instantiation of a static factory class used by clients to create instances of this service
43 
44 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) )
45 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) )
46 
47 namespace {
48  struct DataObjIDSorter {
49  bool operator()( const DataObjID* a, const DataObjID* b ) { return a->fullKey() < b->fullKey(); }
50  };
51 
52  // Sort a DataObjIDColl in a well-defined, reproducible manner.
53  // Used for making debugging dumps.
54  std::vector<const DataObjID*> sortedDataObjIDColl( const DataObjIDColl& coll ) {
56  v.reserve( coll.size() );
57  for ( const DataObjID& id : coll ) v.push_back( &id );
58  std::sort( v.begin(), v.end(), DataObjIDSorter() );
59  return v;
60  }
61 
62  bool subSlotAlgsInStates( const EventSlot& slot, std::initializer_list<AlgsExecutionStates::State> testStates ) {
63  return std::any_of( slot.allSubSlots.begin(), slot.allSubSlots.end(),
64  [testStates]( const EventSlot& ss ) { return ss.algsStates.containsAny( testStates ); } );
65  }
66 } // namespace
67 
68 //---------------------------------------------------------------------------
69 
77 
78  // Initialise mother class (read properties, ...)
80  if ( sc.isFailure() ) warning() << "Base class could not be initialized" << endmsg;
81 
82  // Get hold of the TBBSvc. This should initialize the thread pool
83  m_threadPoolSvc = serviceLocator()->service( "ThreadPoolSvc" );
84  if ( !m_threadPoolSvc.isValid() ) {
85  fatal() << "Error retrieving ThreadPoolSvc" << endmsg;
86  return StatusCode::FAILURE;
87  }
88  auto castTPS = dynamic_cast<ThreadPoolSvc*>( m_threadPoolSvc.get() );
89  if ( !castTPS ) {
90  fatal() << "Cannot cast ThreadPoolSvc" << endmsg;
91  return StatusCode::FAILURE;
92  }
93  m_arena = castTPS->getArena();
94  if ( !m_arena ) {
95  fatal() << "Cannot find valid TBB task_arena" << endmsg;
96  return StatusCode::FAILURE;
97  }
98 
99  // Initialize FiberManager
100  m_fiberManager = std::make_unique<FiberManager>( m_numOffloadThreads.value() );
101 
102  // Activate the scheduler in another thread.
103  info() << "Activating scheduler in a separate thread" << endmsg;
104  m_thread = std::thread( [this]() { this->activate(); } );
105 
106  while ( m_isActive != ACTIVE ) {
107  if ( m_isActive == FAILURE ) {
108  fatal() << "Terminating initialization" << endmsg;
109  return StatusCode::FAILURE;
110  } else {
111  ON_DEBUG debug() << "Waiting for AvalancheSchedulerSvc to activate" << endmsg;
112  sleep( 1 );
113  }
114  }
115 
116  if ( m_enableCondSvc ) {
117  // Get hold of the CondSvc
118  m_condSvc = serviceLocator()->service( "CondSvc" );
119  if ( !m_condSvc.isValid() ) {
120  warning() << "No CondSvc found, or not enabled. "
121  << "Will not manage CondAlgorithms" << endmsg;
122  m_enableCondSvc = false;
123  }
124  }
125 
126  // Get the algo resource pool
127  m_algResourcePool = serviceLocator()->service( "AlgResourcePool" );
128  if ( !m_algResourcePool.isValid() ) {
129  fatal() << "Error retrieving AlgoResourcePool" << endmsg;
130  return StatusCode::FAILURE;
131  }
132 
133  m_algExecStateSvc = serviceLocator()->service( "AlgExecStateSvc" );
134  if ( !m_algExecStateSvc.isValid() ) {
135  fatal() << "Error retrieving AlgExecStateSvc" << endmsg;
136  return StatusCode::FAILURE;
137  }
138 
139  // Get Whiteboard
141  if ( !m_whiteboard.isValid() ) {
142  fatal() << "Error retrieving EventDataSvc interface IHiveWhiteBoard." << endmsg;
143  return StatusCode::FAILURE;
144  }
145 
146  // Set the MaxEventsInFlight parameters from the number of WB stores
147  m_maxEventsInFlight = m_whiteboard->getNumberOfStores();
148 
149  // Set the number of free slots
151 
152  // Get the list of algorithms
153  const std::list<IAlgorithm*>& algos = m_algResourcePool->getFlatAlgList();
154  const unsigned int algsNumber = algos.size();
155  if ( algsNumber != 0 ) {
156  info() << "Found " << algsNumber << " algorithms" << endmsg;
157  } else {
158  error() << "No algorithms found" << endmsg;
159  return StatusCode::FAILURE;
160  }
161 
162  /* Dependencies
163  1) Look for handles in algo, if none
164  2) Assume none are required
165  */
166 
167  DataObjIDColl globalInp, globalOutp;
168 
169  // figure out all outputs
170  std::map<std::string, DataObjIDColl> algosOutputDependenciesMap;
171  for ( IAlgorithm* ialgoPtr : algos ) {
172  Gaudi::Algorithm* algoPtr = dynamic_cast<Gaudi::Algorithm*>( ialgoPtr );
173  if ( !algoPtr ) {
174  fatal() << "Could not convert IAlgorithm into Gaudi::Algorithm: this will result in a crash." << endmsg;
175  return StatusCode::FAILURE;
176  }
177 
178  DataObjIDColl algoOutputs;
179  for ( auto id : algoPtr->outputDataObjs() ) {
180  globalOutp.insert( id );
181  algoOutputs.insert( id );
182  }
183  algosOutputDependenciesMap[algoPtr->name()] = algoOutputs;
184  }
185 
186  std::ostringstream ostdd;
187  ostdd << "Data Dependencies for Algorithms:";
188 
189  std::map<std::string, DataObjIDColl> algosInputDependenciesMap;
190  for ( IAlgorithm* ialgoPtr : algos ) {
191  Gaudi::Algorithm* algoPtr = dynamic_cast<Gaudi::Algorithm*>( ialgoPtr );
192  if ( nullptr == algoPtr ) {
193  fatal() << "Could not convert IAlgorithm into Gaudi::Algorithm for " << ialgoPtr->name()
194  << ": this will result in a crash." << endmsg;
195  return StatusCode::FAILURE;
196  }
197 
198  DataObjIDColl i1, i2;
199  DHHVisitor avis( i1, i2 );
200  algoPtr->acceptDHVisitor( &avis );
201 
202  ostdd << "\n " << algoPtr->name();
203 
204  auto write_owners = [&avis, &ostdd]( const DataObjID id ) {
205  auto owners = avis.owners_names_of( id );
206  if ( !owners.empty() ) { GaudiUtils::operator<<( ostdd << ' ', owners ); }
207  };
208 
209  DataObjIDColl algoDependencies;
210  if ( !algoPtr->inputDataObjs().empty() || !algoPtr->outputDataObjs().empty() ) {
211  for ( const DataObjID* idp : sortedDataObjIDColl( algoPtr->inputDataObjs() ) ) {
212  DataObjID id = *idp;
213  ostdd << "\n o INPUT " << id;
214  write_owners( id );
215  algoDependencies.insert( id );
216  globalInp.insert( id );
217  }
218  for ( const DataObjID* id : sortedDataObjIDColl( algoPtr->outputDataObjs() ) ) {
219  ostdd << "\n o OUTPUT " << *id;
220  write_owners( *id );
221  if ( id->key().find( ":" ) != std::string::npos ) {
222  error() << " in Alg " << algoPtr->name() << " alternatives are NOT allowed for outputs! id: " << *id
223  << endmsg;
224  m_showDataDeps = true;
225  }
226  }
227  } else {
228  ostdd << "\n none";
229  }
230  algosInputDependenciesMap[algoPtr->name()] = algoDependencies;
231  }
232 
233  if ( m_showDataDeps ) { info() << ostdd.str() << endmsg; }
234 
235  // If requested, dump a graph of the data dependencies in a .dot or .md file
236  if ( not m_dataDepsGraphFile.empty() ) {
237  if ( dumpGraphFile( algosInputDependenciesMap, algosOutputDependenciesMap ).isFailure() ) {
238  return StatusCode::FAILURE;
239  }
240  }
241 
242  // Check if we have unmet global input dependencies, and, optionally, heal them
243  // WARNING: this step must be done BEFORE the Precedence Service is initialized
244  DataObjIDColl unmetDepInp, unusedOutp;
245  if ( m_checkDeps || m_checkOutput ) {
246  std::set<std::string> requiredInputKeys;
247  for ( auto o : globalInp ) {
248  // track aliases
249  // (assuming there should be no items with different class and same key corresponding to different objects)
250  requiredInputKeys.insert( o.key() );
251  if ( globalOutp.find( o ) == globalOutp.end() ) unmetDepInp.insert( o );
252  }
253  if ( m_checkOutput ) {
254  for ( auto o : globalOutp ) {
255  if ( globalInp.find( o ) == globalInp.end() && requiredInputKeys.find( o.key() ) == requiredInputKeys.end() ) {
256  // check ignores
257  bool ignored{};
258  for ( const std::string& algoName : m_checkOutputIgnoreList ) {
259  auto it = algosOutputDependenciesMap.find( algoName );
260  if ( it != algosOutputDependenciesMap.end() ) {
261  if ( it->second.find( o ) != it->second.end() ) {
262  ignored = true;
263  break;
264  }
265  }
266  }
267  if ( !ignored ) { unusedOutp.insert( o ); }
268  }
269  }
270  }
271  }
272 
273  if ( m_checkDeps ) {
274  if ( unmetDepInp.size() > 0 ) {
275 
276  auto printUnmet = [&]( auto msg ) {
277  for ( const DataObjID* o : sortedDataObjIDColl( unmetDepInp ) ) {
278  msg << " o " << *o << " required by Algorithm: " << endmsg;
279 
280  for ( const auto& p : algosInputDependenciesMap )
281  if ( p.second.find( *o ) != p.second.end() ) msg << " * " << p.first << endmsg;
282  }
283  };
284 
285  if ( !m_useDataLoader.empty() ) {
286 
287  // Find the DataLoader Alg
288  IAlgorithm* dataLoaderAlg( nullptr );
289  for ( IAlgorithm* algo : algos )
290  if ( m_useDataLoader == algo->name() ) {
291  dataLoaderAlg = algo;
292  break;
293  }
294 
295  if ( dataLoaderAlg == nullptr ) {
296  fatal() << "No DataLoader Algorithm \"" << m_useDataLoader.value()
297  << "\" found, and unmet INPUT dependencies "
298  << "detected:" << endmsg;
299  printUnmet( fatal() );
300  return StatusCode::FAILURE;
301  }
302 
303  info() << "Will attribute the following unmet INPUT dependencies to \"" << dataLoaderAlg->type() << "/"
304  << dataLoaderAlg->name() << "\" Algorithm" << endmsg;
305  printUnmet( info() );
306 
307  // Set the property Load of DataLoader Alg
308  Gaudi::Algorithm* dataAlg = dynamic_cast<Gaudi::Algorithm*>( dataLoaderAlg );
309  if ( !dataAlg ) {
310  fatal() << "Unable to dcast DataLoader \"" << m_useDataLoader.value() << "\" IAlg to Gaudi::Algorithm"
311  << endmsg;
312  return StatusCode::FAILURE;
313  }
314 
315  for ( auto& id : unmetDepInp ) {
316  ON_DEBUG debug() << "adding OUTPUT dep \"" << id << "\" to " << dataLoaderAlg->type() << "/"
317  << dataLoaderAlg->name() << endmsg;
319  }
320 
321  } else {
322  fatal() << "Auto DataLoading not requested, "
323  << "and the following unmet INPUT dependencies were found:" << endmsg;
324  printUnmet( fatal() );
325  return StatusCode::FAILURE;
326  }
327 
328  } else {
329  info() << "No unmet INPUT data dependencies were found" << endmsg;
330  }
331  }
332 
333  if ( m_checkOutput ) {
334  if ( unusedOutp.size() > 0 ) {
335 
336  auto printUnusedOutp = [&]( auto msg ) {
337  for ( const DataObjID* o : sortedDataObjIDColl( unusedOutp ) ) {
338  msg << " o " << *o << " produced by Algorithm: " << endmsg;
339 
340  for ( const auto& p : algosOutputDependenciesMap )
341  if ( p.second.find( *o ) != p.second.end() ) msg << " * " << p.first << endmsg;
342  }
343  };
344 
345  fatal() << "The following unused OUTPUT items were found:" << endmsg;
346  printUnusedOutp( fatal() );
347  return StatusCode::FAILURE;
348  } else {
349  info() << "No unused OUTPUT items were found" << endmsg;
350  }
351  }
352 
353  // Get the precedence service
354  m_precSvc = serviceLocator()->service( "PrecedenceSvc" );
355  if ( !m_precSvc.isValid() ) {
356  fatal() << "Error retrieving PrecedenceSvc" << endmsg;
357  return StatusCode::FAILURE;
358  }
359  const PrecedenceSvc* precSvc = dynamic_cast<const PrecedenceSvc*>( m_precSvc.get() );
360  if ( !precSvc ) {
361  fatal() << "Unable to dcast PrecedenceSvc" << endmsg;
362  return StatusCode::FAILURE;
363  }
364 
365  // Fill the containers to convert algo names to index
366  m_algname_vect.resize( algsNumber );
367  for ( IAlgorithm* algo : algos ) {
368  const std::string& name = algo->name();
369  auto index = precSvc->getRules()->getAlgorithmNode( name )->getAlgoIndex();
372  }
373 
374  // Shortcut for the message service
375  SmartIF<IMessageSvc> messageSvc( serviceLocator() );
376  if ( !messageSvc.isValid() ) error() << "Error retrieving MessageSvc interface IMessageSvc." << endmsg;
377 
379  for ( size_t i = 0; i < m_maxEventsInFlight; ++i ) {
380  m_eventSlots.emplace_back( algsNumber, precSvc->getRules()->getControlFlowNodeCounter(), messageSvc );
381  m_eventSlots.back().complete = true;
382  }
383 
384  if ( m_threadPoolSize > 1 ) { m_maxAlgosInFlight = (size_t)m_threadPoolSize; }
385 
386  // Clearly inform about the level of concurrency
387  info() << "Concurrency level information:" << endmsg;
388  info() << " o Number of events in flight: " << m_maxEventsInFlight << endmsg;
389  info() << " o TBB thread pool size: " << m_threadPoolSize << endmsg;
390 
391  // Inform about task scheduling prescriptions
392  info() << "Task scheduling settings:" << endmsg;
393  info() << " o Avalanche generation mode: "
394  << ( m_optimizationMode.empty() ? "disabled" : m_optimizationMode.toString() ) << endmsg;
395  info() << " o Preemptive scheduling of CPU-blocking tasks: "
397  ? ( "enabled (max. " + std::to_string( m_maxBlockingAlgosInFlight ) + " concurrent tasks)" )
398  : "disabled" )
399  << endmsg;
400  info() << " o Scheduling of condition tasks: " << ( m_enableCondSvc ? "enabled" : "disabled" ) << endmsg;
401 
402  if ( m_showControlFlow ) m_precSvc->dumpControlFlow();
403 
404  if ( m_showDataFlow ) m_precSvc->dumpDataFlow();
405 
406  // Simulate execution flow
407  if ( m_simulateExecution ) sc = m_precSvc->simulate( m_eventSlots[0] );
408 
409  return sc;
410 }
411 //---------------------------------------------------------------------------
412 
417 
419  if ( sc.isFailure() ) warning() << "Base class could not be finalized" << endmsg;
420 
421  sc = deactivate();
422  if ( sc.isFailure() ) warning() << "Scheduler could not be deactivated" << endmsg;
423 
424  debug() << "Deleting FiberManager" << endmsg;
426 
427  info() << "Joining Scheduler thread" << endmsg;
428  m_thread.join();
429 
430  // Final error check after thread pool termination
431  if ( m_isActive == FAILURE ) {
432  error() << "problems in scheduler thread" << endmsg;
433  return StatusCode::FAILURE;
434  }
435 
436  return sc;
437 }
438 //---------------------------------------------------------------------------
439 
451 
452  ON_DEBUG debug() << "AvalancheSchedulerSvc::activate()" << endmsg;
453 
454  if ( m_threadPoolSvc->initPool( m_threadPoolSize, m_maxParallelismExtra ).isFailure() ) {
455  error() << "problems initializing ThreadPoolSvc" << endmsg;
457  return;
458  }
459 
460  // Wait for actions pushed into the queue by finishing tasks.
461  action thisAction;
463 
464  m_isActive = ACTIVE;
465 
466  // Continue to wait if the scheduler is running or there is something to do
467  ON_DEBUG debug() << "Start checking the actionsQueue" << endmsg;
468  while ( m_isActive == ACTIVE || m_actionsQueue.size() != 0 ) {
469  m_actionsQueue.pop( thisAction );
470  sc = thisAction();
471  ON_VERBOSE {
472  if ( sc.isFailure() )
473  verbose() << "Action did not succeed (which is not bad per se)." << endmsg;
474  else
475  verbose() << "Action succeeded." << endmsg;
476  }
477  else sc.ignore();
478 
479  // If all queued actions have been processed, update the slot states
480  if ( m_needsUpdate.load() && m_actionsQueue.empty() ) {
481  sc = iterate();
482  ON_VERBOSE {
483  if ( sc.isFailure() )
484  verbose() << "Iteration did not succeed (which is not bad per se)." << endmsg;
485  else
486  verbose() << "Iteration succeeded." << endmsg;
487  }
488  else sc.ignore();
489  }
490  }
491 
492  ON_DEBUG debug() << "Terminating thread-pool resources" << endmsg;
493  if ( m_threadPoolSvc->terminatePool().isFailure() ) {
494  error() << "Problems terminating thread pool" << endmsg;
496  }
497 }
498 
499 //---------------------------------------------------------------------------
500 
508 
509  if ( m_isActive == ACTIVE ) {
510 
511  // Set the number of slots available to an error code
512  m_freeSlots.store( 0 );
513 
514  // Empty queue
515  action thisAction;
516  while ( m_actionsQueue.try_pop( thisAction ) ) {};
517 
518  // This would be the last action
519  m_actionsQueue.push( [this]() -> StatusCode {
520  ON_VERBOSE verbose() << "Deactivating scheduler" << endmsg;
522  return StatusCode::SUCCESS;
523  } );
524  }
525 
526  return StatusCode::SUCCESS;
527 }
528 
529 //---------------------------------------------------------------------------
530 
531 // EventSlot management
539 
540  if ( !eventContext ) {
541  fatal() << "Event context is nullptr" << endmsg;
542  return StatusCode::FAILURE;
543  }
544 
545  if ( m_freeSlots.load() == 0 ) {
546  ON_DEBUG debug() << "A free processing slot could not be found." << endmsg;
547  return StatusCode::FAILURE;
548  }
549 
550  // no problem as push new event is only called from one thread (event loop manager)
551  --m_freeSlots;
552 
553  auto action = [this, eventContext]() -> StatusCode {
554  // Event processing slot forced to be the same as the wb slot
555  const unsigned int thisSlotNum = eventContext->slot();
556  EventSlot& thisSlot = m_eventSlots[thisSlotNum];
557  if ( !thisSlot.complete ) {
558  fatal() << "The slot " << thisSlotNum << " is supposed to be a finished event but it's not" << endmsg;
559  return StatusCode::FAILURE;
560  }
561 
562  ON_DEBUG debug() << "Executing event " << eventContext->evt() << " on slot " << thisSlotNum << endmsg;
563  thisSlot.reset( eventContext );
564 
565  // Result status code:
567 
568  // promote to CR and DR the initial set of algorithms
569  Cause cs = { Cause::source::Root, "RootDecisionHub" };
570  if ( m_precSvc->iterate( thisSlot, cs ).isFailure() ) {
571  error() << "Failed to call IPrecedenceSvc::iterate for slot " << thisSlotNum << endmsg;
572  result = StatusCode::FAILURE;
573  }
574 
575  if ( this->iterate().isFailure() ) {
576  error() << "Failed to call AvalancheSchedulerSvc::updateStates for slot " << thisSlotNum << endmsg;
577  result = StatusCode::FAILURE;
578  }
579 
580  return result;
581  }; // end of lambda
582 
583  // Kick off scheduling
584  ON_VERBOSE {
585  verbose() << "Pushing the action to update the scheduler for slot " << eventContext->slot() << endmsg;
586  verbose() << "Free slots available " << m_freeSlots.load() << endmsg;
587  }
588 
589  m_actionsQueue.push( action );
590 
591  return StatusCode::SUCCESS;
592 }
593 
594 //---------------------------------------------------------------------------
595 
597  StatusCode sc;
598  for ( auto context : eventContexts ) {
599  sc = pushNewEvent( context );
600  if ( sc != StatusCode::SUCCESS ) return sc;
601  }
602  return sc;
603 }
604 
605 //---------------------------------------------------------------------------
606 
607 unsigned int AvalancheSchedulerSvc::freeSlots() { return std::max( m_freeSlots.load(), 0 ); }
608 
609 //---------------------------------------------------------------------------
610 
612 
613 //---------------------------------------------------------------------------
618 
619  // ON_DEBUG debug() << "popFinishedEvent: queue size: " << m_finishedEvents.size() << endmsg;
620  if ( m_freeSlots.load() == (int)m_maxEventsInFlight || m_isActive == INACTIVE ) {
621  // ON_DEBUG debug() << "freeslots: " << m_freeSlots << "/" << m_maxEventsInFlight
622  // << " active: " << m_isActive << endmsg;
623  return StatusCode::FAILURE;
624  } else {
625  // ON_DEBUG debug() << "freeslots: " << m_freeSlots << "/" << m_maxEventsInFlight
626  // << " active: " << m_isActive << endmsg;
627  m_finishedEvents.pop( eventContext );
628  ++m_freeSlots;
629  ON_DEBUG debug() << "Popped slot " << eventContext->slot() << " (event " << eventContext->evt() << ")" << endmsg;
630  return StatusCode::SUCCESS;
631  }
632 }
633 
634 //---------------------------------------------------------------------------
639 
640  if ( m_finishedEvents.try_pop( eventContext ) ) {
641  ON_DEBUG debug() << "Try Pop successful slot " << eventContext->slot() << "(event " << eventContext->evt() << ")"
642  << endmsg;
643  ++m_freeSlots;
644  return StatusCode::SUCCESS;
645  }
646  return StatusCode::FAILURE;
647 }
648 
649 //--------------------------------------------------------------------------
650 
659 
660  StatusCode global_sc( StatusCode::SUCCESS );
661 
662  // Retry algorithms
663  const size_t retries = m_retryQueue.size();
664  for ( unsigned int retryIndex = 0; retryIndex < retries; ++retryIndex ) {
665  TaskSpec retryTS = std::move( m_retryQueue.front() );
666  m_retryQueue.pop();
667  global_sc = schedule( std::move( retryTS ) );
668  }
669 
670  // Loop over all slots
671  OccupancySnapshot nextSnap;
672  auto now = std::chrono::system_clock::now();
673  for ( EventSlot& thisSlot : m_eventSlots ) {
674 
675  // Ignore slots without a valid context (relevant when populating scheduler for first time)
676  if ( !thisSlot.eventContext ) continue;
677 
678  int iSlot = thisSlot.eventContext->slot();
679 
680  // Cache the states of the algorithms to improve readability and performance
681  AlgsExecutionStates& thisAlgsStates = thisSlot.algsStates;
682 
683  StatusCode partial_sc = StatusCode::FAILURE;
684 
685  // Make an occupancy snapshot
688 
689  // Initialise snapshot
690  if ( nextSnap.states.empty() ) {
691  nextSnap.time = now;
692  nextSnap.states.resize( m_eventSlots.size() );
693  }
694 
695  // Store alg states
696  std::vector<int>& slotStateTotals = nextSnap.states[iSlot];
697  slotStateTotals.resize( AState::MAXVALUE );
698  for ( uint8_t state = 0; state < AState::MAXVALUE; ++state ) {
699  slotStateTotals[state] = thisSlot.algsStates.sizeOfSubset( AState( state ) );
700  }
701 
702  // Add subslot alg states
703  for ( auto& subslot : thisSlot.allSubSlots ) {
704  for ( uint8_t state = 0; state < AState::MAXVALUE; ++state ) {
705  slotStateTotals[state] += subslot.algsStates.sizeOfSubset( AState( state ) );
706  }
707  }
708  }
709 
710  // Perform DR->SCHEDULED
711  const auto& drAlgs = thisAlgsStates.algsInState( AState::DATAREADY );
712  for ( uint algIndex : drAlgs ) {
713  const std::string& algName{ index2algname( algIndex ) };
714  unsigned int rank{ m_optimizationMode.empty() ? 0 : m_precSvc->getPriority( algName ) };
715  bool asynchronous{ m_precSvc->isAsynchronous( algName ) };
716 
717  partial_sc =
718  schedule( TaskSpec( nullptr, algIndex, algName, rank, asynchronous, iSlot, thisSlot.eventContext.get() ) );
719 
720  ON_VERBOSE if ( partial_sc.isFailure() ) verbose()
721  << "Could not apply transition from " << AState::DATAREADY << " for algorithm " << algName
722  << " on processing slot " << iSlot << endmsg;
723  }
724 
725  // Check for algorithms ready in sub-slots
726  for ( auto& subslot : thisSlot.allSubSlots ) {
727  const auto& drAlgsSubSlot = subslot.algsStates.algsInState( AState::DATAREADY );
728  for ( uint algIndex : drAlgsSubSlot ) {
729  const std::string& algName{ index2algname( algIndex ) };
730  unsigned int rank{ m_optimizationMode.empty() ? 0 : m_precSvc->getPriority( algName ) };
731  bool asynchronous{ m_precSvc->isAsynchronous( algName ) };
732  partial_sc =
733  schedule( TaskSpec( nullptr, algIndex, algName, rank, asynchronous, iSlot, subslot.eventContext.get() ) );
734  }
735  }
736 
737  if ( m_dumpIntraEventDynamics ) {
739  s << "START, " << thisAlgsStates.sizeOfSubset( AState::CONTROLREADY ) << ", "
740  << thisAlgsStates.sizeOfSubset( AState::DATAREADY ) << ", " << thisAlgsStates.sizeOfSubset( AState::SCHEDULED )
741  << ", " << std::chrono::high_resolution_clock::now().time_since_epoch().count() << "\n";
744  std::ofstream myfile;
745  myfile.open( "IntraEventFSMOccupancy_" + threads + "T.csv", std::ios::app );
746  myfile << s.str();
747  myfile.close();
748  }
749 
750  // Not complete because this would mean that the slot is already free!
751  if ( m_precSvc->CFRulesResolved( thisSlot ) &&
752  !thisSlot.algsStates.containsAny(
753  { AState::CONTROLREADY, AState::DATAREADY, AState::SCHEDULED, AState::RESOURCELESS } ) &&
754  !subSlotAlgsInStates( thisSlot,
755  { AState::CONTROLREADY, AState::DATAREADY, AState::SCHEDULED, AState::RESOURCELESS } ) &&
756  !thisSlot.complete ) {
757 
758  thisSlot.complete = true;
759  // if the event did not fail, add it to the finished events
760  // otherwise it is taken care of in the error handling
761  if ( m_algExecStateSvc->eventStatus( *thisSlot.eventContext ) == EventStatus::Success ) {
762  ON_DEBUG debug() << "Event " << thisSlot.eventContext->evt() << " finished (slot "
763  << thisSlot.eventContext->slot() << ")." << endmsg;
764  m_finishedEvents.push( thisSlot.eventContext.release() );
765  }
766 
767  // now let's return the fully evaluated result of the control flow
768  ON_DEBUG debug() << m_precSvc->printState( thisSlot ) << endmsg;
769 
770  thisSlot.eventContext.reset( nullptr );
771 
772  } else if ( isStalled( thisSlot ) ) {
773  m_algExecStateSvc->setEventStatus( EventStatus::AlgStall, *thisSlot.eventContext );
774  eventFailed( thisSlot.eventContext.get() ); // can't release yet
775  }
776  partial_sc.ignore();
777  } // end loop on slots
778 
779  // Process snapshot
780  if ( !nextSnap.states.empty() ) {
781  m_lastSnapshot = nextSnap.time;
782  m_snapshotCallback( std::move( nextSnap ) );
783  }
784 
785  ON_VERBOSE verbose() << "Iteration done." << endmsg;
786  m_needsUpdate.store( false );
787  return global_sc;
788 }
789 
790 //---------------------------------------------------------------------------
791 // Update algorithm state and, optionally, revise states of other downstream algorithms
792 StatusCode AvalancheSchedulerSvc::revise( unsigned int iAlgo, EventContext* contextPtr, AState state, bool iterate ) {
793  StatusCode sc;
794  auto slotIndex = contextPtr->slot();
795  EventSlot& slot = m_eventSlots[slotIndex];
796  Cause cs = { Cause::source::Task, index2algname( iAlgo ) };
797 
798  if ( contextPtr->usesSubSlot() ) {
799  // Sub-slot
800  auto subSlotIndex = contextPtr->subSlot();
801  EventSlot& subSlot = slot.allSubSlots[subSlotIndex];
802 
803  sc = subSlot.algsStates.set( iAlgo, state );
804 
805  if ( sc.isSuccess() ) {
806  ON_VERBOSE verbose() << "Promoted " << index2algname( iAlgo ) << " to " << state << " [slot:" << slotIndex
807  << ", subslot:" << subSlotIndex << ", event:" << contextPtr->evt() << "]" << endmsg;
808  // Revise states of algorithms downstream the precedence graph
809  if ( iterate ) sc = m_precSvc->iterate( subSlot, cs );
810  }
811  } else {
812  // Event level (standard behaviour)
813  sc = slot.algsStates.set( iAlgo, state );
814 
815  if ( sc.isSuccess() ) {
816  ON_VERBOSE verbose() << "Promoted " << index2algname( iAlgo ) << " to " << state << " [slot:" << slotIndex
817  << ", event:" << contextPtr->evt() << "]" << endmsg;
818  // Revise states of algorithms downstream the precedence graph
819  if ( iterate ) sc = m_precSvc->iterate( slot, cs );
820  }
821  }
822  return sc;
823 }
824 
825 //---------------------------------------------------------------------------
826 
833 bool AvalancheSchedulerSvc::isStalled( const EventSlot& slot ) const {
834 
835  if ( !slot.algsStates.containsAny( { AState::DATAREADY, AState::SCHEDULED, AState::RESOURCELESS } ) &&
836  !subSlotAlgsInStates( slot, { AState::DATAREADY, AState::SCHEDULED, AState::RESOURCELESS } ) ) {
837 
838  error() << "*** Stall detected, event context: " << slot.eventContext.get() << endmsg;
839 
840  return true;
841  }
842  return false;
843 }
844 
845 //---------------------------------------------------------------------------
846 
852  const uint slotIdx = eventContext->slot();
853 
854  error() << "Event " << eventContext->evt() << " on slot " << slotIdx << " failed" << endmsg;
855 
856  dumpSchedulerState( msgLevel( MSG::VERBOSE ) ? -1 : slotIdx );
857 
858  // dump temporal and topological precedence analysis (if enabled in the PrecedenceSvc)
859  m_precSvc->dumpPrecedenceRules( m_eventSlots[slotIdx] );
860 
861  // Push into the finished events queue the failed context
862  m_eventSlots[slotIdx].complete = true;
863  m_finishedEvents.push( m_eventSlots[slotIdx].eventContext.release() );
864 }
865 
866 //---------------------------------------------------------------------------
867 
873 
874  // To have just one big message
875  std::ostringstream outputMS;
876 
877  outputMS << "Dumping scheduler state\n"
878  << "=========================================================================================\n"
879  << "++++++++++++++++++++++++++++++++++++ SCHEDULER STATE ++++++++++++++++++++++++++++++++++++\n"
880  << "=========================================================================================\n\n";
881 
882  //===========================================================================
883 
884  outputMS << "------------------ Last schedule: Task/Event/Slot/Thread/State Mapping "
885  << "------------------\n\n";
886 
887  // Figure if TimelineSvc is available (used below to detect threads IDs)
888  auto timelineSvc = serviceLocator()->service<ITimelineSvc>( "TimelineSvc", false );
889  if ( !timelineSvc.isValid() || !timelineSvc->isEnabled() ) {
890  outputMS << "WARNING Enable TimelineSvc in record mode (RecordTimeline = True) to trace the mapping\n";
891  } else {
892 
893  // Figure optimal printout layout
894  size_t indt( 0 );
895  for ( auto& slot : m_eventSlots ) {
896 
897  const auto& schedAlgs = slot.algsStates.algsInState( AState::SCHEDULED );
898  for ( uint algIndex : schedAlgs ) {
899  if ( index2algname( algIndex ).length() > indt ) indt = index2algname( algIndex ).length();
900  }
901  }
902 
903  // Figure the last running schedule across all slots
904  for ( auto& slot : m_eventSlots ) {
905 
906  const auto& schedAlgs = slot.algsStates.algsInState( AState::SCHEDULED );
907  for ( uint algIndex : schedAlgs ) {
908 
909  const std::string& algoName{ index2algname( algIndex ) };
910 
911  outputMS << " task: " << std::setw( indt ) << algoName << " evt/slot: " << slot.eventContext->evt() << "/"
912  << slot.eventContext->slot();
913 
914  // Try to get POSIX threads IDs the currently running tasks are scheduled to
915  if ( timelineSvc.isValid() ) {
916  TimelineEvent te{};
917  te.algorithm = algoName;
918  te.slot = slot.eventContext->slot();
919  te.event = slot.eventContext->evt();
920 
921  if ( timelineSvc->getTimelineEvent( te ) )
922  outputMS << " thread.id: 0x" << std::hex << te.thread << std::dec;
923  else
924  outputMS << " thread.id: [unknown]"; // this means a task has just
925  // been signed off as SCHEDULED,
926  // but has not been assigned to a thread yet
927  // (i.e., not running yet)
928  }
929  outputMS << " state: [" << m_algExecStateSvc->algExecState( algoName, *( slot.eventContext ) ) << "]\n";
930  }
931  }
932  }
933 
934  //===========================================================================
935 
936  outputMS << "\n---------------------------- Task/CF/FSM Mapping "
937  << ( 0 > iSlot ? "[all slots] --" : "[target slot] " ) << "--------------------------\n\n";
938 
939  int slotCount = -1;
940  bool wasAlgError = ( iSlot >= 0 ) ? m_eventSlots[iSlot].algsStates.containsAny( { AState::ERROR } ) ||
941  subSlotAlgsInStates( m_eventSlots[iSlot], { AState::ERROR } )
942  : false;
943 
944  for ( auto& slot : m_eventSlots ) {
945  ++slotCount;
946  if ( slot.complete ) continue;
947 
948  outputMS << "[ slot: "
949  << ( slot.eventContext->valid() ? std::to_string( slot.eventContext->slot() ) : "[ctx invalid]" )
950  << ", event: "
951  << ( slot.eventContext->valid() ? std::to_string( slot.eventContext->evt() ) : "[ctx invalid]" );
952 
953  if ( slot.eventContext->eventID().isValid() ) { outputMS << ", eventID: " << slot.eventContext->eventID(); }
954  outputMS << " ]:\n\n";
955 
956  if ( 0 > iSlot || iSlot == slotCount ) {
957 
958  // If an alg has thrown an error then it's not a failure of the CF/DF graph
959  if ( wasAlgError ) {
960  outputMS << "ERROR alg(s):";
961  int errorCount = 0;
962  const auto& errorAlgs = slot.algsStates.algsInState( AState::ERROR );
963  for ( uint algIndex : errorAlgs ) {
964  outputMS << " " << index2algname( algIndex );
965  ++errorCount;
966  }
967  if ( errorCount == 0 ) outputMS << " in subslot(s)";
968  outputMS << "\n\n";
969  } else {
970  // Snapshot of the Control Flow and FSM states
971  outputMS << m_precSvc->printState( slot ) << "\n";
972  }
973 
974  // Mention sub slots (this is expensive if the number of sub-slots is high)
975  if ( m_verboseSubSlots && !slot.allSubSlots.empty() ) {
976  outputMS << "\nNumber of sub-slots: " << slot.allSubSlots.size() << "\n\n";
977  auto slotID = slot.eventContext->valid() ? std::to_string( slot.eventContext->slot() ) : "[ctx invalid]";
978  for ( auto& ss : slot.allSubSlots ) {
979  outputMS << "[ slot: " << slotID << ", sub-slot: "
980  << ( ss.eventContext->valid() ? std::to_string( ss.eventContext->subSlot() ) : "[ctx invalid]" )
981  << ", entry: " << ss.entryPoint << ", event: "
982  << ( ss.eventContext->valid() ? std::to_string( ss.eventContext->evt() ) : "[ctx invalid]" )
983  << " ]:\n\n";
984  if ( wasAlgError ) {
985  outputMS << "ERROR alg(s):";
986  const auto& errorAlgs = ss.algsStates.algsInState( AState::ERROR );
987  for ( uint algIndex : errorAlgs ) { outputMS << " " << index2algname( algIndex ); }
988  outputMS << "\n\n";
989  } else {
990  // Snapshot of the Control Flow and FSM states in sub slot
991  outputMS << m_precSvc->printState( ss ) << "\n";
992  }
993  }
994  }
995  }
996  }
997 
998  //===========================================================================
999 
1000  if ( 0 <= iSlot && !wasAlgError ) {
1001  outputMS << "\n------------------------------ Algorithm Execution States -----------------------------\n\n";
1002  m_algExecStateSvc->dump( outputMS, *( m_eventSlots[iSlot].eventContext ) );
1003  }
1004 
1005  outputMS << "\n=========================================================================================\n"
1006  << "++++++++++++++++++++++++++++++++++++++ END OF DUMP ++++++++++++++++++++++++++++++++++++++\n"
1007  << "=========================================================================================\n\n";
1008 
1009  info() << outputMS.str() << endmsg;
1010 }
1011 
1012 //---------------------------------------------------------------------------
1013 
1015 
1016  // Check if a free Algorithm instance is available
1017  StatusCode getAlgSC( m_algResourcePool->acquireAlgorithm( ts.algName, ts.algPtr ) );
1018 
1019  // If an instance is available, proceed to scheduling
1020  StatusCode sc;
1021  if ( getAlgSC.isSuccess() ) {
1022 
1023  // Decide how to schedule the task and schedule it
1024  if ( -100 != m_threadPoolSize ) {
1025 
1026  // Cache values before moving the TaskSpec further
1027  unsigned int algIndex{ ts.algIndex };
1028  std::string_view algName( ts.algName );
1029  unsigned int algRank{ ts.algRank };
1030  bool asynchronous{ ts.asynchronous };
1031  int slotIndex{ ts.slotIndex };
1032  EventContext* contextPtr{ ts.contextPtr };
1033 
1034  if ( asynchronous ) {
1035  // Add to asynchronous scheduled queue
1037 
1038  // Schedule task
1039  m_fiberManager->schedule( AlgTask( this, serviceLocator(), m_algExecStateSvc, asynchronous ) );
1040  }
1041 
1042  if ( !asynchronous ) {
1043  // Add the algorithm to the scheduled queue
1044  m_scheduledQueue.push( std::move( ts ) );
1045 
1046  // Prepare a TBB task that will execute the Algorithm according to the above queued specs
1047  m_arena->enqueue( AlgTask( this, serviceLocator(), m_algExecStateSvc, asynchronous ) );
1048  ++m_algosInFlight;
1049  }
1050  sc = revise( algIndex, contextPtr, AState::SCHEDULED );
1051 
1052  ON_DEBUG debug() << "Scheduled " << algName << " [slot:" << slotIndex << ", event:" << contextPtr->evt()
1053  << ", rank:" << algRank << ", asynchronous:" << ( asynchronous ? "yes" : "no" )
1054  << "]. Scheduled algorithms: " << m_algosInFlight + m_blockingAlgosInFlight
1056  ? " (including " + std::to_string( m_blockingAlgosInFlight ) + " - off TBB runtime)"
1057  : "" )
1058  << endmsg;
1059 
1060  } else { // Avoid scheduling via TBB if the pool size is -100. Instead, run here in the scheduler's control thread
1061  // Beojan: I don't think this bit works. ts hasn't been pushed into any queue so AlgTask won't retrieve it
1062  ++m_algosInFlight;
1063  sc = revise( ts.algIndex, ts.contextPtr, AState::SCHEDULED );
1064  AlgTask( this, serviceLocator(), m_algExecStateSvc, ts.asynchronous )();
1065  --m_algosInFlight;
1066  }
1067  } else { // if no Algorithm instance available, retry later
1068 
1069  sc = revise( ts.algIndex, ts.contextPtr, AState::RESOURCELESS );
1070  // Add the algorithm to the retry queue
1071  m_retryQueue.push( std::move( ts ) );
1072  }
1073 
1075 
1076  return sc;
1077 }
1078 
1079 //---------------------------------------------------------------------------
1080 
1085 
1086  Gaudi::Hive::setCurrentContext( ts.contextPtr );
1087 
1088  --m_algosInFlight;
1089 
1090  const AlgExecState& algstate = m_algExecStateSvc->algExecState( ts.algPtr, *( ts.contextPtr ) );
1091  AState state = algstate.execStatus().isSuccess()
1092  ? ( algstate.filterPassed() ? AState::EVTACCEPTED : AState::EVTREJECTED )
1093  : AState::ERROR;
1094 
1095  // Update algorithm state and revise the downstream states
1096  auto sc = revise( ts.algIndex, ts.contextPtr, state, true );
1097 
1098  ON_DEBUG debug() << "Executed " << ts.algName << " [slot:" << ts.slotIndex << ", event:" << ts.contextPtr->evt()
1099  << ", rank:" << ts.algRank << ", asynchronous:" << ( ts.asynchronous ? "yes" : "no" )
1100  << "]. Scheduled algorithms: " << m_algosInFlight + m_blockingAlgosInFlight
1102  ? " (including " + std::to_string( m_blockingAlgosInFlight ) + " - off TBB runtime)"
1103  : "" )
1104  << endmsg;
1105 
1106  // Prompt a call to updateStates
1107  m_needsUpdate.store( true );
1108  return sc;
1109 }
1110 
1111 //---------------------------------------------------------------------------
1112 
1113 // Method to inform the scheduler about event views
1114 
1116  std::unique_ptr<EventContext> viewContext ) {
1117  // Prevent view nesting
1118  if ( sourceContext->usesSubSlot() ) {
1119  fatal() << "Attempted to nest EventViews at node " << nodeName << ": this is not supported" << endmsg;
1120  return StatusCode::FAILURE;
1121  }
1122 
1123  ON_VERBOSE verbose() << "Queuing a view for [" << viewContext.get() << "]" << endmsg;
1124 
1125  // It's not possible to create an std::functional from a move-capturing lambda
1126  // So, we have to release the unique pointer
1127  auto action = [this, slotIndex = sourceContext->slot(), viewContextPtr = viewContext.release(),
1128  &nodeName]() -> StatusCode {
1129  // Attach the sub-slot to the top-level slot
1130  EventSlot& topSlot = this->m_eventSlots[slotIndex];
1131 
1132  if ( viewContextPtr ) {
1133  // Re-create the unique pointer
1134  auto viewContext = std::unique_ptr<EventContext>( viewContextPtr );
1135  topSlot.addSubSlot( std::move( viewContext ), nodeName );
1136  return StatusCode::SUCCESS;
1137  } else {
1138  // Disable the view node if there are no views
1139  topSlot.disableSubSlots( nodeName );
1140  return StatusCode::SUCCESS;
1141  }
1142  };
1143 
1144  m_actionsQueue.push( std::move( action ) );
1145 
1146  return StatusCode::SUCCESS;
1147 }
1148 
1149 //---------------------------------------------------------------------------
1150 
1151 // Sample occupancy at fixed interval (ms)
1152 // Negative value to deactivate, 0 to snapshot every change
1153 // Each sample, apply the callback function to the result
1154 
1155 void AvalancheSchedulerSvc::recordOccupancy( int samplePeriod, std::function<void( OccupancySnapshot )> callback ) {
1156 
1157  auto action = [this, samplePeriod, callback = std::move( callback )]() -> StatusCode {
1158  if ( samplePeriod < 0 ) {
1160  } else {
1163  }
1164  return StatusCode::SUCCESS;
1165  };
1166 
1167  m_actionsQueue.push( std::move( action ) );
1168 }
1169 
1171  const std::map<std::string, DataObjIDColl>& outDeps ) const {
1172  // Both maps should have the same algorithm entries
1173  assert( inDeps.size() == outDeps.size() );
1174 
1175  // Check file extension
1176  enum class FileType : short { UNKNOWN, DOT, MD };
1177  std::regex fileExtensionRegexDot( ".dot$" );
1178  std::regex fileExtensionRegexMd( ".md$" );
1179 
1180  std::string fileName = m_dataDepsGraphFile.value();
1181  FileType fileExtension = FileType::UNKNOWN;
1182  if ( std::regex_search( m_dataDepsGraphFile.value(), fileExtensionRegexDot ) ) {
1183  fileExtension = FileType::DOT;
1184  } else if ( std::regex_search( m_dataDepsGraphFile.value(), fileExtensionRegexMd ) ) {
1185  fileExtension = FileType::MD;
1186  } else {
1187  fileExtension = FileType::DOT;
1188  fileName = fileName + ".dot";
1189  }
1190  info() << "Dumping data dependencies graph to file: " << fileName << endmsg;
1191 
1192  std::string startGraph = "";
1193  std::string stopGraph = "";
1194  // define functions
1195  std::function<std::string( const std::string&, const std::string& )> defineAlg;
1196  std::function<std::string( const DataObjID& )> defineObj;
1197  std::function<std::string( const DataObjID&, const std::string& )> defineInput;
1198  std::function<std::string( const std::string&, const DataObjID& )> defineOutput;
1199 
1200  if ( fileExtension == FileType::DOT ) {
1201  // .dot file
1202  startGraph = "digraph datadeps {\nrankdir=\"LR\";\n\n";
1203  stopGraph = "\n}\n";
1204 
1205  defineAlg = []( const std::string& alg, const std::string& idx ) -> std::string {
1206  return "Alg_" + idx + " [label=\"" + alg + "\";shape=box];\n";
1207  };
1208 
1209  defineObj = []( const DataObjID& obj ) -> std::string {
1210  return "obj_" + std::to_string( obj.hash() ) + " [label=\"" + obj.key() + "\"];\n";
1211  };
1212 
1213  defineInput = []( const DataObjID& obj, const std::string& alg ) -> std::string {
1214  return "obj_" + std::to_string( obj.hash() ) + " -> " + "Alg_" + alg + ";\n";
1215  };
1216 
1217  defineOutput = []( const std::string& alg, const DataObjID& obj ) -> std::string {
1218  return "Alg_" + alg + " -> " + "obj_" + std::to_string( obj.hash() ) + ";\n";
1219  };
1220  } else {
1221  // .md file
1222  startGraph = "```mermaid\ngraph LR;\n\n";
1223  stopGraph = "\n```\n";
1224 
1225  defineAlg = []( const std::string& alg, const std::string& idx ) -> std::string {
1226  return "Alg_" + idx + "{{" + alg + "}}\n";
1227  };
1228 
1229  defineObj = []( const DataObjID& obj ) -> std::string {
1230  return "obj_" + std::to_string( obj.hash() ) + ">" + obj.key() + "]\n";
1231  };
1232 
1233  defineInput = []( const DataObjID& obj, const std::string& alg ) -> std::string {
1234  return "obj_" + std::to_string( obj.hash() ) + " --> " + "Alg_" + alg + "\n";
1235  };
1236 
1237  defineOutput = []( const std::string& alg, const DataObjID& obj ) -> std::string {
1238  return "Alg_" + alg + " --> " + "obj_" + std::to_string( obj.hash() ) + "\n";
1239  };
1240  } // fileExtension
1241 
1242  std::ofstream dataDepthGraphFile( m_dataDepsGraphFile.value(), std::ofstream::out );
1243  dataDepthGraphFile << startGraph;
1244 
1245  // define algs and objects
1246  std::set<std::size_t> definedObjects;
1247 
1248  // Regex for selection of algs and objects
1249  std::regex algNameRegex( m_dataDepsGraphAlgoPattern.value() );
1250  std::regex objNameRegex( m_dataDepsGraphObjectPattern.value() );
1251 
1252  // inDeps and outDeps should have the same entries
1253  std::size_t algoIndex = 0ul;
1254  for ( const auto& [name, ideps] : inDeps ) {
1255  if ( not std::regex_search( name, algNameRegex ) ) continue;
1256  dataDepthGraphFile << defineAlg( name, std::to_string( algoIndex ) );
1257 
1258  // inputs
1259  for ( const auto& dep : ideps ) {
1260  if ( not std::regex_search( dep.fullKey(), objNameRegex ) ) continue;
1261 
1262  if ( definedObjects.find( dep.hash() ) == definedObjects.end() ) {
1263  definedObjects.insert( dep.hash() );
1264  dataDepthGraphFile << defineObj( dep );
1265  }
1266  dataDepthGraphFile << defineInput( dep, std::to_string( algoIndex ) );
1267  } // loop on ideps
1268 
1269  const auto& odeps = outDeps.at( name );
1270  for ( const auto& dep : odeps ) {
1271  if ( not std::regex_search( dep.fullKey(), objNameRegex ) ) continue;
1272 
1273  if ( definedObjects.find( dep.hash() ) == definedObjects.end() ) {
1274  definedObjects.insert( dep.hash() );
1275  dataDepthGraphFile << defineObj( dep );
1276  }
1277  dataDepthGraphFile << defineOutput( std::to_string( algoIndex ), dep );
1278  } // loop on odeps
1279 
1280  ++algoIndex;
1281  } // loop on inDeps
1282 
1283  // end the file
1284  dataDepthGraphFile << stopGraph;
1285  dataDepthGraphFile.close();
1286 
1287  return StatusCode::SUCCESS;
1288 }
IOTest.evt
evt
Definition: IOTest.py:107
EventSlot::eventContext
std::unique_ptr< EventContext > eventContext
Cache for the eventContext.
Definition: EventSlot.h:83
AvalancheSchedulerSvc::m_whiteboard
SmartIF< IHiveWhiteBoard > m_whiteboard
A shortcut to the whiteboard.
Definition: AvalancheSchedulerSvc.h:268
Gaudi::Hive::setCurrentContext
GAUDI_API void setCurrentContext(const EventContext *ctx)
Definition: ThreadLocalContext.cpp:41
PrecedenceSvc
A service to resolve the task execution precedence.
Definition: PrecedenceSvc.h:31
std::vector::resize
T resize(T... args)
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: PropertyBase.h:39
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:118
AvalancheSchedulerSvc::m_useDataLoader
Gaudi::Property< std::string > m_useDataLoader
Definition: AvalancheSchedulerSvc.h:208
std::string
STL class.
AvalancheSchedulerSvc::TaskSpec
Struct to hold entries in the alg queues.
Definition: AvalancheSchedulerSvc.h:323
AvalancheSchedulerSvc::finalize
StatusCode finalize() override
Finalise.
Definition: AvalancheSchedulerSvc.cpp:416
std::list< IAlgorithm * >
Gaudi::Algorithm::acceptDHVisitor
void acceptDHVisitor(IDataHandleVisitor *) const override
Definition: Algorithm.cpp:188
std::move
T move(T... args)
Gaudi::Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:528
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:314
AvalancheSchedulerSvc::m_optimizationMode
Gaudi::Property< std::string > m_optimizationMode
Definition: AvalancheSchedulerSvc.h:185
std::unordered_set< DataObjID, DataObjID_Hasher >
std::vector::reserve
T reserve(T... args)
ON_VERBOSE
#define ON_VERBOSE
Definition: AvalancheSchedulerSvc.cpp:45
AvalancheSchedulerSvc::ACTIVE
@ ACTIVE
Definition: AvalancheSchedulerSvc.h:163
concurrency::PrecedenceRulesGraph::getControlFlowNodeCounter
unsigned int getControlFlowNodeCounter() const
Get total number of control flow graph nodes.
Definition: PrecedenceRulesGraph.h:659
gaudirun.s
string s
Definition: gaudirun.py:346
std::vector
STL class.
std::unordered_set::find
T find(T... args)
std::unordered_set::size
T size(T... args)
AvalancheSchedulerSvc::iterate
StatusCode iterate()
Loop on all slots to schedule DATAREADY algorithms and sign off ready events.
Definition: AvalancheSchedulerSvc.cpp:658
EventSlot
Class representing an event slot.
Definition: EventSlot.h:24
AlgsExecutionStates
Definition: AlgsExecutionStates.h:38
DataHandleHolderBase::addDependency
void addDependency(const DataObjID &id, const Gaudi::DataHandle::Mode &mode) override
Definition: DataHandleHolderBase.h:86
std::chrono::duration
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:19
AvalancheSchedulerSvc::m_scheduledAsynchronousQueue
tbb::concurrent_priority_queue< TaskSpec, AlgQueueSort > m_scheduledAsynchronousQueue
Definition: AvalancheSchedulerSvc.h:360
AvalancheSchedulerSvc::m_lastSnapshot
std::chrono::system_clock::time_point m_lastSnapshot
Definition: AvalancheSchedulerSvc.h:167
PrecedenceSvc::getRules
const concurrency::PrecedenceRulesGraph * getRules() const
Precedence rules accessor.
Definition: PrecedenceSvc.h:75
std::stringstream
STL class.
std::unique_ptr::get
T get(T... args)
EventStatus::Success
@ Success
Definition: IAlgExecStateSvc.h:73
std::unique_ptr::release
T release(T... args)
IAlgorithm::type
virtual const std::string & type() const =0
The type of the algorithm.
ConcurrencyFlags.h
EventContext::usesSubSlot
bool usesSubSlot() const
Definition: EventContext.h:53
AvalancheSchedulerSvc::m_dataDepsGraphAlgoPattern
Gaudi::Property< std::string > m_dataDepsGraphAlgoPattern
Definition: AvalancheSchedulerSvc.h:229
std::vector::back
T back(T... args)
std::function
std::any_of
T any_of(T... args)
AvalancheSchedulerSvc::m_scheduledQueue
tbb::concurrent_priority_queue< TaskSpec, AlgQueueSort > m_scheduledQueue
Queues for scheduled algorithms.
Definition: AvalancheSchedulerSvc.h:359
AvalancheSchedulerSvc::m_fiberManager
std::unique_ptr< FiberManager > m_fiberManager
Definition: AvalancheSchedulerSvc.h:371
AvalancheSchedulerSvc::schedule
StatusCode schedule(TaskSpec &&)
Definition: AvalancheSchedulerSvc.cpp:1014
AvalancheSchedulerSvc::m_showControlFlow
Gaudi::Property< bool > m_showControlFlow
Definition: AvalancheSchedulerSvc.h:219
AvalancheSchedulerSvc::m_needsUpdate
std::atomic< bool > m_needsUpdate
Definition: AvalancheSchedulerSvc.h:364
DHHVisitor
Definition: DataHandleHolderVisitor.h:21
GaudiPartProp.tests.id
id
Definition: tests.py:111
std::sort
T sort(T... args)
AvalancheSchedulerSvc::m_enableCondSvc
Gaudi::Property< bool > m_enableCondSvc
Definition: AvalancheSchedulerSvc.h:211
AvalancheSchedulerSvc::deactivate
StatusCode deactivate()
Deactivate scheduler.
Definition: AvalancheSchedulerSvc.cpp:507
std::unique_ptr::reset
T reset(T... args)
CommonMessaging< implements< IService, IProperty, IStateful > >::msgLevel
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
Definition: CommonMessaging.h:148
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:222
ThreadPoolSvc.h
AvalancheSchedulerSvc::m_eventSlots
std::vector< EventSlot > m_eventSlots
Vector of events slots.
Definition: AvalancheSchedulerSvc.h:271
Gaudi::DataHandle::Writer
@ Writer
Definition: DataHandle.h:40
concurrency::AlgorithmNode::getAlgoIndex
unsigned int getAlgoIndex() const
Get algorithm index.
Definition: PrecedenceRulesGraph.h:520
AvalancheSchedulerSvc::m_numOffloadThreads
Gaudi::Property< int > m_numOffloadThreads
Definition: AvalancheSchedulerSvc.h:192
AvalancheSchedulerSvc::m_arena
tbb::task_arena * m_arena
Definition: AvalancheSchedulerSvc.h:370
AvalancheSchedulerSvc::m_algExecStateSvc
SmartIF< IAlgExecStateSvc > m_algExecStateSvc
Algorithm execution state manager.
Definition: AvalancheSchedulerSvc.h:280
EventSlot::complete
bool complete
Flags completion of the event.
Definition: EventSlot.h:89
DataObjID::fullKey
std::string fullKey() const
combination of the key and the ClassName, mostly for debugging
Definition: DataObjID.cpp:99
std::hex
T hex(T... args)
AvalancheSchedulerSvc::FAILURE
@ FAILURE
Definition: AvalancheSchedulerSvc.h:163
AvalancheSchedulerSvc::m_condSvc
SmartIF< ICondSvc > m_condSvc
A shortcut to service for Conditions handling.
Definition: AvalancheSchedulerSvc.h:283
AvalancheSchedulerSvc::eventFailed
void eventFailed(EventContext *eventContext)
Method to execute if an event failed.
Definition: AvalancheSchedulerSvc.cpp:851
ManySmallAlgs.alg
alg
Definition: ManySmallAlgs.py:81
TimelineEvent
Definition: ITimelineSvc.h:23
AvalancheSchedulerSvc::m_threadPoolSize
Gaudi::Property< int > m_threadPoolSize
Definition: AvalancheSchedulerSvc.h:170
DHHVisitor::owners_names_of
std::vector< std::string > owners_names_of(const DataObjID &id, bool with_main=false) const
Definition: DataHandleHolderVisitor.cpp:82
EventSlot::addSubSlot
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)
Definition: EventSlot.h:61
EventStatus::AlgStall
@ AlgStall
Definition: IAlgExecStateSvc.h:73
AvalancheSchedulerSvc::m_dataDepsGraphObjectPattern
Gaudi::Property< std::string > m_dataDepsGraphObjectPattern
Definition: AvalancheSchedulerSvc.h:234
AvalancheSchedulerSvc::m_maxEventsInFlight
size_t m_maxEventsInFlight
Definition: AvalancheSchedulerSvc.h:373
SmartIF::isValid
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:72
AvalancheSchedulerSvc::m_maxBlockingAlgosInFlight
Gaudi::Property< unsigned int > m_maxBlockingAlgosInFlight
Definition: AvalancheSchedulerSvc.h:180
GaudiUtils::operator<<
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)".
Definition: SerializeSTL.h:90
Service::name
const std::string & name() const override
Retrieve name of the service
Definition: Service.cpp:332
StatusCode
Definition: StatusCode.h:65
std::thread
STL class.
AlgTask.h
ITimelineSvc
Definition: ITimelineSvc.h:37
std::vector::at
T at(T... args)
IAlgorithm
Definition: IAlgorithm.h:38
std::atomic::load
T load(T... args)
std::thread::hardware_concurrency
T hardware_concurrency(T... args)
std::ofstream
STL class.
AvalancheSchedulerSvc::m_maxParallelismExtra
Gaudi::Property< int > m_maxParallelismExtra
Definition: AvalancheSchedulerSvc.h:175
compareRootHistos.ts
ts
Definition: compareRootHistos.py:488
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:51
AvalancheSchedulerSvc::m_enablePreemptiveBlockingTasks
Gaudi::Property< bool > m_enablePreemptiveBlockingTasks
Definition: AvalancheSchedulerSvc.h:189
FiberManager::schedule
void schedule(F &&func)
Schedule work to run on the asynchronous pool.
Definition: FiberManager.h:66
Io::UNKNOWN
@ UNKNOWN
Definition: IFileMgr.h:156
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:90
AvalancheSchedulerSvc::m_whiteboardSvcName
Gaudi::Property< std::string > m_whiteboardSvcName
Definition: AvalancheSchedulerSvc.h:179
AvalancheSchedulerSvc
Definition: AvalancheSchedulerSvc.h:114
AvalancheSchedulerSvc::m_checkOutput
Gaudi::Property< bool > m_checkOutput
Definition: AvalancheSchedulerSvc.h:199
EventSlot::reset
void reset(EventContext *theeventContext)
Reset all resources in order to reuse the slot (thread-unsafe)
Definition: EventSlot.h:49
DataHandleHolderVisitor.h
Gaudi::Property::value
const ValueType & value() const
Definition: Property.h:239
std::to_string
T to_string(T... args)
EventSlot::disableSubSlots
void disableSubSlots(const std::string &nodeName)
Disable event views for a given CF view node by registering an empty container Contact B.
Definition: EventSlot.h:78
event_timeout_check.app
app
Definition: event_timeout_check.py:41
AlgExecState::execStatus
const StatusCode & execStatus() const
Definition: IAlgExecStateSvc.h:43
std::ofstream::close
T close(T... args)
AvalancheSchedulerSvc::m_simulateExecution
Gaudi::Property< bool > m_simulateExecution
Definition: AvalancheSchedulerSvc.h:182
AvalancheSchedulerSvc::recordOccupancy
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...
Definition: AvalancheSchedulerSvc.cpp:1155
AvalancheSchedulerSvc::index2algname
const std::string & index2algname(unsigned int index)
Convert an integer to a name.
Definition: AvalancheSchedulerSvc.h:259
Algorithm.h
EventSlot::allSubSlots
std::vector< EventSlot > allSubSlots
Actual sub-slot instances.
Definition: EventSlot.h:100
AvalancheSchedulerSvc::AState
AlgsExecutionStates::State AState
Definition: AvalancheSchedulerSvc.h:160
AvalancheSchedulerSvc::INACTIVE
@ INACTIVE
Definition: AvalancheSchedulerSvc.h:163
std::ofstream::open
T open(T... args)
SmartIF< IMessageSvc >
genconfuser.verbose
verbose
Definition: genconfuser.py:28
AvalancheSchedulerSvc::m_algosInFlight
unsigned int m_algosInFlight
Number of algorithms presently in flight.
Definition: AvalancheSchedulerSvc.h:286
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:203
std::map
STL class.
AvalancheSchedulerSvc::tryPopFinishedEvent
StatusCode tryPopFinishedEvent(EventContext *&eventContext) override
Try to fetch an event from the scheduler.
Definition: AvalancheSchedulerSvc.cpp:638
AvalancheSchedulerSvc::scheduleEventView
virtual StatusCode scheduleEventView(const EventContext *sourceContext, const std::string &nodeName, std::unique_ptr< EventContext > viewContext) override
Method to inform the scheduler about event views.
Definition: AvalancheSchedulerSvc.cpp:1115
AvalancheSchedulerSvc::m_algResourcePool
SmartIF< IAlgResourcePool > m_algResourcePool
Cache for the algorithm resource pool.
Definition: AvalancheSchedulerSvc.h:315
AvalancheSchedulerSvc::freeSlots
unsigned int freeSlots() override
Get free slots number.
Definition: AvalancheSchedulerSvc.cpp:607
std::regex
Cause::source::Root
@ Root
AvalancheSchedulerSvc::m_showDataDeps
Gaudi::Property< bool > m_showDataDeps
Definition: AvalancheSchedulerSvc.h:213
AvalancheSchedulerSvc::m_maxAlgosInFlight
size_t m_maxAlgosInFlight
Definition: AvalancheSchedulerSvc.h:374
DataObjID
Definition: DataObjID.h:47
std::regex_search
T regex_search(T... args)
AvalancheSchedulerSvc::dumpState
void dumpState() override
Dump scheduler state for all slots.
Definition: AvalancheSchedulerSvc.cpp:611
AvalancheSchedulerSvc::initialize
StatusCode initialize() override
Initialise.
Definition: AvalancheSchedulerSvc.cpp:76
AlgsExecutionStates::containsAny
bool containsAny(std::initializer_list< State > l) const
check if the collection contains at least one state of any listed types
Definition: AlgsExecutionStates.h:75
StatusCode::ignore
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition: StatusCode.h:139
std::chrono::duration::min
T min(T... args)
std::ostringstream
STL class.
ON_DEBUG
#define ON_DEBUG
Definition: AvalancheSchedulerSvc.cpp:44
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
ThreadLocalContext.h
std::vector::emplace_back
T emplace_back(T... args)
concurrency::PrecedenceRulesGraph::getAlgorithmNode
AlgorithmNode * getAlgorithmNode(const std::string &algoName) const
Get the AlgorithmNode from by algorithm name using graph index.
Definition: PrecedenceRulesGraph.h:651
AvalancheSchedulerSvc::m_dumpIntraEventDynamics
Gaudi::Property< bool > m_dumpIntraEventDynamics
Definition: AvalancheSchedulerSvc.h:187
AlgsExecutionStates::set
StatusCode set(unsigned int iAlgo, State newState)
Definition: AlgsExecutionStates.cpp:23
AvalancheSchedulerSvc::m_retryQueue
std::queue< TaskSpec > m_retryQueue
Definition: AvalancheSchedulerSvc.h:361
MSG::VERBOSE
@ VERBOSE
Definition: IMessageSvc.h:25
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
EventContext::subSlot
ContextID_t subSlot() const
Definition: EventContext.h:52
Cause::source::Task
@ Task
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:86
AtlasMCRecoScenario.threads
threads
Definition: AtlasMCRecoScenario.py:29
DataHandleHolderBase::outputDataObjs
const DataObjIDColl & outputDataObjs() const override
Definition: DataHandleHolderBase.h:84
AvalancheSchedulerSvc::m_snapshotInterval
std::chrono::duration< int64_t, std::milli > m_snapshotInterval
Definition: AvalancheSchedulerSvc.h:166
std::vector::begin
T begin(T... args)
Gaudi::Decays::valid
bool valid(Iterator begin, Iterator end)
check the validness of the trees or nodes
Definition: Nodes.h:36
std
STL namespace.
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
std::unordered_set::insert
T insert(T... args)
AvalancheSchedulerSvc::m_threadPoolSvc
SmartIF< IThreadPoolSvc > m_threadPoolSvc
Definition: AvalancheSchedulerSvc.h:369
FiberManager.h
MSG::ERROR
@ ERROR
Definition: IMessageSvc.h:25
AvalancheSchedulerSvc::m_dataDepsGraphFile
Gaudi::Property< std::string > m_dataDepsGraphFile
Definition: AvalancheSchedulerSvc.h:224
EventContext
Definition: EventContext.h:34
AlgsExecutionStates::State
State
Execution states of the algorithms Must have contiguous integer values 0, 1...
Definition: AlgsExecutionStates.h:42
TimelineEvent::algorithm
std::string algorithm
Definition: ITimelineSvc.h:31
Gaudi::Property::toString
std::string toString() const override
value -> string
Definition: Property.h:417
AvalancheSchedulerSvc::revise
StatusCode revise(unsigned int iAlgo, EventContext *contextPtr, AState state, bool iterate=false)
Definition: AvalancheSchedulerSvc.cpp:792
AlgExecState::filterPassed
bool filterPassed() const
Definition: IAlgExecStateSvc.h:41
AvalancheSchedulerSvc::activate
void activate()
Activate scheduler.
Definition: AvalancheSchedulerSvc.cpp:450
AvalancheSchedulerSvc::m_actionsQueue
tbb::concurrent_bounded_queue< action > m_actionsQueue
Queue where closures are stored and picked for execution.
Definition: AvalancheSchedulerSvc.h:320
std::unordered_set::empty
T empty(T... args)
AvalancheSchedulerSvc::m_algname_index_map
std::unordered_map< std::string, unsigned int > m_algname_index_map
Map to bookkeep the information necessary to the name2index conversion.
Definition: AvalancheSchedulerSvc.h:253
Properties.v
v
Definition: Properties.py:122
AvalancheSchedulerSvc::m_checkDeps
Gaudi::Property< bool > m_checkDeps
Definition: AvalancheSchedulerSvc.h:197
AvalancheSchedulerSvc::isStalled
bool isStalled(const EventSlot &) const
Check if scheduling in a particular slot is in a stall.
Definition: AvalancheSchedulerSvc.cpp:833
AvalancheSchedulerSvc::AlgTask
friend class AlgTask
Definition: AvalancheSchedulerSvc.h:116
std::ostringstream::str
T str(T... args)
std::atomic::store
T store(T... args)
std::size_t
SerializeSTL.h
DataObjID::hash
std::size_t hash() const
Definition: DataObjID.h:69
DataHandleHolderBase::inputDataObjs
const DataObjIDColl & inputDataObjs() const override
Definition: DataHandleHolderBase.h:83
AvalancheSchedulerSvc::m_thread
std::thread m_thread
The thread in which the activate function runs.
Definition: AvalancheSchedulerSvc.h:250
std::vector::end
T end(T... args)
AvalancheSchedulerSvc::pushNewEvents
StatusCode pushNewEvents(std::vector< EventContext * > &eventContexts) override
Definition: AvalancheSchedulerSvc.cpp:596
AvalancheSchedulerSvc::m_showDataFlow
Gaudi::Property< bool > m_showDataFlow
Definition: AvalancheSchedulerSvc.h:216
IAlgorithm.h
AlgExecState
Definition: IAlgExecStateSvc.h:37
AvalancheSchedulerSvc::m_checkOutputIgnoreList
Gaudi::Property< std::vector< std::string > > m_checkOutputIgnoreList
Definition: AvalancheSchedulerSvc.h:201
std::setw
T setw(T... args)
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
std::max
T max(T... args)
AvalancheSchedulerSvc::signoff
StatusCode signoff(const TaskSpec &)
The call to this method is triggered only from within the AlgTask.
Definition: AvalancheSchedulerSvc.cpp:1084
AlgsExecutionStates::sizeOfSubset
size_t sizeOfSubset(State state) const
Definition: AlgsExecutionStates.h:89
AvalancheSchedulerSvc::m_freeSlots
std::atomic_int m_freeSlots
Atomic to account for asyncronous updates by the scheduler wrt the rest.
Definition: AvalancheSchedulerSvc.h:274
compareRootHistos.state
state
Definition: compareRootHistos.py:496
AvalancheSchedulerSvc::m_blockingAlgosInFlight
unsigned int m_blockingAlgosInFlight
Number of algorithms presently in flight.
Definition: AvalancheSchedulerSvc.h:289
AvalancheSchedulerSvc::m_snapshotCallback
std::function< void(OccupancySnapshot)> m_snapshotCallback
Definition: AvalancheSchedulerSvc.h:168
AvalancheSchedulerSvc::pushNewEvent
StatusCode pushNewEvent(EventContext *eventContext) override
Make an event available to the scheduler.
Definition: AvalancheSchedulerSvc.cpp:538
AvalancheSchedulerSvc::dumpGraphFile
StatusCode dumpGraphFile(const std::map< std::string, DataObjIDColl > &inDeps, const std::map< std::string, DataObjIDColl > &outDeps) const
Definition: AvalancheSchedulerSvc.cpp:1170
AvalancheSchedulerSvc::popFinishedEvent
StatusCode popFinishedEvent(EventContext *&eventContext) override
Blocks until an event is available.
Definition: AvalancheSchedulerSvc.cpp:617
AlgsExecutionStates::algsInState
const boost::container::flat_set< int > algsInState(State state) const
Definition: AlgsExecutionStates.h:83
std::unique_ptr< EventContext >
EventSlot::algsStates
AlgsExecutionStates algsStates
Vector of algorithms states.
Definition: EventSlot.h:85
Cause
Definition: PrecedenceRulesGraph.h:396
AvalancheSchedulerSvc::m_precSvc
SmartIF< IPrecedenceSvc > m_precSvc
A shortcut to the Precedence Service.
Definition: AvalancheSchedulerSvc.h:265
AvalancheSchedulerSvc::m_isActive
std::atomic< ActivationState > m_isActive
Flag to track if the scheduler is active or not.
Definition: AvalancheSchedulerSvc.h:247
AvalancheSchedulerSvc::m_finishedEvents
tbb::concurrent_bounded_queue< EventContext * > m_finishedEvents
Queue of finished events.
Definition: AvalancheSchedulerSvc.h:277
std::set< std::string >
AvalancheSchedulerSvc::m_algname_vect
std::vector< std::string > m_algname_vect
Vector to bookkeep the information necessary to the index2name conversion.
Definition: AvalancheSchedulerSvc.h:259
EventContext::evt
ContextEvt_t evt() const
Definition: EventContext.h:50
AvalancheSchedulerSvc::dumpSchedulerState
void dumpSchedulerState(int iSlot)
Dump the state of the scheduler.
Definition: AvalancheSchedulerSvc.cpp:872
IDataManagerSvc.h
std::thread::join
T join(T... args)
Gaudi::ParticleProperties::index
size_t index(const Gaudi::ParticleProperty *property, const Gaudi::Interfaces::IParticlePropertySvc *service)
helper utility for mapping of Gaudi::ParticleProperty object into non-negative integral sequential id...
Definition: IParticlePropertySvc.cpp:39
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator
Definition: Service.cpp:335
AvalancheSchedulerSvc.h
PrepareBase.out
out
Definition: PrepareBase.py:20
ThreadPoolSvc
A service which initializes a TBB thread pool.
Definition: ThreadPoolSvc.h:38
std::initializer_list
gaudirun.callback
callback
Definition: gaudirun.py:202
std::chrono::system_clock::now
T now(T... args)