The Gaudi Framework  v30r3 (a5ef0a68)
CPUCruncher.h
Go to the documentation of this file.
1 
6 
7 #include <tbb/concurrent_hash_map.h>
8 
9 //------------------------------------------------------------------------------
10 
19 {
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  void findPrimes( const unsigned long int );
50 
52  void calibrate();
53  long unsigned int getNCaliIters( double );
54 
57  bool m_declAugmented{false};
58  Gaudi::Property<bool> m_loader{this, "Loader", false, "Declare the algorithm to be a data loader"};
59 
62 
63  Gaudi::Property<double> m_avg_runtime{this, "avgRuntime", 1., "Average runtime of the module."};
64  Gaudi::Property<double> m_var_runtime{this, "varRuntime", 0.01, "Variance of the runtime of the module."};
65  Gaudi::Property<bool> m_local_rndm_gen{this, "localRndm", true, "Decide if the local random generator is to be used"};
66  Gaudi::Property<bool> m_shortCalib{this, "shortCalib", false, "Enable coarse grained calibration"};
67  Gaudi::Property<unsigned int> m_rwRepetitions{this, "RwRepetitions", 1, "Increase access to the WB"};
69  this, "SleepFraction", 0.0f,
70  "Fraction of time, between 0 and 1, when an algorithm is actually sleeping instead of crunching"};
71  Gaudi::Property<bool> m_invertCFD{this, "InvertDecision", false, "Invert control flow decision."};
72  Gaudi::Property<unsigned int> m_failNEvents{this, "FailNEvents", 0, "Return FAILURE on every Nth event"};
73 
74  // To calib only once
77 
78  // For the concurrency
79  const uint MAX_INPUTS = 40;
80  const uint MAX_OUTPUTS = 10;
81 
84 
85  static CHM m_name_ncopies_map;
86 };
StatusCode execute() override
the execution of the algorithm
Gaudi::Property< float > m_sleepFraction
Definition: CPUCruncher.h:68
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:765
A class that implements a search for prime numbers.
Definition: CPUCruncher.h:18
Implementation of property with value of concrete type.
Definition: Property.h:381
Gaudi::Property< bool > m_loader
Definition: CPUCruncher.h:58
const uint MAX_OUTPUTS
Definition: CPUCruncher.h:80
virtual ~CPUCruncher()
virtual & protected desctrustor
Definition: CPUCruncher.cpp:40
Header file for class GaudiAlgorithm.
void findPrimes(const unsigned long int)
The CPU intensive function.
Gaudi::Property< unsigned int > m_rwRepetitions
Definition: CPUCruncher.h:67
double get_runtime() const
Definition: CPUCruncher.h:33
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
Definition: CPUCruncher.h:83
CPUCruncher & operator=(const CPUCruncher &)
the assignement operator is disabled
void calibrate()
Calibrate.
Definition: CPUCruncher.cpp:86
long unsigned int getNCaliIters(double)
STL class.
tbb::concurrent_hash_map< std::string, unsigned int > CHM
Definition: CPUCruncher.h:22
static std::vector< unsigned int > m_niters_vect
Definition: CPUCruncher.h:75
static CHM m_name_ncopies_map
Definition: CPUCruncher.h:85
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
Gaudi::Property< bool > m_invertCFD
Definition: CPUCruncher.h:71
The useful base class for data processing algorithms.
std::vector< DataObjectHandle< DataObject > * > m_inputHandles
Definition: CPUCruncher.h:82
static std::vector< double > m_times_vect
Definition: CPUCruncher.h:76
bool isClonable() const override
Definition: CPUCruncher.h:24
Gaudi::Property< bool > m_shortCalib
Definition: CPUCruncher.h:66
void declareRuntimeRequestedOutputs()
Pick up late-attributed data outputs.
Gaudi::Property< double > m_avg_runtime
Definition: CPUCruncher.h:63
StatusCode initialize() override
Its initialization.
Definition: CPUCruncher.cpp:47
CPUCruncher()
the default constructor is disabled
Gaudi::Property< unsigned int > m_failNEvents
Definition: CPUCruncher.h:72
Gaudi::Property< std::vector< std::string > > m_outKeys
Definition: CPUCruncher.h:61
Gaudi::Property< std::vector< std::string > > m_inpKeys
Definition: CPUCruncher.h:60
const uint MAX_INPUTS
Definition: CPUCruncher.h:79
StatusCode finalize() override
the finalization of the algorithm
Gaudi::Property< bool > m_local_rndm_gen
Definition: CPUCruncher.h:65
Gaudi::Property< double > m_var_runtime
Definition: CPUCruncher.h:64
bool m_declAugmented
Definition: CPUCruncher.h:57