The Gaudi Framework  v33r0 (d5ea422b)
CPUCruncher.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 
17 
18 #include <tbb/concurrent_hash_map.h>
19 
20 //------------------------------------------------------------------------------
21 
29 class CPUCruncher : public GaudiAlgorithm {
30 
31 public:
32  typedef tbb::concurrent_hash_map<std::string, unsigned int> CHM;
33 
34  bool isClonable() const override { return true; }
35 
37  StatusCode execute() override;
39  StatusCode initialize() override;
41  StatusCode finalize() override;
42 
43  double get_runtime() const { return m_avg_runtime; }
44 
45  CPUCruncher( const std::string& name, // the algorithm instance name
46  ISvcLocator* pSvc ); // the Service Locator
47 
49  virtual ~CPUCruncher(); // virtual & protected desctrustor
50 
51 private:
53  CPUCruncher(); // no default constructor
55  CPUCruncher( const CPUCruncher& ); // no copy constructor
57  CPUCruncher& operator=( const CPUCruncher& ); // no assignement
59 
62  bool m_declAugmented{false};
63  Gaudi::Property<bool> m_loader{this, "Loader", false, "Declare the algorithm to be a data loader"};
64 
67 
68  Gaudi::Property<double> m_avg_runtime{this, "avgRuntime", 1., "Average runtime of the module."};
69  Gaudi::Property<double> m_var_runtime{this, "varRuntime", 0.01, "Variance of the runtime of the module."};
70  Gaudi::Property<bool> m_local_rndm_gen{this, "localRndm", true, "Decide if the local random generator is to be used"};
71  Gaudi::Property<unsigned int> m_rwRepetitions{this, "RwRepetitions", 1, "Increase access to the WB"};
73  this, "SleepFraction", 0.0f,
74  "Fraction of time, between 0 and 1, when an algorithm is actually sleeping instead of crunching"};
75  Gaudi::Property<bool> m_invertCFD{this, "InvertDecision", false, "Invert control flow decision."};
76  Gaudi::Property<unsigned int> m_failNEvents{this, "FailNEvents", 0, "Return FAILURE on every Nth event"};
77 
78  // For the concurrency
79  const uint MAX_INPUTS = 40;
80  const uint MAX_OUTPUTS = 10;
81 
84 
86 
87  // CPUCrunchSvc
89 };
StatusCode execute() override
the execution of the algorithm
SmartIF< ICPUCrunchSvc > m_crunchSvc
Definition: CPUCruncher.h:88
Gaudi::Property< float > m_sleepFraction
Definition: CPUCruncher.h:72
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:35
A class that implements a search for prime numbers.
Definition: CPUCruncher.h:29
Implementation of property with value of concrete type.
Definition: Property.h:370
Gaudi::Property< bool > m_loader
Definition: CPUCruncher.h:63
const uint MAX_OUTPUTS
Definition: CPUCruncher.h:80
virtual ~CPUCruncher()
virtual & protected desctrustor
Definition: CPUCruncher.cpp:44
Header file for class GaudiAlgorithm.
Gaudi::Property< unsigned int > m_rwRepetitions
Definition: CPUCruncher.h:71
bool isClonable() const override
Definition: CPUCruncher.h:34
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
Definition: CPUCruncher.h:83
CPUCruncher & operator=(const CPUCruncher &)
the assignement operator is disabled
STL class.
tbb::concurrent_hash_map< std::string, unsigned int > CHM
Definition: CPUCruncher.h:32
static CHM m_name_ncopies_map
Definition: CPUCruncher.h:85
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
Gaudi::Property< bool > m_invertCFD
Definition: CPUCruncher.h:75
The useful base class for data processing algorithms.
std::vector< DataObjectHandle< DataObject > * > m_inputHandles
Definition: CPUCruncher.h:82
void declareRuntimeRequestedOutputs()
The CPU intensive function.
Definition: CPUCruncher.cpp:89
STL class.
Gaudi::Property< double > m_avg_runtime
Definition: CPUCruncher.h:68
StatusCode initialize() override
Its initialization.
Definition: CPUCruncher.cpp:50
CPUCruncher()
the default constructor is disabled
Gaudi::Property< unsigned int > m_failNEvents
Definition: CPUCruncher.h:76
Gaudi::Property< std::vector< std::string > > m_outKeys
Definition: CPUCruncher.h:66
Gaudi::Property< std::vector< std::string > > m_inpKeys
Definition: CPUCruncher.h:65
const uint MAX_INPUTS
Definition: CPUCruncher.h:79
double get_runtime() const
Definition: CPUCruncher.h:43
StatusCode finalize() override
the finalization of the algorithm
Gaudi::Property< bool > m_local_rndm_gen
Definition: CPUCruncher.h:70
Gaudi::Property< double > m_var_runtime
Definition: CPUCruncher.h:69
bool m_declAugmented
Definition: CPUCruncher.h:62