geopm  3.1.1.dev296+g5916b956
GEOPM - Global Extensible Open Power Manager
CNLIOGroup.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 CNLIOGROUP_HPP_INCLUDE
6 #define CNLIOGROUP_HPP_INCLUDE
7 
8 #include <functional>
9 #include <map>
10 
11 #include "geopm/IOGroup.hpp"
12 #include "geopm_time.h"
13 
14 namespace geopm
15 {
20  class CNLIOGroup : public IOGroup
21  {
22  public:
23  CNLIOGroup();
24  CNLIOGroup(const std::string &pm_counters_path);
25  virtual ~CNLIOGroup() = default;
27  std::set<std::string> signal_names(void) const override;
29  std::set<std::string> control_names(void) const override;
32  bool is_valid_signal(const std::string &signal_name) const override;
34  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,
50  int domain_idx) override;
54  int push_control(const std::string &control_name, int domain_type,
55  int domain_idx) override;
61  void read_batch(void) override;
63  void write_batch(void) override;
69  double sample(int batch_idx) override;
73  void adjust(int batch_idx, double setting) override;
85  double read_signal(const std::string &signal_name, int domain_type,
86  int domain_idx) override;
90  void write_control(const std::string &control_name, int domain_type,
91  int domain_idx, double setting) override;
93  void save_control(void) override;
95  void restore_control(void) override;
101  std::function<double(const std::vector<double> &)>
102  agg_function(const std::string &signal_name) const override;
106  std::function<std::string(double)>
107  format_function(const std::string &signal_name) const override;
109  std::string signal_description(const std::string &signal_name) const override;
113  std::string control_description(const std::string &control_name) const override;
119  int signal_behavior(const std::string &signal_name) const override;
123  void save_control(const std::string &save_path) override;
127  void restore_control(const std::string &save_path) override;
129  std::string name(void) const override;
134  static std::string plugin_name(void);
138  static std::unique_ptr<IOGroup> make_plugin(void);
139 
140  private:
141  void register_signal_alias(const std::string &alias_name, const std::string &signal_name);
142 
143  struct m_signal_info_s {
144  std::string m_description;
145  std::function<double(const std::vector<double> &)> m_agg_function;
146  std::function<std::string(double)> m_format_function;
147  std::function<double()> m_read_function;
148  bool m_do_read;
149  double m_value;
150  int m_units;
151  int m_behavior;
152  };
153  std::map<std::string, m_signal_info_s> m_signal_available;
154 
155  double read_time(const std::string &freshness_path) const;
156 
157  geopm_time_s m_time_zero;
158  double m_initial_freshness;
159  double m_sample_rate;
160  };
161 }
162 
163 #endif
IOGroup that wraps interfaces to Compute Node Linux.
Definition: CNLIOGroup.hpp:21
double sample(int batch_idx) override
Definition: CNLIOGroup.cpp:204
std::string signal_description(const std::string &signal_name) const override
Definition: CNLIOGroup.cpp:286
void write_batch(void) override
Does nothing; this IOGroup does not provide any controls.
Definition: CNLIOGroup.cpp:202
int control_domain_type(const std::string &control_name) const override
Definition: CNLIOGroup.cpp:163
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: CNLIOGroup.cpp:249
void adjust(int batch_idx, double setting) override
Should not be called; this IOGroup does not provide any controls.
Definition: CNLIOGroup.cpp:227
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: CNLIOGroup.cpp:186
int signal_domain_type(const std::string &signal_name) const override
Definition: CNLIOGroup.cpp:158
std::string control_description(const std::string &control_name) const override
Should not be called; this IOGroup does not provide any controls.
Definition: CNLIOGroup.cpp:312
std::set< std::string > signal_names(void) const override
Definition: CNLIOGroup.cpp:134
double read_signal(const std::string &signal_name, int domain_type, int domain_idx) override
Definition: CNLIOGroup.cpp:233
void restore_control(void) override
Does nothing; this IOGroup does not provide any controls.
Definition: CNLIOGroup.cpp:260
virtual ~CNLIOGroup()=default
void read_batch(void) override
Read all pushed signals from the platform so that the next call to sample() will reflect the updated ...
Definition: CNLIOGroup.cpp:193
std::set< std::string > control_names(void) const override
Definition: CNLIOGroup.cpp:143
int signal_behavior(const std::string &signal_name) const override
Definition: CNLIOGroup.cpp:320
std::string name(void) const override
Definition: CNLIOGroup.cpp:341
int push_signal(const std::string &signal_name, int domain_type, int domain_idx) override
Definition: CNLIOGroup.cpp:168
static std::string plugin_name(void)
Definition: CNLIOGroup.cpp:346
std::function< std::string(double)> format_function(const std::string &signal_name) const override
Definition: CNLIOGroup.cpp:275
bool is_valid_control(const std::string &control_name) const override
Definition: CNLIOGroup.cpp:153
bool is_valid_signal(const std::string &signal_name) const override
Definition: CNLIOGroup.cpp:148
CNLIOGroup()
Definition: CNLIOGroup.cpp:33
void save_control(void) override
Does nothing; this IOGroup does not provide any controls.
Definition: CNLIOGroup.cpp:258
static std::unique_ptr< IOGroup > make_plugin(void)
Definition: CNLIOGroup.cpp:351
std::function< double(const std::vector< double > &)> agg_function(const std::string &signal_name) const override
Definition: CNLIOGroup.cpp:263
Definition: IOGroup.hpp:21
Definition: Agg.cpp:20
structure to abstract the timespec on linux from other representations of time.
Definition: geopm_time.h:43