6#ifndef MSRIOGROUP_HPP_INCLUDE
7#define MSRIOGROUP_HPP_INCLUDE
57 std::shared_ptr<MSRIO> msrio,
58 std::shared_ptr<Cpuid>
cpuid,
69 int domain_idx)
override;
72 int domain_idx)
override;
75 double sample(
int sample_idx)
override;
76 void adjust(
int control_idx,
77 double setting)
override;
80 int domain_idx)
override;
84 double setting)
override;
87 std::function<double(
const std::vector<double> &)>
agg_function(
const std::string &signal_name)
const override;
88 std::function<std::string(
double)>
format_function(
const std::string &signal_name)
const override;
92 void save_control(
const std::string &save_path)
override;
94 std::string
name(
void)
const override;
108 std::shared_ptr<MSRIO> msrio);
111 static int cpuid(
void);
118 static void parse_json_msrs_allowlist(
const std::string &str,
119 std::map<uint64_t, std::pair<uint64_t, std::string> > &allowlist_data,
121 std::shared_ptr<MSRIO> msrio);
128 static std::string format_allowlist(
const std::map<uint64_t, std::pair<uint64_t, std::string> > &allowlist_data);
132 static std::string platform_data(
int cpu_id);
134 enum MsrConfigWarningPreference_e {
135 SILENCE_CONFIG_DEPRECATION_WARNING,
136 EMIT_CONFIG_DEPRECATION_WARNING,
143 static std::set<std::string> msr_data_files(
144 MsrConfigWarningPreference_e warning_preference = SILENCE_CONFIG_DEPRECATION_WARNING);
147 void set_signal_description(
const std::string &
name,
const std::string &description);
150 void set_control_description(
const std::string &
name,
const std::string &description);
152 void register_signal_alias(
const std::string &signal_name,
const std::string &msr_field_name);
154 void register_control_alias(
const std::string &control_name,
const std::string &msr_field_name);
157 void register_temperature_signals(
void);
160 void register_power_signals(
void);
163 void register_pcnt_scalability_signals(
void);
166 void register_rdt_signals(
void);
169 void register_frequency_signals(
void);
172 void register_frequency_controls(
void);
175 void check_control(
const std::string &control_name);
177 void check_control_pwrite(
void);
180 void check_control_lock(
const std::string &lock_name,
const std::string &error);
183 static void check_top_level(
const json11::Json &root);
184 static void check_msr_root(
const json11::Json &msr_root,
185 const std::string &msr_name);
186 static void check_msr_field(
const json11::Json &msr_field,
187 const std::string &msr_name,
188 const std::string &msr_field_name);
190 static bool json_check_null_func(
const json11::Json &obj);
191 static bool json_check_is_hex_string(
const json11::Json &obj);
192 static bool json_check_is_valid_offset(
const json11::Json &obj);
193 static bool json_check_is_valid_domain(
const json11::Json &domain);
194 static bool json_check_is_integer(
const json11::Json &num);
195 static bool json_check_is_valid_aggregation(
const json11::Json &obj);
197 void add_raw_msr_signal(
const std::string &msr_name,
int domain_type, uint64_t msr_offset);
199 void add_msr_field_signal(
const std::string &msr_name,
const std::string &msr_field_name,
200 int domain_type,
int begin_bit,
int end_bit,
int function,
201 double scalar,
int units,
const std::string &aggregation,
202 const std::string &description,
int behavior,
205 void add_msr_field_control(
const std::string &msr_field_name,
int domain_type,
206 uint64_t msr_offset,
int begin_bit,
int end_bit,
207 int function,
double scalar,
int units,
208 const std::string &description);
210 static const std::string M_DEFAULT_DESCRIPTION;
211 static const std::string M_PLUGIN_NAME;
212 static const std::string M_NAME_PREFIX;
214 std::shared_ptr<MSRIO> m_msrio;
215 int m_save_restore_ctx;
216 std::shared_ptr<Cpuid> m_cpuid;
221 std::shared_ptr<geopm_time_s> m_time_zero;
222 std::shared_ptr<double> m_time_batch;
224 bool m_is_hwp_enabled;
228 uint32_t m_pmc_bit_width;
230 int m_derivative_window;
239 std::vector<std::shared_ptr<Signal> > signals;
242 std::function<double(
const std::vector<double> &)> agg_function;
243 std::string description;
245 std::function<std::string(
double)> format_function;
247 std::map<std::string, signal_info> m_signal_available;
251 std::vector<std::shared_ptr<Control> > controls;
254 std::string description;
256 std::map<std::string, control_info> m_control_available;
259 std::vector<std::shared_ptr<Signal> > m_signal_pushed;
261 std::vector<std::shared_ptr<Control> > m_control_pushed;
263 std::shared_ptr<SaveControl> m_mock_save_ctl;
265 std::map<int, int> m_power_control_enable_idx;
Definition IOGroup.hpp:21
IOGroup that provides signals and controls based on MSRs.
Definition MSRIOGroup.hpp:35
int control_domain_type(const std::string &control_name) const override
Query the domain for a named control.
Definition MSRIOGroup.cpp:743
void write_batch(void) override
Write all of the pushed controls so that values previously given to adjust() are written to the platf...
Definition MSRIOGroup.cpp:862
void adjust(int control_idx, double setting) override
Adjust a setting for a particular control that was previously pushed with push_control()....
Definition MSRIOGroup.cpp:888
int signal_domain_type(const std::string &signal_name) const override
Query the domain for a named signal.
Definition MSRIOGroup.cpp:733
std::set< std::string > signal_names(void) const override
Returns the names of all signals provided by the IOGroup.
Definition MSRIOGroup.cpp:705
void write_control(const std::string &control_name, int domain_type, int domain_idx, double setting) override
Interpret the setting and write setting to the platform. Does not modify the values stored by calling...
Definition MSRIOGroup.cpp:925
m_cpuid_e
Definition MSRIOGroup.hpp:37
@ M_CPUID_BDX
Definition MSRIOGroup.hpp:41
@ M_CPUID_GNRAP
Definition MSRIOGroup.hpp:48
@ M_CPUID_GNRSP
Definition MSRIOGroup.hpp:47
@ M_CPUID_SKX
Definition MSRIOGroup.hpp:43
@ M_CPUID_HSX
Definition MSRIOGroup.hpp:40
@ M_CPUID_DMR
Definition MSRIOGroup.hpp:51
@ M_CPUID_SRF
Definition MSRIOGroup.hpp:49
@ M_CPUID_SPR
Definition MSRIOGroup.hpp:45
@ M_CPUID_IVT
Definition MSRIOGroup.hpp:39
@ M_CPUID_CWF
Definition MSRIOGroup.hpp:50
@ M_CPUID_KNL
Definition MSRIOGroup.hpp:42
@ M_CPUID_EMR
Definition MSRIOGroup.hpp:46
@ M_CPUID_SNB
Definition MSRIOGroup.hpp:38
@ M_CPUID_ICX
Definition MSRIOGroup.hpp:44
static int cpuid(void)
DEPRECATED Get the cpuid of the current platform.
Definition MSRIOGroup.cpp:975
std::string control_description(const std::string &control_name) const override
Returns a description of the control. This string can be used by tools to generate help text for user...
Definition MSRIOGroup.cpp:1142
static std::string msr_allowlist(int cpuid)
Fill string with the msr-safe allowlist file contents reflecting all known MSRs for the specified pla...
Definition MSRIOGroup.cpp:1844
static std::unique_ptr< IOGroup > make_plugin(void)
Definition MSRIOGroup.cpp:1060
int signal_behavior(const std::string &signal_name) const override
Returns a hint about how a signal will change as a function of time.
Definition MSRIOGroup.cpp:1166
static std::string plugin_name(void)
Definition MSRIOGroup.cpp:1050
std::function< double(const std::vector< double > &)> agg_function(const std::string &signal_name) const override
Return a function that should be used when aggregating the given signal.
Definition MSRIOGroup.cpp:1085
void parse_json_msrs(const std::string &str)
Parse a JSON string and add any raw MSRs and fields as available signals and controls.
Definition MSRIOGroup.cpp:1629
bool is_valid_control(const std::string &control_name) const override
Test if control_name refers to a control supported by the group.
Definition MSRIOGroup.cpp:728
void restore_control(void) override
Restore all controls to values recorded in previous call to the save() method.
Definition MSRIOGroup.cpp:965
double sample(int sample_idx) override
Retrieve signal value from data read by last call to read_batch() for a particular signal previously ...
Definition MSRIOGroup.cpp:874
int push_control(const std::string &control_name, int domain_type, int domain_idx) override
Add a control to the list of controls that is written by write_batch() and configured with adjust().
Definition MSRIOGroup.cpp:797
virtual ~MSRIOGroup()=default
std::set< std::string > control_names(void) const override
Returns the names of all controls provided by the IOGroup.
Definition MSRIOGroup.cpp:714
std::string name(void) const override
Get the IOGroup name.
Definition MSRIOGroup.cpp:1055
int push_signal(const std::string &signal_name, int domain_type, int domain_idx) override
Add a signal to the list of signals that is read by read_batch() and sampled by sample().
Definition MSRIOGroup.cpp:753
void save_control(void) override
Save the state of all controls so that any subsequent changes made through the IOGroup can be undone ...
Definition MSRIOGroup.cpp:955
std::string signal_description(const std::string &signal_name) const override
Returns a description of the signal. This string can be used by tools to generate help text for users...
Definition MSRIOGroup.cpp:1117
double read_signal(const std::string &signal_name, int domain_type, int domain_idx) override
Read from platform and interpret into SI units a signal given its name and domain....
Definition MSRIOGroup.cpp:906
std::function< std::string(double)> format_function(const std::string &signal_name) const override
Returns a function that can be used to convert a signal of the given name into a printable string....
Definition MSRIOGroup.cpp:1095
bool is_valid_signal(const std::string &signal_name) const override
Test if signal_name refers to a signal supported by the group.
Definition MSRIOGroup.cpp:723
void read_batch(void) override
Read all pushed signals from the platform so that the next call to sample() will reflect the updated ...
Definition MSRIOGroup.cpp:850
static std::unique_ptr< IOGroup > make_plugin_safe(void)
Definition MSRIOGroup.cpp:1065
const PlatformTopo & platform_topo(void)
Definition PlatformTopo.cpp:97