1-- 2-- Copyright 2024 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-- https://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 16INCLUDE PERFETTO MODULE wattson.curves.ungrouped; 17 18-- Wattson's estimated usage of the system, split out into cpu cluster based on 19-- the natural grouping of the hardware. 20CREATE PERFETTO TABLE wattson_estimate_per_component( 21 -- Starting timestamp of the slice 22 ts LONG, 23 -- Duration of the slice 24 dur INT, 25 -- Total L3 estimated usage in mW during this slice 26 l3 FLOAT, 27 -- Total little CPU estimated usage in mW during this slice 28 little_cpus FLOAT, 29 -- Total mid CPU cluster estimated usage in mW during this slice 30 mid_cpus FLOAT, 31 -- Total big CPU cluster estimated usage in mW during this slice 32 big_cpus FLOAT 33) 34AS 35SELECT 36 ts, 37 dur, 38 IFNULL(l3_hit_value, 0.0) + IFNULL(l3_miss_value, 0.0) as l3, 39 IFNULL(cpu0_curve, 0.0) + IFNULL(cpu1_curve, 0.0) + IFNULL(cpu2_curve, 0.0) + 40 IFNULL(cpu3_curve, 0.0) + static_curve as little_cpus, 41 cpu4_curve + cpu5_curve as mid_cpus, 42 cpu6_curve + cpu7_curve as big_cpus 43FROM _system_state_curves; 44 45-- Gives total contribution of each HW component for the entire trace, bringing 46-- the output of the table to parity with the Python version of Wattson 47CREATE PERFETTO TABLE _wattson_entire_trace 48AS 49WITH _individual_totals AS ( 50 SELECT 51 -- LUT for l3 is scaled by 10^6 to save resolution, so do the inversion 52 -- scaling by 10^6 after the summation to minimize losing resolution 53 SUM(l3) / 1000000 as total_l3, 54 SUM(dur * little_cpus) / 1000000000 as total_little_cpus, 55 SUM(dur * mid_cpus) / 1000000000 as total_mid_cpus, 56 SUM(dur * big_cpus) / 1000000000 as total_big_cpus 57 FROM wattson_estimate_per_component 58 ) 59SELECT 60 ROUND(total_l3, 2) as total_l3, 61 ROUND(total_little_cpus, 2) as total_little_cpus, 62 ROUND(total_mid_cpus, 2) as total_mid_cpus, 63 ROUND(total_big_cpus, 2) as total_big_cpus, 64 ROUND(total_l3 + total_little_cpus + total_mid_cpus + total_big_cpus, 2) as total 65FROM _individual_totals; 66 67