The Gaudi Framework  master (e3184c44)
CPUCrunchSvc.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 
13 #include <GaudiKernel/ClassID.h>
14 #include <GaudiKernel/Service.h>
15 #include <GaudiKernel/StatusCode.h>
16 
18 #include <chrono>
19 #include <string>
20 #include <vector>
21 
22 class CPUCrunchSvc : public extends<Service, ICPUCrunchSvc> {
23 
24 public:
25  CPUCrunchSvc( const std::string& name, ISvcLocator* svc );
26 
27 public:
28  virtual StatusCode initialize() override;
29 
30 public:
31  // number of seconds to CPUCrunch
32  std::chrono::milliseconds crunch_for( const std::chrono::milliseconds& crunchtime ) const override;
33 
34 private:
35  void calibrate();
36  unsigned int getNCaliIters( std::chrono::microseconds runtime ) const;
37  void findPrimes( unsigned int ) const;
38 
39  std::vector<unsigned int> m_times_vect;
40 
42  this, "NIterationsVect", {}, "Number of iterations for the calibration." };
43  Gaudi::Property<bool> m_shortCalib{ this, "shortCalib", false, "Enable coarse grained calibration" };
45  "Minimum number of milliseconds to do calibration" };
46  Gaudi::Property<int> m_numCalibRuns{ this, "numCalibRuns", 1, "Number of times to do calibration run" };
47  Gaudi::Property<float> m_corrFact{ this, "calibCorrectionFactor", 1.,
48  "Calibration correction factor to take into account things like turbo boost" };
49 };
CPUCrunchSvc::m_minCalibTime
Gaudi::Property< unsigned int > m_minCalibTime
Definition: CPUCrunchSvc.h:44
CPUCrunchSvc::crunch_for
std::chrono::milliseconds crunch_for(const std::chrono::milliseconds &crunchtime) const override
Definition: CPUCrunchSvc.cpp:210
ClassID.h
ISvcLocator
Definition: ISvcLocator.h:42
StatusCode.h
ICPUCrunchSvc.h
Service::name
const std::string & name() const override
Retrieve name of the service
Definition: Service.cpp:333
StatusCode
Definition: StatusCode.h:64
CPUCrunchSvc::getNCaliIters
unsigned int getNCaliIters(std::chrono::microseconds runtime) const
Definition: CPUCrunchSvc.cpp:120
CPUCrunchSvc::m_shortCalib
Gaudi::Property< bool > m_shortCalib
Definition: CPUCrunchSvc.h:43
CPUCrunchSvc::m_corrFact
Gaudi::Property< float > m_corrFact
Definition: CPUCrunchSvc.h:47
CPUCrunchSvc::calibrate
void calibrate()
Definition: CPUCrunchSvc.cpp:58
CPUCrunchSvc
Definition: CPUCrunchSvc.h:22
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:19
Service.h
CPUCrunchSvc::m_numCalibRuns
Gaudi::Property< int > m_numCalibRuns
Definition: CPUCrunchSvc.h:46
CPUCrunchSvc::findPrimes
void findPrimes(unsigned int) const
Definition: CPUCrunchSvc.cpp:158
CPUCrunchSvc::m_times_vect
std::vector< unsigned int > m_times_vect
Definition: CPUCrunchSvc.h:39
CPUCrunchSvc::CPUCrunchSvc
CPUCrunchSvc(const std::string &name, ISvcLocator *svc)
Definition: CPUCrunchSvc.cpp:35
CPUCrunchSvc::initialize
virtual StatusCode initialize() override
Definition: CPUCrunchSvc.cpp:39
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:35
CPUCrunchSvc::m_niters_vect
Gaudi::Property< std::vector< unsigned int > > m_niters_vect
Definition: CPUCrunchSvc.h:41