Brendan Jackman | e81fdcb | 2017-01-04 17:10:29 +0000 | [diff] [blame] | 1 | # Copyright 2015-2017 ARM Limited |
Javi Merino | 7b98b4a | 2015-06-15 16:20:26 +0100 | [diff] [blame] | 2 | # |
Javi Merino | aace7c0 | 2015-08-10 14:10:47 +0100 | [diff] [blame] | 3 | # 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 Merino | 7b98b4a | 2015-06-15 16:20:26 +0100 | [diff] [blame] | 16 | |
Javi Merino | c26a323 | 2015-12-11 18:00:30 +0000 | [diff] [blame] | 17 | import trappy.ftrace |
Javi Merino | 7b98b4a | 2015-06-15 16:20:26 +0100 | [diff] [blame] | 18 | |
| 19 | def compare_runs(actor_order, map_label, runs, **kwords): |
| 20 | """A side by side comparison of multiple runs |
| 21 | |
Javi Merino | dc25fe2 | 2015-06-16 17:34:52 +0100 | [diff] [blame] | 22 | Plots include temperature, utilization, frequencies, PID |
Javi Merino | 7b98b4a | 2015-06-15 16:20:26 +0100 | [diff] [blame] | 23 | controller and power. |
| 24 | |
Kapileshwar Singh | e9da7c6 | 2015-09-04 14:55:01 +0100 | [diff] [blame] | 25 | :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 Merino | 7b98b4a | 2015-06-15 16:20:26 +0100 | [diff] [blame] | 28 | |
Kapileshwar Singh | e9da7c6 | 2015-09-04 14:55:01 +0100 | [diff] [blame] | 29 | For Example: |
| 30 | :: |
Javi Merino | 7b98b4a | 2015-06-15 16:20:26 +0100 | [diff] [blame] | 31 | |
Kapileshwar Singh | e9da7c6 | 2015-09-04 14:55:01 +0100 | [diff] [blame] | 32 | ["GPU", "A15", "A7"] |
Javi Merino | 7b98b4a | 2015-06-15 16:20:26 +0100 | [diff] [blame] | 33 | |
Kapileshwar Singh | e9da7c6 | 2015-09-04 14:55:01 +0100 | [diff] [blame] | 34 | :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 Merino | 961bd95 | 2016-08-22 20:11:39 +0100 | [diff] [blame] | 53 | :param tz_id: thermal zone id as it appears in the id field of the |
| 54 | thermal_temperature trace event |
| 55 | |
Kapileshwar Singh | e9da7c6 | 2015-09-04 14:55:01 +0100 | [diff] [blame] | 56 | :type actor_order: list |
| 57 | :type map_label: dict |
| 58 | :type runs: list |
Javi Merino | 961bd95 | 2016-08-22 20:11:39 +0100 | [diff] [blame] | 59 | :type tz_id: int |
| 60 | |
Javi Merino | 7b98b4a | 2015-06-15 16:20:26 +0100 | [diff] [blame] | 61 | """ |
Javi Merino | ec2ffe0 | 2015-12-07 15:05:13 +0000 | [diff] [blame] | 62 | import trappy.plot_utils |
| 63 | import trappy.wa |
Javi Merino | 7b98b4a | 2015-06-15 16:20:26 +0100 | [diff] [blame] | 64 | |
Javi Merino | adcfc8e | 2015-06-15 18:29:44 +0100 | [diff] [blame] | 65 | if not isinstance(actor_order, list): |
Javi Merino | 7b98b4a | 2015-06-15 16:20:26 +0100 | [diff] [blame] | 66 | raise TypeError("actor_order has to be an array") |
| 67 | |
Javi Merino | adcfc8e | 2015-06-15 18:29:44 +0100 | [diff] [blame] | 68 | if not isinstance(map_label, dict): |
Javi Merino | 7b98b4a | 2015-06-15 16:20:26 +0100 | [diff] [blame] | 69 | 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 Merino | acd73d9 | 2015-06-15 16:50:01 +0100 | [diff] [blame] | 77 | for name, path in runs: |
Javi Merino | c26a323 | 2015-12-11 18:00:30 +0000 | [diff] [blame] | 78 | run_data.append(trappy.FTrace(name=name, path=path, scope="thermal")) |
Javi Merino | 435457c | 2015-08-10 15:59:10 +0100 | [diff] [blame] | 79 | trappy.wa.SysfsExtractor(path).pretty_print_in_ipython() |
Javi Merino | 7b98b4a | 2015-06-15 16:20:26 +0100 | [diff] [blame] | 80 | |
Javi Merino | 435457c | 2015-08-10 15:59:10 +0100 | [diff] [blame] | 81 | trappy.plot_utils.plot_temperature(run_data, **kwords) |
Javi Merino | 961bd95 | 2016-08-22 20:11:39 +0100 | [diff] [blame] | 82 | if "tz_id" in kwords: |
| 83 | del kwords["tz_id"] |
| 84 | |
Javi Merino | 2526583 | 2016-08-22 17:37:19 +0100 | [diff] [blame] | 85 | 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 Merino | 435457c | 2015-08-10 15:59:10 +0100 | [diff] [blame] | 89 | 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 Merino | 7b98b4a | 2015-06-15 16:20:26 +0100 | [diff] [blame] | 95 | |
| 96 | def summary_plots(actor_order, map_label, **kwords): |
| 97 | """A summary of plots for a given run |
| 98 | |
Kapileshwar Singh | e9da7c6 | 2015-09-04 14:55:01 +0100 | [diff] [blame] | 99 | .. warning:: |
| 100 | |
| 101 | This is a wrapper around compare_runs(). Use that instead. |
| 102 | """ |
Javi Merino | 7b98b4a | 2015-06-15 16:20:26 +0100 | [diff] [blame] | 103 | |
| 104 | path = kwords.pop("path", ".") |
| 105 | title = kwords.pop("title", "") |
| 106 | |
| 107 | return compare_runs(actor_order, map_label, [(title, path)], **kwords) |