6 #ifndef MSRIOGROUP_HPP_INCLUDE
7 #define MSRIOGROUP_HPP_INCLUDE
51 std::shared_ptr<MSRIO> msrio,
52 std::shared_ptr<Cpuid>
cpuid,
63 int domain_idx)
override;
66 int domain_idx)
override;
69 double sample(
int sample_idx)
override;
70 void adjust(
int control_idx,
71 double setting)
override;
74 int domain_idx)
override;
78 double setting)
override;
81 std::function<double(
const std::vector<double> &)>
agg_function(
const std::string &signal_name)
const override;
82 std::function<std::string(
double)>
format_function(
const std::string &signal_name)
const override;
86 void save_control(
const std::string &save_path)
override;
88 std::string
name(
void)
const override;
102 std::shared_ptr<MSRIO> msrio);
105 static int cpuid(
void);
112 static void parse_json_msrs_allowlist(
const std::string &str,
113 std::map<uint64_t, std::pair<uint64_t, std::string> > &allowlist_data,
115 std::shared_ptr<MSRIO> msrio);
122 static std::string format_allowlist(
const std::map<uint64_t, std::pair<uint64_t, std::string> > &allowlist_data);
126 static std::string platform_data(
int cpu_id);
128 enum MsrConfigWarningPreference_e {
129 SILENCE_CONFIG_DEPRECATION_WARNING,
130 EMIT_CONFIG_DEPRECATION_WARNING,
137 static std::set<std::string> msr_data_files(
138 MsrConfigWarningPreference_e warning_preference = SILENCE_CONFIG_DEPRECATION_WARNING);
141 void set_signal_description(
const std::string &
name,
const std::string &description);
144 void set_control_description(
const std::string &
name,
const std::string &description);
146 void register_signal_alias(
const std::string &signal_name,
const std::string &msr_field_name);
148 void register_control_alias(
const std::string &control_name,
const std::string &msr_field_name);
151 void register_temperature_signals(
void);
154 void register_power_signals(
void);
157 void register_pcnt_scalability_signals(
void);
160 void register_rdt_signals(
void);
163 void register_frequency_signals(
void);
166 void register_frequency_controls(
void);
169 void check_control(
const std::string &control_name);
171 void check_control_pwrite(
void);
174 void check_control_lock(
const std::string &lock_name,
const std::string &error);
177 static void check_top_level(
const json11::Json &root);
178 static void check_msr_root(
const json11::Json &msr_root,
179 const std::string &msr_name);
180 static void check_msr_field(
const json11::Json &msr_field,
181 const std::string &msr_name,
182 const std::string &msr_field_name);
184 static bool json_check_null_func(
const json11::Json &obj);
185 static bool json_check_is_hex_string(
const json11::Json &obj);
186 static bool json_check_is_valid_offset(
const json11::Json &obj);
187 static bool json_check_is_valid_domain(
const json11::Json &domain);
188 static bool json_check_is_integer(
const json11::Json &num);
189 static bool json_check_is_valid_aggregation(
const json11::Json &obj);
191 void add_raw_msr_signal(
const std::string &msr_name,
int domain_type, uint64_t msr_offset);
193 void add_msr_field_signal(
const std::string &msr_name,
const std::string &msr_field_name,
194 int domain_type,
int begin_bit,
int end_bit,
int function,
195 double scalar,
int units,
const std::string &aggregation,
196 const std::string &description,
int behavior,
199 void add_msr_field_control(
const std::string &msr_field_name,
int domain_type,
200 uint64_t msr_offset,
int begin_bit,
int end_bit,
201 int function,
double scalar,
int units,
202 const std::string &description);
204 static const std::string M_DEFAULT_DESCRIPTION;
205 static const std::string M_PLUGIN_NAME;
206 static const std::string M_NAME_PREFIX;
208 std::shared_ptr<MSRIO> m_msrio;
209 int m_save_restore_ctx;
210 std::shared_ptr<Cpuid> m_cpuid;
213 std::vector<bool> m_is_adjusted;
216 std::shared_ptr<geopm_time_s> m_time_zero;
217 std::shared_ptr<double> m_time_batch;
219 bool m_is_hwp_enabled;
223 uint32_t m_pmc_bit_width;
225 int m_derivative_window;
234 std::vector<std::shared_ptr<Signal> > signals;
237 std::function<double(
const std::vector<double> &)>
agg_function;
238 std::string description;
242 std::map<std::string, signal_info> m_signal_available;
246 std::vector<std::shared_ptr<Control> > controls;
249 std::string description;
251 std::map<std::string, control_info> m_control_available;
254 std::vector<std::shared_ptr<Signal> > m_signal_pushed;
256 std::vector<std::shared_ptr<Control> > m_control_pushed;
258 std::shared_ptr<SaveControl> m_mock_save_ctl;
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:736
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:853
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:879
int signal_domain_type(const std::string &signal_name) const override
Query the domain for a named signal.
Definition: MSRIOGroup.cpp:726
std::set< std::string > signal_names(void) const override
Returns the names of all signals provided by the IOGroup.
Definition: MSRIOGroup.cpp:698
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:908
m_cpuid_e
Definition: MSRIOGroup.hpp:37
@ M_CPUID_BDX
Definition: MSRIOGroup.hpp:41
@ M_CPUID_SKX
Definition: MSRIOGroup.hpp:43
@ M_CPUID_HSX
Definition: MSRIOGroup.hpp:40
@ M_CPUID_SPR
Definition: MSRIOGroup.hpp:45
@ M_CPUID_IVT
Definition: MSRIOGroup.hpp:39
@ M_CPUID_KNL
Definition: MSRIOGroup.hpp:42
@ 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:956
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:1123
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:1810
static std::unique_ptr< IOGroup > make_plugin(void)
Definition: MSRIOGroup.cpp:1041
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:1147
static std::string plugin_name(void)
Definition: MSRIOGroup.cpp:1031
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:1066
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:1595
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:721
void restore_control(void) override
Restore all controls to values recorded in previous call to the save() method.
Definition: MSRIOGroup.cpp:946
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:865
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:790
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:707
std::string name(void) const override
Get the IOGroup name.
Definition: MSRIOGroup.cpp:1036
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:746
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:936
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:1098
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:889
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:1076
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:716
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:841
static std::unique_ptr< IOGroup > make_plugin_safe(void)
Definition: MSRIOGroup.cpp:1046
const PlatformTopo & platform_topo(void)
Definition: PlatformTopo.cpp:81