From 4826f8f2f20ac710b450886739dac5db0f37bdb4 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Wed, 11 Oct 2017 17:10:50 +0100 Subject: [PATCH 1/2] framework/target: fix generic "frequency" runtime param The generic "frequency" runtime parameter was only being set when there are common frequences between avialable cores. It should always be set, even if there are no frequencies in common, as it still valid to use it with special values "min" and "max", in which case it should resolve correctly to the appropriate frequencies. --- wa/framework/target/runtime_config.py | 87 ++++++++++++++------------- 1 file changed, 46 insertions(+), 41 deletions(-) diff --git a/wa/framework/target/runtime_config.py b/wa/framework/target/runtime_config.py index 552e4375..7aadc3e2 100644 --- a/wa/framework/target/runtime_config.py +++ b/wa/framework/target/runtime_config.py @@ -1,5 +1,6 @@ import logging from collections import defaultdict, OrderedDict +from copy import copy from wa.framework.exception import ConfigError from wa.framework.plugin import Plugin, Parameter @@ -255,10 +256,8 @@ class FreqValue(object): return value elif isinstance(value, basestring): value = caseless_string(value) - if value == 'max': - return self.values[-1] - elif value == 'min': - return self.values[0] + if value in ['min', 'max']: + return value msg = 'Invalid frequency value: {}; Must be in {}' raise ValueError(msg.format(value, self.values)) @@ -266,6 +265,7 @@ class FreqValue(object): def __str__(self): return 'valid frequency value: {}'.format(self.values) + class CpufreqRuntimeConfig(RuntimeConfig): name = 'rt-cpufreq' @@ -311,35 +311,34 @@ class CpufreqRuntimeConfig(RuntimeConfig): return self._retrive_cpufreq_info() - common_freqs, common_gov = self._get_common_values() + all_freqs, common_freqs, common_gov = self._get_common_values() # Add common parameters if available. - if common_freqs: - freq_val = FreqValue(common_freqs) - param_name = 'frequency' - self._runtime_params[param_name] = \ - RuntimeParameter(param_name, kind=freq_val, - setter=self.set_frequency, - setter_params={'core': None}, - description=""" - The desired frequency for all cores - """) - param_name = 'max_frequency' - self._runtime_params[param_name] = \ - RuntimeParameter(param_name, kind=freq_val, - setter=self.set_max_frequency, - setter_params={'core': None}, - description=""" - The maximum frequency for all cores - """) - param_name = 'min_frequency' - self._runtime_params[param_name] = \ - RuntimeParameter(param_name, kind=freq_val, - setter=self.set_min_frequency, - setter_params={'core': None}, - description=""" - The minimum frequency for all cores - """) + freq_val = FreqValue(all_freqs) + param_name = 'frequency' + self._runtime_params[param_name] = \ + RuntimeParameter(param_name, kind=freq_val, + setter=self.set_frequency, + setter_params={'core': None}, + description=""" + The desired frequency for all cores + """) + param_name = 'max_frequency' + self._runtime_params[param_name] = \ + RuntimeParameter(param_name, kind=freq_val, + setter=self.set_max_frequency, + setter_params={'core': None}, + description=""" + The maximum frequency for all cores + """) + param_name = 'min_frequency' + self._runtime_params[param_name] = \ + RuntimeParameter(param_name, kind=freq_val, + setter=self.set_min_frequency, + setter_params={'core': None}, + description=""" + The minimum frequency for all cores + """) if common_gov: param_name = 'governor' @@ -351,6 +350,7 @@ class CpufreqRuntimeConfig(RuntimeConfig): description=""" The governor to be set for all cores """) + param_name = 'governor_tunables' self._runtime_params[param_name] = \ RuntimeParameter(param_name, kind=dict, @@ -544,8 +544,14 @@ class CpufreqRuntimeConfig(RuntimeConfig): self.configure_governor(cpu, config.get('governor'), config.get('governor_tunables')) + + frequency = config.get('frequency') + if frequency == 'min': + frequency = self.target.cpufreq.get_min_frequency(cpu) + elif frequency == 'max': + frequency = self.target.cpufreq.get_max_frequency(cpu) self.configure_frequency(cpu, - config.get('frequency'), + frequency, config.get('min_frequency'), config.get('max_frequency'), config.get('governor')) @@ -647,21 +653,20 @@ class CpufreqRuntimeConfig(RuntimeConfig): ''' Find common values for frequency and governors across all cores''' common_freqs = None common_gov = None + all_freqs = None initialized = False for cpu in resolve_unique_domain_cpus('all', self.target): if not initialized: initialized = True - if self.supported_cpu_freqs.get(cpu): - common_freqs = set(self.supported_cpu_freqs.get(cpu)) - if self.supported_cpu_governors.get(cpu): - common_gov = set(self.supported_cpu_governors.get(cpu)) + common_freqs = set(self.supported_cpu_freqs.get(cpu) or []) + all_freqs = copy(common_freqs) + common_gov = set(self.supported_cpu_governors.get(cpu) or []) else: - if self.supported_cpu_freqs.get(cpu): - common_freqs = common_freqs.intersection(self.supported_cpu_freqs.get(cpu)) - if self.supported_cpu_governors.get(cpu): - common_gov = common_gov.intersection(self.supported_cpu_governors.get(cpu)) + common_freqs = common_freqs.intersection(self.supported_cpu_freqs.get(cpu) or set()) + all_freqs = all_freqs.union(self.supported_cpu_freqs.get(cpu) or set()) + common_gov = common_gov.intersection(self.supported_cpu_governors.get(cpu)) - return common_freqs, common_gov + return all_freqs, common_freqs, common_gov class IdleStateValue(object): From 890428dbf67127a91588168675fde9339bcbab50 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Wed, 11 Oct 2017 17:24:09 +0100 Subject: [PATCH 2/2] framework/execution: fix end of run status reporting Changes to the Status enum introduced by 31a535b5 and a9959550 broke ran Jobs summary status at the end of the run. This fixes it so that the total number of jobs and individual status counts are reported correctly. --- wa/framework/execution.py | 2 +- wa/framework/run.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/wa/framework/execution.py b/wa/framework/execution.py index 4cf7c950..159957ea 100644 --- a/wa/framework/execution.py +++ b/wa/framework/execution.py @@ -312,7 +312,7 @@ class Executor(object): counter = context.run_state.get_status_counts() parts = [] - for status in reversed(Status.values): + for status in reversed(Status.levels): if status in counter: parts.append('{} {}'.format(counter[status], status)) self.logger.info(status_summary + ', '.join(parts)) diff --git a/wa/framework/run.py b/wa/framework/run.py index aefd52f4..5b9f577a 100644 --- a/wa/framework/run.py +++ b/wa/framework/run.py @@ -76,7 +76,7 @@ class RunState(object): @property def num_completed_jobs(self): return sum(1 for js in self.jobs.itervalues() - if js.status > Status.SKIPPED) + if js.status > Status.RUNNING) def __init__(self): self.jobs = OrderedDict()