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.device; 17 18INCLUDE PERFETTO MODULE wattson.device_infos; 19 20-- 1D LUT 21CREATE PERFETTO TABLE _filtered_curves_1d_raw AS 22SELECT 23 cp.policy, 24 freq_khz, 25 active, 26 idle0, 27 idle1, 28 static 29FROM _device_curves_1d AS dc 30JOIN _wattson_device AS device 31 ON dc.device = device.name 32JOIN _dev_cpu_policy_map AS cp 33 ON dc.policy = cp.policy; 34 35CREATE PERFETTO TABLE _filtered_curves_1d AS 36SELECT 37 policy, 38 freq_khz, 39 -1 AS idle, 40 active AS curve_value 41FROM _filtered_curves_1d_raw 42UNION 43SELECT 44 policy, 45 freq_khz, 46 0, 47 idle0 48FROM _filtered_curves_1d_raw 49UNION 50SELECT 51 policy, 52 freq_khz, 53 1, 54 idle1 55FROM _filtered_curves_1d_raw 56UNION 57SELECT 58 policy, 59 freq_khz, 60 255, 61 static 62FROM _filtered_curves_1d_raw; 63 64CREATE PERFETTO INDEX freq_1d ON _filtered_curves_1d(policy, freq_khz, idle); 65 66-- 2D LUT; with dependency on another CPU 67CREATE PERFETTO TABLE _filtered_curves_2d_raw AS 68SELECT 69 cp.policy AS other_policy, 70 dc.freq_khz, 71 dc.other_freq_khz, 72 dc.active, 73 dc.idle0, 74 dc.idle1, 75 dc.static 76FROM _device_curves_2d AS dc 77JOIN _wattson_device AS device 78 ON dc.device = device.name 79JOIN _dev_cpu_policy_map AS cp 80 ON dc.other_policy = cp.policy; 81 82CREATE PERFETTO TABLE _filtered_curves_2d AS 83SELECT 84 freq_khz, 85 other_policy, 86 other_freq_khz, 87 -1 AS idle, 88 active AS curve_value 89FROM _filtered_curves_2d_raw 90UNION 91SELECT 92 freq_khz, 93 other_policy, 94 other_freq_khz, 95 0, 96 idle0 97FROM _filtered_curves_2d_raw 98UNION 99SELECT 100 freq_khz, 101 other_policy, 102 other_freq_khz, 103 1, 104 idle1 105FROM _filtered_curves_2d_raw 106UNION 107SELECT 108 freq_khz, 109 other_policy, 110 other_freq_khz, 111 255, 112 static 113FROM _filtered_curves_2d_raw; 114 115CREATE PERFETTO INDEX freq_2d ON _filtered_curves_2d(freq_khz, other_policy, other_freq_khz, idle); 116 117-- L3 cache LUT 118CREATE PERFETTO TABLE _filtered_curves_l3_raw AS 119SELECT 120 cp.policy AS other_policy, 121 dc.freq_khz, 122 dc.other_freq_khz, 123 dc.l3_hit, 124 dc.l3_miss 125FROM _device_curves_l3 AS dc 126JOIN _wattson_device AS device 127 ON dc.device = device.name 128JOIN _dev_cpu_policy_map AS cp 129 ON dc.other_policy = cp.policy; 130 131CREATE PERFETTO TABLE _filtered_curves_l3 AS 132SELECT 133 freq_khz, 134 other_policy, 135 other_freq_khz, 136 'hit' AS action, 137 l3_hit AS curve_value 138FROM _filtered_curves_l3_raw 139UNION 140SELECT 141 freq_khz, 142 other_policy, 143 other_freq_khz, 144 'miss' AS action, 145 l3_miss 146FROM _filtered_curves_l3_raw; 147 148CREATE PERFETTO INDEX freq_l3 ON _filtered_curves_l3(freq_khz, other_policy, other_freq_khz, action); 149