6 #ifndef POWERBALANCERAGENT_HPP_INCLUDE
7 #define POWERBALANCERAGENT_HPP_INCLUDE
21 class SampleAggregator;
124 const PlatformTopo &platform_topo,
125 std::shared_ptr<SampleAggregator> sample_agg,
126 std::vector<std::shared_ptr<PowerBalancer> > power_balancer,
129 std::shared_ptr<Waiter> waiter);
132 void init(
int level,
const std::vector<int> &fan_in,
bool is_level_root)
override;
135 std::vector<std::vector<double> > &out_policy)
override;
138 std::vector<double> &out_sample)
override;
143 void wait(
void)
override;
144 std::vector<std::pair<std::string, std::string> >
report_header(
void)
const override;
145 std::vector<std::pair<std::string, std::string> >
report_host(
void)
const override;
146 std::map<uint64_t, std::vector<std::pair<std::string, std::string> > >
report_region(
void)
const override;
147 std::vector<std::string>
trace_names(
void)
const override;
148 std::vector<std::function<std::string(
double)> >
trace_formats(
void)
const override;
149 void trace_values(std::vector<double> &values)
override;
150 void enforce_policy(
const std::vector<double> &policy)
const override;
163 virtual bool descend(
const std::vector<double> &in_policy,
164 std::vector<std::vector<double> >&out_policy);
167 virtual bool ascend(
const std::vector<std::vector<double> > &in_sample,
168 std::vector<double> &out_sample);
179 int step(
size_t step_count)
const;
180 int step(
void)
const;
253 TreeRole(
int level,
const std::vector<int> &fan_in);
255 virtual bool descend(
const std::vector<double> &in_policy,
256 std::vector<std::vector<double> >&out_policy)
override;
257 virtual bool ascend(
const std::vector<std::vector<double> > &in_sample,
258 std::vector<double> &out_sample)
override;
260 const std::vector<std::function<double(
const std::vector<double>&)> >
M_AGG_FUNC;
270 RootRole(
int level,
const std::vector<int> &fan_in,
double min_power,
double max_power);
272 bool descend(
const std::vector<double> &in_policy,
273 std::vector<std::vector<double> >&out_policy)
override;
274 bool ascend(
const std::vector<std::vector<double> > &in_sample,
275 std::vector<double> &out_sample)
override;
278 const double M_MIN_PKG_POWER_SETTING;
279 const double M_MAX_PKG_POWER_SETTING;
288 const PlatformTopo &platform_topo,
289 std::shared_ptr<SampleAggregator> sample_agg,
290 std::vector<std::shared_ptr<PowerBalancer> > power_balancer,
299 void trace_values(std::vector<double> &values)
override;
301 void init_platform_io(
void);
302 void are_steps_complete(
bool is_complete);
303 bool are_steps_complete(
void);
304 PlatformIO &m_platform_io;
305 const PlatformTopo &m_platform_topo;
306 std::shared_ptr<SampleAggregator> m_sample_agg;
309 std::vector<int> m_count_pio_idx;
310 std::vector<int> m_time_agg_idx;
311 std::vector<int> m_network_agg_idx;
312 std::vector<int> m_ignore_agg_idx;
313 std::vector<std::shared_ptr<PowerBalancer> > m_power_balancer;
314 const double M_STABILITY_FACTOR;
316 int last_epoch_count;
320 double power_headroom;
321 bool is_out_of_bounds;
322 bool is_step_complete;
325 std::vector<m_package_s> m_package;
326 const double M_MIN_PKG_POWER_SETTING;
327 const double M_MAX_PKG_POWER_SETTING;
328 bool m_is_single_node;
329 bool m_is_first_policy;
Definition: PowerBalancerAgent.hpp:282
virtual ~LeafRole()=default
LeafRole(PlatformIO &platform_io, const PlatformTopo &platform_topo, std::shared_ptr< SampleAggregator > sample_agg, std::vector< std::shared_ptr< PowerBalancer > > power_balancer, double min_power, double max_power, double time_window, bool is_single_node, int num_node)
Definition: PowerBalancerAgent.cpp:115
bool sample_platform(std::vector< double > &out_sample) override
Definition: PowerBalancerAgent.cpp:251
bool adjust_platform(const std::vector< double > &in_policy) override
Definition: PowerBalancerAgent.cpp:188
void trace_values(std::vector< double > &values) override
Definition: PowerBalancerAgent.cpp:283
Definition: PowerBalancerAgent.hpp:230
void update_policy(PowerBalancerAgent::Role &role, const std::vector< double > &sample) const
Definition: PowerBalancerAgent.cpp:504
MeasureRuntimeStep()=default
~MeasureRuntimeStep()=default
void sample_platform(PowerBalancerAgent::LeafRole &role) const
Definition: PowerBalancerAgent.cpp:513
void enter_step(PowerBalancerAgent::LeafRole &role, const std::vector< double > &in_policy) const
Definition: PowerBalancerAgent.cpp:509
Definition: PowerBalancerAgent.hpp:239
ReduceLimitStep()=default
void sample_platform(PowerBalancerAgent::LeafRole &role) const
Definition: PowerBalancerAgent.cpp:553
void enter_step(PowerBalancerAgent::LeafRole &role, const std::vector< double > &in_policy) const
Definition: PowerBalancerAgent.cpp:545
~ReduceLimitStep()=default
void update_policy(PowerBalancerAgent::Role &role, const std::vector< double > &sample) const
Definition: PowerBalancerAgent.cpp:538
Definition: PowerBalancerAgent.hpp:159
const std::vector< std::shared_ptr< const Step > > M_STEP_IMP
Definition: PowerBalancerAgent.hpp:184
int m_step_count
Definition: PowerBalancerAgent.hpp:188
int step(void) const
Definition: PowerBalancerAgent.cpp:105
virtual void trace_values(std::vector< double > &values)
Definition: PowerBalancerAgent.cpp:92
virtual bool ascend(const std::vector< std::vector< double > > &in_sample, std::vector< double > &out_sample)
Definition: PowerBalancerAgent.cpp:64
Role(int num_node)
Definition: PowerBalancerAgent.cpp:36
const int M_NUM_NODE
Definition: PowerBalancerAgent.hpp:190
virtual bool descend(const std::vector< double > &in_policy, std::vector< std::vector< double > > &out_policy)
Definition: PowerBalancerAgent.cpp:54
std::vector< double > m_policy
Definition: PowerBalancerAgent.hpp:186
virtual bool sample_platform(std::vector< double > &out_sample)
Definition: PowerBalancerAgent.cpp:83
virtual bool adjust_platform(const std::vector< double > &in_policy)
Definition: PowerBalancerAgent.cpp:74
const Step & step_imp()
Definition: PowerBalancerAgent.cpp:110
Definition: PowerBalancerAgent.hpp:265
RootRole(int level, const std::vector< int > &fan_in, double min_power, double max_power)
Definition: PowerBalancerAgent.cpp:390
virtual ~RootRole()=default
bool ascend(const std::vector< std::vector< double > > &in_sample, std::vector< double > &out_sample) override
Definition: PowerBalancerAgent.cpp:401
bool descend(const std::vector< double > &in_policy, std::vector< std::vector< double > > &out_policy) override
Definition: PowerBalancerAgent.cpp:417
Definition: PowerBalancerAgent.hpp:221
void sample_platform(PowerBalancerAgent::LeafRole &role) const
Definition: PowerBalancerAgent.cpp:500
~SendDownLimitStep()=default
void update_policy(PowerBalancerAgent::Role &role, const std::vector< double > &sample) const
Definition: PowerBalancerAgent.cpp:458
SendDownLimitStep()=default
void enter_step(PowerBalancerAgent::LeafRole &role, const std::vector< double > &in_policy) const
Definition: PowerBalancerAgent.cpp:463
Definition: PowerBalancerAgent.hpp:212
virtual void enter_step(LeafRole &role, const std::vector< double > &in_policy) const =0
virtual void sample_platform(LeafRole &role) const =0
virtual void update_policy(Role &role, const std::vector< double > &sample) const =0
Definition: PowerBalancerAgent.hpp:248
bool m_is_step_complete
Definition: PowerBalancerAgent.hpp:262
virtual bool ascend(const std::vector< std::vector< double > > &in_sample, std::vector< double > &out_sample) override
Definition: PowerBalancerAgent.cpp:363
TreeRole(int level, const std::vector< int > &fan_in)
Definition: PowerBalancerAgent.cpp:310
const std::vector< std::function< double(const std::vector< double > &)> > M_AGG_FUNC
Definition: PowerBalancerAgent.hpp:260
const int M_NUM_CHILDREN
Definition: PowerBalancerAgent.hpp:261
virtual ~TreeRole()=default
virtual bool descend(const std::vector< double > &in_policy, std::vector< std::vector< double > > &out_policy) override
Definition: PowerBalancerAgent.cpp:329
Definition: PowerBalancerAgent.hpp:25
m_sample_e
Definition: PowerBalancerAgent.hpp:69
@ M_SAMPLE_STEP_COUNT
The the step counter that is currently in execution. Note that the step is equal to the step counter ...
Definition: PowerBalancerAgent.hpp:76
@ M_NUM_SAMPLE
Number of elements in a sample vector.
Definition: PowerBalancerAgent.hpp:88
@ M_SAMPLE_MAX_EPOCH_RUNTIME
Maximum expected runtime for any node below.
Definition: PowerBalancerAgent.hpp:79
@ M_SAMPLE_SUM_POWER_SLACK
The sum of all slack power available from children below the agent.
Definition: PowerBalancerAgent.hpp:82
@ M_SAMPLE_MIN_POWER_HEADROOM
Smallest difference between maximum power limit and current power limit for any node below.
Definition: PowerBalancerAgent.hpp:86
std::vector< std::function< std::string(double)> > trace_formats(void) const override
Returns format string for each column added to the trace.
Definition: PowerBalancerAgent.cpp:723
static std::unique_ptr< Agent > make_plugin(void)
Definition: PowerBalancerAgent.cpp:752
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: PowerBalancerAgent.cpp:688
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: PowerBalancerAgent.cpp:661
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: PowerBalancerAgent.cpp:698
void validate_policy(std::vector< double > &policy) const override
Called by Controller to validate incoming policy values and configure defaults requested in incoming ...
Definition: PowerBalancerAgent.cpp:795
std::vector< std::string > trace_names(void) const override
Column headers to be added to the trace.
Definition: PowerBalancerAgent.cpp:713
void adjust_platform(const std::vector< double > &in_policy) override
Adjust the platform settings based the policy from above.
Definition: PowerBalancerAgent.cpp:672
virtual ~PowerBalancerAgent()=default
static std::vector< std::string > policy_names(void)
Definition: PowerBalancerAgent.cpp:757
m_policy_e
Definition: PowerBalancerAgent.hpp:27
@ M_POLICY_POWER_SLACK
This value is updated in step M_STEP_ADJUST_LIMIT to the amount that each leaf agent should increase ...
Definition: PowerBalancerAgent.hpp:63
@ M_POLICY_CPU_POWER_LIMIT
The power cap enforced on average over all nodes running the application. This has value 0....
Definition: PowerBalancerAgent.hpp:38
@ M_POLICY_STEP_COUNT
Step that the root is providing a policy for. The parent has received a sample matching this step in ...
Definition: PowerBalancerAgent.hpp:48
@ M_NUM_POLICY
Number of steps in each iteration of the balancing algorithm.
Definition: PowerBalancerAgent.hpp:66
@ M_POLICY_MAX_EPOCH_RUNTIME
The largest runtime reported by any leaf agent since the last redistribution of power....
Definition: PowerBalancerAgent.hpp:54
bool m_do_send_policy
Definition: PowerBalancerAgent.hpp:201
std::vector< std::shared_ptr< PowerBalancer > > m_power_balancer
Definition: PowerBalancerAgent.hpp:197
const double M_MAX_PKG_POWER_SETTING
Definition: PowerBalancerAgent.hpp:204
static std::string plugin_name(void)
Definition: PowerBalancerAgent.cpp:747
std::shared_ptr< Role > m_role
Definition: PowerBalancerAgent.hpp:196
static std::vector< std::string > sample_names(void)
Definition: PowerBalancerAgent.cpp:765
PowerBalancerAgent()
Definition: PowerBalancerAgent.cpp:581
bool do_write_batch(void) const override
Called by the Controller to decide whether to call write_batch() to update platform controls.
Definition: PowerBalancerAgent.cpp:683
void wait(void) override
Called by Controller to wait for sample period to elapse. This controls the cadence of the Controller...
Definition: PowerBalancerAgent.cpp:693
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: PowerBalancerAgent.cpp:738
m_step_e
Definition: PowerBalancerAgent.hpp:100
@ M_STEP_SEND_DOWN_LIMIT
On first iteration send down resource manager average limit requested, otherwise send down average ex...
Definition: PowerBalancerAgent.hpp:104
@ M_STEP_REDUCE_LIMIT
Decrease power limit on all nodes (other than the slowest) until epoch runtime matches the slowest....
Definition: PowerBalancerAgent.hpp:118
@ M_STEP_MEASURE_RUNTIME
Measure epoch runtime several times and apply median filter. Aggregate epoch runtime up tree by apply...
Definition: PowerBalancerAgent.hpp:111
@ M_NUM_STEP
Number of steps in process.
Definition: PowerBalancerAgent.hpp:120
std::shared_ptr< SampleAggregator > m_sample_agg
Definition: PowerBalancerAgent.hpp:195
void trace_values(std::vector< double > &values) override
Called by Controller to get latest values to be added to the trace.
Definition: PowerBalancerAgent.cpp:733
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: PowerBalancerAgent.cpp:617
m_trace_sample_e
Definition: PowerBalancerAgent.hpp:91
@ M_TRACE_SAMPLE_POLICY_MAX_EPOCH_RUNTIME
Definition: PowerBalancerAgent.hpp:94
@ M_TRACE_SAMPLE_ENFORCED_POWER_LIMIT
Definition: PowerBalancerAgent.hpp:96
@ M_TRACE_SAMPLE_POLICY_STEP_COUNT
Definition: PowerBalancerAgent.hpp:93
@ M_TRACE_SAMPLE_POLICY_POWER_SLACK
Definition: PowerBalancerAgent.hpp:95
@ M_TRACE_NUM_SAMPLE
Definition: PowerBalancerAgent.hpp:97
@ M_TRACE_SAMPLE_POLICY_CPU_POWER_LIMIT
Definition: PowerBalancerAgent.hpp:92
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: PowerBalancerAgent.cpp:656
PlatformIO & m_platform_io
Definition: PowerBalancerAgent.hpp:193
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: PowerBalancerAgent.cpp:708
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: PowerBalancerAgent.cpp:644
bool m_do_write_batch
Definition: PowerBalancerAgent.hpp:202
const double M_MIN_PKG_POWER_SETTING
Definition: PowerBalancerAgent.hpp:203
std::vector< std::pair< std::string, std::string > > report_host(void) const override
Custom fields for the host section of the report.
Definition: PowerBalancerAgent.cpp:703
static std::string format_step_count(double step)
Definition: PowerBalancerAgent.cpp:773
bool do_send_sample(void) const override
Definition: PowerBalancerAgent.cpp:667
bool m_do_send_sample
Definition: PowerBalancerAgent.hpp:200
static constexpr double M_WAIT_SEC
Definition: PowerBalancerAgent.hpp:198
std::shared_ptr< Waiter > m_waiter
Definition: PowerBalancerAgent.hpp:206
const double M_TIME_WINDOW
Definition: PowerBalancerAgent.hpp:205
double m_power_tdp
Definition: PowerBalancerAgent.hpp:199
const PlatformTopo & m_platform_topo
Definition: PowerBalancerAgent.hpp:194
Definition: Accumulator.cpp:12