The Gaudi Framework  v33r1 (b1225454)
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, const EventContext &ctx, ISvcLocator *svcLocator, IAlgExecStateSvc *aem, std::function< StatusCode()> promote2ExecutedClosure)
 
StatusCode execute () override final
 
- Public Member Functions inherited from IAlgTask
virtual ~IAlgTask ()=default
 

Private Attributes

SmartIF< IAlgorithmm_algorithm
 
const EventContextm_evtCtx
 
IAlgExecStateSvcm_aess
 
SmartIF< ISvcLocatorm_serviceLocator
 
std::function< StatusCode()> m_promote2ExecutedClosure
 

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 33 of file IOBoundAlgTask.h.

Constructor & Destructor Documentation

◆ IOBoundAlgTask()

IOBoundAlgTask::IOBoundAlgTask ( IAlgorithm algorithm,
const EventContext ctx,
ISvcLocator svcLocator,
IAlgExecStateSvc aem,
std::function< StatusCode()>  promote2ExecutedClosure 
)
inline

Definition at line 35 of file IOBoundAlgTask.h.

37  : m_algorithm( algorithm )
38  , m_evtCtx( ctx )
39  , m_aess( aem )
41  , m_promote2ExecutedClosure( std::move( promote2ExecutedClosure ) ) {}
SmartIF< IAlgorithm > m_algorithm
GAUDI_API ISvcLocator * svcLocator()
const EventContext & m_evtCtx
SmartIF< ISvcLocator > m_serviceLocator
T move(T... args)
IAlgExecStateSvc * m_aess
std::function< StatusCode()> m_promote2ExecutedClosure

Member Function Documentation

◆ execute()

StatusCode IOBoundAlgTask::execute ( )
finaloverridevirtual

Implements IAlgTask.

Definition at line 21 of file IOBoundAlgTask.cpp.

21  {
22 
23  IAlgorithm* ialg = m_algorithm.get();
24  Algorithm* this_algo = dynamic_cast<Algorithm*>( ialg );
25  if ( !this_algo ) { throw GaudiException( "Cast to Algorithm failed!", "AlgoExecutionTask", StatusCode::FAILURE ); }
26 
27  bool eventfailed = false;
29 
30  // Get the IProperty interface of the ApplicationMgr to pass it to RetCodeGuard
31  const SmartIF<IProperty> appmgr( m_serviceLocator );
32 
34  MsgStream log( messageSvc, "AccelAlgoExecutionTask" );
35 
36  // select the appropriate store
37  this_algo->whiteboard()->selectStore( m_evtCtx.valid() ? m_evtCtx.slot() : 0 ).ignore();
38 
40  try {
42  log << MSG::DEBUG << "Starting execution of algorithm " << m_algorithm->name() << endmsg;
44  if ( UNLIKELY( !sc.isSuccess() ) ) {
45  log << MSG::WARNING << "Execution of algorithm " << m_algorithm->name() << " failed" << endmsg;
46  eventfailed = true;
47  }
48  log << MSG::DEBUG << "Stopped execution of algorithm " << m_algorithm->name() << endmsg;
49  rcg.ignore(); // disarm the guard
50  } catch ( const GaudiException& Exception ) {
51  log << MSG::FATAL << ".executeEvent(): Exception with tag=" << Exception.tag() << " thrown by "
52  << m_algorithm->name() << endmsg;
53  log << MSG::ERROR << Exception << endmsg;
54  eventfailed = true;
55  } catch ( const std::exception& Exception ) {
56  log << MSG::FATAL << ".executeEvent(): Standard std::exception thrown by " << m_algorithm->name() << endmsg;
57  log << MSG::ERROR << Exception.what() << endmsg;
58  eventfailed = true;
59  } catch ( ... ) {
60  log << MSG::FATAL << ".executeEvent(): UNKNOWN Exception thrown by " << m_algorithm->name() << endmsg;
61  eventfailed = true;
62  }
63 
64  // DP it is important to propagate the failure of an event.
65  // We need to stop execution when this happens so that execute run can
66  // then receive the FAILURE
67  m_aess->updateEventStatus( eventfailed, m_evtCtx );
68 
69  // update scheduler state
71  if ( UNLIKELY( sc.isFailure() ) ) {
72  log << MSG::WARNING << "Cannot schedule update of algorithm state for " << m_algorithm->name() << endmsg;
73  }
74 
76 
77  return sc;
78 }
#define UNLIKELY(x)
Definition: Kernel.h:106
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:34
ContextID_t slot() const
Definition: EventContext.h:51
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:19
SmartIF< IHiveWhiteBoard > & whiteboard() const
Definition: Algorithm.cpp:591
virtual const std::string & tag() const
name tag for the exception, or exception type
TYPE * get() const
Get interface pointer.
Definition: SmartIF.h:86
bool valid() const
Definition: EventContext.h:54
constexpr int UnhandledException
Definition: AppReturnCode.h:37
virtual StatusCode selectStore(size_t partitionIndex)=0
Activate an given 'slot' 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:61
const EventContext & m_evtCtx
virtual StatusCode sysExecute(const EventContext &)=0
System execution. This method invokes the execute() method of a concrete algorithm.
SmartIF< ISvcLocator > m_serviceLocator
STL class.
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:38
GAUDI_API void setCurrentContext(const EventContext *ctx)
virtual void updateEventStatus(const bool &b, const EventContext &ctx)=0
IAlgExecStateSvc * m_aess
Alias for backward compatibility.
Definition: Algorithm.h:58
constexpr static const auto FAILURE
Definition: StatusCode.h:101
GAUDI_API void setCurrentContextEvt(long int evtN)
std::function< StatusCode()> m_promote2ExecutedClosure
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

Member Data Documentation

◆ m_aess

IAlgExecStateSvc* IOBoundAlgTask::m_aess
private

Definition at line 48 of file IOBoundAlgTask.h.

◆ m_algorithm

SmartIF<IAlgorithm> IOBoundAlgTask::m_algorithm
private

Definition at line 46 of file IOBoundAlgTask.h.

◆ m_evtCtx

const EventContext& IOBoundAlgTask::m_evtCtx
private

Definition at line 47 of file IOBoundAlgTask.h.

◆ m_promote2ExecutedClosure

std::function<StatusCode()> IOBoundAlgTask::m_promote2ExecutedClosure
private

Definition at line 50 of file IOBoundAlgTask.h.

◆ m_serviceLocator

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: