geopm 3.1.1.dev410+g40bf96ed
GEOPM - Global Extensible Open Power Manager
Loading...
Searching...
No Matches
FFNetAgent.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 FFNETAGENT_HPP_INCLUDE
7#define FFNETAGENT_HPP_INCLUDE
8
9#include <cstdint>
10#include <vector>
11#include <string>
12#include <utility>
13#include <memory>
14
15#include "geopm/Agent.hpp"
16#include "geopm_time.h"
17#include "DomainNetMap.hpp"
19
20namespace geopm
21{
22 class PlatformTopo;
23 class PlatformIO;
24 class Waiter;
25
27 class FFNetAgent : public Agent
28 {
29 public:
39
40 FFNetAgent();
41 FFNetAgent(PlatformIO &plat_io,
42 const PlatformTopo &topo,
43 const std::map<std::pair<geopm_domain_e, int>, std::shared_ptr<DomainNetMap> > &net_map,
44 const std::map<geopm_domain_e, std::shared_ptr<RegionHintRecommender> > &freq_recommender,
45 std::shared_ptr<Waiter> waiter);
46 virtual ~FFNetAgent() = default;
47 void init(int level, const std::vector<int> &fan_in, bool is_level_root) override;
48 void validate_policy(std::vector<double> &in_policy) const override;
49 void split_policy(const std::vector<double> &in_policy,
50 std::vector<std::vector<double> > &out_policy) override;
51 bool do_send_policy(void) const override;
52 void aggregate_sample(const std::vector<std::vector<double> > &in_sample,
53 std::vector<double> &out_sample) override;
54 bool do_send_sample(void) const override;
55 void adjust_platform(const std::vector<double> &in_policy) override;
56 bool do_write_batch(void) const override;
57 void sample_platform(std::vector<double> &out_sample) override;
58 void wait(void) override;
59 std::vector<std::pair<std::string, std::string> > report_header(void) const override;
60 std::vector<std::pair<std::string, std::string> > report_host(void) const override;
61 std::map<uint64_t, std::vector<std::pair<std::string, std::string> > >
62 report_region(void) const override;
63 std::vector<std::string> trace_names(void) const override;
64 std::vector<std::function<std::string(double)> > trace_formats(void) const override;
65 void trace_values(std::vector<double> &values) override;
66 void enforce_policy(const std::vector<double> &policy) const override;
67
68 static std::string plugin_name(void);
69 static std::unique_ptr<Agent> make_plugin(void);
70 static std::vector<std::string> policy_names(void);
71 static std::vector<std::string> sample_names(void);
72
73 private:
74 struct m_domain_key_s {
75 geopm_domain_e type;
76 int index;
77 bool operator<(const m_domain_key_s &other) const; /*{
78 return type < other.type || (type == other.type && index < other.index);
79 }*/
80 };
81 struct m_control_s {
82 int max_idx;
83 int min_idx;
84 double last_value;
85 };
86
87 static bool is_all_nan(const std::vector<double> &vec);
88 static std::string get_env_value(const std::string &env_var);
89 void init_domain_indices(const PlatformTopo &topo);
90
91 PlatformIO &m_platform_io;
92 static constexpr double M_WAIT_SEC = 0.020;
93 bool m_do_write_batch;
94
95 std::map<std::string, double> m_policy_available;
96
97 double m_perf_energy_bias;
98 std::map<m_domain_key_s, std::shared_ptr<DomainNetMap> > m_net_map;
99 std::map<geopm_domain_e, std::shared_ptr<RegionHintRecommender> > m_freq_recommender;
100
101 std::map<m_domain_key_s, m_control_s> m_freq_control;
102 std::vector<geopm_domain_e> m_domain_types;
103 std::vector<m_domain_key_s> m_domains;
104 std::shared_ptr<Waiter> m_waiter;
105
106 static const std::map<geopm_domain_e, std::string> M_NNET_ENVNAME;
107 static const std::map<geopm_domain_e, std::string> M_FREQMAP_ENVNAME;
108 static const std::map<geopm_domain_e, std::string> M_MAX_FREQ_SIGNAL_NAME;
109 static const std::map<geopm_domain_e, std::string> M_MIN_FREQ_SIGNAL_NAME;
110 static const std::map<geopm_domain_e, std::string> M_MAX_FREQ_CONTROL_NAME;
111 static const std::map<geopm_domain_e, std::string> M_MIN_FREQ_CONTROL_NAME;
112 static const std::map<geopm_domain_e, std::string> M_TRACE_SUFFIX;
113 };
114}
115#endif /* FFNETAGENT_HPP_INCLUDE */
Definition Agent.hpp:20
Feed Forward Net Agent.
Definition FFNetAgent.hpp:28
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 FFNetAgent.cpp:194
void trace_values(std::vector< double > &values) override
Called by Controller to get latest values to be added to the trace.
Definition FFNetAgent.cpp:298
void adjust_platform(const std::vector< double > &in_policy) override
Adjust the platform settings based the policy from above.
Definition FFNetAgent.cpp:206
bool do_write_batch(void) const override
Called by the Controller to decide whether to call write_batch() to update platform controls.
Definition FFNetAgent.cpp:230
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 FFNetAgent.cpp:236
std::vector< std::function< std::string(double)> > trace_formats(void) const override
Returns format string for each column added to the trace.
Definition FFNetAgent.cpp:292
void validate_policy(std::vector< double > &in_policy) const override
Called by Controller to validate incoming policy values and configure defaults requested in incoming ...
Definition FFNetAgent.cpp:154
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 FFNetAgent.cpp:180
void wait(void) override
Called by Controller to wait for sample period to elapse. This controls the cadence of the Controller...
Definition FFNetAgent.cpp:244
static std::vector< std::string > sample_names(void)
Definition FFNetAgent.cpp:255
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 FFNetAgent.cpp:261
static std::string plugin_name(void)
Definition FFNetAgent.cpp:122
static std::vector< std::string > policy_names(void)
Definition FFNetAgent.cpp:250
static std::unique_ptr< Agent > make_plugin(void)
Definition FFNetAgent.cpp:128
virtual ~FFNetAgent()=default
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 FFNetAgent.cpp:134
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 FFNetAgent.cpp:189
FFNetAgent()
Definition FFNetAgent.cpp:55
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 FFNetAgent.cpp:273
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 FFNetAgent.cpp:309
m_policy_e
Definition FFNetAgent.hpp:30
@ M_POLICY_PERF_ENERGY_BIAS
Perf-energy-bias represents the user's desire to trade off performance for energy efficiency....
Definition FFNetAgent.hpp:36
@ M_NUM_POLICY
Definition FFNetAgent.hpp:37
std::vector< std::string > trace_names(void) const override
Column headers to be added to the trace.
Definition FFNetAgent.cpp:279
std::vector< std::pair< std::string, std::string > > report_host(void) const override
Custom fields for the host section of the report.
Definition FFNetAgent.cpp:266
bool do_send_sample(void) const override
Definition FFNetAgent.cpp:201
Definition Accumulator.cpp:12