geopm  3.1.1.dev214+gba4f9f6d
GEOPM - Global Extensible Open Power Manager
PowerBalancerImp.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015 - 2024 Intel Corporation
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #ifndef POWERBALANCERIMP_HPP_INCLUDE
7 #define POWERBALANCERIMP_HPP_INCLUDE
8 
9 #include <memory>
10 #include <vector>
11 
12 #include "geopm_time.h"
13 #include "geopm/PowerBalancer.hpp"
14 
15 namespace geopm
16 {
17  template <typename T> class CircularBuffer;
18 
20  {
21  public:
23  PowerBalancerImp(double ctl_latency, double trial_delta, int num_sample, double measure_duration);
25  PowerBalancerImp(double ctl_latency);
27  virtual ~PowerBalancerImp() = default;
28  void power_cap(double cap) override;
29  double power_cap(void) const override;
30  double power_limit(void) const override;
31  void power_limit_adjusted(double limit) override;
32  bool is_runtime_stable(double measured_runtime) override;
33  double runtime_sample(void) const override;
34  void calculate_runtime_sample(void) override;
35  void target_runtime(double largest_runtime) override;
36  bool is_target_met(double measured_runtime) override;
37  double power_slack(void) override;
38  private:
39  bool is_limit_stable(void);
40 
41  const double M_CONTROL_LATENCY;
42  const double M_MIN_TRIAL_DELTA;
43  const int M_MIN_NUM_SAMPLE;
44  const double M_MIN_DURATION;
45  const double M_RUNTIME_FRACTION;
46  int m_num_sample;
47  // @brief Maximum power as set in last global budget
48  // increase.
49  double m_power_cap;
50  // @brief Current power limit to get to target runtime
51  // which may be lower than the cap.
52  double m_power_limit;
53  struct geopm_time_s m_power_limit_change_time;
54  double m_target_runtime;
55  double m_trial_delta;
56  double m_runtime_sample;
57  bool m_is_target_met;
58  std::unique_ptr<CircularBuffer<double> > m_runtime_buffer;
59  std::vector<double> m_runtime_vec;
60  };
61 }
62 
63 #endif
Definition: PowerBalancerImp.hpp:17
Stay within a power cap but redistribute power to optimize performance. An average per compute node p...
Definition: PowerBalancer.hpp:20
Definition: PowerBalancerImp.hpp:20
PowerBalancerImp(double ctl_latency, double trial_delta, int num_sample, double measure_duration)
Construct a testable PowerBalancerImp object.
Definition: PowerBalancer.cpp:33
void target_runtime(double largest_runtime) override
Definition: PowerBalancer.cpp:144
void calculate_runtime_sample(void) override
Sample the measured runtimes under the current power cap in the first phase of execution....
Definition: PowerBalancer.cpp:134
double power_cap(void) const override
The current power cap which cannot be exceeded without breaking contract that the average power budge...
Definition: PowerBalancer.cpp:61
void power_limit_adjusted(double limit) override
Notify power balancer that a new limit has been set with the governor.
Definition: PowerBalancer.cpp:66
double power_limit(void) const override
Returns the current power limit prescribed for this node.
Definition: PowerBalancer.cpp:82
double power_slack(void) override
Query the difference between the last power cap setting and the current power limit....
Definition: PowerBalancer.cpp:183
bool is_target_met(double measured_runtime) override
During the second phase of execution the power limit is decreased until the epoch runtime on the comp...
Definition: PowerBalancer.cpp:155
bool is_runtime_stable(double measured_runtime) override
Update the object with a runtime measured under the current power limit and test if the current runti...
Definition: PowerBalancer.cpp:92
double runtime_sample(void) const override
Return the expected execution time of an application epoch under the current power limit.
Definition: PowerBalancer.cpp:129
virtual ~PowerBalancerImp()=default
Destroy a PowerBalancerImp object.
Definition: Accumulator.cpp:12