The Gaudi Framework  v29r0 (ff2e7097)
GaudiParallelizer.h
Go to the documentation of this file.
1 #ifndef LIB_GAUDIPARALLELIZER_H
2 #define LIB_GAUDIPARALLELIZER_H 1
3 // Include files
4 // from Gaudi
7 
8 #include <boost/bind.hpp>
9 #include <tbb/task_group.h>
10 #include <tbb/task_scheduler_init.h>
11 
12 // Forward declarations
14 
22 {
23 public:
25  GaudiParallelizer( const std::string& name, ISvcLocator* pSvcLocator );
27  ~GaudiParallelizer() noexcept( true ) override {}
28  StatusCode initialize() override;
29  StatusCode execute() override;
30  StatusCode finalize() override;
31 
34 
35 protected:
37  {
38  public:
41  {
42  m_algorithm = alg;
43  m_reverse = false;
44  m_timer = 0;
45  }
46 
47  virtual ~AlgorithmEntry(){};
48  void setReverse( bool flag ) { m_reverse = flag; }
49 
50  Algorithm* algorithm() const { return m_algorithm; }
51  bool reverse() const { return m_reverse; }
52  void setTimer( int nb ) { m_timer = nb; }
53  int timer() const { return m_timer; }
54 
56  void run( GaudiParallelizer& prlzr )
57  {
58  if ( prlzr.m_measureTime ) prlzr.m_timerTool->start( timer() );
60  if ( prlzr.m_measureTime ) prlzr.m_timerTool->stop( timer() );
61  algorithm()->setExecuted( true );
62  }
63 
65 
66  private:
68  bool m_reverse;
69  int m_timer;
70  };
71 
74 
75 private:
76  Gaudi::Property<std::vector<std::string>> m_names{this, "Members", {}, "list of algorithms"};
77  Gaudi::Property<bool> m_modeOR{this, "ModeOR", false, "use OR loginc instead of AND"};
78  Gaudi::Property<bool> m_measureTime{this, "MeasureTime", false, "measure time"};
79  Gaudi::Property<bool> m_returnOK{this, "ReturnOK", false, "forces the sequencer to return a good status"};
80  Gaudi::Property<unsigned short> m_nthreads{this, "NumberOfThreads", 0, "number of threads in the thread pool"};
81 
83 
85  int m_timer;
86 
87  tbb::task_group m_task_group;
88 };
89 
90 #endif // LIB_GAUDIPARALLELIZER_H
StatusCode initialize() override
Algorithm initialization.
Gaudi::Property< bool > m_measureTime
StatusCode execute() override
Algorithm execution.
bool m_reverse
Indicates that the flag has to be inverted.
AlgorithmEntry(Algorithm *alg)
Standard constructor.
Gaudi::Property< bool > m_modeOR
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
GaudiParallelizer(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
Algorithm * algorithm() const
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:731
Implementation of property with value of concrete type.
Definition: Property.h:319
Header file for class GaudiAlgorithm.
StatusCode decodeNames()
Decode a vector of string.
STL class.
StatusCode finalize() override
Algorithm finalization.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
The useful base class for data processing algorithms.
GAUDI_API const EventContext & currentContext()
Gaudi::Property< bool > m_returnOK
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
~GaudiParallelizer() noexcept(true) override
Destructor. An explicit noexcept(true) is necessary for Gaudi to build (see GAUDI-1187) ...
Gaudi::Property< unsigned short > m_nthreads
tbb::task_group m_task_group
TBB task group.
virtual void start(int index)=0
start the counter, i.e.
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
STL class.
Algorithm * m_algorithm
Algorithm pointer.
virtual ~AlgorithmEntry()
void setReverse(bool flag)
Destructor.
std::vector< AlgorithmEntry > m_entries
List of algorithms to process.
int timer() const
Implements the time measurement inside a sequencer.
void setTimer(int nb)
void setExecuted(bool state) const override
Set the executed flag to the specified state.
Definition: Algorithm.cpp:747
StatusCode m_returncode
StatusCode of an algorithm execution received from a thread.
void membershipHandler(Gaudi::Details::PropertyBase &theProp)
for asynchronous changes in the list of algorithms
Gaudi::Property< std::vector< std::string > > m_names
int m_timer
Timer number for this algorithm.
ISequencerTimerTool * m_timerTool
Pointer to the timer tool.
int m_timer
Timer number for the sequencer.
bool reverse() const
virtual double stop(int index)=0
stop the counter, return the elapsed time
void run(GaudiParallelizer &prlzr)
Thread task executor method to wrap an algorithm execution in.
StatusCode sysExecute(const EventContext &ctx) override
The actions to be performed by the algorithm on an event.
Definition: Algorithm.cpp:502