• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1  /*
2   * Copyright 2022 The Android Open Source Project
3   *
4   * Licensed under the Apache License, Version 2.0 (the "License");
5   * you may not use this file except in compliance with the License.
6   * You may obtain a copy of the License at
7   *
8   *      http://www.apache.org/licenses/LICENSE-2.0
9   *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  #pragma once
18  
19  #include <optional>
20  #include <string>
21  
22  namespace android {
23  namespace perfmgr {
24  
25  struct AdpfConfig {
26      std::string mName;
27      // Pid control
28      bool mPidOn;
29      double mPidPo;
30      double mPidPu;
31      double mPidI;
32      int64_t mPidIInit;
33      int64_t mPidIHigh;
34      int64_t mPidILow;
35      double mPidDo;
36      double mPidDu;
37      // Uclamp boost control
38      bool mUclampMinOn;
39      uint32_t mUclampMinInit;
40      uint32_t mUclampMinHigh;
41      uint32_t mUclampMinLow;
42      // Batch update control
43      uint64_t mSamplingWindowP;
44      uint64_t mSamplingWindowI;
45      uint64_t mSamplingWindowD;
46      int64_t mReportingRateLimitNs;
47      double mTargetTimeFactor;
48      // Stale control
49      double mStaleTimeFactor;
50  
51      std::optional<bool> mGpuBoostOn;
52      std::optional<uint64_t> mGpuBoostCapacityMax;
53      uint64_t mGpuCapacityLoadUpHeadroom;
54  
55      // Heuristic boost control
56      std::optional<bool> mHeuristicBoostOn;
57      std::optional<uint32_t> mHBoostOnMissedCycles;
58      std::optional<double> mHBoostOffMaxAvgRatio;
59      std::optional<uint32_t> mHBoostOffMissedCycles;
60      std::optional<double> mHBoostPidPuFactor;
61      std::optional<uint32_t> mHBoostUclampMin;
62      std::optional<double> mJankCheckTimeFactor;
63      std::optional<uint32_t> mLowFrameRateThreshold;
64      std::optional<uint32_t> mMaxRecordsNum;
65  
66      uint32_t mUclampMinLoadUp;
67      uint32_t mUclampMinLoadReset;
68  
69      // Power efficient sessions
70      std::optional<int32_t> mUclampMaxEfficientBase;
71      std::optional<int32_t> mUclampMaxEfficientOffset;
72  
73      int64_t getPidIInitDivI();
74      int64_t getPidIHighDivI();
75      int64_t getPidILowDivI();
76      void dumpToFd(int fd);
77  
AdpfConfigAdpfConfig78      AdpfConfig(std::string name, bool pidOn, double pidPo, double pidPu, double pidI,
79                 int64_t pidIInit, int64_t pidIHigh, int64_t pidILow, double pidDo, double pidDu,
80                 bool uclampMinOn, uint32_t uclampMinInit, uint32_t uclampMinHigh,
81                 uint32_t uclampMinLow, uint64_t samplingWindowP, uint64_t samplingWindowI,
82                 uint64_t samplingWindowD, int64_t reportingRateLimitNs, double targetTimeFactor,
83                 double staleTimeFactor, std::optional<bool> gpuBoostOn,
84                 std::optional<uint64_t> gpuBoostCapacityMax, uint64_t gpuCapacityLoadUpHeadroom,
85                 std::optional<bool> heuristicBoostOn, std::optional<uint32_t> hBoostOnMissedCycles,
86                 std::optional<double> hBoostOffMaxAvgRatio,
87                 std::optional<uint32_t> hBoostOffMissedCycles,
88                 std::optional<double> hBoostPidPuFactor, std::optional<uint32_t> hBoostUclampMin,
89                 std::optional<double> jankCheckTimeFactor,
90                 std::optional<uint32_t> lowFrameRateThreshold, std::optional<uint32_t> maxRecordsNum,
91                 uint32_t uclampMinLoadUp, uint32_t uclampMinLoadReset,
92                 std::optional<int32_t> uclampMaxEfficientBase,
93                 std::optional<int32_t> uclampMaxEfficientOffset)
94          : mName(std::move(name)),
95            mPidOn(pidOn),
96            mPidPo(pidPo),
97            mPidPu(pidPu),
98            mPidI(pidI),
99            mPidIInit(pidIInit),
100            mPidIHigh(pidIHigh),
101            mPidILow(pidILow),
102            mPidDo(pidDo),
103            mPidDu(pidDu),
104            mUclampMinOn(uclampMinOn),
105            mUclampMinInit(uclampMinInit),
106            mUclampMinHigh(uclampMinHigh),
107            mUclampMinLow(uclampMinLow),
108            mSamplingWindowP(samplingWindowP),
109            mSamplingWindowI(samplingWindowI),
110            mSamplingWindowD(samplingWindowD),
111            mReportingRateLimitNs(reportingRateLimitNs),
112            mTargetTimeFactor(targetTimeFactor),
113            mStaleTimeFactor(staleTimeFactor),
114            mGpuBoostOn(gpuBoostOn),
115            mGpuBoostCapacityMax(gpuBoostCapacityMax),
116            mGpuCapacityLoadUpHeadroom(gpuCapacityLoadUpHeadroom),
117            mHeuristicBoostOn(heuristicBoostOn),
118            mHBoostOnMissedCycles(hBoostOnMissedCycles),
119            mHBoostOffMaxAvgRatio(hBoostOffMaxAvgRatio),
120            mHBoostOffMissedCycles(hBoostOffMissedCycles),
121            mHBoostPidPuFactor(hBoostPidPuFactor),
122            mHBoostUclampMin(hBoostUclampMin),
123            mJankCheckTimeFactor(jankCheckTimeFactor),
124            mLowFrameRateThreshold(lowFrameRateThreshold),
125            mMaxRecordsNum(maxRecordsNum),
126            mUclampMinLoadUp(uclampMinLoadUp),
127            mUclampMinLoadReset(uclampMinLoadReset),
128            mUclampMaxEfficientBase(uclampMaxEfficientBase),
129            mUclampMaxEfficientOffset(uclampMaxEfficientOffset) {}
130  };
131  
132  }  // namespace perfmgr
133  }  // namespace android
134