From ad684697958471077d325ae144a48ad49acd7716 Mon Sep 17 00:00:00 2001 From: Jonathan Herman Date: Mon, 19 Nov 2012 14:53:04 -0500 Subject: Bug fixes for scaling factors. --- parse/dir_map.py | 4 ++-- parse/sched.py | 35 ++++++++++++++++++++++++++++++----- 2 files changed, 32 insertions(+), 7 deletions(-) (limited to 'parse') diff --git a/parse/dir_map.py b/parse/dir_map.py index 319a5de..499c712 100644 --- a/parse/dir_map.py +++ b/parse/dir_map.py @@ -44,7 +44,7 @@ class DirMap(object): if not base_type in measurement: continue # Ex: wcet/avg/max/vary-type/other-stuff.csv - path = [ stat, summary_type, base_type, "vary-%s" % vary ] + path = [ stat, summary_type, base_type, "vary-%s" % vary ] result = measurement[base_type] self.__update_node(path, keys, (vary_value, result)) @@ -68,7 +68,7 @@ class DirMap(object): if node.values: # Leaf with open("/".join(path), "w") as f: - arr = [",".join([str(b) for b in n]) for n in node.values] + arr = [", ".join([str(b) for b in n]) for n in sorted(node.values, key=lambda node: int(node[0]))] f.write("\n".join(arr) + "\n") elif not os.path.isdir(out_path): os.mkdir(out_path) diff --git a/parse/sched.py b/parse/sched.py index bbf6e10..65df8ac 100644 --- a/parse/sched.py +++ b/parse/sched.py @@ -15,7 +15,7 @@ import pprint from collections import namedtuple,defaultdict from operator import methodcaller -from point import Measurement,Type +from point import Measurement,Type,ExpPoint PARAM_RECORD = r"(?P" +\ r"PARAM *?(?P\d+)\/.*?" +\ @@ -43,6 +43,7 @@ COMPLETION_RECORD = r"(?P" +\ TaskConfig = namedtuple('TaskConfig', ['cpu','wcet','period','type','level']) Task = namedtuple('Task', ['pid', 'config', 'run']) +SchedReturn = namedtuple('SchedReturn', ['util', 'wcet_scales']) class LeveledArray(object): """ @@ -193,7 +194,8 @@ def extract_variance(task_dict, data, exp_point): raise Exception("Invalid completion record, missed: %d:" "\n\t%s\n\t%s" % (missed[pid], match.groupdict(), match.group("RECORD"))) - completions[pid] += [duration] + if duration or not completions[pid]: + completions[pid] += [duration] for pid, durations in completions.iteritems(): m = Measurement(pid).from_array(durations) @@ -257,11 +259,21 @@ def get_base_stats(base_file): saved_stats[base_file] = result return result +def compute_util(task_dict): + util = 0 + for task in task_dict.itervalues(): + if task.config.level.lower() == "b": + util += float(task.config.wcet) / task.config.period + return util + def extract_scaling_data(task_dict, data, result, base_file): # Generate trees of tasks with matching configurations data_stats = config_exit_stats(task_dict, data) base_stats = get_base_stats(base_file) + util = compute_util(task_dict) + by_wcet = defaultdict(lambda:[]) + # Scaling factors are calculated by matching groups of tasks with the same # config, then comparing task-to-task exec times in order of PID within # each group @@ -269,7 +281,8 @@ def extract_scaling_data(task_dict, data, result, base_file): avg_scales = LeveledArray("avg-scaling") for config in data_stats: - if len(data_stats[config]) != len(base_stats[config]): + # if len(data_stats[config]) != len(base_stats[config]): + if len(data_stats[config]) >1 or len(base_stats[config]) > 1: # Quit, we are missing a record and can't guarantee # a task-to-task comparison continue @@ -282,14 +295,25 @@ def extract_scaling_data(task_dict, data, result, base_file): avg_scale = float(base_stat[Type.Avg]) / float(data_stat[Type.Avg]) max_scale = float(base_stat[Type.Max]) / float(data_stat[Type.Max]) + if (avg_scale < 1 or max_scale < 1) and config.level.lower() == "b": + print("Task with config {} has sub 1.0 scaling factors!".format(config)) + continue + task = task_dict[data_stat.id] avg_scales.add(task, avg_scale) max_scales.add(task, max_scale) + name = "scaling-exp-{}".format(config.level) + loop_data = {Type.Avg:avg_scale, Type.Max:max_scale, Type.Var:0} + loop_exp = ExpPoint("scaling-id",{name: Measurement("", loop_data)}) + by_wcet[config.wcet] += [loop_exp] + avg_scales.write_measurements(result) max_scales.write_measurements(result) + return SchedReturn(util, by_wcet) + def extract_sched_data(data_file, result, base_file): with open(data_file, 'r') as f: data = f.read() @@ -300,8 +324,9 @@ def extract_sched_data(data_file, result, base_file): extract_tardy_vals(task_dict, data, result) extract_variance(task_dict, data, result) except Exception as e: - print("Error in %s" % data_file) raise e if (base_file): - extract_scaling_data(task_dict, data, result, base_file) + return extract_scaling_data(task_dict, data, result, base_file) + else: + return None -- cgit v1.2.2