• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 <chrono>
20 #include <iostream>
21 
22 #include "ThrottleDecision.h"
23 
24 namespace aidl {
25 namespace google {
26 namespace hardware {
27 namespace power {
28 namespace impl {
29 namespace pixel {
30 
31 struct AdaptiveCpuConfig {
32     static bool ReadFromSystemProperties(AdaptiveCpuConfig *output);
33     static const AdaptiveCpuConfig DEFAULT;
34 
35     // How long to sleep for between Adaptive CPU runs.
36     std::chrono::milliseconds iterationSleepDuration;
37     // Timeout applied to hints. If Adaptive CPU doesn't receive any frames in this time, CPU
38     // throttling hints are cancelled.
39     std::chrono::milliseconds hintTimeout;
40     // Instead of throttling based on model output, choose a random throttle X% of the time. Must be
41     // between 0 and 1 inclusive.
42     double randomThrottleDecisionProbability;
43     std::vector<ThrottleDecision> randomThrottleOptions;
44     // Setting AdaptiveCpu to enabled only lasts this long. For a continuous run, AdaptiveCpu needs
45     // to receive the enabled hint more frequently than this value.
46     std::chrono::milliseconds enabledHintTimeout;
47 
48     bool operator==(const AdaptiveCpuConfig &other) const;
49 };
50 
51 std::ostream &operator<<(std::ostream &os, const AdaptiveCpuConfig &config);
52 
53 }  // namespace pixel
54 }  // namespace impl
55 }  // namespace power
56 }  // namespace hardware
57 }  // namespace google
58 }  // namespace aidl
59