6 #ifndef POWERGOVERNORAGENT_HPP_INCLUDE
7 #define POWERGOVERNORAGENT_HPP_INCLUDE
14 #include "geopm/CircularBuffer.hpp"
47 std::unique_ptr<PowerGovernor> power_gov,
48 std::shared_ptr<Waiter> waiter);
50 void init(
int level,
const std::vector<int> &fan_in,
bool is_level_root)
override;
53 std::vector<std::vector<double> > &out_policy)
override;
56 std::vector<double> &out_sample)
override;
61 void wait(
void)
override;
62 std::vector<std::pair<std::string, std::string> >
report_header(
void)
const override;
63 std::vector<std::pair<std::string, std::string> >
report_host(
void)
const override;
64 std::map<uint64_t, std::vector<std::pair<std::string, std::string> > >
report_region(
void)
const override;
65 std::vector<std::string>
trace_names(
void)
const override;
66 std::vector<std::function<std::string(
double)> >
trace_formats(
void)
const override;
68 void enforce_policy(
const std::vector<double> &policy)
const override;
75 void init_platform_io(
void);
76 PlatformIO &m_platform_io;
78 bool m_is_sample_stable;
79 bool m_do_send_sample;
80 double m_min_power_setting;
81 double m_max_power_setting;
82 double m_tdp_power_setting;
83 std::unique_ptr<PowerGovernor> m_power_gov;
84 std::vector<int> m_pio_idx;
85 std::vector<std::function<double(
const std::vector<double>&)> > m_agg_func;
87 double m_last_power_budget;
88 bool m_power_budget_changed;
89 std::unique_ptr<CircularBuffer<double> > m_epoch_power_buf;
90 std::vector<double> m_sample;
92 const int m_ascend_period;
93 const int m_min_num_converged;
94 double m_adjusted_power;
95 static constexpr
double M_WAIT_SEC = 0.005;
96 std::shared_ptr<Waiter> m_waiter;
Definition: PowerGovernorAgent.hpp:24
void split_policy(const std::vector< double > &in_policy, std::vector< std::vector< double > > &out_policy) override
Called by Controller to split policy for children at next level down the tree.
Definition: PowerGovernorAgent.cpp:114
void init(int level, const std::vector< int > &fan_in, bool is_level_root) override
Set the level where this Agent is active and push signals/controls for that level.
Definition: PowerGovernorAgent.cpp:58
bool do_send_sample(void) const override
Definition: PowerGovernorAgent.cpp:206
std::vector< std::pair< std::string, std::string > > report_host(void) const override
Custom fields for the host section of the report.
Definition: PowerGovernorAgent.cpp:271
std::vector< std::function< std::string(double)> > trace_formats(void) const override
Returns format string for each column added to the trace.
Definition: PowerGovernorAgent.cpp:286
void aggregate_sample(const std::vector< std::vector< double > > &in_sample, std::vector< double > &out_sample) override
Aggregate samples from children for the next level up the tree.
Definition: PowerGovernorAgent.cpp:162
std::vector< std::pair< std::string, std::string > > report_header(void) const override
Custom fields that will be added to the report header when this agent is used.
Definition: PowerGovernorAgent.cpp:266
void wait(void) override
Called by Controller to wait for sample period to elapse. This controls the cadence of the Controller...
Definition: PowerGovernorAgent.cpp:261
bool do_send_policy(void) const override
Called by Controller to determine if new policy values should be sent down the tree to the Agent's ch...
Definition: PowerGovernorAgent.cpp:157
m_sample_e
Definition: PowerGovernorAgent.hpp:38
@ M_SAMPLE_POWER
Definition: PowerGovernorAgent.hpp:39
@ M_NUM_SAMPLE
Definition: PowerGovernorAgent.hpp:42
@ M_SAMPLE_POWER_ENFORCED
Definition: PowerGovernorAgent.hpp:41
@ M_SAMPLE_IS_CONVERGED
Definition: PowerGovernorAgent.hpp:40
std::vector< std::string > trace_names(void) const override
Column headers to be added to the trace.
Definition: PowerGovernorAgent.cpp:281
m_policy_e
Definition: PowerGovernorAgent.hpp:26
@ M_NUM_POLICY
Definition: PowerGovernorAgent.hpp:28
@ M_POLICY_POWER
Definition: PowerGovernorAgent.hpp:27
m_plat_signal_e
Definition: PowerGovernorAgent.hpp:30
@ M_PLAT_SIGNAL_PKG_POWER
Definition: PowerGovernorAgent.hpp:31
@ M_PLAT_NUM_SIGNAL
Definition: PowerGovernorAgent.hpp:32
virtual ~PowerGovernorAgent()=default
static std::vector< std::string > policy_names(void)
Definition: PowerGovernorAgent.cpp:321
void adjust_platform(const std::vector< double > &in_policy) override
Adjust the platform settings based the policy from above.
Definition: PowerGovernorAgent.cpp:211
void trace_values(std::vector< double > &values) override
Called by Controller to get latest values to be added to the trace.
Definition: PowerGovernorAgent.cpp:291
void enforce_policy(const std::vector< double > &policy) const override
Enforce the policy one time with PlatformIO::write_control(). Called to enforce static policies in th...
Definition: PowerGovernorAgent.cpp:302
static std::unique_ptr< Agent > make_plugin(void)
Definition: PowerGovernorAgent.cpp:316
static std::vector< std::string > sample_names(void)
Definition: PowerGovernorAgent.cpp:326
void validate_policy(std::vector< double > &policy) const override
Called by Controller to validate incoming policy values and configure defaults requested in incoming ...
Definition: PowerGovernorAgent.cpp:99
static std::string plugin_name(void)
Definition: PowerGovernorAgent.cpp:311
bool do_write_batch(void) const override
Called by the Controller to decide whether to call write_batch() to update platform controls.
Definition: PowerGovernorAgent.cpp:224
m_trace_sample_e
Definition: PowerGovernorAgent.hpp:34
@ M_TRACE_NUM_SAMPLE
Definition: PowerGovernorAgent.hpp:36
@ M_TRACE_SAMPLE_PWR_BUDGET
Definition: PowerGovernorAgent.hpp:35
PowerGovernorAgent()
Definition: PowerGovernorAgent.cpp:24
std::map< uint64_t, std::vector< std::pair< std::string, std::string > > > report_region(void) const override
Custom fields for each region in the report.
Definition: PowerGovernorAgent.cpp:276
void sample_platform(std::vector< double > &out_sample) override
Read signals from the platform and interpret/aggregate these signals to create a sample which can be ...
Definition: PowerGovernorAgent.cpp:229
Definition: Accumulator.cpp:12