| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

HiveSlimEventLoopMgr.cpp
Go to the documentation of this file.
1 // FW includes
2 #include "GaudiKernel/SmartIF.h"
3 #include "GaudiKernel/Incident.h"
4 #include "GaudiKernel/MsgStream.h"
5 #include "GaudiKernel/SvcFactory.h"
6 #include "GaudiKernel/DataObject.h"
7 #include "GaudiKernel/IAlgManager.h"
8 #include "GaudiKernel/IIncidentSvc.h"
9 #include "GaudiKernel/IEvtSelector.h"
10 #include "GaudiKernel/IDataManagerSvc.h"
11 #include "GaudiKernel/IDataProviderSvc.h"
12 #include "GaudiKernel/IConversionSvc.h"
13 #include "GaudiKernel/AppReturnCode.h"
14 #include "GaudiKernel/DataSvc.h"
15 #include "GaudiKernel/IChronoStatSvc.h"
16 #include "GaudiKernel/IIncidentListener.h"
17
18 #include "HistogramAgent.h"
19
20
21 #include "GaudiHive/HiveSlimEventLoopMgr.h"
22
23 #include "GaudiKernel/EventContext.h"
24 #include "GaudiKernel/Algorithm.h"
25
26 #include <GaudiKernel/GaudiException.h>
27
28 #include <GaudiKernel/IScheduler.h>
29
30 // External libraries
31 #include <chrono>
32
33
34 // Instantiation of a static factory class used by clients to create instances of this service
35 DECLARE_SERVICE_FACTORY(HiveSlimEventLoopMgr)
36
37
38 #define ON_DEBUG if (UNLIKELY(outputLevel() <= MSG::DEBUG))
39 #define ON_VERBOSE if (UNLIKELY(outputLevel() <= MSG::VERBOSE))
40
41 #define DEBMSG ON_DEBUG debug()
42 #define VERMSG ON_VERBOSE verbose()
43
44 //--------------------------------------------------------------------------------------------
45 // Standard Constructor
46 //--------------------------------------------------------------------------------------------
47 HiveSlimEventLoopMgr::HiveSlimEventLoopMgr(const std::string& name, ISvcLocator* svcLoc)
48 : base_class(name, svcLoc), m_appMgrUI(svcLoc)
49 {
50 }
51
52 //--------------------------------------------------------------------------------------------
53 // Standard Destructor
54 //--------------------------------------------------------------------------------------------
55 HiveSlimEventLoopMgr::~HiveSlimEventLoopMgr() {
56 m_histoDataMgrSvc.reset();
57 m_histoPersSvc.reset();
58 m_evtDataMgrSvc.reset();
59 m_whiteboard.reset();
60 m_evtSelector.reset();
61 if( m_evtContext ) delete m_evtContext;
62 }
63
64 //--------------------------------------------------------------------------------------------
65 // implementation of IAppMgrUI::initialize
66 //--------------------------------------------------------------------------------------------
67 StatusCode HiveSlimEventLoopMgr::initialize() {
68
69 if ( !m_appMgrUI.isValid() ) {
70 return StatusCode::FAILURE;
71 }
72
73 StatusCode sc = Service::initialize();
74 if ( !sc.isSuccess() ) {
75 error() << "Failed to initialize Service Base class." << endmsg;
76 return StatusCode::FAILURE;
77 }
78
79 // Get the references to the services that are needed by the ApplicationMgr itself
80 m_incidentSvc = serviceLocator()->service("IncidentSvc");
81 if( !m_incidentSvc.isValid() ) {
82 fatal() << "Error retrieving IncidentSvc." << endmsg;
83 return StatusCode::FAILURE;
84 }
85
86 // Setup access to event data services
87 m_evtDataMgrSvc = serviceLocator()->service("EventDataSvc");
88 if( !m_evtDataMgrSvc.isValid() ) {
89 fatal() << "Error retrieving EventDataSvc interface IDataManagerSvc." << endmsg;
90 return StatusCode::FAILURE;
91 }
92 m_whiteboard = serviceLocator()->service("EventDataSvc");
93 if( !m_whiteboard.isValid() ) {
94 fatal() << "Error retrieving EventDataSvc interface IHiveWhiteBoard." << endmsg;
95 return StatusCode::FAILURE;
96 }
97 m_schedulerSvc = serviceLocator()->service(m_schedulerName);
98 if ( !m_schedulerSvc.isValid()){
99 fatal() << "Error retrieving SchedulerSvc interface IScheduler." << endmsg;
100 return StatusCode::FAILURE;
101 }
102 // Obtain the IProperty of the ApplicationMgr
103 m_appMgrProperty = serviceLocator();
104 if ( ! m_appMgrProperty.isValid() ) {
105 fatal() << "IProperty interface not found in ApplicationMgr." << endmsg;
106 return StatusCode::FAILURE;
107 }
108
109 // We do not expect a Event Selector necessarily being declared
110 setProperty(m_appMgrProperty->getProperty("EvtSel")).ignore();
111
112 if( m_evtsel != "NONE" || m_evtsel.length() == 0) {
113 m_evtSelector = serviceLocator()->service("EventSelector");
114 if( m_evtSelector.isValid() ) {
115 // Setup Event Selector
116 sc=m_evtSelector->createContext(m_evtContext);
117 if( !sc.isSuccess() ) {
118 fatal() << "Can not create the event selector Context." << endmsg;
119 return sc;
120 }
121 }
122 else {
123 fatal() << "EventSelector not found." << endmsg;
124 return sc;
125 }
126 }
127 else {
128 m_evtSelector = 0;
129 m_evtContext = 0;
130 if ( m_warnings ) {
131 warning() << "Unable to locate service \"EventSelector\" " << endmsg;
132 warning() << "No events will be processed from external input." << endmsg;
133 }
134 }
135
136 // Setup access to histogramming services
137 m_histoDataMgrSvc = serviceLocator()->service("HistogramDataSvc");
138 if( !m_histoDataMgrSvc.isValid() ) {
139 fatal() << "Error retrieving HistogramDataSvc." << endmsg;
140 return sc;
141 }
142 // Setup histogram persistency
143 m_histoPersSvc = serviceLocator()->service("HistogramPersistencySvc");
144 if( !m_histoPersSvc.isValid() ) {
145 warning() << "Histograms cannot not be saved - though required." << endmsg;
146 return sc;
147 }
148
149 // Setup algorithm resource pool
150 m_algResourcePool = serviceLocator()->service("AlgResourcePool");
151 if( !m_algResourcePool.isValid() ) {
152 fatal() << "Error retrieving AlgResourcePool" << endmsg;
153 return StatusCode::FAILURE;
154 }
155
156 m_algExecStateSvc = serviceLocator()->service("AlgExecStateSvc");
157 if( !m_algExecStateSvc.isValid() ) {
158 fatal() << "Error retrieving AlgExecStateSvc" << endmsg;
159 return StatusCode::FAILURE;
160 }
161
162 std::sort(m_eventNumberBlacklist.begin(), m_eventNumberBlacklist.end());
163 info() << "Found " << m_eventNumberBlacklist.size() << " events in black list" << endmsg;
164
165 return StatusCode::SUCCESS;
166 }
167 //--------------------------------------------------------------------------------------------
168 // implementation of IService::reinitialize
169 //--------------------------------------------------------------------------------------------
170 StatusCode HiveSlimEventLoopMgr::reinitialize() {
171
172
173 // Check to see whether a new Event Selector has been specified
174 setProperty(m_appMgrProperty->getProperty("EvtSel"));
175 if( m_evtsel != "NONE" || m_evtsel.length() == 0) {
176 SmartIF<IService> theSvc(serviceLocator()->service("EventSelector"));
177 SmartIF<IEvtSelector> theEvtSel(theSvc);
178 StatusCode sc;
179 if( theEvtSel.isValid() && ( theEvtSel.get() != m_evtSelector.get() ) ) {
180 // Setup Event Selector
181 if ( m_evtSelector.get() && m_evtContext ) {
182 // Need to release context before switching to new event selector
183 m_evtSelector->releaseContext(m_evtContext);
184 m_evtContext = 0;
185 }
186 m_evtSelector = theEvtSel;
187 if (theSvc->FSMState() == Gaudi::StateMachine::INITIALIZED) {
188 sc = theSvc->reinitialize();
189 if( !sc.isSuccess() ) {
190 error() << "Failure Reinitializing EventSelector "
191 << theSvc->name( ) << endmsg;
192 return sc;
193 }
194 }
195 else {
196 sc = theSvc->sysInitialize();
197 if( !sc.isSuccess() ) {
198 error() << "Failure Initializing EventSelector "
199 << theSvc->name( ) << endmsg;
200 return sc;
201 }
202 }
203 sc = m_evtSelector->createContext(m_evtContext);
204 if( !sc.isSuccess() ) {
205 error() << "Can not create Context " << theSvc->name( ) << endmsg;
206 return sc;
207 }
208
209 }
210 else if ( m_evtSelector.isValid() ) {
211 if ( m_evtContext ) {
212 m_evtSelector->releaseContext(m_evtContext);
213 m_evtContext = 0;
214 }
215 sc = m_evtSelector->createContext(m_evtContext);
216 if( !sc.isSuccess() ) {
217 error() << "Can not create Context " << theSvc->name( ) << endmsg;
218 return sc;
219 }
220 }
221 }
222 else if ( m_evtSelector.isValid() && m_evtContext ) {
223 m_evtSelector->releaseContext(m_evtContext);
224 m_evtSelector = 0;
225 m_evtContext = 0;
226 }
227 return StatusCode::SUCCESS;
228 }
229
230 //--------------------------------------------------------------------------------------------
231 // implementation of IService::stop
232 //--------------------------------------------------------------------------------------------
233 // Removed call to MinimalEventLoopMgr!
234 StatusCode HiveSlimEventLoopMgr::stop() {
235 if ( ! m_endEventFired ) {
236 // Fire pending EndEvent incident
237 m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndEvent));
238 m_endEventFired = true;
239 }
240 return StatusCode::SUCCESS;
241 }
242
243 //--------------------------------------------------------------------------------------------
244 // implementation of IAppMgrUI::finalize
245 //--------------------------------------------------------------------------------------------
246 // Removed call to MinimalEventLoopMgr!
247 StatusCode HiveSlimEventLoopMgr::finalize() {
248
249 StatusCode scRet;
250 StatusCode sc = Service::finalize();
251
252 if (sc.isFailure()) {
253 scRet = StatusCode::FAILURE;
254 error() << "Problems finalizing Service base class" << endmsg;
255 }
256
257 // Save Histograms Now
258 if ( m_histoPersSvc != 0 ) {
259 HistogramAgent agent;
260 sc = m_histoDataMgrSvc->traverseTree( &agent );
261 if( sc.isSuccess() ) {
262 IDataSelector* objects = agent.selectedObjects();
263 // skip /stat entry!
264 if ( objects->size() > 0 ) {
265 IDataSelector::iterator i;
266 for ( i = objects->begin(); i != objects->end(); i++ ) {
267 IOpaqueAddress* pAddr = 0;
268 StatusCode iret = m_histoPersSvc->createRep(*i, pAddr);
269 if ( iret.isSuccess() ) {
270 (*i)->registry()->setAddress(pAddr);
271 }
272 else {
273 sc = iret;
274 }
275 }
276 for ( i = objects->begin(); i != objects->end(); i++ ) {
277 IRegistry* reg = (*i)->registry();
278 StatusCode iret = m_histoPersSvc->fillRepRefs(reg->address(), *i);
279 if ( !iret.isSuccess() ) {
280 sc = iret;
281 }
282 }
283 }
284 if ( sc.isSuccess() ) {
285 info() << "Histograms converted successfully according to request." << endmsg;
286 }
287 else {
288 error() << "Error while saving Histograms." << endmsg;
289 }
290 }
291 else {
292 error() << "Error while traversing Histogram data store" << endmsg;
293 }
294 }
295
296 scRet=sc;
297
298 // Release event selector context
299 if ( m_evtSelector && m_evtContext ) {
300 m_evtSelector->releaseContext(m_evtContext).ignore();
301 m_evtContext = 0;
302 }
303
304 m_incidentSvc = 0; // release
305 m_appMgrUI = 0; // release
306
307 // Release all interfaces...
308 m_histoDataMgrSvc = 0;
309 m_histoPersSvc = 0;
310
311 m_evtSelector = 0;
312 m_whiteboard = 0;
313 m_evtDataMgrSvc = 0;
314
315 return scRet;
316 }
317
318 //--------------------------------------------------------------------------------------------
319 // implementation of executeEvent(void* par)
320 //--------------------------------------------------------------------------------------------
321 StatusCode HiveSlimEventLoopMgr::executeEvent(void* createdEvts_IntPtr) {
322
323 // Leave the interface intact and swallow this C trick.
324 int& createdEvts = *((int*)createdEvts_IntPtr);
325
326 EventContext* evtContext(nullptr);
327
328 // Check if event number is in blacklist
329 if(LIKELY(m_blackListBS != nullptr)){ //we are processing a finite number of events, use bitset blacklist
330 if(m_blackListBS->test(createdEvts)){
331 verbose() << "Event " << createdEvts << " on black list" << endmsg;
332 return StatusCode::RECOVERABLE;
333 }
334 } else if(std::binary_search(m_eventNumberBlacklist.begin(),m_eventNumberBlacklist.end(),createdEvts)){
335
336 verbose() << "Event " << createdEvts << " on black list" << endmsg;
337 return StatusCode::RECOVERABLE;
338 }
339
340 if ( createEventContext(evtContext,createdEvts).isFailure() ){
341 fatal() << "Impossible to create event context" << endmsg;
342 return StatusCode::FAILURE;
343 }
344
345 verbose() << "Beginning to process event " << createdEvts << endmsg;
346
347 // An incident may schedule a stop, in which case is better to exit before the actual execution.
348 // DP have to find out who shoots this
349 /* if ( m_scheduledStop ) {
350 always() << "Terminating event processing loop due to a stop scheduled by an incident listener" << endmsg;
351 return StatusCode::SUCCESS;
352 }*/
353
354
355 StatusCode declEvtRootSc = declareEventRootAddress();
356 if (declEvtRootSc.isFailure()) { // We ran out of events!
357 createdEvts = -1; // Set created event to a negative value: we finished!
358 return StatusCode::SUCCESS;
359 }
360
361 // Fire BeginEvent "Incident"
362 m_incidentSvc->fireIncident(std::unique_ptr<Incident>(new Incident(name(),IncidentType::BeginEvent,*evtContext)));
363
364 // Now add event to the scheduler
365 verbose() << "Adding event " << evtContext->evt()
366 << ", slot " << evtContext->slot()
367 << " to the scheduler" << endmsg;
368
369 m_incidentSvc->fireIncident(std::unique_ptr<Incident>(new Incident(name(), IncidentType::BeginProcessing,*evtContext)));
370
371 StatusCode addEventStatus = m_schedulerSvc->pushNewEvent(evtContext);
372
373 // If this fails, we need to wait for something to complete
374 if (!addEventStatus.isSuccess()){
375 fatal() << "An event processing slot should be now free in the scheduler, but it appears not to be the case." << endmsg;
376 }
377
378 createdEvts++;
379 return StatusCode::SUCCESS;
380
381 }
382
383 //--------------------------------------------------------------------------------------------
384 // implementation of IEventProcessing::executeRun
385 //--------------------------------------------------------------------------------------------
386 StatusCode HiveSlimEventLoopMgr::executeRun( int maxevt ) {
387 StatusCode sc;
388 bool eventfailed = false;
389
390 if(maxevt > 0){ //finite number of events to process
391 const unsigned int umaxevt = static_cast<unsigned int>(maxevt);
392 m_blackListBS = new boost::dynamic_bitset<>(maxevt); //all initialized to zero
393 for(unsigned int i = 0; i < m_eventNumberBlacklist.size() && m_eventNumberBlacklist[i] <= umaxevt; ++i ){ //black list is sorted in init
394 m_blackListBS->set(m_eventNumberBlacklist[i], true);
395 }
396 }
397
398 sc = m_algResourcePool->beginRun();
399 if (sc.isFailure())
400 eventfailed=true;
401
402 // Call now the nextEvent(...)
403 sc = nextEvent(maxevt);
404 if (!sc.isSuccess())
405 eventfailed = true;
406
407 sc = m_algResourcePool->endRun();
408 if (sc.isFailure())
409 eventfailed=true;
410
411 if(m_blackListBS != nullptr)
412 delete m_blackListBS;
413
414 if (eventfailed)
415 return StatusCode::FAILURE;
416 else
417 return StatusCode::SUCCESS;
418 }
419
420 //--------------------------------------------------------------------------------------------
421 // Implementation of IEventProcessor::stopRun()
422 //--------------------------------------------------------------------------------------------
423 StatusCode HiveSlimEventLoopMgr::stopRun() {
424 // Set the application return code
425 SmartIF<IProperty> appmgr(serviceLocator());
426 if(Gaudi::setAppReturnCode(appmgr, Gaudi::ReturnCode::ScheduledStop).isFailure()) {
427 error() << "Could not set return code of the application ("
428 << Gaudi::ReturnCode::ScheduledStop << ")" << endmsg;
429 }
430 m_scheduledStop = true;
431 return StatusCode::SUCCESS;
432 }
433
434 //--------------------------------------------------------------------------------------------
435 // implementation of IAppMgrUI::nextEvent
436 //--------------------------------------------------------------------------------------------
437 // Here the loop on the events takes place.
438 // This is also the natural place to put the preparation of the algorithms
439 // contexts, which contain the event specific data.
440 #include "GaudiKernel/Memory.h"
441 StatusCode HiveSlimEventLoopMgr::nextEvent(int maxevt) {
442
443 // Calculate runtime
444 typedef std::chrono::high_resolution_clock Clock;
445 typedef Clock::time_point time_point;
446
447 // Reset the application return code.
448 Gaudi::setAppReturnCode(m_appMgrProperty, Gaudi::ReturnCode::Success, true).ignore();
449
450 int finishedEvts =0;
451 int createdEvts =0;
452 int skippedEvts = 0;
453 info() << "Starting loop on events" << endmsg;
454 // Loop until the finished events did not reach the maxevt number
455 bool loop_ended = false;
456 // Run the first event before spilling more than one
457 bool newEvtAllowed = false ;
458
459 constexpr double oneOver1204 = 1./1024.;
460
461 uint iteration = 0;
462 time_point start_time = Clock::now();
463 while ( !loop_ended and (maxevt < 0 or (finishedEvts+skippedEvts) < maxevt)){
464 debug() << "work loop iteration " << iteration++ << endmsg;
465 // if the created events did not reach maxevt, create an event
466 if ((newEvtAllowed or createdEvts == 0 ) && // Launch the first event alone
467 createdEvts >= 0 && // The events are not finished with an unlimited number of events
468 (createdEvts < maxevt or maxevt<0) && // The events are not finished with a limited number of events
469 m_schedulerSvc->freeSlots()>0){ // There are still free slots in the scheduler
470
471 if (1==createdEvts) // reset counter to count from event 1
472 start_time = Clock::now();
473
474 debug() << "createdEvts: " << createdEvts << ", freeslots: " << m_schedulerSvc->freeSlots() << endmsg;
475 // DP remove to remove the syscalls...
476 // if (0!=createdEvts){
477 // info() << "Event Number = " << createdEvts
478 // << " WSS (MB) = " << System::mappedMemory(System::MemoryUnit::kByte)*oneOver1204
479 // << " Time (s) = " << secsFromStart(start_time) << endmsg;
480 // }
481
482 //TODO can we adapt the interface of executeEvent for a nicer solution?
483 StatusCode sc = StatusCode::RECOVERABLE;
484 while(!sc.isSuccess() //we haven't created an event yet
485 && (createdEvts < maxevt or maxevt<0)){ //redunant check for maxEvts, can we do better?
486 sc = executeEvent(&createdEvts);
487
488 if (sc.isRecoverable()){ //we skipped an event
489
490 //this is all to skip the event
491 size_t slot = m_whiteboard->allocateStore(createdEvts); //we need a new store, not to change the previous event
492 m_whiteboard->selectStore(slot);
493 declareEventRootAddress(); //actually skip over the event
494 m_whiteboard->freeStore(slot); // delete the store
495
496 ++createdEvts;
497 ++skippedEvts;
498 } else if (sc.isRecoverable()){ //exit immediatly
499 return StatusCode::FAILURE;
500 } // else we have an success --> exit loop
501 }
502
503 } // end if condition createdEvts < maxevt
504 else{
505 // all the events were created but not all finished or the slots were
506 // all busy: the scheduler should finish its job
507
508 debug() << "Draining the scheduler" << endmsg;
509
510 // Pull out of the scheduler the finished events
511 if (drainScheduler(finishedEvts).isFailure()){
512 loop_ended = true;
513 }
514 newEvtAllowed = true;
515 }
516 } // end main loop on finished events
517 time_point end_time = Clock::now();
518
519 info() << "---> Loop Finished (skipping 1st evt) - "
520 << " WSS " << System::mappedMemory(System::MemoryUnit::kByte)*oneOver1204
521 << " total time " << std::chrono::duration_cast < std::chrono::nanoseconds > (end_time - start_time).count() <<endmsg;
522 info() << skippedEvts << " events were SKIPed" << endmsg;
523
524 return StatusCode::SUCCESS;
525
526 }
527
528 //---------------------------------------------------------------------------
529
531 StatusCode HiveSlimEventLoopMgr::getEventRoot(IOpaqueAddress*& refpAddr) {
532 refpAddr = 0;
533 StatusCode sc = m_evtSelector->next(*m_evtContext);
534 if ( !sc.isSuccess() ) {
535 return sc;
536 }
537 // Create root address and assign address to data service
538 sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
539 if( !sc.isSuccess() ) {
540 sc = m_evtSelector->next(*m_evtContext);
541 if ( sc.isSuccess() ) {
542 sc = m_evtSelector->createAddress(*m_evtContext,refpAddr);
543 if ( !sc.isSuccess() ) {
544 warning() << "Error creating IOpaqueAddress." << endmsg;
545 }
546 }
547 }
548 return sc;
549 }
550
551 //---------------------------------------------------------------------------
552
553 StatusCode HiveSlimEventLoopMgr::declareEventRootAddress(){
554
555 StatusCode sc;
556 if( m_evtContext ) {
557 //---This is the "event iterator" context from EventSelector
558 IOpaqueAddress* pAddr = 0;
559 sc = getEventRoot(pAddr);
560 if( !sc.isSuccess() ) {
561 info() << "No more events in event selection " << endmsg;
562 return StatusCode::FAILURE;
563 }
564 sc = m_evtDataMgrSvc->setRoot ("/Event", pAddr);
565 if( !sc.isSuccess() ) {
566 warning() << "Error declaring event root address." << endmsg;
567 }
568 }
569 else {
570 //---In case of no event selector----------------
571 sc = m_evtDataMgrSvc->setRoot ("/Event", new DataObject());
572 if( !sc.isSuccess() ) {
573 warning() << "Error declaring event root DataObject" << endmsg;
574 }
575 }
576 return StatusCode::SUCCESS;
577 }
578
579 //---------------------------------------------------------------------------
580
581 StatusCode HiveSlimEventLoopMgr::createEventContext(EventContext*& evtContext, int createdEvts){
582 evtContext = new EventContext;
583
584 evtContext->set(createdEvts, m_whiteboard->allocateStore(createdEvts));
585
586 m_algExecStateSvc->reset(*evtContext);
587
588 StatusCode sc = m_whiteboard->selectStore(evtContext->slot());
589 if (sc.isFailure()){
590 warning() << "Slot " << evtContext->slot()
591 << " could not be selected for the WhiteBoard" << endmsg;
592 }
593 return sc;
594 }
595
596 //---------------------------------------------------------------------------
597
598 StatusCode HiveSlimEventLoopMgr::drainScheduler(int& finishedEvts){
599
600 StatusCode sc(StatusCode::SUCCESS);
601
602 // maybe we can do better
603 std::vector<EventContext*> finishedEvtContexts;
604
605 EventContext* finishedEvtContext(nullptr);
606
607 // Here we wait not to loose cpu resources
608 debug() << "Waiting for a context" << endmsg;
609 sc = m_schedulerSvc->popFinishedEvent(finishedEvtContext);
610
611 // We got past it: cache the pointer
612 if (sc.isSuccess()){
613 debug() << "Context obtained" << endmsg;
614 } else{
615 // A problem occurred.
616 debug() << "Context not obtained: a problem in the scheduling?" << endmsg;
617 // return StatusCode::FAILURE;
618 }
619
620 finishedEvtContexts.push_back(finishedEvtContext);
621
622 // Let's see if we can pop other event contexts
623 while (m_schedulerSvc->tryPopFinishedEvent(finishedEvtContext).isSuccess()){
624 finishedEvtContexts.push_back(finishedEvtContext);
625 }
626
627 // Now we flush them
628 StatusCode finalSC;
629 for (auto& thisFinishedEvtContext : finishedEvtContexts){
630 if (nullptr == thisFinishedEvtContext){
631 error() << "Detected nullptr ctxt before clearing WB!"<< endmsg;
632 finalSC = StatusCode::FAILURE;
633 continue;
634 }
635 if (m_algExecStateSvc->eventStatus(*thisFinishedEvtContext) != EventStatus::Success) {
636 fatal() << "Failed event detected on " << thisFinishedEvtContext << endmsg;
637 finalSC = StatusCode::FAILURE;
638 }
639 //shouldn't these incidents move to the forward scheduler?
640 // If we want to consume incidents with an algorithm at the end of the graph
641 // we need to add this to forward scheduler lambda action,
642 // otherwise we have to do this serially on this thread!
643 m_incidentSvc->fireIncident(Incident(name(), IncidentType::EndProcessing,*thisFinishedEvtContext));
644 m_incidentSvc->fireIncident(Incident(name(),IncidentType::EndEvent,*thisFinishedEvtContext));
645
646 debug() << "Clearing slot " << thisFinishedEvtContext->slot()
647 << " (event " << thisFinishedEvtContext->evt()
648 << ") of the whiteboard" << endmsg;
649
650 StatusCode sc = clearWBSlot(thisFinishedEvtContext->slot());
651 if (!sc.isSuccess())
652 error() << "Whiteboard slot " << thisFinishedEvtContext->slot()
653 << " could not be properly cleared";
654
655
656 delete thisFinishedEvtContext;
657
658 finishedEvts++;
659
660 }
661 return finalSC;
662 }
663
664 //---------------------------------------------------------------------------
665
666 StatusCode HiveSlimEventLoopMgr::clearWBSlot(int evtSlot) {
667 StatusCode sc = m_whiteboard->clearStore(evtSlot);
668 if( !sc.isSuccess() ) {
669 warning() << "Clear of Event data store failed" << endmsg;
670 }
671 return m_whiteboard->freeStore(evtSlot);
672 }
673 //---------------------------------------------------------------------------
HiveSlimEventLoopMgr::clearWBSlot
StatusCode clearWBSlot(int evtSlot)
Clear a slot in the WB.
Definition: HiveSlimEventLoopMgr.cpp:666
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:64
std::chrono::nanoseconds
Gaudi::StateMachine::INITIALIZED
Definition: StateMachine.h:15
StatusCode::SUCCESS
Definition: StatusCode.h:30
HiveSlimEventLoopMgr::m_evtsel
Gaudi::Property< std::string > m_evtsel
Definition: HiveSlimEventLoopMgr.h:31
HiveSlimEventLoopMgr::m_incidentSvc
SmartIF< IIncidentSvc > m_incidentSvc
Reference to the incident service.
Definition: HiveSlimEventLoopMgr.h:75
Algorithm.h
SmartIF< IService >
HiveSlimEventLoopMgr::m_evtDataMgrSvc
SmartIF< IDataManagerSvc > m_evtDataMgrSvc
Reference to the Event Data Service&#39;s IDataManagerSvc interface.
Definition: HiveSlimEventLoopMgr.h:38
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
HiveSlimEventLoopMgr::declareEventRootAddress
StatusCode declareEventRootAddress()
Declare the root address of the event.
Definition: HiveSlimEventLoopMgr.cpp:553
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:28
StatusCode::FAILURE
Definition: StatusCode.h:29
EventContext::set
void set(const ContextEvt_t &e=0, const ContextID_t &s=INVALID_CONTEXT_ID)
Definition: EventContext.h:46
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:174
PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >::setProperty
StatusCode setProperty(const Gaudi::Details::PropertyBase &p) override
set the property form another property
Definition: PropertyHolder.h:210
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:41
MsgStream.h
HiveSlimEventLoopMgr::m_appMgrUI
SmartIF< IAppMgrUI > m_appMgrUI
Reference to the IAppMgrUI interface of the application manager.
Definition: HiveSlimEventLoopMgr.h:73
CommonMessagingBase::info
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Definition: CommonMessaging.h:123
HiveSlimEventLoopMgr::HiveSlimEventLoopMgr
HiveSlimEventLoopMgr(const std::string &nam, ISvcLocator *svcLoc)
Standard Constructor.
Definition: HiveSlimEventLoopMgr.cpp:47
HiveSlimEventLoopMgr::drainScheduler
StatusCode drainScheduler(int &finishedEvents)
Drain the scheduler from all actions that may be queued.
Definition: HiveSlimEventLoopMgr.cpp:598
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
HistogramAgent
HistogramAgent base in charge of collecting all the refereces to DataObjects in a transient store tha...
Definition: HistogramAgent.h:17
HiveSlimEventLoopMgr::m_whiteboard
SmartIF< IHiveWhiteBoard > m_whiteboard
Reference to the Whiteboard.
Definition: HiveSlimEventLoopMgr.h:48
HiveSlimEventLoopMgr::m_schedulerSvc
SmartIF< IScheduler > m_schedulerSvc
A shortcut for the scheduler.
Definition: HiveSlimEventLoopMgr.h:59
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:129
HiveSlimEventLoopMgr::m_scheduledStop
bool m_scheduledStop
Scheduled stop of event processing.
Definition: HiveSlimEventLoopMgr.h:71
std::binary_search
T binary_search(T...args)
EventContext.h
HiveSlimEventLoopMgr
Definition: HiveSlimEventLoopMgr.h:26
HiveSlimEventLoopMgr::m_eventNumberBlacklist
Gaudi::Property< std::vector< unsigned int > > m_eventNumberBlacklist
Definition: HiveSlimEventLoopMgr.h:35
std::chrono::duration_cast
T duration_cast(T...args)
std::vector::end
T end(T...args)
IProperty::getProperty
virtual StatusCode getProperty(Gaudi::Details::PropertyBase *p) const =0
Get the property by property.
IConverter::createRep
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
IScheduler.h
EventContext
This class represents an entry point to all the event specific data.
Definition: EventContext.h:25
HiveSlimEventLoopMgr::m_appMgrProperty
SmartIF< IProperty > m_appMgrProperty
Property interface of ApplicationMgr.
Definition: HiveSlimEventLoopMgr.h:54
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:84
Gaudi::ReturnCode::ScheduledStop
constexpr int ScheduledStop
Definition: AppReturnCode.h:27
System::kByte
Definition: Memory.h:56
EventContext::evt
ContextEvt_t evt() const
Definition: EventContext.h:40
std::string
STL class.
Incident.h
SmartIF::get
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
IService::sysInitialize
virtual StatusCode sysInitialize()=0
Initialize Service.
HiveSlimEventLoopMgr::m_warnings
Gaudi::Property< bool > m_warnings
Definition: HiveSlimEventLoopMgr.h:32
DataSvc.h
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
std::vector::push_back
T push_back(T...args)
HiveSlimEventLoopMgr::finalize
StatusCode finalize() override
implementation of IService::finalize
Definition: HiveSlimEventLoopMgr.cpp:247
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:117
SvcFactory.h
HiveSlimEventLoopMgr::stopRun
StatusCode stopRun() override
implementation of IEventProcessor::stopRun()
Definition: HiveSlimEventLoopMgr.cpp:423
IHiveWhiteBoard::selectStore
virtual StatusCode selectStore(size_t partitionIndex)=0
Activate an given &#39;slot&#39; for all subsequent calls within the same thread id.
IIncidentSvc::fireIncident
virtual void fireIncident(const Incident &incident)=0
Fire an Incident.
IDataManagerSvc.h
IDataProviderSvc.h
HiveSlimEventLoopMgr::~HiveSlimEventLoopMgr
~HiveSlimEventLoopMgr() override
Standard Destructor.
Definition: HiveSlimEventLoopMgr.cpp:55
std::chrono::high_resolution_clock
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:120
IHiveWhiteBoard::clearStore
virtual StatusCode clearStore(size_t partitionIndex)=0
Clear an given &#39;slot&#39;.
HiveSlimEventLoopMgr.h
IDataManagerSvc::traverseTree
virtual StatusCode traverseTree(IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects in the data store.
IAlgResourcePool::endRun
virtual StatusCode endRun()=0
End Run.
IIncidentSvc.h
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
GaudiException.h
HiveSlimEventLoopMgr::executeRun
StatusCode executeRun(int maxevt) override
implementation of IEventProcessor::executeRun()
Definition: HiveSlimEventLoopMgr.cpp:386
SmartIF.h
HiveSlimEventLoopMgr::createEventContext
StatusCode createEventContext(EventContext *&eventContext, int createdEvents)
Create event context.
Definition: HiveSlimEventLoopMgr.cpp:581
EventStatus::Success
Definition: IAlgExecStateSvc.h:64
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
IScheduler::pushNewEvent
virtual StatusCode pushNewEvent(EventContext *eventContext)=0
Make an event available to the scheduler.
DECLARE_SERVICE_FACTORY
#define DECLARE_SERVICE_FACTORY(x)
Definition: Service.h:242
HiveSlimEventLoopMgr::getEventRoot
StatusCode getEventRoot(IOpaqueAddress *&refpAddr)
Create event address using event selector.
Definition: HiveSlimEventLoopMgr.cpp:531
StatusCode::isRecoverable
bool isRecoverable() const
Definition: StatusCode.h:85
IEvtSelector::releaseContext
virtual StatusCode releaseContext(Context *&) const =0
Release the Context object.
Clock
std::chrono::high_resolution_clock Clock
Definition: ITimelineSvc.h:10
HistogramAgent::selectedObjects
IDataSelector * selectedObjects()
Return the set of selected DataObjects.
Definition: HistogramAgent.h:28
Gaudi::setAppReturnCode
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.
Definition: AppReturnCode.h:51
IDataManagerSvc::setRoot
virtual StatusCode setRoot(std::string root_name, DataObject *pObject)=0
Initialize data store for new event by giving new event path.
AppReturnCode.h
GaudiPython.Bindings.DataObject
DataObject
Definition: Bindings.py:51
IAlgExecStateSvc::reset
virtual void reset(const EventContext &ctx)=0
System::mappedMemory
GAUDI_API long mappedMemory(MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
Basic Process Information: priority boost.
Definition: Memory.cpp:180
std::vector::size
T size(T...args)
HiveSlimEventLoopMgr::initialize
StatusCode initialize() override
implementation of IService::initialize
Definition: HiveSlimEventLoopMgr.cpp:67
std::vector< DataObject * >
Memory.h
IAlgResourcePool::beginRun
virtual StatusCode beginRun()=0
Begin Run.
HiveSlimEventLoopMgr::m_algExecStateSvc
SmartIF< IAlgExecStateSvc > m_algExecStateSvc
Reference to the AlgExecStateSvc.
Definition: HiveSlimEventLoopMgr.h:52
std::unique_ptr< Incident >
LIKELY
#define LIKELY(x)
Definition: Kernel.h:125
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:126
IConversionSvc.h
HiveSlimEventLoopMgr::m_histoPersSvc
SmartIF< IConversionSvc > m_histoPersSvc
Reference to the Histogram Persistency Service.
Definition: HiveSlimEventLoopMgr.h:46
IHiveWhiteBoard::allocateStore
virtual size_t allocateStore(int evtnumber)=0
Allocate a store partition for new event.
HiveSlimEventLoopMgr::m_schedulerName
Gaudi::Property< std::string > m_schedulerName
Definition: HiveSlimEventLoopMgr.h:33
StatusCode::RECOVERABLE
Definition: StatusCode.h:31
SmartIF::isValid
bool isValid() const
Allow for check if smart pointer is valid.
Definition: SmartIF.h:62
std::vector::begin
T begin(T...args)
time_point
Clock::time_point time_point
Definition: ITimelineSvc.h:11
std::chrono::high_resolution_clock::now
T now(T...args)
IScheduler::tryPopFinishedEvent
virtual StatusCode tryPopFinishedEvent(EventContext *&eventContext)=0
Try to retrieve a finished event from the scheduler.
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
IAlgExecStateSvc::eventStatus
virtual const EventStatus::Status & eventStatus(const EventContext &ctx) const =0
HiveSlimEventLoopMgr::m_histoDataMgrSvc
SmartIF< IDataManagerSvc > m_histoDataMgrSvc
Reference to the Histogram Data Service.
Definition: HiveSlimEventLoopMgr.h:44
HiveSlimEventLoopMgr::m_evtSelector
SmartIF< IEvtSelector > m_evtSelector
Reference to the Event Selector.
Definition: HiveSlimEventLoopMgr.h:40
IHiveWhiteBoard::freeStore
virtual StatusCode freeStore(size_t partitionIndex)=0
Free a store partition.
CommonMessaging
Definition: CommonMessaging.h:55
HiveSlimEventLoopMgr::reinitialize
StatusCode reinitialize() override
implementation of IService::reinitialize
Definition: HiveSlimEventLoopMgr.cpp:170
IEvtSelector::next
virtual StatusCode next(Context &c) const =0
Fetch the next event or the first event if it will be use soon after the creation of the context...
IAlgManager.h
IEvtSelector.h
IIncidentListener.h
Service::service
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:85
IChronoStatSvc.h
std::sort
T sort(T...args)
IEvtSelector::createContext
virtual StatusCode createContext(Context *&c) const =0
Create and return a context object that will keep track of the state of selection.
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
HistogramAgent.h
IEvtSelector::createAddress
virtual StatusCode createAddress(const Context &c, IOpaqueAddress *&iop) const =0
Create an IOpaqueAddress object from the event fetched.
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
maxevt
int maxevt
Definition: Bootstrap.cpp:279
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:106
CommonMessagingBase::fatal
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
Definition: CommonMessaging.h:111
Gaudi::ReturnCode::Success
constexpr int Success
Definition: AppReturnCode.h:18
HiveSlimEventLoopMgr::m_algResourcePool
SmartIF< IAlgResourcePool > m_algResourcePool
Reference to the Algorithm resource pool.
Definition: HiveSlimEventLoopMgr.h:50
HiveSlimEventLoopMgr::executeEvent
StatusCode executeEvent(void *par) override
implementation of IEventProcessor::executeEvent(void* par)
Definition: HiveSlimEventLoopMgr.cpp:321
IRegistry::address
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
IConverter::fillRepRefs
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.
HiveSlimEventLoopMgr::nextEvent
StatusCode nextEvent(int maxevt) override
implementation of IService::nextEvent
Definition: HiveSlimEventLoopMgr.cpp:441
IScheduler::freeSlots
virtual unsigned int freeSlots()=0
Get the free event processing slots.
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
IScheduler::popFinishedEvent
virtual StatusCode popFinishedEvent(EventContext *&eventContext)=0
Retrieve a finished event from the scheduler.
HiveSlimEventLoopMgr::m_endEventFired
bool m_endEventFired
Flag to avoid to fire the EnvEvent incident twice in a row (and also not before the first event) ...
Definition: HiveSlimEventLoopMgr.h:57
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
HiveSlimEventLoopMgr::m_blackListBS
boost::dynamic_bitset * m_blackListBS
Definition: HiveSlimEventLoopMgr.h:78
HiveSlimEventLoopMgr::stop
StatusCode stop() override
implementation of IService::stop
Definition: HiveSlimEventLoopMgr.cpp:234
DataObject.h
HiveSlimEventLoopMgr::m_evtContext
IEvtSelector::Context * m_evtContext
Event Iterator.
Definition: HiveSlimEventLoopMgr.h:42