| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

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
12 class ISequencerTimerTool;
13
20 class GaudiParallelizer: public GaudiAlgorithm {
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:
34 class AlgorithmEntry {
35 public:
37 AlgorithmEntry( Algorithm* alg ) {
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() );
54 m_returncode = m_algorithm->sysExecute();
55 if ( prlzr.m_measureTime ) prlzr.m_timerTool->stop( timer() );
56 algorithm()->setExecuted( true );
57 }
58
59 StatusCode m_returncode;
60
61 private:
62 Algorithm* m_algorithm;
63 bool m_reverse;
64 int m_timer;
65 };
66
68 StatusCode decodeNames( );
69
70 private:
71 StringArrayProperty m_names;
72 std::vector<AlgorithmEntry> m_entries;
73 bool m_modeOR;
74
75 bool m_measureTime;
76 bool m_returnOK;
77 ISequencerTimerTool* m_timerTool;
78 int m_timer;
79
80 tbb::task_group m_task_group;
81 unsigned short m_nthreads;
82 };
83
84 #endif // LIB_GAUDIPARALLELIZER_H
GaudiParallelizer::AlgorithmEntry::m_reverse
bool m_reverse
Indicates that the flag has to be inverted.
Definition: GaudiParallelizer.h:63
GaudiParallelizer::AlgorithmEntry::AlgorithmEntry
AlgorithmEntry(Algorithm *alg)
Standard constructor.
Definition: GaudiParallelizer.h:37
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
GaudiParallelizer::GaudiParallelizer
GaudiParallelizer(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
Definition: GaudiParallelizer.cpp:21
GaudiParallelizer::AlgorithmEntry::algorithm
Algorithm * algorithm() const
Definition: GaudiParallelizer.h:46
GaudiParallelizer::~GaudiParallelizer
virtual ~GaudiParallelizer()
Destructor.
Definition: GaudiParallelizer.cpp:37
GaudiParallelizer::m_returnOK
bool m_returnOK
Forces the sequencer to return a good status.
Definition: GaudiParallelizer.h:76
GaudiAlgorithm.h
GaudiParallelizer
Definition: GaudiParallelizer.h:20
GaudiParallelizer::decodeNames
StatusCode decodeNames()
Decode a vector of string.
Definition: GaudiParallelizer.cpp:139
GaudiParallelizer::m_modeOR
bool m_modeOR
Indicates that the OR is wanted instead of AND.
Definition: GaudiParallelizer.h:73
GaudiParallelizer::finalize
virtual StatusCode finalize()
Algorithm finalization.
Definition: GaudiParallelizer.cpp:131
std::string
STL class.
Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:820
SimpleProperty< std::vector< std::string > >
GaudiParallelizer::m_names
StringArrayProperty m_names
Input string, list of algorithms.
Definition: GaudiParallelizer.h:71
Algorithm::setExecuted
void setExecuted(bool state) override
Set the executed flag to the specified state.
Definition: Algorithm.cpp:844
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Algorithm::sysExecute
StatusCode sysExecute() override
The actions to be performed by the algorithm on an event.
Definition: Algorithm.cpp:567
GaudiAlgorithm
The useful base class for data processing algorithms.
Definition: GaudiAlgorithm.h:93
GaudiParallelizer::m_task_group
tbb::task_group m_task_group
TBB task group.
Definition: GaudiParallelizer.h:80
ISequencerTimerTool::start
virtual void start(int index)=0
start the counter, i.e.
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
Property
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
std::vector
STL class.
GaudiParallelizer::AlgorithmEntry::m_algorithm
Algorithm * m_algorithm
Algorithm pointer.
Definition: GaudiParallelizer.h:62
GaudiParallelizer::execute
virtual StatusCode execute()
Algorithm execution.
Definition: GaudiParallelizer.cpp:94
GaudiParallelizer::AlgorithmEntry::~AlgorithmEntry
virtual ~AlgorithmEntry()
Definition: GaudiParallelizer.h:43
GaudiParallelizer::AlgorithmEntry::setReverse
void setReverse(bool flag)
Destructor.
Definition: GaudiParallelizer.h:44
GaudiParallelizer::m_entries
std::vector< AlgorithmEntry > m_entries
List of algorithms to process.
Definition: GaudiParallelizer.h:72
GaudiParallelizer::AlgorithmEntry::timer
int timer() const
Definition: GaudiParallelizer.h:49
GaudiParallelizer::membershipHandler
void membershipHandler(Property &theProp)
for asynchronous changes in the list of algorithms
Definition: GaudiParallelizer.cpp:279
ISequencerTimerTool
Implements the time measurement inside a sequencer.
Definition: ISequencerTimerTool.h:14
GaudiParallelizer::AlgorithmEntry::setTimer
void setTimer(int nb)
Definition: GaudiParallelizer.h:48
GaudiParallelizer::AlgorithmEntry::m_returncode
StatusCode m_returncode
StatusCode of an algorithm execution received from a thread.
Definition: GaudiParallelizer.h:59
GaudiParallelizer::AlgorithmEntry::m_timer
int m_timer
Timer number for this algorithm.
Definition: GaudiParallelizer.h:64
GaudiParallelizer::m_timerTool
ISequencerTimerTool * m_timerTool
Pointer to the timer tool.
Definition: GaudiParallelizer.h:77
GaudiParallelizer::m_measureTime
bool m_measureTime
Flag to measure time.
Definition: GaudiParallelizer.h:75
GaudiParallelizer::m_timer
int m_timer
Timer number for the sequencer.
Definition: GaudiParallelizer.h:78
GaudiParallelizer::AlgorithmEntry::reverse
bool reverse() const
Definition: GaudiParallelizer.h:47
GaudiParallelizer::m_nthreads
unsigned short m_nthreads
Number of threads in the thread pool.
Definition: GaudiParallelizer.h:81
GaudiParallelizer::AlgorithmEntry
Definition: GaudiParallelizer.h:34
ISequencerTimerTool::stop
virtual double stop(int index)=0
stop the counter, return the elapsed time
GaudiParallelizer::AlgorithmEntry::run
void run(GaudiParallelizer &prlzr)
Thread task executor method to wrap an algorithm execution in.
Definition: GaudiParallelizer.h:52
GaudiParallelizer::initialize
virtual StatusCode initialize()
Algorithm initialization.
Definition: GaudiParallelizer.cpp:42