All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
CPUCruncher.h
Go to the documentation of this file.
1 
2 #include "GaudiKernel/AlgFactory.h"
3 #include "GaudiKernel/IRndmGenSvc.h"
4 #include "GaudiKernel/RndmGenerators.h"
5 #include "GaudiAlg/GaudiAlgorithm.h"
6 #include "GaudiKernel/RegistryEntry.h"
7 
8 #include <tbb/concurrent_hash_map.h>
9 
10 //------------------------------------------------------------------------------
11 
19  class CPUCruncher : public GaudiAlgorithm
20  {
21 
22  friend class AlgFactory<CPUCruncher> ;
23 
24  public:
25 
26  typedef tbb::concurrent_hash_map<std::string,unsigned int> CHM;
27 
29  virtual StatusCode execute () ; // the execution of the algorithm
31  virtual StatusCode initialize();
33  virtual StatusCode finalize () ; // the finalization of the algorithm
35  virtual const std::vector<std::string> get_inputs();
37  virtual const std::vector<std::string> get_outputs();
38 
39  double get_runtime() const { return m_avg_runtime; };
40 
41  protected:
42 
44  ( const std::string& name , // the algorithm instance name
45  ISvcLocator* pSvc ); // the Service Locator
46 
48  virtual ~CPUCruncher(); // virtual & protected desctrustor
49 
50  private:
51 
53  CPUCruncher () ; // no default constructor
55  CPUCruncher ( const CPUCruncher& ) ; // no copy constructor
57  CPUCruncher& operator= ( const CPUCruncher& ) ; // no assignement
59  void findPrimes (const unsigned long int ) ;
60 
62  void calibrate();
63  long unsigned int getNCaliIters(double);
64 
65  double m_avg_runtime ; //Avg Runtime
66  double m_var_runtime ; //Variance of Runtime
67  bool m_local_rndm_gen; //Decide what random number generation to use
69 
70  // To calib only once
71  static std::vector<unsigned int>m_niters_vect;
72  static std::vector<double> m_times_vect;
73 
74  // For the concurrency
75 
76  const uint MAX_INPUTS = 40;
77  const uint MAX_OUTPUTS = 10;
78 
79  std::vector<DataObjectHandle<DataObject> *> m_inputHandles;
80  std::vector<DataObjectHandle<DataObject> *> m_outputHandles;
81 
82  unsigned int m_rwRepetitions;
83 
84  static CHM m_name_ncopies_map;
85 
86  // Sleep during execution instead of real CPU crunching
88 
89  };
90 
bool m_sleepyExecution
Definition: CPUCruncher.h:87
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
virtual StatusCode initialize()
Its initialization.
Definition: CPUCruncher.cpp:71
bool m_shortCalib
Definition: CPUCruncher.h:68
const uint MAX_OUTPUTS
Definition: CPUCruncher.h:77
virtual ~CPUCruncher()
virtual & protected desctrustor
Definition: CPUCruncher.cpp:60
void findPrimes(const unsigned long int)
The CPU intensive function.
double m_avg_runtime
Definition: CPUCruncher.h:65
double get_runtime() const
Definition: CPUCruncher.h:39
CPUCruncher & operator=(const CPUCruncher &)
the assignement operator is disabled
void calibrate()
Calibrate.
Definition: CPUCruncher.cpp:83
virtual const std::vector< std::string > get_inputs()
Get the inputs.
virtual StatusCode execute()
the execution of the algorithm
long unsigned int getNCaliIters(double)
virtual StatusCode finalize()
the finalization of the algorithm
static std::vector< unsigned int > m_niters_vect
Definition: CPUCruncher.h:71
static CHM m_name_ncopies_map
Definition: CPUCruncher.h:84
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
The useful base class for data processing algorithms.
static std::vector< double > m_times_vect
Definition: CPUCruncher.h:72
std::vector< DataObjectHandle< DataObject > * > m_inputHandles
Definition: CPUCruncher.h:79
CPUCruncher()
the default constructor is disabled
unsigned int m_rwRepetitions
Definition: CPUCruncher.h:82
const uint MAX_INPUTS
Definition: CPUCruncher.h:76
virtual const std::vector< std::string > get_outputs()
Get the outputs.
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
Definition: CPUCruncher.h:80
bool m_local_rndm_gen
Definition: CPUCruncher.h:67
double m_var_runtime
Definition: CPUCruncher.h:66
tbb::concurrent_hash_map< std::string, unsigned int > CHM
Definition: CPUCruncher.h:26