geopm  3.1.1.dev214+gba4f9f6d
GEOPM - Global Extensible Open Power Manager
MSRFieldControl.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 MSRFIELDCONTROL_HPP_INCLUDE
7 #define MSRFIELDCONTROL_HPP_INCLUDE
8 
9 #include <cstdint>
10 #include <cmath>
11 
12 #include <string>
13 #include <memory>
14 
15 #include "Control.hpp"
16 
17 namespace geopm
18 {
19  class MSRIO;
20 
23  class MSRFieldControl : public Control
24  {
25  public:
26  MSRFieldControl(std::shared_ptr<MSRIO> msrio,
27  int cpu,
28  uint64_t offset,
29  int begin_bit,
30  int end_bit,
31  int function,
32  double scalar);
33  MSRFieldControl(const MSRFieldControl &other) = delete;
34  MSRFieldControl &operator=(const MSRFieldControl &other) = delete;
35  virtual ~MSRFieldControl() = default;
36  void setup_batch(void) override;
37  void adjust(double value) override;
38  void write(double value) override;
39  void save(void) override;
40  void restore(void) override;
41  void add_save_restore_context(int);
42  private:
43  uint64_t encode(double value) const;
44 
45  std::shared_ptr<MSRIO> m_msrio;
46  int m_save_restore_ctx;
47  const int m_cpu;
48  const uint64_t m_offset;
49  const int m_shift;
50  const int m_num_bit;
51  const uint64_t m_mask;
52  const int m_function;
53  const double m_inverse;
54  bool m_is_batch_ready;
55  int m_adjust_idx;
56  int m_save_idx;
57  int m_restore_idx;
58  uint64_t m_saved_msr_value;
59  };
60 }
61 
62 #endif
Definition: Control.hpp:16
Definition: MSRFieldControl.hpp:24
MSRFieldControl & operator=(const MSRFieldControl &other)=delete
void restore(void) override
Restore the setting stored by save().
Definition: MSRFieldControl.cpp:143
virtual ~MSRFieldControl()=default
MSRFieldControl(const MSRFieldControl &other)=delete
void save(void) override
Store the current setting of the control for use by a future call to restore().
Definition: MSRFieldControl.cpp:136
void write(double value) override
Write the value of the control without affecting any pushed batch controls.
Definition: MSRFieldControl.cpp:130
void setup_batch(void) override
Prepare the control for being written through side effects by the owner's write_batch step....
Definition: MSRFieldControl.cpp:62
void adjust(double value) override
Store values to be written by the owner's write_batch step.
Definition: MSRFieldControl.cpp:120
void add_save_restore_context(int)
Definition: MSRFieldControl.cpp:149
MSRFieldControl(std::shared_ptr< MSRIO > msrio, int cpu, uint64_t offset, int begin_bit, int end_bit, int function, double scalar)
Definition: MSRFieldControl.cpp:18
Definition: Agg.cpp:20