geopm 3.1.1.dev410+g40bf96ed
GEOPM - Global Extensible Open Power Manager
Loading...
Searching...
No Matches
Environment.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 ENVIRONMENT_HPP_INCLUDE
7#define ENVIRONMENT_HPP_INCLUDE
8
9#include <string>
10#include <vector>
11#include <utility>
12#include <map>
13#include <set>
14#include <memory>
15
16#include "geopm_public.h"
17
18
19namespace geopm
20{
23 class GEOPM_PUBLIC Environment
24 {
25 public:
34
35 Environment() = default;
36 virtual ~Environment() = default;
37 virtual std::string report(void) const = 0;
38 virtual std::string comm(void) const = 0;
39 virtual std::string policy(void) const = 0;
40 virtual std::string endpoint(void) const = 0;
41 virtual std::string trace(void) const = 0;
42 virtual std::string trace_profile(void) const = 0;
43 virtual std::string trace_endpoint_policy(void) const = 0;
44 virtual std::string profile(void) const = 0;
45 virtual std::string frequency_map(void) const = 0;
46 virtual std::string agent(void) const = 0;
47 virtual std::string trace_signals(void) const = 0;
48 virtual std::string report_signals(void) const = 0;
49 virtual int max_fan_out(void) const = 0;
50 virtual int pmpi_ctl(void) const = 0;
51 virtual bool do_policy(void) const = 0;
52 virtual bool do_endpoint(void) const = 0;
53 virtual bool do_trace(void) const = 0;
54 virtual bool do_trace_profile(void) const = 0;
55 virtual bool do_trace_endpoint_policy(void) const = 0;
56 virtual bool do_profile(void) const = 0;
57 virtual int timeout(void) const = 0;
58 virtual bool do_ompt(void) const = 0;
59 virtual std::string default_config_path(void) const = 0;
60 virtual std::string override_config_path(void) const = 0;
61 virtual std::string record_filter(void) const = 0;
62 virtual bool do_record_filter(void) const = 0;
63 virtual bool do_debug_attach_all(void) const = 0;
64 virtual bool do_debug_attach_one(void) const = 0;
65 virtual bool do_init_control(void) const = 0;
66 virtual int debug_attach_process(void) const = 0;
67 virtual std::string init_control(void) const = 0;
68 virtual double period(double default_period) const = 0;
69 virtual int num_proc(void) const = 0;
70 virtual bool do_ctl_local(void) const = 0;
71 static std::map<std::string, std::string> parse_environment_file(const std::string &env_file_path);
72 };
73
74 class GEOPM_PUBLIC EnvironmentImp : public Environment
75 {
76 public:
78 EnvironmentImp(const std::string &default_settings_path,
79 const std::string &override_settings_path);
80 virtual ~EnvironmentImp() = default;
81 std::string report(void) const override;
82 std::string comm(void) const override;
83 std::string policy(void) const override;
84 std::string endpoint(void) const override;
85 std::string trace(void) const override;
86 std::string trace_profile(void) const override;
87 std::string trace_endpoint_policy(void) const override;
88 std::string profile(void) const override;
89 std::string frequency_map(void) const override;
90 std::string agent(void) const override;
91 std::string trace_signals(void) const override;
92 std::string report_signals(void) const override;
93 int max_fan_out(void) const override;
94 int pmpi_ctl(void) const override;
95 bool do_policy(void) const override;
96 bool do_endpoint(void) const override;
97 bool do_trace(void) const override;
98 bool do_trace_profile(void) const override;
99 bool do_trace_endpoint_policy(void) const override;
100 bool do_profile() const override;
101 int timeout(void) const override;
102 static std::set<std::string> get_all_vars(void);
103 bool do_ompt(void) const override;
104 std::string default_config_path(void) const override;
105 std::string override_config_path(void) const override;
106 static void parse_environment_file(const std::string &settings_path,
107 const std::set<std::string> &all_names,
108 const std::set<std::string> &user_defined_names,
109 std::map<std::string, std::string> &name_value_map);
110 std::string record_filter(void) const override;
111 bool do_record_filter(void) const override;
112 bool do_debug_attach_all(void) const override;
113 bool do_debug_attach_one(void) const override;
114 bool do_init_control(void) const override;
115 int debug_attach_process(void) const override;
116 std::string init_control(void) const override;
117 double period(double default_period) const override;
118 int num_proc(void) const override;
119 bool do_ctl_local(void) const override;
120 protected:
121 void parse_environment(void);
122 bool is_set(const std::string &env_var) const;
123 std::string lookup(const std::string &env_var) const;
124 const std::set<std::string> m_all_names;
125 std::set<std::string> m_user_defined_names;
126 std::map<std::string, std::string> m_name_value_map;
127 const std::string m_default_config_path;
128 const std::string m_override_config_path;
129 };
130
131 const Environment GEOPM_PUBLIC &environment(void);
132}
133#endif
Environment class encapsulates all functionality related to dealing with runtime environment variable...
Definition Environment.hpp:24
virtual bool do_policy(void) const =0
virtual std::string trace_profile(void) const =0
virtual bool do_trace(void) const =0
virtual std::string init_control(void) const =0
virtual bool do_debug_attach_all(void) const =0
virtual std::string trace_signals(void) const =0
virtual ~Environment()=default
virtual int timeout(void) const =0
virtual std::string frequency_map(void) const =0
virtual bool do_init_control(void) const =0
virtual std::string default_config_path(void) const =0
virtual bool do_debug_attach_one(void) const =0
virtual bool do_trace_profile(void) const =0
virtual std::string trace_endpoint_policy(void) const =0
virtual int max_fan_out(void) const =0
virtual std::string trace(void) const =0
virtual bool do_record_filter(void) const =0
Environment()=default
virtual std::string record_filter(void) const =0
virtual double period(double default_period) const =0
virtual std::string policy(void) const =0
virtual int num_proc(void) const =0
m_ctl_e
Enum for controller launch methods.
Definition Environment.hpp:29
@ M_CTL_NONE
Definition Environment.hpp:30
@ M_CTL_PROCESS
Definition Environment.hpp:31
@ M_CTL_PTHREAD
Definition Environment.hpp:32
virtual std::string profile(void) const =0
virtual std::string endpoint(void) const =0
virtual std::string comm(void) const =0
virtual int pmpi_ctl(void) const =0
virtual std::string override_config_path(void) const =0
virtual bool do_trace_endpoint_policy(void) const =0
virtual bool do_ctl_local(void) const =0
virtual bool do_endpoint(void) const =0
virtual bool do_ompt(void) const =0
virtual std::string report_signals(void) const =0
virtual std::string report(void) const =0
virtual bool do_profile(void) const =0
virtual int debug_attach_process(void) const =0
virtual std::string agent(void) const =0
Definition Environment.hpp:75
const std::set< std::string > m_all_names
Definition Environment.hpp:124
std::map< std::string, std::string > m_name_value_map
Definition Environment.hpp:126
const std::string m_override_config_path
Definition Environment.hpp:128
const std::string m_default_config_path
Definition Environment.hpp:127
std::set< std::string > m_user_defined_names
Definition Environment.hpp:125
virtual ~EnvironmentImp()=default
Definition Accumulator.cpp:12
const Environment & environment(void)
Definition Environment.cpp:41