The Gaudi Framework  master (37c0b60a)
AlgTask Class Reference

#include </builds/gaudi/Gaudi/GaudiHive/src/AlgTask.h>

Collaboration diagram for AlgTask:

Public Member Functions

 AlgTask (AvalancheSchedulerSvc *scheduler, ISvcLocator *svcLocator, IAlgExecStateSvc *aem, bool asynchronous)
 
void operator() () const
 

Private Attributes

AvalancheSchedulerSvcm_scheduler
 
IAlgExecStateSvcm_aess
 
SmartIF< ISvcLocatorm_serviceLocator
 
bool m_asynchronous { false }
 

Detailed Description

Definition at line 36 of file AlgTask.h.

Constructor & Destructor Documentation

◆ AlgTask()

AlgTask::AlgTask ( AvalancheSchedulerSvc scheduler,
ISvcLocator svcLocator,
IAlgExecStateSvc aem,
bool  asynchronous 
)
inline

Definition at line 38 of file AlgTask.h.

39  : m_scheduler( scheduler ), m_aess( aem ), m_serviceLocator( svcLocator ), m_asynchronous( asynchronous ) {}

Member Function Documentation

◆ operator()()

void AlgTask::operator() ( ) const
inline

Definition at line 41 of file AlgTask.h.

41  {
42 
44  MsgStream log( messageSvc, "AlgTask" );
45 
46  // Get task specification dynamically if it was not provided statically
48  log << MSG::DEBUG << "Getting taskspec for " << ( m_asynchronous ? "asynchronous" : "standard" ) << " algorithm"
49  << endmsg;
50  if ( !m_scheduler->next( ts, m_asynchronous ) ) {
51  log << MSG::WARNING << "Missing specification while task is running" << endmsg;
52  return;
53  }
54 
55  EventContext& evtCtx = *( ts.contextPtr );
56  IAlgorithm*& iAlgoPtr = ts.algPtr;
57 
58  Gaudi::Algorithm* this_algo = dynamic_cast<Gaudi::Algorithm*>( iAlgoPtr );
59  if ( !this_algo ) { throw GaudiException( "Cast to Algorithm failed!", "AlgTask", StatusCode::FAILURE ); }
60 
61  bool eventfailed = false;
63 
64  // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
65  const SmartIF<IProperty> appmgr( m_serviceLocator );
66 
68  log << MSG::DEBUG << "New thread detected: 0x" << std::hex << pthread_self() << std::dec
69  << ". Doing thread local initialization." << endmsg;
70  if ( SmartIF<IThreadPoolSvc> tps{ m_serviceLocator->service( "ThreadPoolSvc" ) } ) {
71  tps->initThisThread();
72  } else {
73  log << MSG::ERROR << "Unable to get the ThreadPoolSvc to trigger thread local initialization" << endmsg;
74  throw GaudiException( "Retrieval of ThreadPoolSvc failed", "AlgTask", StatusCode::FAILURE );
75  }
76  }
77 
78  // select the appropriate store
79  this_algo->whiteboard()->selectStore( evtCtx.valid() ? evtCtx.slot() : 0 ).ignore();
80  try {
82 
83  if ( iAlgoPtr->sysExecute( evtCtx ).isFailure() ) {
84  log << MSG::WARNING << "Execution of algorithm " << ts.algName << " failed" << endmsg;
85  eventfailed = true;
86  }
87  rcg.ignore(); // disarm the guard
88  } catch ( const GaudiException& Exception ) {
89  log << MSG::FATAL << ".executeEvent(): Exception with tag=" << Exception.tag() << " thrown by " << ts.algName
90  << endmsg;
91  log << MSG::ERROR << Exception << endmsg;
92  eventfailed = true;
93  } catch ( const std::exception& Exception ) {
94  log << MSG::FATAL << ".executeEvent(): Standard std::exception thrown by " << ts.algName << endmsg;
95  log << MSG::ERROR << Exception.what() << endmsg;
96  eventfailed = true;
97  } catch ( ... ) {
98  log << MSG::FATAL << ".executeEvent(): UNKNOWN Exception thrown by " << ts.algName << endmsg;
99  eventfailed = true;
100  }
101 
102  // A FAILURE in algorithm execution must be communicated to the framework
103  m_aess->updateEventStatus( eventfailed, evtCtx );
104 
105  // Release algorithm
106  m_scheduler->m_algResourcePool->releaseAlgorithm( ts.algName, iAlgoPtr ).ignore();
107 
108  // schedule a sign-off of the Algorithm execution
110  [schdlr = this->m_scheduler, ts = std::move( ts )]() { return schdlr->signoff( ts ); } );
111 
113  }

Member Data Documentation

◆ m_aess

IAlgExecStateSvc* AlgTask::m_aess
private

Definition at line 118 of file AlgTask.h.

◆ m_asynchronous

bool AlgTask::m_asynchronous { false }
private

Definition at line 121 of file AlgTask.h.

◆ m_scheduler

AvalancheSchedulerSvc* AlgTask::m_scheduler
private

Definition at line 117 of file AlgTask.h.

◆ m_serviceLocator

SmartIF<ISvcLocator> AlgTask::m_serviceLocator
private

Definition at line 119 of file AlgTask.h.


The documentation for this class was generated from the following file:
MSG::DEBUG
@ DEBUG
Definition: IMessageSvc.h:25
EventContext::valid
bool valid() const
Definition: EventContext.h:54
IAlgorithm::sysExecute
virtual StatusCode sysExecute(const EventContext &)=0
System execution. This method invokes the execute() method of a concrete algorithm.
Gaudi::Hive::setCurrentContext
GAUDI_API void setCurrentContext(const EventContext *ctx)
Definition: ThreadLocalContext.cpp:41
AvalancheSchedulerSvc::TaskSpec
Struct to hold entries in the alg queues.
Definition: AvalancheSchedulerSvc.h:322
std::exception
STL class.
Gaudi.Configuration.log
log
Definition: Configuration.py:28
std::move
T move(T... args)
GaudiException
Definition: GaudiException.h:31
Gaudi::Concurrency::ThreadInitDone
thread_local bool ThreadInitDone
Definition: ThreadInitTask.cpp:22
RetCodeGuard
Helper class to set the application return code in case of early exit (e.g.
Definition: RetCodeGuard.h:19
MSG::WARNING
@ WARNING
Definition: IMessageSvc.h:25
AlgTask::m_asynchronous
bool m_asynchronous
Definition: AlgTask.h:121
AlgTask::m_serviceLocator
SmartIF< ISvcLocator > m_serviceLocator
Definition: AlgTask.h:119
std::hex
T hex(T... args)
Gaudi::Algorithm::whiteboard
SmartIF< IHiveWhiteBoard > & whiteboard() const
Definition: Algorithm.cpp:568
Gaudi::svcLocator
GAUDI_API ISvcLocator * svcLocator()
IAlgorithm
Definition: IAlgorithm.h:38
compareRootHistos.ts
ts
Definition: compareRootHistos.py:488
EventContext::slot
ContextID_t slot() const
Definition: EventContext.h:51
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:90
SmartIF< IMessageSvc >
Gaudi::ReturnCode::UnhandledException
constexpr int UnhandledException
Definition: AppReturnCode.h:37
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
AvalancheSchedulerSvc::m_algResourcePool
SmartIF< IAlgResourcePool > m_algResourcePool
Cache for the algorithm resource pool.
Definition: AvalancheSchedulerSvc.h:314
MsgStream
Definition: MsgStream.h:33
MSG::FATAL
@ FATAL
Definition: IMessageSvc.h:25
AvalancheSchedulerSvc::next
bool next(TaskSpec &ts, bool asynchronous)
Definition: AvalancheSchedulerSvc.h:377
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
AlgTask::m_aess
IAlgExecStateSvc * m_aess
Definition: AlgTask.h:118
MSG::ERROR
@ ERROR
Definition: IMessageSvc.h:25
EventContext
Definition: EventContext.h:34
AvalancheSchedulerSvc::m_actionsQueue
tbb::concurrent_bounded_queue< action > m_actionsQueue
Queue where closures are stored and picked for execution.
Definition: AvalancheSchedulerSvc.h:319
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
Gaudi::Details::Property::ParsingErrorPolicy::Exception
@ Exception
IAlgExecStateSvc::updateEventStatus
virtual void updateEventStatus(const bool &b, const EventContext &ctx)=0
GPUAvalancheSchedulerSimpleTest.scheduler
scheduler
Definition: GPUAvalancheSchedulerSimpleTest.py:84
Gaudi::Hive::setCurrentContextEvt
GAUDI_API void setCurrentContextEvt(long int evtN)
Definition: ThreadLocalContext.cpp:32
AlgTask::m_scheduler
AvalancheSchedulerSvc * m_scheduler
Definition: AlgTask.h:117