geopm  3.1.1.dev272+gdfb40a8d
GEOPM - Global Extensible Open Power Manager
DebugIOGroup.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 DEBUGIOGROUP_HPP_INCLUDE
7 #define DEBUGIOGROUP_HPP_INCLUDE
8 
9 #include <cstdint>
10 
11 #include <functional>
12 #include <map>
13 #include <vector>
14 #include <memory>
15 #include <set>
16 
17 #include "geopm/IOGroup.hpp"
18 
19 namespace geopm
20 {
21  class PlatformTopo;
22 
24  class DebugIOGroup : public IOGroup
25  {
26  public:
31  DebugIOGroup(const PlatformTopo &topo,
32  std::shared_ptr<std::vector<double> > value_cache);
33  virtual ~DebugIOGroup() = default;
34  std::set<std::string> signal_names(void) const override;
35  std::set<std::string> control_names(void) const override;
36  bool is_valid_signal(const std::string &signal_name) const override;
37  bool is_valid_control(const std::string &control_name) const override;
38  int signal_domain_type(const std::string &signal_name) const override;
39  int control_domain_type(const std::string &control_name) const override;
40  int push_signal(const std::string &signal_name, int domain_type, int domain_idx) override;
41  int push_control(const std::string &control_name, int domain_type, int domain_idx) override;
42  void read_batch(void) override;
43  void write_batch(void) override;
44  double sample(int batch_idx) override;
45  void adjust(int batch_idx, double setting) override;
46  double read_signal(const std::string &signal_name, int domain_type, int domain_idx) override;
47  void write_control(const std::string &control_name, int domain_type, int domain_idx, double setting) override;
48  void save_control(void) override;
49  void restore_control(void) override;
50  std::function<double(const std::vector<double> &)> agg_function(const std::string &signal_name) const override;
51  std::string signal_description(const std::string &signal_name) const override;
52  std::string control_description(const std::string &control_name) const override;
53  int signal_behavior(const std::string &signal_name) const override;
54  void save_control(const std::string &save_path) override;
55  void restore_control(const std::string &save_path) override;
56  std::string name(void) const override;
57  static std::string plugin_name(void);
58  static std::unique_ptr<IOGroup> make_plugin(void);
59 
63  void register_signal(const std::string &name, int domain_type,
64  int signal_behavior);
65  private:
66  struct m_signal_info_s {
67  int domain_type;
68  int behavior;
69  };
70 
71  const PlatformTopo &m_topo;
72  const std::shared_ptr<std::vector<double> > m_value_cache;
73  size_t m_num_reg_signals;
75  std::map<std::pair<std::string, int>, int> m_signal_idx;
76  std::map<std::string, m_signal_info_s> m_signal_info;
77  std::set<std::string> m_signal_name;
78  };
79 }
80 
81 #endif
IOGroup that Agents can use to expose internal values.
Definition: DebugIOGroup.hpp:25
virtual ~DebugIOGroup()=default
DebugIOGroup(const PlatformTopo &topo, std::shared_ptr< std::vector< double > > value_cache)
Constructor; should be called in the Agent's constructor. value_cache is created and updated by the A...
Definition: DebugIOGroup.cpp:14
void read_batch(void) override
Definition: DebugIOGroup.cpp:106
int signal_domain_type(const std::string &signal_name) const override
Definition: DebugIOGroup.cpp:66
std::string signal_description(const std::string &signal_name) const override
Definition: DebugIOGroup.cpp:193
int control_domain_type(const std::string &control_name) const override
Definition: DebugIOGroup.cpp:75
void restore_control(void) override
Definition: DebugIOGroup.cpp:161
int signal_behavior(const std::string &signal_name) const override
Definition: DebugIOGroup.cpp:213
bool is_valid_signal(const std::string &signal_name) const override
Definition: DebugIOGroup.cpp:56
void write_control(const std::string &control_name, int domain_type, int domain_idx, double setting) override
Definition: DebugIOGroup.cpp:151
static std::unique_ptr< IOGroup > make_plugin(void)
Definition: DebugIOGroup.cpp:176
double read_signal(const std::string &signal_name, int domain_type, int domain_idx) override
Definition: DebugIOGroup.cpp:131
std::set< std::string > control_names(void) const override
Definition: DebugIOGroup.cpp:51
int push_signal(const std::string &signal_name, int domain_type, int domain_idx) override
Definition: DebugIOGroup.cpp:80
int push_control(const std::string &control_name, int domain_type, int domain_idx) override
Definition: DebugIOGroup.cpp:100
bool is_valid_control(const std::string &control_name) const override
Definition: DebugIOGroup.cpp:61
void register_signal(const std::string &name, int domain_type, int signal_behavior)
Set up a signal name and base domain to map to one or more underlying values. One signal will be adde...
Definition: DebugIOGroup.cpp:26
static std::string plugin_name(void)
Definition: DebugIOGroup.cpp:171
void adjust(int batch_idx, double setting) override
Definition: DebugIOGroup.cpp:125
double sample(int batch_idx) override
Definition: DebugIOGroup.cpp:116
void save_control(void) override
Definition: DebugIOGroup.cpp:156
std::set< std::string > signal_names(void) const override
Definition: DebugIOGroup.cpp:46
std::string name(void) const override
Definition: DebugIOGroup.cpp:166
std::function< double(const std::vector< double > &)> agg_function(const std::string &signal_name) const override
Definition: DebugIOGroup.cpp:183
std::string control_description(const std::string &control_name) const override
Definition: DebugIOGroup.cpp:204
void write_batch(void) override
Definition: DebugIOGroup.cpp:111
Definition: Accumulator.cpp:12