The Gaudi Framework  master (9f3f8895)
Loading...
Searching...
No Matches
CPUCruncher.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2026 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 bool isClonable() const override { return true; }
34
36 StatusCode execute() override;
38 StatusCode initialize() override;
40 StatusCode finalize() override;
41
42 CPUCruncher( const std::string& name, // the algorithm instance name
43 ISvcLocator* pSvc ); // the Service Locator
44
46 virtual ~CPUCruncher(); // virtual & protected destructor
47
48private:
50 CPUCruncher(); // no default constructor
52 CPUCruncher( const CPUCruncher& ); // no copy constructor
54 CPUCruncher& operator=( const CPUCruncher& ); // no assignment
56
59 bool m_declAugmented{ false };
60 Gaudi::Property<bool> m_loader{ this, "Loader", false, "Declare the algorithm to be a data loader" };
61
64
65 Gaudi::Property<double> m_avg_runtime{ this, "avgRuntime", 1., "Average runtime of the module." };
66 Gaudi::Property<double> m_var_runtime{ this, "varRuntime", 0.01, "Variance of the runtime of the module." };
67 Gaudi::Property<bool> m_local_rndm_gen{ this, "localRndm", true,
68 "Decide if the local random generator is to be used" };
69 Gaudi::Property<unsigned int> m_rwRepetitions{ this, "RwRepetitions", 1, "Increase access to the WB" };
71 this, "SleepFraction", 0.0,
72 "Fraction of time, between 0 and 1, when an algorithm is actually sleeping instead of crunching" };
73 Gaudi::Property<bool> m_invertCFD{ this, "InvertDecision", false, "Invert control flow decision." };
74 Gaudi::Property<unsigned int> m_failNEvents{ this, "FailNEvents", 0, "Return FAILURE on every Nth event" };
75 Gaudi::Property<int> m_nParallel{ this, "NParallel", -1, "Run N parallel crunching tasks" };
76
77 std::vector<DataObjectHandle<DataObject>*> m_inputHandles;
78 std::vector<DataObjectHandle<DataObject>*> m_outputHandles;
79
80 using CHM = tbb::concurrent_hash_map<std::string, unsigned int>;
82
83 // CPUCrunchSvc
85};
Gaudi::Property< bool > m_invertCFD
Definition CPUCruncher.h:73
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
Definition CPUCruncher.h:78
CPUCruncher & operator=(const CPUCruncher &)
the assignment operator is disabled
CPUCruncher()
the default constructor is disabled
StatusCode execute() override
the execution of the algorithm
virtual ~CPUCruncher()
virtual & protected destructor
bool m_declAugmented
Definition CPUCruncher.h:59
void declareRuntimeRequestedOutputs()
The CPU intensive function.
Gaudi::Property< std::vector< std::string > > m_outKeys
Definition CPUCruncher.h:63
StatusCode finalize() override
the finalization of the algorithm
std::vector< DataObjectHandle< DataObject > * > m_inputHandles
Definition CPUCruncher.h:77
static CHM m_name_ncopies_map
Definition CPUCruncher.h:81
SmartIF< ICPUCrunchSvc > m_crunchSvc
Definition CPUCruncher.h:84
tbb::concurrent_hash_map< std::string, unsigned int > CHM
Definition CPUCruncher.h:80
Gaudi::Property< bool > m_local_rndm_gen
Definition CPUCruncher.h:67
Gaudi::Property< double > m_var_runtime
Definition CPUCruncher.h:66
Gaudi::Property< std::vector< std::string > > m_inpKeys
Definition CPUCruncher.h:62
StatusCode initialize() override
Its initialization.
Gaudi::Property< int > m_nParallel
Definition CPUCruncher.h:75
bool isClonable() const override
Definition CPUCruncher.h:33
Gaudi::Property< double > m_avg_runtime
Definition CPUCruncher.h:65
Gaudi::Property< bool > m_loader
Definition CPUCruncher.h:60
Gaudi::Property< double > m_sleepFraction
Definition CPUCruncher.h:70
CPUCruncher(const CPUCruncher &)
the copy constructor is disabled
Gaudi::Property< unsigned int > m_rwRepetitions
Definition CPUCruncher.h:69
CPUCruncher(const std::string &name, ISvcLocator *pSvc)
Gaudi::Property< unsigned int > m_failNEvents
Definition CPUCruncher.h:74
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 Property.h:35
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