Skip to content

Commit

Permalink
Merge "stdlib: Function to query for Wattson in time window" into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Samuel Wu authored and Gerrit Code Review committed Oct 22, 2024
2 parents 0580205 + 25defaf commit 5b5cb09
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,3 +156,28 @@ SELECT
) + static_curve as dsu_scu_mw
FROM _system_state_curves;

-- API to get power from each system state in an arbitrary time window
CREATE PERFETTO FUNCTION _windowed_system_state_mw(ts LONG, dur LONG)
RETURNS TABLE(
cpu0_mw FLOAT,
cpu1_mw FLOAT,
cpu2_mw FLOAT,
cpu3_mw FLOAT,
cpu4_mw FLOAT,
cpu5_mw FLOAT,
cpu6_mw FLOAT,
cpu7_mw FLOAT,
dsu_scu_mw FLOAT
) AS
SELECT
SUM(ss.cpu0_mw * ss.dur) / SUM(ss.dur) AS cpu0_mw,
SUM(ss.cpu1_mw * ss.dur) / SUM(ss.dur) AS cpu1_mw,
SUM(ss.cpu2_mw * ss.dur) / SUM(ss.dur) AS cpu2_mw,
SUM(ss.cpu3_mw * ss.dur) / SUM(ss.dur) AS cpu3_mw,
SUM(ss.cpu4_mw * ss.dur) / SUM(ss.dur) AS cpu4_mw,
SUM(ss.cpu5_mw * ss.dur) / SUM(ss.dur) AS cpu5_mw,
SUM(ss.cpu6_mw * ss.dur) / SUM(ss.dur) AS cpu6_mw,
SUM(ss.cpu7_mw * ss.dur) / SUM(ss.dur) AS cpu7_mw,
SUM(ss.dsu_scu_mw * ss.dur) / SUM(ss.dur) AS dsu_scu_mw
FROM _interval_intersect_single!($ts, $dur, _ii_subquery!(_system_state_mw)) ii
JOIN _system_state_mw AS ss ON ss._auto_id = id;
23 changes: 23 additions & 0 deletions test/trace_processor/diff_tests/stdlib/wattson/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,3 +410,26 @@ def test_wattson_dsu_devfreq_system_state(self):
4108587746105,12451,2.670000,2.670000,2.670000,205.600000,674.240000,674.240000,674.240000,3327.560000,1166.556475
4108587758556,28524,2.670000,2.670000,205.600000,205.600000,674.240000,674.240000,674.240000,3327.560000,1166.680924
"""))

def test_wattson_time_window_api(self):
return DiffTestBlueprint(
trace=DataPath('wattson_dsu_pmu.pb'),
query="""
INCLUDE PERFETTO MODULE wattson.curves.estimates;
SELECT
cpu0_mw,
cpu1_mw,
cpu2_mw,
cpu3_mw,
cpu4_mw,
cpu5_mw,
cpu6_mw,
cpu7_mw,
dsu_scu_mw
FROM _windowed_system_state_mw(362426061658, 5067704349)
""",
out=Csv("""
"cpu0_mw","cpu1_mw","cpu2_mw","cpu3_mw","cpu4_mw","cpu5_mw","cpu6_mw","cpu7_mw","dsu_scu_mw"
13.025673,6.270190,5.448549,8.796540,8.937174,10.717942,29.482823,30.239208,26.121213
"""))

0 comments on commit 5b5cb09

Please sign in to comment.