6 #ifndef MSRIOGROUP_HPP_INCLUDE
7 #define MSRIOGROUP_HPP_INCLUDE
54 std::shared_ptr<MSRIO> msrio,
55 std::shared_ptr<Cpuid>
cpuid,
67 int domain_idx)
override;
70 int domain_idx)
override;
73 double sample(
int sample_idx)
override;
74 void adjust(
int control_idx,
75 double setting)
override;
78 int domain_idx)
override;
82 double setting)
override;
85 std::function<double(
const std::vector<double> &)>
agg_function(
const std::string &signal_name)
const override;
86 std::function<std::string(
double)>
format_function(
const std::string &signal_name)
const override;
90 void save_control(
const std::string &save_path)
override;
92 std::string
name(
void)
const override;
106 std::shared_ptr<MSRIO> msrio);
108 static int cpuid(
void);
115 static void parse_json_msrs_allowlist(
const std::string &str,
116 std::map<uint64_t, std::pair<uint64_t, std::string> > &allowlist_data,
118 std::shared_ptr<MSRIO> msrio);
125 static std::string format_allowlist(
const std::map<uint64_t, std::pair<uint64_t, std::string> > &allowlist_data);
129 static std::string platform_data(
int cpu_id);
131 enum MsrConfigWarningPreference_e {
132 SILENCE_CONFIG_DEPRECATION_WARNING,
133 EMIT_CONFIG_DEPRECATION_WARNING,
140 static std::set<std::string> msr_data_files(
141 MsrConfigWarningPreference_e warning_preference = SILENCE_CONFIG_DEPRECATION_WARNING);
144 void set_signal_description(
const std::string &
name,
const std::string &description);
147 void set_control_description(
const std::string &
name,
const std::string &description);
149 void register_signal_alias(
const std::string &signal_name,
const std::string &msr_field_name);
151 void register_control_alias(
const std::string &control_name,
const std::string &msr_field_name);
154 void register_temperature_signals(
void);
157 void register_power_signals(
void);
160 void register_pcnt_scalability_signals(
void);
163 void register_rdt_signals(
void);
166 void register_frequency_signals(
void);
169 void register_frequency_controls(
void);
171 void enable_fixed_counters(
void);
174 void check_control(
const std::string &control_name);
177 void check_control_lock(
const std::string &lock_name,
const std::string &error);
180 static void check_top_level(
const json11::Json &root);
181 static void check_msr_root(
const json11::Json &msr_root,
182 const std::string &msr_name);
183 static void check_msr_field(
const json11::Json &msr_field,
184 const std::string &msr_name,
185 const std::string &msr_field_name);
187 static bool json_check_null_func(
const json11::Json &obj);
188 static bool json_check_is_hex_string(
const json11::Json &obj);
189 static bool json_check_is_valid_offset(
const json11::Json &obj);
190 static bool json_check_is_valid_domain(
const json11::Json &domain);
191 static bool json_check_is_integer(
const json11::Json &num);
192 static bool json_check_is_valid_aggregation(
const json11::Json &obj);
194 void add_raw_msr_signal(
const std::string &msr_name,
int domain_type, uint64_t msr_offset);
196 void add_msr_field_signal(
const std::string &msr_name,
const std::string &msr_field_name,
197 int domain_type,
int begin_bit,
int end_bit,
int function,
198 double scalar,
int units,
const std::string &aggregation,
199 const std::string &description,
int behavior,
202 void add_msr_field_control(
const std::string &msr_field_name,
int domain_type,
203 uint64_t msr_offset,
int begin_bit,
int end_bit,
204 int function,
double scalar,
int units,
205 const std::string &description);
207 static const std::string M_DEFAULT_DESCRIPTION;
208 static const std::string M_PLUGIN_NAME;
209 static const std::string M_NAME_PREFIX;
211 std::shared_ptr<MSRIO> m_msrio;
212 int m_save_restore_ctx;
213 std::shared_ptr<Cpuid> m_cpuid;
217 bool m_is_fixed_enabled;
218 std::vector<bool> m_is_adjusted;
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;
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;
int geopm_allowlist(size_t result_max, char *result)
Definition: MSRIOGroup.cpp:1858
Definition: IOGroup.hpp:21
IOGroup that provides signals and controls based on MSRs.
Definition: MSRIOGroup.hpp:38
int control_domain_type(const std::string &control_name) const override
Query the domain for a named control.
Definition: MSRIOGroup.cpp:735
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:855
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:881
int signal_domain_type(const std::string &signal_name) const override
Query the domain for a named signal.
Definition: MSRIOGroup.cpp:725
std::set< std::string > signal_names(void) const override
Returns the names of all signals provided by the IOGroup.
Definition: MSRIOGroup.cpp:697
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:913
m_cpuid_e
Definition: MSRIOGroup.hpp:40
@ M_CPUID_BDX
Definition: MSRIOGroup.hpp:44
@ M_CPUID_SKX
Definition: MSRIOGroup.hpp:46
@ M_CPUID_HSX
Definition: MSRIOGroup.hpp:43
@ M_CPUID_SPR
Definition: MSRIOGroup.hpp:48
@ M_CPUID_IVT
Definition: MSRIOGroup.hpp:42
@ M_CPUID_KNL
Definition: MSRIOGroup.hpp:45
@ M_CPUID_SNB
Definition: MSRIOGroup.hpp:41
@ M_CPUID_ICX
Definition: MSRIOGroup.hpp:47
static int cpuid(void)
DEPRECATED Get the cpuid of the current platform.
Definition: MSRIOGroup.cpp:961
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:1146
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:1833
static std::unique_ptr< IOGroup > make_plugin(void)
Definition: MSRIOGroup.cpp:1046
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:1170
static std::string plugin_name(void)
Definition: MSRIOGroup.cpp:1036
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:1089
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:1618
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:720
void restore_control(void) override
Restore all controls to values recorded in previous call to the save() method.
Definition: MSRIOGroup.cpp:951
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:867
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:792
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:706
std::string name(void) const override
Get the IOGroup name.
Definition: MSRIOGroup.cpp:1041
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:745
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:941
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:1121
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:891
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:1099
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:715
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:843
static std::unique_ptr< IOGroup > make_plugin_safe(void)
Definition: MSRIOGroup.cpp:1051
const PlatformTopo & platform_topo(void)
Definition: PlatformTopo.cpp:81