The Gaudi Framework  master (1304469f)
Loading...
Searching...
No Matches
CPUCruncher.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 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#pragma once
12
19#include <tbb/concurrent_hash_map.h>
20
21//------------------------------------------------------------------------------
22
30class CPUCruncher : public Algorithm {
31
32public:
33 typedef tbb::concurrent_hash_map<std::string, unsigned int> CHM;
34
35 bool isClonable() const override { return true; }
36
38 StatusCode execute() override;
40 StatusCode initialize() override;
42 StatusCode finalize() override;
43
44 double get_runtime() const { return m_avg_runtime; }
45
46 CPUCruncher( const std::string& name, // the algorithm instance name
47 ISvcLocator* pSvc ); // the Service Locator
48
50 virtual ~CPUCruncher(); // virtual & protected desctrustor
51
52private:
54 CPUCruncher(); // no default constructor
56 CPUCruncher( const CPUCruncher& ); // no copy constructor
58 CPUCruncher& operator=( const CPUCruncher& ); // no assignement
60
63 bool m_declAugmented{ false };
64 Gaudi::Property<bool> m_loader{ this, "Loader", false, "Declare the algorithm to be a data loader" };
65
68
69 Gaudi::Property<double> m_avg_runtime{ this, "avgRuntime", 1., "Average runtime of the module." };
70 Gaudi::Property<double> m_var_runtime{ this, "varRuntime", 0.01, "Variance of the runtime of the module." };
71 Gaudi::Property<bool> m_local_rndm_gen{ this, "localRndm", true,
72 "Decide if the local random generator is to be used" };
73 Gaudi::Property<unsigned int> m_rwRepetitions{ this, "RwRepetitions", 1, "Increase access to the WB" };
75 this, "SleepFraction", 0.0,
76 "Fraction of time, between 0 and 1, when an algorithm is actually sleeping instead of crunching" };
77 Gaudi::Property<bool> m_invertCFD{ this, "InvertDecision", false, "Invert control flow decision." };
78 Gaudi::Property<unsigned int> m_failNEvents{ this, "FailNEvents", 0, "Return FAILURE on every Nth event" };
79 Gaudi::Property<int> m_nParallel{ this, "NParallel", -1, "Run N parallel crunching tasks" };
80
81 // For the concurrency
82 const uint MAX_INPUTS = 40;
83 const uint MAX_OUTPUTS = 10;
84
85 std::vector<DataObjectHandle<DataObject>*> m_inputHandles;
86 std::vector<DataObjectHandle<DataObject>*> m_outputHandles;
87
89
90 // CPUCrunchSvc
92};
Gaudi::Property< bool > m_invertCFD
Definition CPUCruncher.h:77
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
Definition CPUCruncher.h:86
CPUCruncher & operator=(const CPUCruncher &)
the assignement operator is disabled
CPUCruncher()
the default constructor is disabled
StatusCode execute() override
the execution of the algorithm
const uint MAX_OUTPUTS
Definition CPUCruncher.h:83
virtual ~CPUCruncher()
virtual & protected desctrustor
bool m_declAugmented
Definition CPUCruncher.h:63
const uint MAX_INPUTS
Definition CPUCruncher.h:82
void declareRuntimeRequestedOutputs()
The CPU intensive function.
Gaudi::Property< std::vector< std::string > > m_outKeys
Definition CPUCruncher.h:67
StatusCode finalize() override
the finalization of the algorithm
std::vector< DataObjectHandle< DataObject > * > m_inputHandles
Definition CPUCruncher.h:85
double get_runtime() const
Definition CPUCruncher.h:44
tbb::concurrent_hash_map< std::string, unsigned int > CHM
Definition CPUCruncher.h:33
static CHM m_name_ncopies_map
Definition CPUCruncher.h:88
SmartIF< ICPUCrunchSvc > m_crunchSvc
Definition CPUCruncher.h:91
Gaudi::Property< bool > m_local_rndm_gen
Definition CPUCruncher.h:71
Gaudi::Property< double > m_var_runtime
Definition CPUCruncher.h:70
Gaudi::Property< std::vector< std::string > > m_inpKeys
Definition CPUCruncher.h:66
StatusCode initialize() override
Its initialization.
Gaudi::Property< int > m_nParallel
Definition CPUCruncher.h:79
bool isClonable() const override
Definition CPUCruncher.h:35
Gaudi::Property< double > m_avg_runtime
Definition CPUCruncher.h:69
Gaudi::Property< bool > m_loader
Definition CPUCruncher.h:64
Gaudi::Property< double > m_sleepFraction
Definition CPUCruncher.h:74
CPUCruncher(const CPUCruncher &)
the copy constructor is disabled
Gaudi::Property< unsigned int > m_rwRepetitions
Definition CPUCruncher.h:73
CPUCruncher(const std::string &name, ISvcLocator *pSvc)
Gaudi::Property< unsigned int > m_failNEvents
Definition CPUCruncher.h:78
Algorithm(std::string name, ISvcLocator *svcloc, std::string version=PACKAGE_VERSION)
Constructor.
Definition Algorithm.h:98
const std::string & name() const override
The identifying name of the algorithm object.
Implementation of property with value of concrete type.
Definition PropertyFwd.h:27
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
Small smart pointer class with automatic reference counting for IInterface.
Definition SmartIF.h:28
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64