geopm  3.1.1.dev296+g5916b956
GEOPM - Global Extensible Open Power Manager
ApplicationSamplerImp.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 APPLICATIONSAMPLERIMP_HPP_INCLUDE
7 #define APPLICATIONSAMPLERIMP_HPP_INCLUDE
8 
9 #include "ApplicationSampler.hpp"
10 #include "ValidateRecord.hpp"
11 #include "geopm_hint.h"
12 
13 struct geopm_prof_message_s;
14 namespace geopm
15 {
16  class RecordFilter;
17  class ApplicationStatus;
18  class SharedMemory;
19  class PlatformTopo;
20  class Scheduler;
21 
23  {
24  public:
25  struct m_process_s {
26  std::shared_ptr<RecordFilter> filter;
28  std::shared_ptr<SharedMemory> record_log_shmem;
29  std::shared_ptr<ApplicationRecordLog> record_log;
30  std::vector<record_s> records;
31  std::vector<short_region_s> short_regions;
32  };
34  ApplicationSamplerImp(std::shared_ptr<ApplicationStatus> status,
35  const PlatformTopo &platform_topo,
36  const std::map<int, m_process_s> &process_map,
37  bool is_filtered,
38  const std::string &filter_name,
39  const std::vector<bool> &is_cpu_active,
40  const std::string &profile_name,
41  const std::map<int, std::set<int> > &client_cpu_map,
42  std::shared_ptr<Scheduler> scheduler);
43  virtual ~ApplicationSamplerImp() = default;
44  void update(const geopm_time_s &curr_time) override;
45  std::vector<record_s> get_records(void) const override;
46  short_region_s get_short_region(uint64_t event_signal) const override;
47  uint64_t cpu_region_hash(int cpu_idx) const override;
48  uint64_t cpu_hint(int cpu_idx) const override;
49  double cpu_hint_time(int cpu_idx, uint64_t hint) const override;
50  double cpu_progress(int cpu_idx) const override;
51  void connect(const std::vector<int> &client_pids) override;
52  std::vector<int> client_pids(void) const override;
53  std::set<int> client_cpu_set(int client_pid) const override;
54  bool do_shutdown(void) const override;
55  double total_time(void) const override;
56  double overhead_time(void) const override;
57  int sampler_cpu(void);
58  private:
59  std::map<int, m_process_s> connect_record_log(const std::vector<int> &client_pids);
60  void connect_status(void);
61  void update_cpu_active(void);
62  void update_start(void);
63  void update_stop(void);
64  std::vector<record_s> m_record_buffer;
65  std::vector<short_region_s> m_short_region_buffer;
66  std::shared_ptr<ApplicationStatus> m_status;
67  const PlatformTopo &m_topo;
68  int m_num_cpu;
69  std::map<int, m_process_s> m_process_map;
70  const bool m_is_filtered;
71  const std::string m_filter_name;
72  std::vector<std::array<double, GEOPM_NUM_REGION_HINT>> m_hint_time;
73  std::vector<bool> m_is_cpu_active;
74  geopm_time_s m_update_time;
75  bool m_is_first_update;
76  std::vector<uint64_t> m_hint_last;
77  std::string m_profile_name;
78  std::map<int, std::set<int> > m_client_cpu_map;
79  std::shared_ptr<Scheduler> m_scheduler;
80  std::set<int> m_client_pids;
81  bool m_do_shutdown;
82  geopm_time_s m_last_stop;
83  double m_total_time;
84  double m_overhead_time;
85  int m_num_registered;
86  int m_num_client;
87  };
88 }
89 
90 #endif
Definition: ApplicationSampler.hpp:27
Definition: ApplicationSamplerImp.hpp:23
bool do_shutdown(void) const override
Definition: ApplicationSampler.cpp:433
double cpu_hint_time(int cpu_idx, uint64_t hint) const override
Get the amount of time a CPU has been measured running with a hint.
Definition: ApplicationSampler.cpp:319
std::set< int > client_cpu_set(int client_pid) const override
Definition: ApplicationSampler.cpp:417
uint64_t cpu_region_hash(int cpu_idx) const override
Get the region hash associated with a CPU.
Definition: ApplicationSampler.cpp:295
std::vector< record_s > get_records(void) const override
Get all of the application events that have been recorded since the last call to update_records().
Definition: ApplicationSampler.cpp:281
double overhead_time(void) const override
Definition: ApplicationSampler.cpp:448
void update(const geopm_time_s &curr_time) override
Update the record buffer by clearing out old records and providing a new cache for subsequent calls t...
Definition: ApplicationSampler.cpp:144
void connect(const std::vector< int > &client_pids) override
Connect with an application using a key.
Definition: ApplicationSampler.cpp:405
uint64_t cpu_hint(int cpu_idx) const override
Get the hint associated with a CPU.
Definition: ApplicationSampler.cpp:307
short_region_s get_short_region(uint64_t event_signal) const override
Definition: ApplicationSampler.cpp:286
double total_time(void) const override
Definition: ApplicationSampler.cpp:438
std::vector< int > client_pids(void) const override
Definition: ApplicationSampler.cpp:427
ApplicationSamplerImp()
Definition: ApplicationSampler.cpp:95
int sampler_cpu(void)
Definition: ApplicationSampler.cpp:457
virtual ~ApplicationSamplerImp()=default
double cpu_progress(int cpu_idx) const override
Get the progress reported on a CPU.
Definition: ApplicationSampler.cpp:334
Checks validity and self consistency of a record stream from a single process. This check is applied ...
Definition: ValidateRecord.hpp:19
Definition: Accumulator.cpp:12
Definition: ApplicationSamplerImp.hpp:25
std::vector< record_s > records
Definition: ApplicationSamplerImp.hpp:30
std::vector< short_region_s > short_regions
Definition: ApplicationSamplerImp.hpp:31
ValidateRecord valid
Definition: ApplicationSamplerImp.hpp:27
std::shared_ptr< RecordFilter > filter
Definition: ApplicationSamplerImp.hpp:26
std::shared_ptr< SharedMemory > record_log_shmem
Definition: ApplicationSamplerImp.hpp:28
std::shared_ptr< ApplicationRecordLog > record_log
Definition: ApplicationSamplerImp.hpp:29
Definition: record.hpp:72