blob: c99f2f364931e91144c8b1b02b1226423172e441 [file] [log] [blame]
Brendan Jackmane81fdcb2017-01-04 17:10:29 +00001# Copyright 2015-2017 ARM Limited
Javi Merino7b98b4a2015-06-15 16:20:26 +01002#
Javi Merinoaace7c02015-08-10 14:10:47 +01003# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14#
15
Javi Merino7b98b4a2015-06-15 16:20:26 +010016
Javi Merinoc26a3232015-12-11 18:00:30 +000017import trappy.ftrace
Javi Merino7b98b4a2015-06-15 16:20:26 +010018
19def compare_runs(actor_order, map_label, runs, **kwords):
20 """A side by side comparison of multiple runs
21
Javi Merinodc25fe22015-06-16 17:34:52 +010022 Plots include temperature, utilization, frequencies, PID
Javi Merino7b98b4a2015-06-15 16:20:26 +010023 controller and power.
24
Kapileshwar Singhe9da7c62015-09-04 14:55:01 +010025 :param actor_order: An array showing the order in which the actors
26 were registered. The array values are the labels that
27 will be used in the input and output power plots.
Javi Merino7b98b4a2015-06-15 16:20:26 +010028
Kapileshwar Singhe9da7c62015-09-04 14:55:01 +010029 For Example:
30 ::
Javi Merino7b98b4a2015-06-15 16:20:26 +010031
Kapileshwar Singhe9da7c62015-09-04 14:55:01 +010032 ["GPU", "A15", "A7"]
Javi Merino7b98b4a2015-06-15 16:20:26 +010033
Kapileshwar Singhe9da7c62015-09-04 14:55:01 +010034 :param map_label: A dict that matches cpumasks (as found in the
35 trace) with their proper name. This "proper name" will be used as
36 a label for the load and allfreqs plots. It's recommended that
37 the names of the cpus matches those in actor_order.
38
39 For Example:
40 ::
41
42 {"0000000f": "A7", "000000f0": "A15"}
43
44 :param runs: An array of tuples consisting of a name and the path to
45 the directory where the trace.dat is.
46
47 For example:
48 ::
49
50 [("experiment1", "wa_output/antutu_antutu_1"),
51 ("known good", "good/antutu_antutu_1")]
52
Javi Merino961bd952016-08-22 20:11:39 +010053 :param tz_id: thermal zone id as it appears in the id field of the
54 thermal_temperature trace event
55
Kapileshwar Singhe9da7c62015-09-04 14:55:01 +010056 :type actor_order: list
57 :type map_label: dict
58 :type runs: list
Javi Merino961bd952016-08-22 20:11:39 +010059 :type tz_id: int
60
Javi Merino7b98b4a2015-06-15 16:20:26 +010061 """
Javi Merinoec2ffe02015-12-07 15:05:13 +000062 import trappy.plot_utils
63 import trappy.wa
Javi Merino7b98b4a2015-06-15 16:20:26 +010064
Javi Merinoadcfc8e2015-06-15 18:29:44 +010065 if not isinstance(actor_order, list):
Javi Merino7b98b4a2015-06-15 16:20:26 +010066 raise TypeError("actor_order has to be an array")
67
Javi Merinoadcfc8e2015-06-15 18:29:44 +010068 if not isinstance(map_label, dict):
Javi Merino7b98b4a2015-06-15 16:20:26 +010069 raise TypeError("map_label has to be a dict")
70
71 if "width" not in kwords:
72 kwords["width"] = 20
73 if "height" not in kwords:
74 kwords["height"] = 5
75
76 run_data = []
Javi Merinoacd73d92015-06-15 16:50:01 +010077 for name, path in runs:
Javi Merinoc26a3232015-12-11 18:00:30 +000078 run_data.append(trappy.FTrace(name=name, path=path, scope="thermal"))
Javi Merino435457c2015-08-10 15:59:10 +010079 trappy.wa.SysfsExtractor(path).pretty_print_in_ipython()
Javi Merino7b98b4a2015-06-15 16:20:26 +010080
Javi Merino435457c2015-08-10 15:59:10 +010081 trappy.plot_utils.plot_temperature(run_data, **kwords)
Javi Merino961bd952016-08-22 20:11:39 +010082 if "tz_id" in kwords:
83 del kwords["tz_id"]
84
Javi Merino25265832016-08-22 17:37:19 +010085 try:
86 trappy.plot_utils.plot_load(run_data, map_label, **kwords)
87 except IndexError:
88 raise ValueError("No power allocator traces found. Was IPA active (temp above switch on temperature) and FTrace configured to collect all thermal events?")
Javi Merino435457c2015-08-10 15:59:10 +010089 trappy.plot_utils.plot_allfreqs(run_data, map_label, **kwords)
90 trappy.plot_utils.plot_controller(run_data, **kwords)
91 trappy.plot_utils.plot_input_power(run_data, actor_order, **kwords)
92 trappy.plot_utils.plot_output_power(run_data, actor_order, **kwords)
93 trappy.plot_utils.plot_freq_hists(run_data, map_label)
94 trappy.plot_utils.plot_temperature_hist(run_data)
Javi Merino7b98b4a2015-06-15 16:20:26 +010095
96def summary_plots(actor_order, map_label, **kwords):
97 """A summary of plots for a given run
98
Kapileshwar Singhe9da7c62015-09-04 14:55:01 +010099 .. warning::
100
101 This is a wrapper around compare_runs(). Use that instead.
102 """
Javi Merino7b98b4a2015-06-15 16:20:26 +0100103
104 path = kwords.pop("path", ".")
105 title = kwords.pop("title", "")
106
107 return compare_runs(actor_order, map_label, [(title, path)], **kwords)