geopm  3.1.1.dev296+g5916b956
GEOPM - Global Extensible Open Power Manager
ProfileIOGroup.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 PROFILEIOGROUP_HPP_INCLUDE
7 #define PROFILEIOGROUP_HPP_INCLUDE
8 
9 #include <set>
10 #include <string>
11 #include <functional>
12 #include <array>
13 
14 #include "geopm/IOGroup.hpp"
15 
16 namespace geopm
17 {
18  class ApplicationSampler;
19  class PlatformTopo;
20 
22  class ProfileIOGroup : public IOGroup
23  {
24  public:
26  ProfileIOGroup(const PlatformTopo &topo, ApplicationSampler &application_sampler);
27  virtual ~ProfileIOGroup();
28  std::set<std::string> signal_names(void) const override;
29  std::set<std::string> control_names(void) const override;
30  bool is_valid_signal(const std::string &signal_name) const override;
31  bool is_valid_control(const std::string &control_name) const override;
32  int signal_domain_type(const std::string &signal_name) const override;
33  int control_domain_type(const std::string &control_name) const override;
34  int push_signal(const std::string &signal_name, int domain_type, int domain_idx) override;
35  int push_control(const std::string &control_name, int domain_type, int domain_idx) override;
36  void read_batch(void) override;
37  void write_batch(void) override;
38  double sample(int signal_idx) override;
39  void adjust(int control_idx, double setting) override;
40  double read_signal(const std::string &signal_name, int domain_type, int domain_idx) override;
41  void write_control(const std::string &control_name, int domain_type, int domain_idx, double setting) override;
42  void save_control(void) override;
43  void restore_control(void) override;
44  std::function<double(const std::vector<double> &)> agg_function(const std::string &signal_name) const override;
45  std::function<std::string(double)> format_function(const std::string &signal_name) const override;
46  std::string signal_description(const std::string &signal_name) const override;
47  std::string control_description(const std::string &control_name) const override;
48  int signal_behavior(const std::string &signal_name) const override;
49  void save_control(const std::string &save_path) override;
50  void restore_control(const std::string &save_path) override;
51  std::string name(void) const override;
53  static std::string plugin_name(void);
54  static std::unique_ptr<IOGroup> make_plugin(void);
57  void connect(void);
58 
59  private:
60  enum m_signal_type {
61  M_SIGNAL_REGION_HASH,
62  M_SIGNAL_REGION_HINT,
63  M_SIGNAL_THREAD_PROGRESS,
64  M_SIGNAL_TIME_HINT_UNSET,
65  M_SIGNAL_TIME_HINT_UNKNOWN,
66  M_SIGNAL_TIME_HINT_COMPUTE,
67  M_SIGNAL_TIME_HINT_MEMORY,
68  M_SIGNAL_TIME_HINT_NETWORK,
69  M_SIGNAL_TIME_HINT_IO,
70  M_SIGNAL_TIME_HINT_SERIAL,
71  M_SIGNAL_TIME_HINT_PARALLEL,
72  M_SIGNAL_TIME_HINT_IGNORE,
73  M_SIGNAL_TIME_HINT_SPIN,
74  M_NUM_SIGNAL,
75  };
76  struct m_signal_config {
77  int signal_type;
78  int domain_type;
79  int domain_idx;
80  };
81 
85  int check_signal(const std::string &signal_name, int domain_type, int domain_idx) const;
89  static double hash_to_signal(uint64_t hash);
93  static double hint_to_signal(uint64_t hint);
98  static uint64_t signal_type_to_hint(int signal_type);
99 
100  ApplicationSampler &m_application_sampler;
101 
102  std::map<std::string, int> m_signal_idx_map;
103  const PlatformTopo &m_platform_topo;
104  const int m_num_cpu;
105  std::vector<bool> m_do_read;
106  bool m_is_batch_read;
107  std::vector<struct m_signal_config> m_active_signal;
108  std::array<std::vector<double>, M_NUM_SIGNAL> m_per_cpu_sample;
110  std::map<int, int> m_rid_idx;
111  bool m_is_pushed;
112  };
113 }
114 
115 #endif
Definition: ApplicationSampler.hpp:27
IOGroup that provides signals from the application.
Definition: ProfileIOGroup.hpp:23
std::string name(void) const override
Definition: ProfileIOGroup.cpp:469
void read_batch(void) override
Definition: ProfileIOGroup.cpp:144
ProfileIOGroup()
Definition: ProfileIOGroup.cpp:23
int control_domain_type(const std::string &control_name) const override
Definition: ProfileIOGroup.cpp:106
int push_signal(const std::string &signal_name, int domain_type, int domain_idx) override
Definition: ProfileIOGroup.cpp:111
std::set< std::string > control_names(void) const override
Definition: ProfileIOGroup.cpp:82
bool is_valid_control(const std::string &control_name) const override
Definition: ProfileIOGroup.cpp:92
int signal_behavior(const std::string &signal_name) const override
Definition: ProfileIOGroup.cpp:408
void write_batch(void) override
Definition: ProfileIOGroup.cpp:177
std::function< double(const std::vector< double > &)> agg_function(const std::string &signal_name) const override
Definition: ProfileIOGroup.cpp:321
double sample(int signal_idx) override
Definition: ProfileIOGroup.cpp:222
void save_control(void) override
Definition: ProfileIOGroup.cpp:311
void restore_control(void) override
Definition: ProfileIOGroup.cpp:316
std::function< std::string(double)> format_function(const std::string &signal_name) const override
Definition: ProfileIOGroup.cpp:359
int push_control(const std::string &control_name, int domain_type, int domain_idx) override
Definition: ProfileIOGroup.cpp:138
void connect(void)
Connect to the application via shared memory.
double read_signal(const std::string &signal_name, int domain_type, int domain_idx) override
Definition: ProfileIOGroup.cpp:250
virtual ~ProfileIOGroup()
Definition: ProfileIOGroup.cpp:68
void write_control(const std::string &control_name, int domain_type, int domain_idx, double setting) override
Definition: ProfileIOGroup.cpp:305
int signal_domain_type(const std::string &signal_name) const override
Definition: ProfileIOGroup.cpp:97
std::string control_description(const std::string &control_name) const override
Definition: ProfileIOGroup.cpp:403
void adjust(int control_idx, double setting) override
Definition: ProfileIOGroup.cpp:244
static std::unique_ptr< IOGroup > make_plugin(void)
Definition: ProfileIOGroup.cpp:479
std::string signal_description(const std::string &signal_name) const override
Definition: ProfileIOGroup.cpp:398
static std::string plugin_name(void)
Definition: ProfileIOGroup.cpp:474
std::set< std::string > signal_names(void) const override
Definition: ProfileIOGroup.cpp:73
bool is_valid_signal(const std::string &signal_name) const override
Definition: ProfileIOGroup.cpp:87
Definition: Accumulator.cpp:12