geopm  3.1.1.dev272+gdfb40a8d
GEOPM - Global Extensible Open Power Manager
PlatformIO.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 PLATFORMIO_HPP_INCLUDE
7 #define PLATFORMIO_HPP_INCLUDE
8 
9 #include <functional>
10 #include <memory>
11 #include <set>
12 #include <string>
13 #include <vector>
14 
15 #include "geopm_pio.h"
16 #include "geopm_public.h"
17 
18 namespace geopm
19 {
20  class IOGroup;
21  class ProfileIOGroup;
22 
26  {
27  public:
28  PlatformIO() = default;
29  virtual ~PlatformIO() = default;
39  virtual void register_iogroup(std::shared_ptr<IOGroup> iogroup) = 0;
44  virtual std::set<std::string> signal_names(void) const = 0;
49  virtual std::set<std::string> control_names(void) const = 0;
58  virtual int signal_domain_type(const std::string &signal_name) const = 0;
68  virtual int control_domain_type(const std::string &control_name) const = 0;
86  virtual int push_signal(const std::string &signal_name,
87  int domain_type,
88  int domain_idx) = 0;
105  virtual int push_control(const std::string &control_name,
106  int domain_type,
107  int domain_idx) = 0;
117  virtual double sample(int signal_idx) = 0;
127  virtual void adjust(int control_idx,
128  double setting) = 0;
131  virtual void read_batch(void) = 0;
135  virtual void write_batch(void) = 0;
152  virtual double read_signal(const std::string &signal_name,
153  int domain_type,
154  int domain_idx) = 0;
171  virtual void write_control(const std::string &control_name,
172  int domain_type,
173  int domain_idx,
174  double setting) = 0;
179  virtual void save_control(void) = 0;
182  virtual void restore_control(void) = 0;
190  virtual std::function<double(const std::vector<double> &)> agg_function(const std::string &signal_name) const = 0;
198  virtual std::function<std::string(double)> format_function(const std::string &signal_name) const = 0;
202  virtual std::string signal_description(const std::string &signal_name) const = 0;
206  virtual std::string control_description(const std::string &control_name) const = 0;
218  virtual int signal_behavior(const std::string &signal_name) const = 0;
229  virtual void save_control(const std::string &save_dir) = 0;
237  virtual void restore_control(const std::string &save_dir) = 0;
239  virtual void start_batch_server(int client_pid,
240  const std::vector<geopm_request_s> &signal_config,
241  const std::vector<geopm_request_s> &control_config,
242  int &server_pid,
243  std::string &server_key) = 0;
244  virtual void stop_batch_server(int server_pid) = 0;
245 
249  static bool is_valid_value(double value);
250  };
251 
253  platform_io(void);
254 }
255 
256 #endif
Class which is a collection of all valid control and signal objects for a platform.
Definition: PlatformIO.hpp:26
virtual void restore_control(void)=0
Restore all controls to values recorded in previous call to the save_control() method.
virtual void start_batch_server(int client_pid, const std::vector< geopm_request_s > &signal_config, const std::vector< geopm_request_s > &control_config, int &server_pid, std::string &server_key)=0
virtual void save_control(const std::string &save_dir)=0
Save the state of all controls so that any subsequent changes made through PlatformIO can be undone w...
virtual void register_iogroup(std::shared_ptr< IOGroup > iogroup)=0
Registers an IOGroup with the PlatformIO so that its signals and controls are available through the P...
virtual void write_batch(void)=0
Write all of the pushed controls so that values previously given to adjust() are written to the platf...
virtual int control_domain_type(const std::string &control_name) const =0
Query the domain for a named control.
virtual std::set< std::string > signal_names(void) const =0
Returns the names of all available signals. This includes all signals and aliases provided by IOGroup...
virtual int push_signal(const std::string &signal_name, int domain_type, int domain_idx)=0
Push a signal onto the end of the vector that can be sampled.
virtual void read_batch(void)=0
Read all pushed signals so that the next call to sample() will reflect the updated data.
virtual std::string control_description(const std::string &control_name) const =0
Returns a description of the control. This string can be used by tools to generate help text for user...
virtual double sample(int signal_idx)=0
Sample a single signal that has been pushed on to the signal stack. Must be called after a call to re...
virtual std::function< double(const std::vector< double > &)> agg_function(const std::string &signal_name) const =0
Returns a function appropriate for aggregating multiple values of the given signal into a single valu...
virtual double read_signal(const std::string &signal_name, int domain_type, int domain_idx)=0
Read from platform and interpret into SI units a signal given its name and domain....
virtual void adjust(int control_idx, double setting)=0
Adjust a single control that has been pushed on to the control stack. This control will not take effe...
virtual ~PlatformIO()=default
virtual std::string signal_description(const std::string &signal_name) const =0
Returns a description of the signal. This string can be used by tools to generate help text for users...
virtual void restore_control(const std::string &save_dir)=0
Restore all controls to values recorded in previous call to the save_control(save_dir) method....
virtual int push_control(const std::string &control_name, int domain_type, int domain_idx)=0
Push a control onto the end of the vector that can be adjusted.
virtual std::set< std::string > control_names(void) const =0
Returns the names of all available controls. This includes all controls and aliases provided by IOGro...
virtual int signal_behavior(const std::string &signal_name) const =0
Returns a hint about how a signal will change as a function of time.
virtual std::function< std::string(double)> format_function(const std::string &signal_name) const =0
Returns a function that can be used to convert a signal of the given name into a printable string.
virtual void stop_batch_server(int server_pid)=0
PlatformIO()=default
virtual void write_control(const std::string &control_name, int domain_type, int domain_idx, double setting)=0
Interpret the setting and write setting to the platform. Does not modify the values stored by calling...
virtual void save_control(void)=0
Save the state of all controls so that any subsequent changes made through PlatformIO can be undone w...
virtual int signal_domain_type(const std::string &signal_name) const =0
Query the domain for a named signal.
#define GEOPM_PUBLIC
Definition: geopm_public.h:10
Definition: Agg.cpp:20
PlatformIO & platform_io(void)
Definition: PlatformIO.cpp:41