geopm 3.1.1.dev410+g40bf96ed
GEOPM - Global Extensible Open Power Manager
Loading...
Searching...
No Matches
SampleAggregatorImp.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 SAMPLEAGGREGATORIMP_HPP_INCLUDE
7#define SAMPLEAGGREGATORIMP_HPP_INCLUDE
8
9#include <cmath>
10
11#include <map>
12
14
15namespace geopm
16{
17 class PlatformIO;
18 class SumAccumulator;
19 class AvgAccumulator;
20
22 {
23 public:
25 SampleAggregatorImp(PlatformIO &platio);
26 int push_signal(const std::string &signal_name,
27 int domain_type,
28 int domain_idx) override;
29 int push_signal_total(const std::string &signal_idx,
30 int domain_type,
31 int domain_idx) override;
32 int push_signal_average(const std::string &signal_idx,
33 int domain_type,
34 int domain_idx) override;
35 void update(void) override;
36 double sample_application(int signal_idx) override;
37 double sample_epoch(int signal_idx) override;
38 double sample_region(int signal_idx, uint64_t region_hash) override;
39 double sample_epoch_last(int signal_idx) override;
40 double sample_region_last(int signal_idx, uint64_t region_hash) override;
41 void period_duration(double duration) override;
42 int get_period(void) override;
43 double sample_period_last(int signal_idx) override;
44
45 private:
46 // All of the data relating to a pushed "total" signal
47 struct m_sum_signal_s {
48 // Value of the signal from last control interval
49 double sample_last;
50 // PlatformIO signal index to get the region hash
51 int region_hash_idx;
52 // Value of the hash from last control interval
53 uint64_t region_hash_last;
54 // PlatformIO signal index to get the epoch count
55 int epoch_count_idx;
56 // Value of the epoch count from last control interval
57 int epoch_count_last;
58 // Accumulator for application totals (always updated)
59 std::shared_ptr<SumAccumulator> app_accum;
60 // Accumulator for epoch totals (updated after first epoch call)
61 std::shared_ptr<SumAccumulator> epoch_accum;
62 // Accumulator for periodic totals (always updated)
63 std::shared_ptr<SumAccumulator> period_accum;
64 // Map from region hash to an accumulator for that region
65 std::map<uint64_t, std::shared_ptr<SumAccumulator> > region_accum;
66 // Iterator pointing to the region_hash_last map location
67 std::map<uint64_t, std::shared_ptr<SumAccumulator> >::iterator region_accum_it;
68 };
69
70 // All of the data relating to each pushed "average" signal
71 struct m_avg_signal_s {
72 // Time stamp from last control interval
73 double time_last;
74 // PlatformIO signal index to get the region hash
75 int region_hash_idx;
76 // Value of the hash from last control interval
77 uint64_t region_hash_last;
78 // PlatformIO signal index to get the epoch count
79 int epoch_count_idx;
80 // Value of the epoch count from last control interval
81 int epoch_count_last;
82 // Accumulator for application totals (always updated)
83 std::shared_ptr<AvgAccumulator> app_accum;
84 // Accumulator for epoch totals (updated after first epoch call)
85 std::shared_ptr<AvgAccumulator> epoch_accum;
86 // Accumulator for periodic totals (always updated)
87 std::shared_ptr<AvgAccumulator> period_accum;
88 // Map from region hash to an accumulator for that region
89 std::map<uint64_t, std::shared_ptr<AvgAccumulator> > region_accum;
90 // Iterator pointing to the region_hash_last map location
91 std::map<uint64_t, std::shared_ptr<AvgAccumulator> >::iterator region_accum_it;
92 };
93
94 void update_total(void);
95 void update_average(void);
96 double sample_epoch_helper(int signal_idx, bool is_last);
97 double sample_region_helper(int signal_idx, uint64_t region_hash, bool is_last);
98 uint64_t sample_to_hash(double sample);
99
100 PlatformIO &m_platform_io;
101 // PlatformIO signal index for time of last sample
102 int m_time_idx;
103 bool m_is_updated;
104 // Map from index returned by push_signal_total() to the
105 // signal structure
106 std::map<int, m_sum_signal_s> m_sum_signal;
107 // Map from index returned by push_signal_average() to the
108 // signal structure
109 std::map<int, m_avg_signal_s> m_avg_signal;
110 double m_period_duration;
111 int m_period_last;
112 };
113}
114
115#endif
Definition SampleAggregator.hpp:19
Definition SampleAggregatorImp.hpp:22
int get_period(void) override
Get the index of the current time period.
Definition SampleAggregator.cpp:214
double sample_region_last(int signal_idx, uint64_t region_hash) override
Get the aggregated value of a signal during the the last completed execution of a particular region.
Definition SampleAggregator.cpp:435
int push_signal_average(const std::string &signal_idx, int domain_type, int domain_idx) override
Push a signal to be accumulated per-region as an average.
Definition SampleAggregator.cpp:105
double sample_epoch(int signal_idx) override
Get the aggregated value of a signal since the first epoch.
Definition SampleAggregator.cpp:446
int push_signal_total(const std::string &signal_idx, int domain_type, int domain_idx) override
Push a signal to be accumulated per-region as a total.
Definition SampleAggregator.cpp:73
void update(void) override
Update stored totals for each signal.
Definition SampleAggregator.cpp:322
SampleAggregatorImp()
Definition SampleAggregator.cpp:26
void period_duration(double duration) override
Set the time period for sample_period_last()
Definition SampleAggregator.cpp:205
int push_signal(const std::string &signal_name, int domain_type, int domain_idx) override
Push a signal to be accumulated per-region.
Definition SampleAggregator.cpp:42
double sample_region(int signal_idx, uint64_t region_hash) override
Get the aggregated value of a signal during the execution of a particular region.
Definition SampleAggregator.cpp:421
double sample_application(int signal_idx) override
Get the aggregated value of a signal.
Definition SampleAggregator.cpp:330
double sample_period_last(int signal_idx) override
Get the aggregated value of a signal during the last completed time interval.
Definition SampleAggregator.cpp:462
double sample_epoch_last(int signal_idx) override
Get the aggregated value of a signal over the last completed epoch interval.
Definition SampleAggregator.cpp:454
Definition Accumulator.cpp:12