aboutsummaryrefslogtreecommitdiff
path: root/wa/commands
diff options
context:
space:
mode:
authorMarc Bonnici <marc.bonnici@arm.com>2018-08-02 10:37:42 +0100
committerMarc Bonnici <marc.bonnici@arm.com>2018-08-14 13:41:39 +0100
commit42b3f4cf9f3a7a9e547c896bf910f4ad66ffc98b (patch)
tree7d6cf3c4a35f5976565fc4e8701a4f71133b481c /wa/commands
parent1eaffb6744ad34232ade9959395affd1da8e01f3 (diff)
commands/create: Add special case for EnergyInstruemntBackends
Previously when using the create command for adding EnergyInstruemntBackends they were treated like any other plugin and generated incorrect configuration. Now automatically add the `energy_measurement` instrument and populate it's configuration with the relevant defaults for the specified Backend.
Diffstat (limited to 'wa/commands')
-rw-r--r--wa/commands/create.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/wa/commands/create.py b/wa/commands/create.py
index f6c59fea..4b18ec35 100644
--- a/wa/commands/create.py
+++ b/wa/commands/create.py
@@ -27,6 +27,7 @@ from devlib.utils.types import identifier
from wa import ComplexCommand, SubCommand, pluginloader, settings
from wa.framework.target.descriptor import list_target_descriptions
from wa.framework.exception import ConfigError, CommandError
+from wa.instruments.energy_measurement import EnergyInstrumentBackend
from wa.utils.misc import (ensure_directory_exists as _d, capitalize,
ensure_file_directory_exists as _f)
from wa.utils.serializer import yaml
@@ -51,6 +52,7 @@ class CreateAgendaSubcommand(SubCommand):
self.parser.add_argument('-o', '--output', metavar='FILE',
help='Output file. If not specfied, STDOUT will be used instead.')
+ # pylint: disable=too-many-branches
def execute(self, state, args):
agenda = OrderedDict()
agenda['config'] = OrderedDict(augmentations=[], iterations=args.iterations)
@@ -71,7 +73,15 @@ class CreateAgendaSubcommand(SubCommand):
extcls = pluginloader.get_plugin_class(name)
config = pluginloader.get_default_config(name)
- if extcls.kind == 'workload':
+ # Handle special case for EnergyInstrumentBackends
+ if issubclass(extcls, EnergyInstrumentBackend):
+ if 'energy_measurement' not in agenda['config']['augmentations']:
+ energy_config = pluginloader.get_default_config('energy_measurement')
+ agenda['config']['augmentations'].append('energy_measurement')
+ agenda['config']['energy_measurement'] = energy_config
+ agenda['config']['energy_measurement']['instrument'] = name
+ agenda['config']['energy_measurement']['instrument_parameters'] = config
+ elif extcls.kind == 'workload':
entry = OrderedDict()
entry['name'] = extcls.name
if name != extcls.name: