• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.cpu_split;
17
18-- The final system state for the CPU subsystem, which has all the information
19-- needed by Wattson to estimate energy for the CPU subsystem.
20CREATE PERFETTO TABLE _wattson_system_states (
21  -- Starting timestamp of the current counter where system state is constant.
22  ts TIMESTAMP,
23  -- Duration of the current counter where system state is constant.
24  dur DURATION,
25  -- Number of L3 hits the current system state.
26  l3_hit_count LONG,
27  -- Number of L3 misses in the current system state.
28  l3_miss_count LONG,
29  -- Frequency of CPU0.
30  freq_0 LONG,
31  -- Idle state of CPU0.
32  idle_0 LONG,
33  -- Frequency of CPU1.
34  freq_1 LONG,
35  -- Idle state of CPU1.
36  idle_1 LONG,
37  -- Frequency of CPU2.
38  freq_2 LONG,
39  -- Idle state of CPU2.
40  idle_2 LONG,
41  -- Frequency of CPU3.
42  freq_3 LONG,
43  -- Idle state of CPU3.
44  idle_3 LONG,
45  -- Frequency of CPU4.
46  freq_4 LONG,
47  -- Idle state of CPU4.
48  idle_4 LONG,
49  -- Frequency of CPU5.
50  freq_5 LONG,
51  -- Idle state of CPU5.
52  idle_5 LONG,
53  -- Frequency of CPU6.
54  freq_6 LONG,
55  -- Idle state of CPU6.
56  idle_6 LONG,
57  -- Frequency of CPU7.
58  freq_7 LONG,
59  -- Idle state of CPU7.
60  idle_7 LONG,
61  -- Flag indicating if current system state is suspended.
62  suspended BOOL
63) AS
64SELECT
65  s.ts,
66  s.dur,
67  cast_int!(round(l3_hit_rate * s.dur, 0)) AS l3_hit_count,
68  cast_int!(round(l3_miss_rate * s.dur, 0)) AS l3_miss_count,
69  freq_0,
70  idle_0,
71  freq_1,
72  idle_1,
73  freq_2,
74  idle_2,
75  freq_3,
76  idle_3,
77  freq_4,
78  idle_4,
79  freq_5,
80  idle_5,
81  freq_6,
82  idle_6,
83  freq_7,
84  idle_7,
85  coalesce(suspended, FALSE) AS suspended
86FROM _idle_freq_l3_hit_l3_miss_slice AS s
87JOIN _stats_cpu0
88  ON _stats_cpu0._auto_id = s.cpu0_id
89JOIN _stats_cpu1
90  ON _stats_cpu1._auto_id = s.cpu1_id
91JOIN _stats_cpu2
92  ON _stats_cpu2._auto_id = s.cpu2_id
93JOIN _stats_cpu3
94  ON _stats_cpu3._auto_id = s.cpu3_id
95LEFT JOIN _stats_cpu4
96  ON _stats_cpu4._auto_id = s.cpu4_id
97LEFT JOIN _stats_cpu5
98  ON _stats_cpu5._auto_id = s.cpu5_id
99LEFT JOIN _stats_cpu6
100  ON _stats_cpu6._auto_id = s.cpu6_id
101LEFT JOIN _stats_cpu7
102  ON _stats_cpu7._auto_id = s.cpu7_id
103-- Needs to be at least 1us to reduce inconsequential rows.
104WHERE
105  s.dur > time_from_us(1);
106