The Gaudi Framework  v29r0 (ff2e7097)
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, EventContext *ctx, ISvcLocator *svcLocator, IAlgExecStateSvc *aem)
 
 ~IOBoundAlgTask () override
 
virtual StatusCode execute () override
 
- Public Member Functions inherited from IAlgTask
virtual ~IAlgTask ()=default
 

Private Attributes

SmartIF< IAlgorithmm_algorithm
 
EventContextm_evtCtx
 
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 21 of file IOBoundAlgTask.h.

Constructor & Destructor Documentation

IOBoundAlgTask::IOBoundAlgTask ( IAlgorithm algorithm,
EventContext ctx,
ISvcLocator svcLocator,
IAlgExecStateSvc aem 
)
inline

Definition at line 24 of file IOBoundAlgTask.h.

25  : m_algorithm( algorithm ), m_evtCtx( ctx ), m_aess( aem ), m_serviceLocator( svcLocator )
26  {
27  }
SmartIF< IAlgorithm > m_algorithm
EventContext * m_evtCtx
SmartIF< ISvcLocator > m_serviceLocator
IAlgExecStateSvc * m_aess
IOBoundAlgTask::~IOBoundAlgTask ( )
inlineoverride

Definition at line 29 of file IOBoundAlgTask.h.

29 {}

Member Function Documentation

StatusCode IOBoundAlgTask::execute ( )
overridevirtual

Implements IAlgTask.

Definition at line 13 of file IOBoundAlgTask.cpp.

14 {
15 
16  IAlgorithm* ialg = m_algorithm.get();
17  Algorithm* this_algo = dynamic_cast<Algorithm*>( ialg );
18  if ( !this_algo ) {
19  throw GaudiException( "Cast to Algorithm failed!", "AlgoExecutionTask", StatusCode::FAILURE );
20  }
21 
22  bool eventfailed = false;
24 
25  // TODO reproduce the commented out functionality in a different service
26  // m_schedSvc->addAlg(this_algo, m_evtCtx, pthread_self());
27 
28  // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
29  const SmartIF<IProperty> appmgr( m_serviceLocator );
30 
32  MsgStream log( messageSvc, "AccelAlgoExecutionTask" );
33 
34  // select the appropriate store
35  this_algo->whiteboard()->selectStore( m_evtCtx->valid() ? m_evtCtx->slot() : 0 ).ignore();
36 
38  try {
40  log << MSG::DEBUG << "Starting execution of algorithm " << m_algorithm->name() << endmsg;
41  m_aess->algExecState( ialg, *m_evtCtx ).setState( AlgExecState::State::Executing );
43  if ( UNLIKELY( !sc.isSuccess() ) ) {
44  log << MSG::WARNING << "Execution of algorithm " << m_algorithm->name() << " failed" << endmsg;
45  eventfailed = true;
46  }
47  log << MSG::DEBUG << "Stopped execution of algorithm " << m_algorithm->name() << endmsg;
48  rcg.ignore(); // disarm the guard
49  } catch ( const GaudiException& Exception ) {
50  log << MSG::FATAL << ".executeEvent(): Exception with tag=" << Exception.tag() << " thrown by "
51  << m_algorithm->name() << endmsg;
52  log << MSG::ERROR << Exception << endmsg;
53  eventfailed = true;
54  } catch ( const std::exception& Exception ) {
55  log << MSG::FATAL << ".executeEvent(): Standard std::exception thrown by " << m_algorithm->name() << endmsg;
56  log << MSG::ERROR << Exception.what() << endmsg;
57  eventfailed = true;
58  } catch ( ... ) {
59  log << MSG::FATAL << ".executeEvent(): UNKNOWN Exception thrown by " << 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
69  m_aess->algExecState( ialg, *m_evtCtx ).setState( AlgExecState::State::Done, sc );
70  m_aess->updateEventStatus( eventfailed, *m_evtCtx );
71 
72  // TODO reproduce the commented out functionality in a different service
73  // m_schedSvc->delAlg(this_algo);
74 
76 
77  return sc;
78 }
#define UNLIKELY(x)
Definition: Kernel.h:128
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:959
ContextID_t slot() const
Definition: EventContext.h:40
EventContext * m_evtCtx
void setState(State s)
constexpr int UnhandledException
Definition: AppReturnCode.h:29
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:82
virtual StatusCode selectStore(size_t partitionIndex)=0
Activate an given &#39;slot&#39; for all subsequent calls within the same thread id.
T what(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
virtual const AlgExecState & algExecState(const Gaudi::StringKey &algName, const EventContext &ctx) const =0
virtual StatusCode sysExecute(const EventContext &)=0
System execution. This method invokes the execute() method of a concrete algorithm.
SmartIF< ISvcLocator > m_serviceLocator
virtual const std::string & tag() const
name tag for the exception, or exception type
STL class.
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
GAUDI_API void setCurrentContext(const EventContext *ctx)
virtual void updateEventStatus(const bool &b, const EventContext &ctx)=0
SmartIF< IHiveWhiteBoard > & whiteboard() const
Definition: Algorithm.cpp:807
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:209
bool valid() const
Definition: EventContext.h:41

Member Data Documentation

IAlgExecStateSvc* IOBoundAlgTask::m_aess
private

Definition at line 36 of file IOBoundAlgTask.h.

SmartIF<IAlgorithm> IOBoundAlgTask::m_algorithm
private

Definition at line 34 of file IOBoundAlgTask.h.

EventContext* IOBoundAlgTask::m_evtCtx
private

Definition at line 35 of file IOBoundAlgTask.h.

SmartIF<ISvcLocator> IOBoundAlgTask::m_serviceLocator
private

Definition at line 37 of file IOBoundAlgTask.h.


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