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
5 #include "GaudiAlg/GaudiAlgorithm.h"
6 
7 #include <tbb/task_group.h>
8 #include <tbb/task_scheduler_init.h>
9 #include <boost/bind.hpp>
10 
11 // Forward declarations
13 
21 public:
23  GaudiParallelizer(const std::string& name, ISvcLocator* pSvcLocator);
24  virtual ~GaudiParallelizer();
25 
26  virtual StatusCode initialize();
27  virtual StatusCode execute ();
28  virtual StatusCode finalize ();
29 
31  void membershipHandler( Property& theProp );
32 
33 protected:
35  public:
38  m_algorithm = alg;
39  m_reverse = false;
40  m_timer = 0;
41  }
42 
43  virtual ~AlgorithmEntry( ) {};
44  void setReverse( bool flag ) { m_reverse = flag; }
45 
46  Algorithm* algorithm() const { return m_algorithm; }
47  bool reverse() const { return m_reverse; }
48  void setTimer( int nb ) { m_timer = nb; }
49  int timer() const { return m_timer; }
50 
52  void run( GaudiParallelizer& prlzr ) {
53  if ( prlzr.m_measureTime ) prlzr.m_timerTool->start( timer() );
55  if ( prlzr.m_measureTime ) prlzr.m_timerTool->stop( timer() );
56  algorithm()->setExecuted( true );
57  }
58 
60 
61  private:
63  bool m_reverse;
64  int m_timer;
65  };
66 
69 
70 private:
72  std::vector<AlgorithmEntry> m_entries;
73  bool m_modeOR;
74 
76  bool m_returnOK;
78  int m_timer;
79 
80  tbb::task_group m_task_group;
81  unsigned short m_nthreads;
82 };
83 
84 #endif // LIB_GAUDIPARALLELIZER_H
bool m_reverse
Indicates that the flag has to be inverted.
AlgorithmEntry(Algorithm *alg)
Standard constructor.
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
virtual ~GaudiParallelizer()
Destructor.
bool m_returnOK
Forces the sequencer to return a good status.
StatusCode decodeNames()
Decode a vector of string.
bool m_modeOR
Indicates that the OR is wanted instead of AND.
virtual StatusCode finalize()
Algorithm finalization.
StringArrayProperty m_names
Input string, list of algorithms.
void setExecuted(bool state) override
Set the executed flag to the specified state.
Definition: Algorithm.cpp:935
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode sysExecute() override
The actions to be performed by the algorithm on an event.
Definition: Algorithm.cpp:652
The useful base class for data processing algorithms.
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:77
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
Algorithm * m_algorithm
Algorithm pointer.
virtual StatusCode execute()
Algorithm execution.
virtual ~AlgorithmEntry()
void setReverse(bool flag)
Destructor.
std::vector< AlgorithmEntry > m_entries
List of algorithms to process.
int timer() const
void membershipHandler(Property &theProp)
for asynchronous changes in the list of algorithms
Implements the time measurement inside a sequencer.
void setTimer(int nb)
StatusCode m_returncode
StatusCode of an algorithm execution received from a thread.
int m_timer
Timer number for this algorithm.
ISequencerTimerTool * m_timerTool
Pointer to the timer tool.
bool m_measureTime
Flag to measure time.
int m_timer
Timer number for the sequencer.
bool reverse() const
unsigned short m_nthreads
Number of threads in the thread pool.
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.
virtual StatusCode initialize()
Algorithm initialization.