IOBoundAlgTask Class Reference

Wrapper around I/O-bound Gaudi-algorithms. More...

#include <GaudiHive/src/IOBoundAlgTask.h>

Inheritance diagram for IOBoundAlgTask:
Collaboration diagram for IOBoundAlgTask:

Public Member Functions

 IOBoundAlgTask (IAlgorithm *algorithm, unsigned int algoIndex, EventContext *ctx, ISvcLocator *svcLocator, ForwardSchedulerSvc *schedSvc, IAlgExecStateSvc *aem)
 
 ~IOBoundAlgTask () override
 
virtual StatusCode execute () override
 
- Public Member Functions inherited from IAlgTask
virtual ~IAlgTask ()=default
 

Private Attributes

SmartIF< IAlgorithmm_algorithm
 
EventContextm_evtCtx
 
const unsigned int m_algoIndex
 
SmartIF< ForwardSchedulerSvcm_schedSvc
 
IAlgExecStateSvcm_aess
 
SmartIF< ISvcLocatorm_serviceLocator
 

Detailed Description

Wrapper around I/O-bound Gaudi-algorithms.

It may also cover the accelerator-targeted algorithms. It must be used to prepare algorithms before sending them to I/O-bound scheduler.

Author
Illya Shapoval
Version
1.0

Definition at line 23 of file IOBoundAlgTask.h.

Constructor & Destructor Documentation

IOBoundAlgTask::IOBoundAlgTask ( IAlgorithm algorithm,
unsigned int  algoIndex,
EventContext ctx,
ISvcLocator svcLocator,
ForwardSchedulerSvc schedSvc,
IAlgExecStateSvc aem 
)
inline

Definition at line 25 of file IOBoundAlgTask.h.

30  :
31  m_algorithm(algorithm),
32  m_evtCtx(ctx),
33  m_algoIndex(algoIndex),
34  m_schedSvc(schedSvc),
35  m_aess(aem),
36  m_serviceLocator(svcLocator) {}
SmartIF< IAlgorithm > m_algorithm
EventContext * m_evtCtx
SmartIF< ForwardSchedulerSvc > m_schedSvc
SmartIF< ISvcLocator > m_serviceLocator
const unsigned int m_algoIndex
IAlgExecStateSvc * m_aess
IOBoundAlgTask::~IOBoundAlgTask ( )
inlineoverride

Definition at line 38 of file IOBoundAlgTask.h.

38 {}

Member Function Documentation

StatusCode IOBoundAlgTask::execute ( )
overridevirtual

Implements IAlgTask.

Definition at line 13 of file IOBoundAlgTask.cpp.

13  {
14 
15  IAlgorithm *ialg = m_algorithm.get();
16  Algorithm* this_algo = dynamic_cast<Algorithm*>(ialg);
17  if (!this_algo){
18  throw GaudiException ("Cast to Algorithm failed!","AlgoExecutionTask",
20  }
21 
22  bool eventfailed=false;
24 
25  m_schedSvc->addAlg(this_algo, m_evtCtx, pthread_self());
26 
27  // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
29 
31  MsgStream log(messageSvc, "AccelAlgoExecutionTask");
32 
34  try {
36  log << MSG::DEBUG << "Starting execution of algorithm " << m_algorithm->name()
37  << endmsg;
38  sc = m_algorithm->sysExecute();
39  if (UNLIKELY(!sc.isSuccess())) {
40  log << MSG::WARNING << "Execution of algorithm "
41  << m_algorithm->name() << " failed" << endmsg;
42  eventfailed = true;
43  }
44  log << MSG::DEBUG << "Stopped execution of algorithm " << m_algorithm->name()
45  << endmsg;
46  rcg.ignore(); // disarm the guard
47  } catch ( const GaudiException& Exception ) {
48  log << MSG::FATAL << ".executeEvent(): Exception with tag=" << Exception.tag()
49  << " thrown by " << m_algorithm->name() << endmsg;
50  log << MSG::ERROR << Exception << endmsg;
51  eventfailed = true;
52  } catch ( const std::exception& Exception ) {
53  log << MSG::FATAL << ".executeEvent(): Standard std::exception thrown by "
54  << m_algorithm->name() << endmsg;
55  log << MSG::ERROR << Exception.what() << endmsg;
56  eventfailed = true;
57  } catch(...) {
58  log << MSG::FATAL << ".executeEvent(): UNKNOWN Exception thrown by "
59  << m_algorithm->name() << endmsg;
60  eventfailed = true;
61  }
62 
63  // Commit all DataHandles
64  this_algo->commitHandles();
65 
66  // DP it is important to propagate the failure of an event.
67  // We need to stop execution when this happens so that execute run can
68  // then receive the FAILURE
71  m_aess->updateEventStatus(eventfailed,*m_evtCtx);
72 
73 
74  // Push in the scheduler queue an action to be performed
75  auto action_promote2Executed = std::bind(&ForwardSchedulerSvc::promoteToAsyncExecuted,
76  m_schedSvc,
78  m_evtCtx->slot(),
80  m_evtCtx);
81 
82  // TODO Expose a method to push actions in IScheduler?
83  m_schedSvc->m_actionsQueue.push(action_promote2Executed);
84 
85  m_schedSvc->delAlg(this_algo);
86 
88 
89  return sc;
90 }
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
Define general base for Gaudi exception.
SmartIF< IAlgorithm > m_algorithm
Helper class to set the application return code in case of early exit (e.g.
Definition: RetCodeGuard.h:9
void commitHandles() override
Definition: Algorithm.cpp:949
ContextID_t slot() const
Definition: EventContext.h:41
EventContext * m_evtCtx
void setExecStatus(const StatusCode &sc=StatusCode::SUCCESS)
#define UNLIKELY(x)
Definition: Kernel.h:126
SmartIF< ForwardSchedulerSvc > m_schedSvc
StatusCode promoteToAsyncExecuted(unsigned int iAlgo, int si, IAlgorithm *algo, EventContext *)
The call to this method is triggered only from within the IOBoundAlgTask.
virtual StatusCode sysExecute()=0
System execution. This method invokes the execute() method of a concrete algorithm.
constexpr int UnhandledException
Definition: AppReturnCode.h:29
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:76
void addAlg(Algorithm *, EventContext *, pthread_t)
T what(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
virtual const AlgExecState & algExecState(const Gaudi::StringKey &algName, const EventContext &ctx) const =0
SmartIF< ISvcLocator > m_serviceLocator
virtual const std::string & tag() const
name tag for the exception, or exception type
T bind(T...args)
void setExecuted(bool e=true)
STL class.
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:27
GAUDI_API void setCurrentContext(const EventContext *ctx)
tbb::concurrent_bounded_queue< action > m_actionsQueue
Queue where closures are stored and picked for execution.
virtual void updateEventStatus(const bool &b, const EventContext &ctx)=0
const unsigned int m_algoIndex
IAlgExecStateSvc * m_aess
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
GAUDI_API void setCurrentContextEvt(long int evtN)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

Member Data Documentation

IAlgExecStateSvc* IOBoundAlgTask::m_aess
private

Definition at line 48 of file IOBoundAlgTask.h.

const unsigned int IOBoundAlgTask::m_algoIndex
private

Definition at line 45 of file IOBoundAlgTask.h.

SmartIF<IAlgorithm> IOBoundAlgTask::m_algorithm
private

Definition at line 43 of file IOBoundAlgTask.h.

EventContext* IOBoundAlgTask::m_evtCtx
private

Definition at line 44 of file IOBoundAlgTask.h.

SmartIF<ForwardSchedulerSvc> IOBoundAlgTask::m_schedSvc
private

Definition at line 47 of file IOBoundAlgTask.h.

SmartIF<ISvcLocator> IOBoundAlgTask::m_serviceLocator
private

Definition at line 49 of file IOBoundAlgTask.h.


The documentation for this class was generated from the following files: