geopm  3.1.1.dev296+g5916b956
GEOPM - Global Extensible Open Power Manager
EditDistPeriodicityDetector.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 EDITDISTPERIODICITYDETECTOR_HPP_INCLUDE
7 #define EDITDISTPERIODICITYDETECTOR_HPP_INCLUDE
8 
9 #include <cstdint>
10 #include <vector>
11 
12 #include "geopm/CircularBuffer.hpp"
13 
14 namespace geopm
15 {
16  struct record_s;
17 
19  {
20  public:
26  EditDistPeriodicityDetector(int history_buffer_size);
27  virtual ~EditDistPeriodicityDetector() = default;
29  void update(const record_s &record);
34  int get_period(void) const;
38  int get_score(void) const;
41  int num_records(void) const;
42  private:
43  void calc_period();
44  size_t Didx(int ii, int jj, int mm) const;
45  uint32_t Dget(int ii, int jj, int mm) const;
46  void Dset(int ii, int jj, int mm, uint32_t val);
47  uint64_t get_history_value(int index) const;
48  int find_smallest_repeating_pattern(int index) const;
49 
50  CircularBuffer<uint64_t> m_history_buffer;
51  const int m_history_buffer_size;
52  int m_period;
53  int m_score;
54  int m_record_count;
55  std::vector<uint32_t> m_DP;
56  };
57 }
58 
59 #endif
Definition: EditDistPeriodicityDetector.hpp:19
int get_period(void) const
Return the best estimate of the period length in number of records, based on the data inserted throug...
Definition: EditDistPeriodicityDetector.cpp:136
virtual ~EditDistPeriodicityDetector()=default
int get_score(void) const
Return the metric that will be maximized to determine the period. Until a stable period is determined...
Definition: EditDistPeriodicityDetector.cpp:141
void update(const record_s &record)
Update detector with a new record from the application.
Definition: EditDistPeriodicityDetector.cpp:30
EditDistPeriodicityDetector(int history_buffer_size)
Default constructor for String Edit Distance based periodicity detector used in EditDistEpochRecordFi...
Definition: EditDistPeriodicityDetector.cpp:19
int num_records(void) const
Return the number of records that this object has received so far via update().
Definition: EditDistPeriodicityDetector.cpp:151
Definition: Accumulator.cpp:12
Record of an application event.
Definition: record.hpp:61