1// Copyright (C) 2024 The Android Open Source Project 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6// 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15import {RecordProbe, RecordSubpage} from '../config/config_interfaces'; 16import {TraceConfigBuilder} from '../config/trace_config_builder'; 17 18export function gpuRecordSection(): RecordSubpage { 19 return { 20 kind: 'PROBES_PAGE', 21 id: 'gpu', 22 title: 'GPU', 23 subtitle: 'GPU Frequency, memory', 24 icon: 'aspect_ratio', 25 probes: [gpuFreq(), gpuMemory(), gpuWorkPeriod()], 26 }; 27} 28 29function gpuFreq(): RecordProbe { 30 return { 31 id: 'gpu_frequency', 32 image: 'rec_cpu_freq.png', 33 title: 'GPU frequency', 34 description: 'Records gpu frequency via ftrace', 35 supportedPlatforms: ['ANDROID', 'LINUX', 'CHROME_OS'], 36 genConfig: function (tc: TraceConfigBuilder) { 37 tc.addFtraceEvents('power/gpu_frequency'); 38 }, 39 }; 40} 41 42function gpuMemory(): RecordProbe { 43 return { 44 id: 'gpu_memory', 45 image: 'rec_gpu_mem_total.png', 46 title: 'GPU memory', 47 description: 48 'Allows to track per process and global total GPU memory usages. ' + 49 '(Available on recent Android 12+ kernels)', 50 supportedPlatforms: ['ANDROID'], 51 genConfig: function (tc: TraceConfigBuilder) { 52 tc.addDataSource('android.gpu.memory'); 53 tc.addFtraceEvents('gpu_mem/gpu_mem_total'); 54 }, 55 }; 56} 57 58function gpuWorkPeriod(): RecordProbe { 59 return { 60 id: 'gpu_work_period', 61 title: 'GPU work period', 62 description: 63 'Allows to track per package GPU work.' + 64 '(Available on recent Android 14+ kernels)', 65 supportedPlatforms: ['ANDROID'], 66 genConfig: function (tc: TraceConfigBuilder) { 67 tc.addFtraceEvents('power/gpu_work_period'); 68 }, 69 }; 70} 71