geopm  3.1.1.dev296+g5916b956
GEOPM - Global Extensible Open Power Manager
CpuinfoIOGroup.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 #ifndef CPUINFOIOGROUP_HPP_INCLUDE
6 #define CPUINFOIOGROUP_HPP_INCLUDE
7 
8 #include <map>
9 #include <functional>
10 
11 #include "geopm/IOGroup.hpp"
12 
13 namespace geopm
14 {
17  class CpuinfoIOGroup : public IOGroup
18  {
19  public:
21  CpuinfoIOGroup(const std::string &cpu_freq_min_path,
22  const std::string &cpu_freq_max_path,
23  double cpu_freq_sticker);
24  virtual ~CpuinfoIOGroup() = default;
26  std::set<std::string> signal_names(void) const override;
28  std::set<std::string> control_names(void) const override;
31  bool is_valid_signal(const std::string &signal_name) const override;
33  bool is_valid_control(const std::string &control_name) const override;
37  int signal_domain_type(const std::string &signal_name) const override;
39  int control_domain_type(const std::string &control_name) const override;
49  int push_signal(const std::string &signal_name, int domain_type, int domain_idx) override;
53  int push_control(const std::string &control_name, int domain_type, int domain_idx) override;
55  void read_batch(void) override;
57  void write_batch(void) override;
63  double sample(int batch_idx) override;
67  void adjust(int batch_idx, double setting) override;
79  double read_signal(const std::string &signal_name, int domain_type, int domain_idx) override;
83  void write_control(const std::string &control_name, int domain_type, int domain_idx, double setting) override;
85  void save_control(void) override;
87  void restore_control(void) override;
96  std::function<double(const std::vector<double> &)> agg_function(const std::string &signal_name) const override;
100  std::function<std::string(double)> format_function(const std::string &signal_name) const override;
102  std::string signal_description(const std::string &signal_name) const override;
106  std::string control_description(const std::string &control_name) const override;
112  int signal_behavior(const std::string &signal_name) const override;
116  void save_control(const std::string &save_path) override;
120  void restore_control(const std::string &save_path) override;
122  std::string name(void) const override;
127  static std::string plugin_name(void);
131  static std::unique_ptr<IOGroup> make_plugin(void);
132  private:
134  void register_signal_alias(const std::string &alias_name, const std::string &signal_name);
135 
136  struct m_signal_info_s {
137  double value;
138  int units;
139  std::function<double(const std::vector<double> &)> agg_function;
140  std::string description;
141  };
142  std::map<std::string, m_signal_info_s> m_signal_available;
143  };
144 }
145 
146 #endif
IOGroup that provides constants for CPU frequency limits as signals for PlatformIO.
Definition: CpuinfoIOGroup.hpp:18
std::string name(void) const override
Definition: CpuinfoIOGroup.cpp:323
void write_control(const std::string &control_name, int domain_type, int domain_idx, double setting) override
Should not be called; this IOGroup does not provide any controls.
Definition: CpuinfoIOGroup.cpp:246
std::string control_description(const std::string &control_name) const override
Does nothing; this IOGroup does not provide any controls.
Definition: CpuinfoIOGroup.cpp:308
void adjust(int batch_idx, double setting) override
Should not be called; this IOGroup does not provide any controls.
Definition: CpuinfoIOGroup.cpp:225
void write_batch(void) override
Does nothing; this IOGroup does not provide any controls.
Definition: CpuinfoIOGroup.cpp:205
bool is_valid_signal(const std::string &signal_name) const override
Definition: CpuinfoIOGroup.cpp:149
void save_control(void) override
Does nothing; this IOGroup does not provide any controls.
Definition: CpuinfoIOGroup.cpp:252
void restore_control(void) override
Does nothing; this IOGroup does not provide any controls.
Definition: CpuinfoIOGroup.cpp:257
std::set< std::string > control_names(void) const override
Definition: CpuinfoIOGroup.cpp:144
int control_domain_type(const std::string &control_name) const override
Definition: CpuinfoIOGroup.cpp:175
std::set< std::string > signal_names(void) const override
Definition: CpuinfoIOGroup.cpp:135
virtual ~CpuinfoIOGroup()=default
int push_control(const std::string &control_name, int domain_type, int domain_idx) override
Should not be called; this IOGroup does not provide any controls.
Definition: CpuinfoIOGroup.cpp:195
void read_batch(void) override
Does nothing; this IOGroup's signals are constant.
Definition: CpuinfoIOGroup.cpp:201
double read_signal(const std::string &signal_name, int domain_type, int domain_idx) override
Definition: CpuinfoIOGroup.cpp:231
std::function< double(const std::vector< double > &)> agg_function(const std::string &signal_name) const override
For all valid signals in this IOGroup, the aggregation function is expect_same()
Definition: CpuinfoIOGroup.cpp:262
CpuinfoIOGroup()
Definition: CpuinfoIOGroup.cpp:63
int push_signal(const std::string &signal_name, int domain_type, int domain_idx) override
Definition: CpuinfoIOGroup.cpp:180
std::function< std::string(double)> format_function(const std::string &signal_name) const override
Definition: CpuinfoIOGroup.cpp:272
std::string signal_description(const std::string &signal_name) const override
Definition: CpuinfoIOGroup.cpp:282
static std::string plugin_name(void)
Definition: CpuinfoIOGroup.cpp:328
int signal_behavior(const std::string &signal_name) const override
Definition: CpuinfoIOGroup.cpp:313
int signal_domain_type(const std::string &signal_name) const override
Definition: CpuinfoIOGroup.cpp:159
static std::unique_ptr< IOGroup > make_plugin(void)
Definition: CpuinfoIOGroup.cpp:333
double sample(int batch_idx) override
Definition: CpuinfoIOGroup.cpp:209
bool is_valid_control(const std::string &control_name) const override
Definition: CpuinfoIOGroup.cpp:154
Definition: IOGroup.hpp:21
Definition: Agg.cpp:20