geopm  3.1.1.dev296+g5916b956
GEOPM - Global Extensible Open Power Manager
TimeIOGroup.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 TIMEIOGROUP_HPP_INCLUDE
7 #define TIMEIOGROUP_HPP_INCLUDE
8 
9 #include <set>
10 #include <functional>
11 
12 #include "geopm/IOGroup.hpp"
13 #include "geopm_time.h"
14 
15 namespace geopm
16 {
18  class TimeIOGroup : public IOGroup
19  {
20  public:
21  TimeIOGroup();
22  virtual ~TimeIOGroup() = default;
23  std::set<std::string> signal_names(void) const override;
24  std::set<std::string> control_names(void) const override;
25  bool is_valid_signal(const std::string &signal_name) const override;
26  bool is_valid_control(const std::string &control_name) const override;
27  int signal_domain_type(const std::string &signal_name) const override;
28  int control_domain_type(const std::string &control_name) const override;
29  int push_signal(const std::string &signal_name, int domain_type, int domain_idx) override;
30  int push_control(const std::string &control_name, int domain_type, int domain_idx) override;
31  void read_batch(void) override;
32  void write_batch(void) override;
33  double sample(int batch_idx) override;
34  void adjust(int batch_idx, double setting) override;
35  double read_signal(const std::string &signal_name, int domain_type, int domain_idx) override;
36  void write_control(const std::string &control_name, int domain_type, int domain_idx, double setting) override;
37  void save_control(void) override;
38  void restore_control(void) override;
39  std::function<double(const std::vector<double> &)> agg_function(const std::string &signal_name) const override;
40  std::function<std::string(double)> format_function(const std::string &signal_name) const override;
41  std::string signal_description(const std::string &signal_name) const override;
42  std::string control_description(const std::string &control_name) const override;
43  int signal_behavior(const std::string &signal_name) const override;
44  void save_control(const std::string &save_path) override;
45  void restore_control(const std::string &save_path) override;
46  std::string name(void) const override;
47  static std::string plugin_name(void);
48  static std::unique_ptr<IOGroup> make_plugin(void);
49  private:
50  bool m_is_signal_pushed;
51  bool m_is_batch_read;
52  geopm_time_s m_time_zero;
53  double m_time_curr;
54  const std::set<std::string> m_valid_signal_name;
55  };
56 }
57 
58 #endif
Definition: IOGroup.hpp:21
IOGroup that provides a signal for the time since GEOPM startup.
Definition: TimeIOGroup.hpp:19
int signal_domain_type(const std::string &signal_name) const override
Query the domain for a named signal.
Definition: TimeIOGroup.cpp:48
void read_batch(void) override
Read all pushed signals from the platform so that the next call to sample() will reflect the updated ...
Definition: TimeIOGroup.cpp:88
double sample(int batch_idx) override
Retrieve signal value from data read by last call to read_batch() for a particular signal previously ...
Definition: TimeIOGroup.cpp:102
std::set< std::string > signal_names(void) const override
Returns the names of all signals provided by the IOGroup.
Definition: TimeIOGroup.cpp:28
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: TimeIOGroup.cpp:216
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: TimeIOGroup.cpp:182
void adjust(int batch_idx, double setting) override
Adjust a setting for a particular control that was previously pushed with push_control()....
Definition: TimeIOGroup.cpp:119
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: TimeIOGroup.cpp:82
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: TimeIOGroup.cpp:125
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: TimeIOGroup.cpp:172
std::set< std::string > control_names(void) const override
Returns the names of all controls provided by the IOGroup.
Definition: TimeIOGroup.cpp:33
std::string name(void) const override
Get the IOGroup name.
Definition: TimeIOGroup.cpp:157
void restore_control(void) override
Restore all controls to values recorded in previous call to the save() method.
Definition: TimeIOGroup.cpp:152
static std::unique_ptr< IOGroup > make_plugin(void)
Definition: TimeIOGroup.cpp:167
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: TimeIOGroup.cpp:192
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: TimeIOGroup.cpp:62
void save_control(void) override
Save the state of all controls so that any subsequent changes made through the IOGroup can be undone ...
Definition: TimeIOGroup.cpp:147
bool is_valid_control(const std::string &control_name) const override
Test if control_name refers to a control supported by the group.
Definition: TimeIOGroup.cpp:43
bool is_valid_signal(const std::string &signal_name) const override
Test if signal_name refers to a signal supported by the group.
Definition: TimeIOGroup.cpp:38
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: TimeIOGroup.cpp:210
virtual ~TimeIOGroup()=default
static std::string plugin_name(void)
Definition: TimeIOGroup.cpp:162
TimeIOGroup()
Definition: TimeIOGroup.cpp:17
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: TimeIOGroup.cpp:141
int control_domain_type(const std::string &control_name) const override
Query the domain for a named control.
Definition: TimeIOGroup.cpp:57
void write_batch(void) override
Write all of the pushed controls so that values previously given to adjust() are written to the platf...
Definition: TimeIOGroup.cpp:97
Definition: Agg.cpp:20
structure to abstract the timespec on linux from other representations of time.
Definition: geopm_time.h:43