geopm 3.1.1.dev410+g40bf96ed
GEOPM - Global Extensible Open Power Manager
Loading...
Searching...
No Matches
Controller.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 CONTROLLER_HPP_INCLUDE
7#define CONTROLLER_HPP_INCLUDE
8
9#include <pthread.h>
10
11#include <string>
12#include <memory>
13#include <vector>
14#include <map>
15#include <set>
16
17namespace geopm
18{
19 class Comm;
20 class PlatformIO;
21 class EndpointUser;
22 class FilePolicy;
23 class ApplicationIO;
24 class Reporter;
25 class Tracer;
26 class EndpointPolicyTracer;
27 class TreeComm;
28 class Agent;
29 class ProfileTracer;
30 class ApplicationSampler;
31 class InitControl;
32
34 {
35 public:
36 Controller();
41 Controller(std::shared_ptr<Comm> ppn1_comm);
44 Controller(std::shared_ptr<Comm> comm,
45 PlatformIO &plat_io,
46 const std::string &agent_name,
47 int num_send_down,
48 int num_send_up,
49 std::unique_ptr<TreeComm> tree_comm,
50 ApplicationSampler &application_sampler,
51 std::shared_ptr<ApplicationIO> application_io,
52 std::unique_ptr<Reporter> reporter,
53 std::unique_ptr<Tracer> tracer,
54 std::unique_ptr<EndpointPolicyTracer> policy_tracer,
55 std::shared_ptr<ProfileTracer> profile_tracer,
56 std::vector<std::unique_ptr<Agent> > level_agent,
57 std::vector<std::string> policy_names,
58 const std::string &policy_path,
59 bool do_policy,
60 std::unique_ptr<EndpointUser> endpoint,
61 const std::string &endpoint_path,
62 bool do_endpoint,
63 std::shared_ptr<InitControl> init_control,
64 bool do_init_control);
65
66 Controller(const Controller &other) = delete;
67 Controller &operator=(const Controller &other) = delete;
68 virtual ~Controller();
75 void run(void);
82 void step(void);
89 void walk_down(void);
97 void walk_up(void);
99 void generate(void);
114 void pthread(const pthread_attr_t *attr, pthread_t *thread);
117 void setup_trace(void);
120 void abort(void);
129 std::set<std::string> get_hostnames(const std::string &hostname);
130 private:
134 void create_agents(void);
137 void init_agents(void);
138
139 std::shared_ptr<Comm> m_comm;
140 PlatformIO &m_platform_io;
141 std::string m_agent_name;
142 const int m_num_send_down;
143 const int m_num_send_up;
144 std::unique_ptr<TreeComm> m_tree_comm;
145 const int m_num_level_ctl;
146 const int m_max_level;
147 const int m_root_level;
148 ApplicationSampler &m_application_sampler;
149 std::shared_ptr<ApplicationIO> m_application_io;
150 std::unique_ptr<Reporter> m_reporter;
151 std::unique_ptr<Tracer> m_tracer;
152 std::unique_ptr<EndpointPolicyTracer> m_policy_tracer;
153 std::shared_ptr<ProfileTracer> m_profile_tracer;
154 std::vector<std::unique_ptr<Agent> > m_agent;
155 const bool m_is_root;
156 std::vector<double> m_in_policy;
157 std::vector<double> m_last_policy;
158 std::vector<std::vector<std::vector<double> > > m_out_policy;
159 std::vector<std::vector<std::vector<double> > > m_in_sample;
160 std::vector<double> m_out_sample;
161 std::vector<double> m_trace_sample;
162
163 std::unique_ptr<EndpointUser> m_endpoint;
164 bool m_do_endpoint;
165 std::unique_ptr<FilePolicy> m_file_policy;
166 bool m_do_policy;
167
168 std::vector<std::string> m_agent_policy_names;
169 std::vector<std::string> m_agent_sample_names;
170 std::string m_shm_key;
171
172 std::shared_ptr<InitControl> m_init_control;
173 bool m_do_init_control;
174 bool m_do_restore;
175 };
176}
177#endif
Definition ApplicationSampler.hpp:27
Definition Controller.hpp:34
Controller()
Definition Controller.cpp:175
void abort(void)
Called upon failure to facilitate graceful destruction of the Controller and notify application.
Definition Controller.cpp:536
void step(void)
Run a single step of the control algorithm.
Definition Controller.cpp:425
Controller(const Controller &other)=delete
void generate(void)
Write the report file and finalize the trace.
Definition Controller.cpp:406
std::set< std::string > get_hostnames(const std::string &hostname)
Return the names of hosts active in the current job. Must be called by all controllers in the tree or...
Definition Controller.cpp:347
virtual ~Controller()
Definition Controller.cpp:302
Controller & operator=(const Controller &other)=delete
void run(void)
Run control algorithm.
Definition Controller.cpp:370
void walk_up(void)
Read hardware telemetry and application data and send the combined data up the tree to the resource m...
Definition Controller.cpp:481
void pthread(const pthread_attr_t *attr, pthread_t *thread)
Run control algorithm as a separate thread.
Definition Controller.cpp:516
void setup_trace(void)
Configure the trace with custom columns from the Agent.
Definition Controller.cpp:525
void walk_down(void)
Propagate policy information from the resource manager at the root of the tree down to the controller...
Definition Controller.cpp:432
Definition Accumulator.cpp:12