geopm 3.1.1.dev410+g40bf96ed
GEOPM - Global Extensible Open Power Manager
Loading...
Searching...
No Matches
MonitorAgent.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 MONITORAGENT_HPP_INCLUDE
7#define MONITORAGENT_HPP_INCLUDE
8
9#include <vector>
10#include <map>
11#include <string>
12#include <memory>
13#include <functional>
14
15#include "geopm/Agent.hpp"
16
17namespace geopm
18{
19 class PlatformIO;
20 class PlatformTopo;
21 class Waiter;
22
24 class MonitorAgent : public Agent
25 {
26 public:
28 MonitorAgent(PlatformIO &plat_io, const PlatformTopo &topo,
29 std::shared_ptr<Waiter> waiter);
30 virtual ~MonitorAgent() = default;
31 void init(int level, const std::vector<int> &fan_in, bool is_level_root) override;
32 void validate_policy(std::vector<double> &policy) const override;
33 void split_policy(const std::vector<double> &in_policy,
34 std::vector<std::vector<double> > &out_policy) override;
35 bool do_send_policy(void) const override;
36 void aggregate_sample(const std::vector<std::vector<double> > &in_sample,
37 std::vector<double> &out_sample) override;
38 bool do_send_sample(void) const override;
39 void adjust_platform(const std::vector<double> &in_policy) override;
40 bool do_write_batch(void) const override;
41 void sample_platform(std::vector<double> &out_sample) override;
42 void wait(void) override;
43 std::vector<std::pair<std::string, std::string> > report_header(void) const override;
44 std::vector<std::pair<std::string, std::string> > report_host(void) const override;
45 std::map<uint64_t, std::vector<std::pair<std::string, std::string> > > report_region(void) const override;
46 std::vector<std::string> trace_names(void) const override;
47 std::vector<std::function<std::string(double)> > trace_formats(void) const override;
48 void trace_values(std::vector<double> &values) override;
49 void enforce_policy(const std::vector<double> &policy) const override;
50
52 static std::string plugin_name(void);
53 static std::unique_ptr<Agent> make_plugin(void);
55 static std::vector<std::string> policy_names(void);
57 static std::vector<std::string> sample_names(void);
58 static constexpr double M_WAIT_SEC = 0.2; // 200 msec
59 private:
60 std::shared_ptr<Waiter> m_waiter;
61
62 };
63}
64
65#endif
Definition Agent.hpp:20
Agent used to do sampling only; no policy will be enforced.
Definition MonitorAgent.hpp:25
void trace_values(std::vector< double > &values) override
Called by Controller to get latest values to be added to the trace.
Definition MonitorAgent.cpp:129
void split_policy(const std::vector< double > &in_policy, std::vector< std::vector< double > > &out_policy) override
Called by Controller to split policy for children at next level down the tree.
Definition MonitorAgent.cpp:52
static std::vector< std::string > policy_names(void)
Definition MonitorAgent.cpp:94
std::vector< std::string > trace_names(void) const override
Column headers to be added to the trace.
Definition MonitorAgent.cpp:119
void sample_platform(std::vector< double > &out_sample) override
Read signals from the platform and interpret/aggregate these signals to create a sample which can be ...
Definition MonitorAgent.cpp:84
std::map< uint64_t, std::vector< std::pair< std::string, std::string > > > report_region(void) const override
Custom fields for each region in the report.
Definition MonitorAgent.cpp:114
bool do_write_batch(void) const override
Called by the Controller to decide whether to call write_batch() to update platform controls.
Definition MonitorAgent.cpp:79
std::vector< std::pair< std::string, std::string > > report_header(void) const override
Custom fields that will be added to the report header when this agent is used.
Definition MonitorAgent.cpp:104
void init(int level, const std::vector< int > &fan_in, bool is_level_root) override
Set the level where this Agent is active and push signals/controls for that level.
Definition MonitorAgent.cpp:42
void aggregate_sample(const std::vector< std::vector< double > > &in_sample, std::vector< double > &out_sample) override
Aggregate samples from children for the next level up the tree.
Definition MonitorAgent.cpp:63
bool do_send_sample(void) const override
Definition MonitorAgent.cpp:69
static std::vector< std::string > sample_names(void)
Definition MonitorAgent.cpp:99
std::vector< std::function< std::string(double)> > trace_formats(void) const override
Returns format string for each column added to the trace.
Definition MonitorAgent.cpp:124
std::vector< std::pair< std::string, std::string > > report_host(void) const override
Custom fields for the host section of the report.
Definition MonitorAgent.cpp:109
static std::string plugin_name(void)
Definition MonitorAgent.cpp:32
bool do_send_policy(void) const override
Called by Controller to determine if new policy values should be sent down the tree to the Agent's ch...
Definition MonitorAgent.cpp:58
void adjust_platform(const std::vector< double > &in_policy) override
Adjust the platform settings based the policy from above.
Definition MonitorAgent.cpp:74
void validate_policy(std::vector< double > &policy) const override
Called by Controller to validate incoming policy values and configure defaults requested in incoming ...
Definition MonitorAgent.cpp:47
void wait(void) override
Called by Controller to wait for sample period to elapse. This controls the cadence of the Controller...
Definition MonitorAgent.cpp:89
void enforce_policy(const std::vector< double > &policy) const override
Enforce the policy one time with PlatformIO::write_control(). Called to enforce static policies in th...
Definition MonitorAgent.cpp:134
virtual ~MonitorAgent()=default
static std::unique_ptr< Agent > make_plugin(void)
Definition MonitorAgent.cpp:37
static constexpr double M_WAIT_SEC
Definition MonitorAgent.hpp:58
MonitorAgent()
Definition MonitorAgent.cpp:18
Definition Accumulator.cpp:12