| The Gaudi Framework v29r1 (5cd95fa2)

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

- File List
- File Members

CPUCruncher.h
Go to the documentation of this file.
1
2 #include "GaudiAlg/GaudiAlgorithm.h"
3 #include "GaudiKernel/AlgFactory.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
22 public:
23 typedef tbb::concurrent_hash_map<std::string, unsigned int> CHM;
24
25 bool isClonable() const override { return true; }
26
28 StatusCode execute() override;
30 StatusCode initialize() override;
32 StatusCode finalize() override;
33
34 double get_runtime() const { return m_avg_runtime; }
35
36 CPUCruncher( const std::string& name, // the algorithm instance name
37 ISvcLocator* pSvc ); // the Service Locator
38
40 virtual ~CPUCruncher(); // virtual & protected desctrustor
41
42 private:
44 CPUCruncher(); // no default constructor
46 CPUCruncher( const CPUCruncher& ); // no copy constructor
48 CPUCruncher& operator=( const CPUCruncher& ); // no assignement
50 void findPrimes( const unsigned long int );
51
53 void calibrate();
54 long unsigned int getNCaliIters( double );
55
56 Gaudi::Property<std::vector<std::string>> m_inpKeys{this, "inpKeys", {}, ""};
57 Gaudi::Property<std::vector<std::string>> m_outKeys{this, "outKeys", {}, ""};
58
59 Gaudi::Property<double> m_avg_runtime{this, "avgRuntime", 1., "Average runtime of the module."};
60 Gaudi::Property<double> m_var_runtime{this, "varRuntime", 0.01, "Variance of the runtime of the module."};
61 Gaudi::Property<bool> m_local_rndm_gen{this, "localRndm", true, "Decide if the local random generator is to be used"};
62 Gaudi::Property<bool> m_shortCalib{this, "shortCalib", false, "Enable coarse grained calibration"};
63 Gaudi::Property<unsigned int> m_rwRepetitions{this, "RwRepetitions", 1, "Increase access to the WB"};
64 Gaudi::Property<float> m_sleepFraction{
65 this, "SleepFraction", 0.0f,
66 "Fraction of time, between 0 and 1, when an algorithm is actually sleeping instead of crunching"};
67 Gaudi::Property<bool> m_invertCFD{this, "InvertDecision", false, "Invert control flow decision."};
68
69 // To calib only once
70 static std::vector<unsigned int> m_niters_vect;
71 static std::vector<double> m_times_vect;
72
73 // For the concurrency
74 const uint MAX_INPUTS = 40;
75 const uint MAX_OUTPUTS = 10;
76
77 std::vector<DataObjectHandle<DataObject>*> m_inputHandles;
78 std::vector<DataObjectHandle<DataObject>*> m_outputHandles;
79
80 static CHM m_name_ncopies_map;
81 };
CPUCruncher::execute
StatusCode execute() override
the execution of the algorithm
Definition: CPUCruncher.cpp:201
CPUCruncher::m_sleepFraction
Gaudi::Property< float > m_sleepFraction
Definition: CPUCruncher.h:64
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:731
CPUCruncher
A class that implements a search for prime numbers.
Definition: CPUCruncher.h:19
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:319
CPUCruncher::MAX_OUTPUTS
const uint MAX_OUTPUTS
Definition: CPUCruncher.h:75
CPUCruncher::~CPUCruncher
virtual ~CPUCruncher()
virtual & protected desctrustor
Definition: CPUCruncher.cpp:40
GaudiAlgorithm.h
Header file for class GaudiAlgorithm.
CPUCruncher::findPrimes
void findPrimes(const unsigned long int)
The CPU intensive function.
Definition: CPUCruncher.cpp:149
CPUCruncher::m_rwRepetitions
Gaudi::Property< unsigned int > m_rwRepetitions
Definition: CPUCruncher.h:63
CPUCruncher::get_runtime
double get_runtime() const
Definition: CPUCruncher.h:34
CPUCruncher::m_outputHandles
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
Definition: CPUCruncher.h:78
CPUCruncher::operator=
CPUCruncher & operator=(const CPUCruncher &)
the assignement operator is disabled
CPUCruncher::calibrate
void calibrate()
Calibrate.
Definition: CPUCruncher.cpp:86
CPUCruncher::getNCaliIters
long unsigned int getNCaliIters(double)
Definition: CPUCruncher.cpp:115
std::string
STL class.
CPUCruncher::CHM
tbb::concurrent_hash_map< std::string, unsigned int > CHM
Definition: CPUCruncher.h:23
CPUCruncher::m_niters_vect
static std::vector< unsigned int > m_niters_vect
Definition: CPUCruncher.h:70
CPUCruncher::m_name_ncopies_map
static CHM m_name_ncopies_map
Definition: CPUCruncher.h:80
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
CPUCruncher::m_invertCFD
Gaudi::Property< bool > m_invertCFD
Definition: CPUCruncher.h:67
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:77
RndmGenerators.h
CPUCruncher::m_times_vect
static std::vector< double > m_times_vect
Definition: CPUCruncher.h:71
RegistryEntry.h
CPUCruncher::isClonable
bool isClonable() const override
Definition: CPUCruncher.h:25
CPUCruncher::m_shortCalib
Gaudi::Property< bool > m_shortCalib
Definition: CPUCruncher.h:62
std::vector< unsigned int >
IRndmGenSvc.h
CPUCruncher::m_avg_runtime
Gaudi::Property< double > m_avg_runtime
Definition: CPUCruncher.h:59
CPUCruncher::initialize
StatusCode initialize() override
Its initialization.
Definition: CPUCruncher.cpp:47
CPUCruncher::CPUCruncher
CPUCruncher()
the default constructor is disabled
CPUCruncher::m_outKeys
Gaudi::Property< std::vector< std::string > > m_outKeys
Definition: CPUCruncher.h:57
AlgFactory.h
CPUCruncher::m_inpKeys
Gaudi::Property< std::vector< std::string > > m_inpKeys
Definition: CPUCruncher.h:56
CPUCruncher::MAX_INPUTS
const uint MAX_INPUTS
Definition: CPUCruncher.h:74
CPUCruncher::finalize
StatusCode finalize() override
the finalization of the algorithm
Definition: CPUCruncher.cpp:327
CPUCruncher::m_local_rndm_gen
Gaudi::Property< bool > m_local_rndm_gen
Definition: CPUCruncher.h:61
CPUCruncher::m_var_runtime
Gaudi::Property< double > m_var_runtime
Definition: CPUCruncher.h:60