blob: fdc5c700b7fe418f63d89be3b5056c3b278f8842 [file] [log] [blame]
Javi Merino491cf732014-03-31 17:34:44 +01001#!/usr/bin/python
Javi Merinoc47d2df2015-02-06 16:04:03 +00002# $Copyright:
3# ----------------------------------------------------------------
4# This confidential and proprietary software may be used only as
5# authorised by a licensing agreement from ARM Limited
6# (C) COPYRIGHT 2015 ARM Limited
7# ALL RIGHTS RESERVED
8# The entire notice above must be reproduced on all authorised
9# copies and copies may only be made to the extent permitted
10# by a licensing agreement from ARM Limited.
11# ----------------------------------------------------------------
12# File: thermal.py
13# ----------------------------------------------------------------
14# $
15#
Javi Merino5bd3d442014-04-08 12:55:13 +010016"""Process the output of the power allocator trace in the current
17directory's trace.dat"""
Javi Merino572049d2014-03-31 16:45:23 +010018
19import os
Javi Merinoee56c362014-03-31 17:30:34 +010020import re
Javi Merinoa6399fb2014-03-31 19:17:08 +010021from matplotlib import pyplot as plt
Javi Merino572049d2014-03-31 16:45:23 +010022
Dietmar Eggemannb42a50b2014-12-11 20:28:45 +000023from base import Base
Javi Merino1a3dca32014-08-11 16:12:50 +010024from plot_utils import normalize_title, pre_plot_setup, post_plot_setup, plot_hist
Javi Merino51db3632014-06-13 11:24:51 +010025
Dietmar Eggemannb42a50b2014-12-11 20:28:45 +000026class Thermal(Base):
Javi Merino0e83b612014-06-05 11:45:23 +010027 """Process the thermal framework data in a ftrace dump"""
KP Singh7319a882014-12-24 18:18:01 +000028
29 unique_word="thermal_temperature:"
30 name="thermal"
31
Javi Merino0e83b612014-06-05 11:45:23 +010032 def __init__(self, path=None):
33 super(Thermal, self).__init__(
34 basepath=path,
KP Singh7319a882014-12-24 18:18:01 +000035 unique_word=self.unique_word,
Javi Merino0e83b612014-06-05 11:45:23 +010036 )
37
Javi Merino516d5942014-06-26 15:06:04 +010038 def plot_temperature(self, control_temperature=None, title="", width=None,
Javi Merino80114162014-08-08 16:48:32 +010039 height=None, ylim="range", ax=None, legend_label=""):
Javi Merino516d5942014-06-26 15:06:04 +010040 """Plot the temperature.
41
42 If control_temp is a pd.Series() representing the (possible)
43 variation of control_temp during the run, draw it using a
44 dashed yellow line. Otherwise, only the temperature is
45 plotted.
46
47 """
Javi Merinoc68737a2014-06-10 15:21:59 +010048 title = normalize_title("Temperature", title)
49
Javi Merino49cbcfe2014-08-08 16:03:49 +010050 setup_plot = False
51 if not ax:
52 ax = pre_plot_setup(width, height)
53 setup_plot = True
54
Javi Merino80114162014-08-08 16:48:32 +010055 temp_label = normalize_title("Temperature", legend_label)
Javi Merino92f4d012014-08-08 17:55:32 +010056 (self.data_frame["temp"] / 1000).plot(ax=ax, label=temp_label)
Javi Merino516d5942014-06-26 15:06:04 +010057 if control_temperature is not None:
Javi Merino80114162014-08-08 16:48:32 +010058 ct_label = normalize_title("Control", legend_label)
Javi Merino516d5942014-06-26 15:06:04 +010059 control_temperature.plot(ax=ax, color="y", linestyle="--",
Javi Merino80114162014-08-08 16:48:32 +010060 label=ct_label)
Javi Merinoc68737a2014-06-10 15:21:59 +010061
Javi Merino49cbcfe2014-08-08 16:03:49 +010062 if setup_plot:
63 post_plot_setup(ax, title=title, ylim=ylim)
64 plt.legend()
Javi Merinoc68737a2014-06-10 15:21:59 +010065
Javi Merinoe5ea60a2014-08-12 16:41:42 +010066 def plot_temperature_hist(self, ax, title):
Javi Merino1a3dca32014-08-11 16:12:50 +010067 """Plot a temperature histogram"""
68
69 temps = self.data_frame["temp"] / 1000
70 title = normalize_title("Temperature", title)
71 xlim = (0, temps.max())
72
Javi Merinoe5ea60a2014-08-12 16:41:42 +010073 plot_hist(temps, ax, title, 30, "Temperature", xlim, "default")
Javi Merino1a3dca32014-08-11 16:12:50 +010074
Dietmar Eggemannb42a50b2014-12-11 20:28:45 +000075class ThermalGovernor(Base):
Javi Merino5bd3d442014-04-08 12:55:13 +010076 """Process the power allocator data in a ftrace dump"""
KP Singh7319a882014-12-24 18:18:01 +000077
78 unique_word="thermal_power_allocator:"
79 name="thermal_governor"
Javi Merino68461552014-04-08 11:40:09 +010080 def __init__(self, path=None):
Javi Merino1e69e2c2014-06-04 18:25:09 +010081 super(ThermalGovernor, self).__init__(
Javi Merino68461552014-04-08 11:40:09 +010082 basepath=path,
KP Singh7319a882014-12-24 18:18:01 +000083 unique_word=self.unique_word,
Javi Merinoc2ec5682014-04-01 15:16:06 +010084 )
85
Javi Merino29223812014-08-12 15:24:43 +010086 def plot_input_power(self, actor_order, title="", width=None, height=None, ax=None):
Javi Merinod6d5f892014-07-03 16:24:23 +010087 """Plot input power
88
89 actor_order is an array with the order in which the actors were registered.
90 """
91
Javi Merino92f4d012014-08-08 17:55:32 +010092 dfr = self.data_frame
Javi Merinof7968a72014-07-03 15:35:02 +010093 in_cols = [s for s in dfr.columns if re.match("req_power[0-9]+", s)]
Javi Merinoe0ddf0d2014-05-07 18:40:12 +010094
Javi Merinod6d5f892014-07-03 16:24:23 +010095 plot_dfr = dfr[in_cols]
96 # Rename the columns from "req_power0" to "A15" or whatever is
97 # in actor_order. Note that we can do it just with an
98 # assignment because the columns are already sorted (i.e.:
99 # req_power0, req_power1...)
100 plot_dfr.columns = actor_order
101
Javi Merinoc00feff2014-04-14 15:41:51 +0100102 title = normalize_title("Input Power", title)
Javi Merino8ecd8172014-07-03 16:09:01 +0100103
Javi Merino29223812014-08-12 15:24:43 +0100104 if not ax:
105 ax = pre_plot_setup(width, height)
106
Javi Merinod6d5f892014-07-03 16:24:23 +0100107 plot_dfr.plot(ax=ax)
Javi Merino8ecd8172014-07-03 16:09:01 +0100108 post_plot_setup(ax, title=title)
Javi Merino9c010772014-04-02 16:54:41 +0100109
Javi Merino6003b252014-08-12 15:32:17 +0100110 def plot_output_power(self, actor_order, title="", width=None, height=None, ax=None):
Javi Merinod6d5f892014-07-03 16:24:23 +0100111 """Plot output power
112
113 actor_order is an array with the order in which the actors were registered.
114 """
115
Javi Merino92f4d012014-08-08 17:55:32 +0100116 out_cols = [s for s in self.data_frame.columns
Javi Merinof7968a72014-07-03 15:35:02 +0100117 if re.match("granted_power[0-9]+", s)]
Javi Merinoe0ddf0d2014-05-07 18:40:12 +0100118
Javi Merinod6d5f892014-07-03 16:24:23 +0100119 # See the note in plot_input_power()
Javi Merino92f4d012014-08-08 17:55:32 +0100120 plot_dfr = self.data_frame[out_cols]
Javi Merinod6d5f892014-07-03 16:24:23 +0100121 plot_dfr.columns = actor_order
122
Javi Merinoc00feff2014-04-14 15:41:51 +0100123 title = normalize_title("Output Power", title)
Javi Merino8ecd8172014-07-03 16:09:01 +0100124
Javi Merino6003b252014-08-12 15:32:17 +0100125 if not ax:
126 ax = pre_plot_setup(width, height)
127
Javi Merinod6d5f892014-07-03 16:24:23 +0100128 plot_dfr.plot(ax=ax)
Javi Merino8ecd8172014-07-03 16:09:01 +0100129 post_plot_setup(ax, title=title)
Javi Merinocd4a8272014-04-14 15:50:01 +0100130
Javi Merino9fc54852014-05-07 19:06:53 +0100131 def plot_inout_power(self, title="", width=None, height=None):
132 """Make multiple plots showing input and output power for each actor"""
Javi Merino92f4d012014-08-08 17:55:32 +0100133 dfr = self.data_frame
Javi Merino9fc54852014-05-07 19:06:53 +0100134
135 actors = []
136 for col in dfr.columns:
137 match = re.match("P(.*)_in", col)
138 if match and col != "Ptot_in":
139 actors.append(match.group(1))
140
141 for actor in actors:
142 cols = ["P" + actor + "_in", "P" + actor + "_out"]
143 this_title = normalize_title(actor, title)
144 dfr[cols].plot(title=this_title)