Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 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 | |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 17 | /** |
| 18 | * @defgroup APerformanceHint Performance Hint Manager |
| 19 | * |
| 20 | * APerformanceHint allows apps to create performance hint sessions for groups |
| 21 | * of threads, and provide hints to the system about the workload of those threads, |
Matt Buckley | 122a117 | 2024-10-21 12:16:36 -0700 | [diff] [blame] | 22 | * to help the system more accurately allocate resources for them. It is the NDK |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 23 | * counterpart to the Java PerformanceHintManager SDK API. |
| 24 | * |
Matt Buckley | 122a117 | 2024-10-21 12:16:36 -0700 | [diff] [blame] | 25 | * This API is intended for periodic workloads, such as frame production. Clients are |
| 26 | * expected to create an instance of APerformanceHintManager, create a session with |
| 27 | * that, and then set a target duration for the session. Then, they can report the actual |
| 28 | * work duration at the end of each cycle to inform the framework about how long those |
| 29 | * workloads are taking. The framework will then compare the actual durations to the target |
| 30 | * duration and attempt to help the client reach a steady state under the target. |
| 31 | * |
| 32 | * Unlike reportActualWorkDuration, the "notify..." hints are intended to be sent in |
| 33 | * advance of large changes in the workload, to prevent them from going over the target |
| 34 | * when there is a sudden, unforseen change. Their effects are intended to last for only |
| 35 | * one cycle, after which reportActualWorkDuration will have a chance to catch up. |
| 36 | * These hints should be used judiciously, only in cases where the workload is changing |
| 37 | * substantially. To enforce that, they are tracked using a per-app rate limiter to avoid |
| 38 | * excessive hinting and encourage clients to be mindful about when to send them. |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 39 | * @{ |
| 40 | */ |
| 41 | |
| 42 | /** |
| 43 | * @file performance_hint.h |
| 44 | * @brief API for creating and managing a hint session. |
| 45 | */ |
| 46 | |
| 47 | |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 48 | #ifndef ANDROID_NATIVE_PERFORMANCE_HINT_H |
| 49 | #define ANDROID_NATIVE_PERFORMANCE_HINT_H |
| 50 | |
| 51 | #include <sys/cdefs.h> |
| 52 | |
| 53 | /****************************************************************** |
| 54 | * |
| 55 | * IMPORTANT NOTICE: |
| 56 | * |
| 57 | * This file is part of Android's set of stable system headers |
| 58 | * exposed by the Android NDK (Native Development Kit). |
| 59 | * |
| 60 | * Third-party source AND binary code relies on the definitions |
| 61 | * here to be FROZEN ON ALL UPCOMING PLATFORM RELEASES. |
| 62 | * |
| 63 | * - DO NOT MODIFY ENUMS (EXCEPT IF YOU ADD NEW 32-BIT VALUES) |
| 64 | * - DO NOT MODIFY CONSTANTS OR FUNCTIONAL MACROS |
| 65 | * - DO NOT CHANGE THE SIGNATURE OF FUNCTIONS IN ANY WAY |
| 66 | * - DO NOT CHANGE THE LAYOUT OR SIZE OF STRUCTURES |
| 67 | */ |
| 68 | |
Dan Albert | 8d4bea1 | 2024-08-01 22:31:09 +0000 | [diff] [blame] | 69 | #include <stdbool.h> |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 70 | #include <stdint.h> |
Peiyong Lin | c1041d4 | 2023-01-26 00:51:33 +0000 | [diff] [blame] | 71 | #include <unistd.h> |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 72 | |
| 73 | __BEGIN_DECLS |
| 74 | |
| 75 | struct APerformanceHintManager; |
| 76 | struct APerformanceHintSession; |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 77 | struct AWorkDuration; |
| 78 | |
| 79 | /** |
| 80 | * {@link AWorkDuration} is an opaque type that represents the breakdown of the |
| 81 | * actual workload duration in each component internally. |
| 82 | * |
| 83 | * A new {@link AWorkDuration} can be obtained using |
| 84 | * {@link AWorkDuration_create()}, when the client finishes using |
| 85 | * {@link AWorkDuration}, {@link AWorkDuration_release()} must be |
| 86 | * called to destroy and free up the resources associated with |
| 87 | * {@link AWorkDuration}. |
| 88 | * |
| 89 | * This file provides a set of functions to allow clients to set the measured |
| 90 | * work duration of each component on {@link AWorkDuration}. |
| 91 | * |
| 92 | * - AWorkDuration_setWorkPeriodStartTimestampNanos() |
| 93 | * - AWorkDuration_setActualTotalDurationNanos() |
| 94 | * - AWorkDuration_setActualCpuDurationNanos() |
| 95 | * - AWorkDuration_setActualGpuDurationNanos() |
| 96 | */ |
| 97 | typedef struct AWorkDuration AWorkDuration; |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 98 | |
| 99 | /** |
| 100 | * An opaque type representing a handle to a performance hint manager. |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 101 | * |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 102 | * To use:<ul> |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 103 | * <li>Obtain the performance hint manager instance by calling |
| 104 | * {@link APerformanceHint_getManager} function.</li> |
| 105 | * <li>Create an {@link APerformanceHintSession} with |
| 106 | * {@link APerformanceHint_createSession}.</li> |
| 107 | * <li>Get the preferred update rate in nanoseconds with |
| 108 | * {@link APerformanceHint_getPreferredUpdateRateNanos}.</li> |
| 109 | */ |
| 110 | typedef struct APerformanceHintManager APerformanceHintManager; |
| 111 | |
| 112 | /** |
| 113 | * An opaque type representing a handle to a performance hint session. |
| 114 | * A session can only be acquired from a {@link APerformanceHintManager} |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 115 | * with {@link APerformanceHint_createSession}. It must be |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 116 | * freed with {@link APerformanceHint_closeSession} after use. |
| 117 | * |
| 118 | * A Session represents a group of threads with an inter-related workload such that hints for |
| 119 | * their performance should be considered as a unit. The threads in a given session should be |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 120 | * long-lived and not created or destroyed dynamically. |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 121 | * |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 122 | * The work duration API can be used with periodic workloads to dynamically adjust thread |
| 123 | * performance and keep the work on schedule while optimizing the available power budget. |
| 124 | * When using the work duration API, the starting target duration should be specified |
| 125 | * while creating the session, and can later be adjusted with |
| 126 | * {@link APerformanceHint_updateTargetWorkDuration}. While using the work duration |
| 127 | * API, the client is expected to call {@link APerformanceHint_reportActualWorkDuration} each |
| 128 | * cycle to report the actual time taken to complete to the system. |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 129 | * |
Xiang Wang | c8681f8 | 2024-04-08 12:45:59 -0700 | [diff] [blame] | 130 | * Note, methods of {@link APerformanceHintSession_*} are not thread safe so callers must |
| 131 | * ensure thread safety. |
| 132 | * |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 133 | * All timings should be from `std::chrono::steady_clock` or `clock_gettime(CLOCK_MONOTONIC, ...)` |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 134 | */ |
| 135 | typedef struct APerformanceHintSession APerformanceHintSession; |
| 136 | |
| 137 | /** |
| 138 | * Acquire an instance of the performance hint manager. |
| 139 | * |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 140 | * @return APerformanceHintManager instance on success, nullptr on failure. |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 141 | */ |
Xiang Wang | 352ff40 | 2024-01-09 13:27:05 -0800 | [diff] [blame] | 142 | APerformanceHintManager* _Nullable APerformanceHint_getManager() |
| 143 | __INTRODUCED_IN(__ANDROID_API_T__); |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 144 | |
| 145 | /** |
| 146 | * Creates a session for the given set of threads and sets their initial target work |
| 147 | * duration. |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 148 | * |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 149 | * @param manager The performance hint manager instance. |
| 150 | * @param threadIds The list of threads to be associated with this session. They must be part of |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 151 | * this process' thread group. |
| 152 | * @param size The size of the list of threadIds. |
| 153 | * @param initialTargetWorkDurationNanos The target duration in nanoseconds for the new session. |
| 154 | * This must be positive if using the work duration API, or 0 otherwise. |
| 155 | * @return APerformanceHintManager instance on success, nullptr on failure. |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 156 | */ |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 157 | APerformanceHintSession* _Nullable APerformanceHint_createSession( |
| 158 | APerformanceHintManager* _Nonnull manager, |
| 159 | const int32_t* _Nonnull threadIds, size_t size, |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 160 | int64_t initialTargetWorkDurationNanos) __INTRODUCED_IN(__ANDROID_API_T__); |
| 161 | |
| 162 | /** |
| 163 | * Get preferred update rate information for this device. |
| 164 | * |
| 165 | * @param manager The performance hint manager instance. |
| 166 | * @return the preferred update rate supported by device software. |
| 167 | */ |
| 168 | int64_t APerformanceHint_getPreferredUpdateRateNanos( |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 169 | APerformanceHintManager* _Nonnull manager) __INTRODUCED_IN(__ANDROID_API_T__); |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 170 | |
| 171 | /** |
| 172 | * Updates this session's target duration for each cycle of work. |
| 173 | * |
| 174 | * @param session The performance hint session instance to update. |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 175 | * @param targetDurationNanos The new desired duration in nanoseconds. This must be positive. |
| 176 | * @return 0 on success. |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 177 | * EINVAL if targetDurationNanos is not positive. |
| 178 | * EPIPE if communication with the system service has failed. |
| 179 | */ |
| 180 | int APerformanceHint_updateTargetWorkDuration( |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 181 | APerformanceHintSession* _Nonnull session, |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 182 | int64_t targetDurationNanos) __INTRODUCED_IN(__ANDROID_API_T__); |
| 183 | |
| 184 | /** |
| 185 | * Reports the actual duration for the last cycle of work. |
| 186 | * |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 187 | * The system will attempt to adjust the scheduling and performance of the |
| 188 | * threads within the thread group to bring the actual duration close to the target duration. |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 189 | * |
| 190 | * @param session The performance hint session instance to update. |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 191 | * @param actualDurationNanos The duration of time the thread group took to complete its last |
| 192 | * task in nanoseconds. This must be positive. |
| 193 | * @return 0 on success. |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 194 | * EINVAL if actualDurationNanos is not positive. |
| 195 | * EPIPE if communication with the system service has failed. |
| 196 | */ |
| 197 | int APerformanceHint_reportActualWorkDuration( |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 198 | APerformanceHintSession* _Nonnull session, |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 199 | int64_t actualDurationNanos) __INTRODUCED_IN(__ANDROID_API_T__); |
| 200 | |
| 201 | /** |
| 202 | * Release the performance hint manager pointer acquired via |
| 203 | * {@link APerformanceHint_createSession}. |
| 204 | * |
| 205 | * @param session The performance hint session instance to release. |
| 206 | */ |
| 207 | void APerformanceHint_closeSession( |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 208 | APerformanceHintSession* _Nonnull session) __INTRODUCED_IN(__ANDROID_API_T__); |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 209 | |
Peiyong Lin | f9c984f | 2022-11-11 18:28:20 +0000 | [diff] [blame] | 210 | /** |
| 211 | * Set a list of threads to the performance hint session. This operation will replace |
| 212 | * the current list of threads with the given list of threads. |
| 213 | * |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 214 | * @param session The performance hint session instance to update. |
Peiyong Lin | f9c984f | 2022-11-11 18:28:20 +0000 | [diff] [blame] | 215 | * @param threadIds The list of threads to be associated with this session. They must be part of |
| 216 | * this app's thread group. |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 217 | * @param size The size of the list of threadIds. |
Peiyong Lin | f9c984f | 2022-11-11 18:28:20 +0000 | [diff] [blame] | 218 | * @return 0 on success. |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 219 | * EINVAL if the list of thread ids is empty or if any of the thread ids are not part of |
| 220 | the thread group. |
Peiyong Lin | f9c984f | 2022-11-11 18:28:20 +0000 | [diff] [blame] | 221 | * EPIPE if communication with the system service has failed. |
Xiang Wang | f6d21b5 | 2023-07-25 17:34:01 -0700 | [diff] [blame] | 222 | * EPERM if any thread id doesn't belong to the application. |
Peiyong Lin | f9c984f | 2022-11-11 18:28:20 +0000 | [diff] [blame] | 223 | */ |
| 224 | int APerformanceHint_setThreads( |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 225 | APerformanceHintSession* _Nonnull session, |
| 226 | const pid_t* _Nonnull threadIds, |
Peiyong Lin | f9c984f | 2022-11-11 18:28:20 +0000 | [diff] [blame] | 227 | size_t size) __INTRODUCED_IN(__ANDROID_API_U__); |
| 228 | |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 229 | /** |
| 230 | * This tells the session that these threads can be |
| 231 | * safely scheduled to prefer power efficiency over performance. |
| 232 | * |
| 233 | * @param session The performance hint session instance to update. |
| 234 | * @param enabled The flag which sets whether this session will use power-efficient scheduling. |
| 235 | * @return 0 on success. |
| 236 | * EPIPE if communication with the system service has failed. |
| 237 | */ |
| 238 | int APerformanceHint_setPreferPowerEfficiency( |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 239 | APerformanceHintSession* _Nonnull session, |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 240 | bool enabled) __INTRODUCED_IN(__ANDROID_API_V__); |
| 241 | |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 242 | /** |
| 243 | * Reports the durations for the last cycle of work. |
| 244 | * |
| 245 | * The system will attempt to adjust the scheduling and performance of the |
| 246 | * threads within the thread group to bring the actual duration close to the target duration. |
| 247 | * |
| 248 | * @param session The {@link APerformanceHintSession} instance to update. |
| 249 | * @param workDuration The {@link AWorkDuration} structure of times the thread group took to |
| 250 | * complete its last task in nanoseconds breaking down into different components. |
| 251 | * |
Matt Buckley | 0bbd177 | 2024-01-31 22:10:42 +0000 | [diff] [blame] | 252 | * The work period start timestamp and actual total duration must be greater than zero. |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 253 | * |
Matt Buckley | 0bbd177 | 2024-01-31 22:10:42 +0000 | [diff] [blame] | 254 | * The actual CPU and GPU durations must be greater than or equal to zero, and at least one |
| 255 | * of them must be greater than zero. When one of them is equal to zero, it means that type |
| 256 | * of work was not measured for this workload. |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 257 | * |
| 258 | * @return 0 on success. |
Matt Buckley | 81cc093 | 2024-01-18 19:56:31 +0000 | [diff] [blame] | 259 | * EINVAL if any duration is an invalid number. |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 260 | * EPIPE if communication with the system service has failed. |
| 261 | */ |
| 262 | int APerformanceHint_reportActualWorkDuration2( |
| 263 | APerformanceHintSession* _Nonnull session, |
| 264 | AWorkDuration* _Nonnull workDuration) __INTRODUCED_IN(__ANDROID_API_V__); |
| 265 | |
| 266 | /** |
Matt Buckley | 122a117 | 2024-10-21 12:16:36 -0700 | [diff] [blame] | 267 | * Informs the framework of an upcoming increase in the workload of a graphics pipeline |
| 268 | * bound to this session. The user can specify whether the increase is expected to be |
| 269 | * on the CPU, GPU, or both. |
| 270 | * |
| 271 | * Sending hints for both CPU and GPU counts as two separate hints for the purposes of the |
| 272 | * rate limiter. |
| 273 | * |
| 274 | * @param cpu Indicates if the workload increase is expected to affect the CPU. |
| 275 | * @param gpu Indicates if the workload increase is expected to affect the GPU. |
| 276 | * @param debugName A required string used to identify this specific hint during |
| 277 | * tracing. This debug string will only be held for the duration of the |
| 278 | * method, and can be safely discarded after. |
| 279 | * |
| 280 | * @return 0 on success. |
| 281 | * EINVAL if no hints were requested. |
| 282 | * EBUSY if the hint was rate limited. |
| 283 | * EPIPE if communication with the system service has failed. |
| 284 | * ENOTSUP if the hint is not supported. |
| 285 | */ |
| 286 | int APerformanceHint_notifyWorkloadIncrease( |
| 287 | APerformanceHintSession* _Nonnull session, |
| 288 | bool cpu, bool gpu, const char* _Nonnull debugName) __INTRODUCED_IN(36); |
| 289 | |
| 290 | /** |
| 291 | * Informs the framework of an upcoming reset in the workload of a graphics pipeline |
| 292 | * bound to this session, or the imminent start of a new workload. The user can specify |
| 293 | * whether the reset is expected to affect the CPU, GPU, or both. |
| 294 | * |
| 295 | * Sending hints for both CPU and GPU counts as two separate hints for the purposes of the |
| 296 | * this load tracking. |
| 297 | * |
| 298 | * @param cpu Indicates if the workload reset is expected to affect the CPU. |
| 299 | * @param gpu Indicates if the workload reset is expected to affect the GPU. |
| 300 | * @param debugName A required string used to identify this specific hint during |
| 301 | * tracing. This debug string will only be held for the duration of the |
| 302 | * method, and can be safely discarded after. |
| 303 | * |
| 304 | * @return 0 on success. |
| 305 | * EINVAL if no hints were requested. |
| 306 | * EBUSY if the hint was rate limited. |
| 307 | * EPIPE if communication with the system service has failed. |
| 308 | * ENOTSUP if the hint is not supported. |
| 309 | */ |
| 310 | int APerformanceHint_notifyWorkloadReset( |
| 311 | APerformanceHintSession* _Nonnull session, |
| 312 | bool cpu, bool gpu, const char* _Nonnull debugName) __INTRODUCED_IN(36); |
| 313 | |
| 314 | /** |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 315 | * Creates a new AWorkDuration. When the client finishes using {@link AWorkDuration}, it should |
| 316 | * call {@link AWorkDuration_release()} to destroy {@link AWorkDuration} and release all resources |
| 317 | * associated with it. |
| 318 | * |
| 319 | * @return AWorkDuration on success and nullptr otherwise. |
| 320 | */ |
| 321 | AWorkDuration* _Nonnull AWorkDuration_create() __INTRODUCED_IN(__ANDROID_API_V__); |
| 322 | |
| 323 | /** |
| 324 | * Destroys {@link AWorkDuration} and free all resources associated to it. |
| 325 | * |
| 326 | * @param aWorkDuration The {@link AWorkDuration} created by calling {@link AWorkDuration_create()} |
| 327 | */ |
Xiang Wang | 352ff40 | 2024-01-09 13:27:05 -0800 | [diff] [blame] | 328 | void AWorkDuration_release(AWorkDuration* _Nonnull aWorkDuration) |
| 329 | __INTRODUCED_IN(__ANDROID_API_V__); |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 330 | |
| 331 | /** |
| 332 | * Sets the work period start timestamp in nanoseconds. |
| 333 | * |
| 334 | * @param aWorkDuration The {@link AWorkDuration} created by calling {@link AWorkDuration_create()} |
| 335 | * @param workPeriodStartTimestampNanos The work period start timestamp in nanoseconds based on |
Matt Buckley | 81cc093 | 2024-01-18 19:56:31 +0000 | [diff] [blame] | 336 | * CLOCK_MONOTONIC about when the work starts. This timestamp must be greater than zero. |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 337 | */ |
| 338 | void AWorkDuration_setWorkPeriodStartTimestampNanos(AWorkDuration* _Nonnull aWorkDuration, |
| 339 | int64_t workPeriodStartTimestampNanos) __INTRODUCED_IN(__ANDROID_API_V__); |
| 340 | |
| 341 | /** |
| 342 | * Sets the actual total work duration in nanoseconds. |
| 343 | * |
| 344 | * @param aWorkDuration The {@link AWorkDuration} created by calling {@link AWorkDuration_create()} |
Matt Buckley | 81cc093 | 2024-01-18 19:56:31 +0000 | [diff] [blame] | 345 | * @param actualTotalDurationNanos The actual total work duration in nanoseconds. This number must |
| 346 | * be greater than zero. |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 347 | */ |
| 348 | void AWorkDuration_setActualTotalDurationNanos(AWorkDuration* _Nonnull aWorkDuration, |
| 349 | int64_t actualTotalDurationNanos) __INTRODUCED_IN(__ANDROID_API_V__); |
| 350 | |
| 351 | /** |
| 352 | * Sets the actual CPU work duration in nanoseconds. |
| 353 | * |
| 354 | * @param aWorkDuration The {@link AWorkDuration} created by calling {@link AWorkDuration_create()} |
Matt Buckley | 81cc093 | 2024-01-18 19:56:31 +0000 | [diff] [blame] | 355 | * @param actualCpuDurationNanos The actual CPU work duration in nanoseconds. This number must be |
Matt Buckley | 0bbd177 | 2024-01-31 22:10:42 +0000 | [diff] [blame] | 356 | * greater than or equal to zero. If it is equal to zero, that means the CPU was not |
| 357 | * measured. |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 358 | */ |
| 359 | void AWorkDuration_setActualCpuDurationNanos(AWorkDuration* _Nonnull aWorkDuration, |
| 360 | int64_t actualCpuDurationNanos) __INTRODUCED_IN(__ANDROID_API_V__); |
| 361 | |
| 362 | /** |
| 363 | * Sets the actual GPU work duration in nanoseconds. |
| 364 | * |
| 365 | * @param aWorkDuration The {@link AWorkDuration} created by calling {@link AWorkDuration_create()}. |
| 366 | * @param actualGpuDurationNanos The actual GPU work duration in nanoseconds, the number must be |
Matt Buckley | 0bbd177 | 2024-01-31 22:10:42 +0000 | [diff] [blame] | 367 | * greater than or equal to zero. If it is equal to zero, that means the GPU was not |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 368 | * measured. |
| 369 | */ |
| 370 | void AWorkDuration_setActualGpuDurationNanos(AWorkDuration* _Nonnull aWorkDuration, |
| 371 | int64_t actualGpuDurationNanos) __INTRODUCED_IN(__ANDROID_API_V__); |
| 372 | |
Bo Liu | 406c8ab | 2021-11-10 19:20:40 -0500 | [diff] [blame] | 373 | __END_DECLS |
| 374 | |
| 375 | #endif // ANDROID_NATIVE_PERFORMANCE_HINT_H |
Matt Buckley | cc14642 | 2023-06-28 19:14:02 +0000 | [diff] [blame] | 376 | |
Peiyong Lin | 81780c4 | 2023-10-08 21:11:26 +0000 | [diff] [blame] | 377 | /** @} */ |