| The Gaudi Framework v32r1 (f65d50dc)

CPUCruncher.h
Go to the documentation of this file.
1
2 #include "GaudiAlg/GaudiAlgorithm.h"
3 #include "GaudiKernel/ICPUCrunchSvc.h"
4 #include "GaudiKernel/IRndmGenSvc.h"
5 #include "GaudiKernel/RegistryEntry.h"
6 #include "GaudiKernel/RndmGenerators.h"
7
8 #include <tbb/concurrent_hash_map.h>
9
10 //------------------------------------------------------------------------------
11
19 class CPUCruncher : public GaudiAlgorithm {
20
21 public:
22 typedef tbb::concurrent_hash_map<std::string, unsigned int> CHM;
23
24 bool isClonable() const override { return true; }
25
27 StatusCode execute() override;
29 StatusCode initialize() override;
31 StatusCode finalize() override;
32
33 double get_runtime() const { return m_avg_runtime; }
34
35 CPUCruncher( const std::string& name, // the algorithm instance name
36 ISvcLocator* pSvc ); // the Service Locator
37
39 virtual ~CPUCruncher(); // virtual & protected desctrustor
40
41 private:
43 CPUCruncher(); // no default constructor
45 CPUCruncher( const CPUCruncher& ); // no copy constructor
47 CPUCruncher& operator=( const CPUCruncher& ); // no assignement
49
51 void declareRuntimeRequestedOutputs();
52 bool m_declAugmented{false};
53 Gaudi::Property<bool> m_loader{this, "Loader", false, "Declare the algorithm to be a data loader"};
54
55 Gaudi::Property<std::vector<std::string>> m_inpKeys{this, "inpKeys", {}, ""};
56 Gaudi::Property<std::vector<std::string>> m_outKeys{this, "outKeys", {}, ""};
57
58 Gaudi::Property<double> m_avg_runtime{this, "avgRuntime", 1., "Average runtime of the module."};
59 Gaudi::Property<double> m_var_runtime{this, "varRuntime", 0.01, "Variance of the runtime of the module."};
60 Gaudi::Property<bool> m_local_rndm_gen{this, "localRndm", true, "Decide if the local random generator is to be used"};
61 Gaudi::Property<unsigned int> m_rwRepetitions{this, "RwRepetitions", 1, "Increase access to the WB"};
62 Gaudi::Property<float> m_sleepFraction{
63 this, "SleepFraction", 0.0f,
64 "Fraction of time, between 0 and 1, when an algorithm is actually sleeping instead of crunching"};
65 Gaudi::Property<bool> m_invertCFD{this, "InvertDecision", false, "Invert control flow decision."};
66 Gaudi::Property<unsigned int> m_failNEvents{this, "FailNEvents", 0, "Return FAILURE on every Nth event"};
67
68 // For the concurrency
69 const uint MAX_INPUTS = 40;
70 const uint MAX_OUTPUTS = 10;
71
72 std::vector<DataObjectHandle<DataObject>*> m_inputHandles;
73 std::vector<DataObjectHandle<DataObject>*> m_outputHandles;
74
75 static CHM m_name_ncopies_map;
76
77 // CPUCrunchSvc
78 SmartIF<ICPUCrunchSvc> m_crunchSvc;
79 };
CPUCruncher::execute
StatusCode execute() override
the execution of the algorithm
Definition: CPUCruncher.cpp:95
CPUCruncher::m_crunchSvc
SmartIF< ICPUCrunchSvc > m_crunchSvc
Definition: CPUCruncher.h:78
SmartIF< ICPUCrunchSvc >
CPUCruncher::m_sleepFraction
Gaudi::Property< float > m_sleepFraction
Definition: CPUCruncher.h:62
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
CPUCruncher
A class that implements a search for prime numbers.
Definition: CPUCruncher.h:19
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
CPUCruncher::m_loader
Gaudi::Property< bool > m_loader
Definition: CPUCruncher.h:53
CPUCruncher::MAX_OUTPUTS
const uint MAX_OUTPUTS
Definition: CPUCruncher.h:70
CPUCruncher::~CPUCruncher
virtual ~CPUCruncher()
virtual & protected desctrustor
Definition: CPUCruncher.cpp:34
GaudiAlgorithm.h
Header file for class GaudiAlgorithm.
CPUCruncher::m_rwRepetitions
Gaudi::Property< unsigned int > m_rwRepetitions
Definition: CPUCruncher.h:61
CPUCruncher::isClonable
bool isClonable() const override
Definition: CPUCruncher.h:24
CPUCruncher::m_outputHandles
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
Definition: CPUCruncher.h:73
CPUCruncher::operator=
CPUCruncher & operator=(const CPUCruncher &)
the assignement operator is disabled
std::string
STL class.
CPUCruncher::CHM
tbb::concurrent_hash_map< std::string, unsigned int > CHM
Definition: CPUCruncher.h:22
CPUCruncher::m_name_ncopies_map
static CHM m_name_ncopies_map
Definition: CPUCruncher.h:75
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
CPUCruncher::m_invertCFD
Gaudi::Property< bool > m_invertCFD
Definition: CPUCruncher.h:65
GaudiAlgorithm
The useful base class for data processing algorithms.
Definition: GaudiAlgorithm.h:94
CPUCruncher::m_inputHandles
std::vector< DataObjectHandle< DataObject > * > m_inputHandles
Definition: CPUCruncher.h:72
RndmGenerators.h
RegistryEntry.h
CPUCruncher::declareRuntimeRequestedOutputs
void declareRuntimeRequestedOutputs()
The CPU intensive function.
Definition: CPUCruncher.cpp:79
std::vector
STL class.
IRndmGenSvc.h
CPUCruncher::m_avg_runtime
Gaudi::Property< double > m_avg_runtime
Definition: CPUCruncher.h:58
CPUCruncher::initialize
StatusCode initialize() override
Its initialization.
Definition: CPUCruncher.cpp:40
CPUCruncher::CPUCruncher
CPUCruncher()
the default constructor is disabled
CPUCruncher::m_failNEvents
Gaudi::Property< unsigned int > m_failNEvents
Definition: CPUCruncher.h:66
CPUCruncher::m_outKeys
Gaudi::Property< std::vector< std::string > > m_outKeys
Definition: CPUCruncher.h:56
CPUCruncher::m_inpKeys
Gaudi::Property< std::vector< std::string > > m_inpKeys
Definition: CPUCruncher.h:55
CPUCruncher::MAX_INPUTS
const uint MAX_INPUTS
Definition: CPUCruncher.h:69
CPUCruncher::get_runtime
double get_runtime() const
Definition: CPUCruncher.h:33
ICPUCrunchSvc.h
CPUCruncher::finalize
StatusCode finalize() override
the finalization of the algorithm
Definition: CPUCruncher.cpp:222
CPUCruncher::m_local_rndm_gen
Gaudi::Property< bool > m_local_rndm_gen
Definition: CPUCruncher.h:60
CPUCruncher::m_var_runtime
Gaudi::Property< double > m_var_runtime
Definition: CPUCruncher.h:59
CPUCruncher::m_declAugmented
bool m_declAugmented
Definition: CPUCruncher.h:52