mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-20 11:58:55 +00:00
wa/workloads: Update to use new cpu_mask type
Update workloads that allow for specifying which cpus to be ran on to all use the same interface while maintaining backwards compatibility with the existing configuration options.
This commit is contained in:
parent
670fe6fb83
commit
8d7d32d180
@ -20,6 +20,7 @@ import re
|
||||
|
||||
from wa import Workload, Parameter, ConfigError, Executable
|
||||
from wa.utils.exec_control import once
|
||||
from wa.utils.types import cpu_mask
|
||||
|
||||
|
||||
class Dhrystone(Workload):
|
||||
@ -65,11 +66,11 @@ class Dhrystone(Workload):
|
||||
The delay, in seconds, between kicking off of dhrystone
|
||||
threads (if ``threads`` > 1).
|
||||
''')),
|
||||
Parameter('taskset_mask', kind=int, default=0,
|
||||
description='''
|
||||
The processes spawned by dhrystone will be pinned to cores as
|
||||
specified by this parameter.
|
||||
'''),
|
||||
Parameter('cpus', kind=cpu_mask, default=0, aliases=['taskset_mask'],
|
||||
description=''' The processes spawned by dhrystone will be
|
||||
pinned to cores as specified by this parameter. The mask can
|
||||
be specified directly as a mask, as a list of cpus or a sysfs-
|
||||
style string '''),
|
||||
]
|
||||
|
||||
@once
|
||||
@ -83,9 +84,9 @@ class Dhrystone(Workload):
|
||||
execution_mode = '-l {}'.format(self.mloops)
|
||||
else:
|
||||
execution_mode = '-r {}'.format(self.duration)
|
||||
if self.taskset_mask:
|
||||
taskset_string = '{} taskset 0x{:x} '.format(self.target.busybox,
|
||||
self.taskset_mask)
|
||||
if self.cpus:
|
||||
taskset_string = '{} taskset {} '.format(self.target.busybox,
|
||||
self.cpus.mask())
|
||||
else:
|
||||
taskset_string = ''
|
||||
self.command = '{}{} {} -t {} -d {}'.format(taskset_string,
|
||||
|
@ -20,6 +20,7 @@ import re
|
||||
|
||||
from wa import Workload, Parameter, Executable
|
||||
from wa.utils.exec_control import once
|
||||
from wa.utils.types import cpu_mask
|
||||
|
||||
|
||||
THIS_DIR = os.path.dirname(__file__)
|
||||
@ -52,11 +53,12 @@ class Memcpy(Workload):
|
||||
description='''
|
||||
Specfies the number of iterations that will be performed.
|
||||
'''),
|
||||
Parameter('cpus', kind=list,
|
||||
Parameter('cpus', kind=cpu_mask, default=0,
|
||||
description='''
|
||||
A list of integers specifying ordinals of cores to which the
|
||||
affinity of the test process should be set. If not specified,
|
||||
all available cores will be used.
|
||||
The cpus for which the affinity of the test
|
||||
process should be set, specified as a mask, as a list of
|
||||
cpus or a sysfs-style string. If not specified, all available
|
||||
cores will be used.
|
||||
'''),
|
||||
]
|
||||
@once
|
||||
@ -68,7 +70,7 @@ class Memcpy(Workload):
|
||||
|
||||
def setup(self, context):
|
||||
self.command = '{} -i {} -s {}'.format(Memcpy.target_exe, self.iterations, self.buffer_size)
|
||||
for c in (self.cpus or []):
|
||||
for c in (self.cpus.list()):
|
||||
self.command += ' -c {}'.format(c)
|
||||
self.result = None
|
||||
|
||||
|
@ -24,6 +24,7 @@ from wa import Workload, Parameter, Executable, File
|
||||
from wa.framework.exception import WorkloadError, ResourceError, ConfigError
|
||||
from wa.utils.misc import check_output
|
||||
from wa.utils.exec_control import once
|
||||
from wa.utils.types import cpu_mask
|
||||
|
||||
|
||||
RAW_OUTPUT_FILENAME = 'raw-output.txt'
|
||||
@ -127,7 +128,7 @@ class RtApp(Workload):
|
||||
Duration of the workload execution in Seconds. If specified, this
|
||||
will override the corresponding parameter in the JSON config.
|
||||
'''),
|
||||
Parameter('taskset_mask', kind=int,
|
||||
Parameter('cpus', kind=cpu_mask, default=0, aliases=['taskset_mask'],
|
||||
description='Constrain execution to specific CPUs.'),
|
||||
Parameter('uninstall_on_exit', kind=bool, default=False,
|
||||
description="""
|
||||
@ -170,7 +171,7 @@ class RtApp(Workload):
|
||||
def run(self, context):
|
||||
self.output = self.target.invoke(self.command,
|
||||
in_directory=self.target_working_directory,
|
||||
on_cpus=self.taskset_mask,
|
||||
on_cpus=self.cpus and self.cpus.list() or None,
|
||||
redirect_stderr=True,
|
||||
timeout=self.timeout,
|
||||
as_root=self.target.is_rooted)
|
||||
|
@ -20,7 +20,7 @@ import os
|
||||
from wa import Workload, Parameter, Executable, WorkloadError, ConfigError
|
||||
from wa.utils.exec_control import once
|
||||
from wa.utils.misc import parse_value
|
||||
from wa.utils.types import numeric
|
||||
from wa.utils.types import numeric, cpu_mask
|
||||
|
||||
|
||||
class Sysbench(Workload):
|
||||
@ -84,10 +84,11 @@ class Sysbench(Workload):
|
||||
Additional parameters to be passed to sysbench as a single
|
||||
string.
|
||||
'''),
|
||||
Parameter('taskset_mask', kind=int, default=0,
|
||||
Parameter('cpus', kind=cpu_mask, default=0, aliases=['taskset_mask'],
|
||||
description='''
|
||||
The processes spawned by sysbench will be pinned to cores as
|
||||
specified by this parameter.
|
||||
The processes spawned by sysbench will be
|
||||
pinned to cores as specified by this parameter. Can be
|
||||
provided as a mask, a list of cpus or a sysfs-style string.
|
||||
'''),
|
||||
]
|
||||
|
||||
@ -158,8 +159,8 @@ class Sysbench(Workload):
|
||||
if self.file_test_mode:
|
||||
param_strings.append('--file-test-mode={}'.format(self.file_test_mode))
|
||||
sysbench_command = '{} {} {} run'.format(self.target_binary, ' '.join(param_strings), self.cmd_params)
|
||||
if self.taskset_mask:
|
||||
taskset_string = '{} taskset 0x{:x} '.format(self.target.busybox, self.taskset_mask)
|
||||
if self.cpus:
|
||||
taskset_string = '{} taskset {} '.format(self.target.busybox, self.cpus.mask())
|
||||
else:
|
||||
taskset_string = ''
|
||||
return 'cd {} && {} {} > sysbench_result.txt'.format(self.target.working_directory, taskset_string, sysbench_command)
|
||||
|
Loading…
x
Reference in New Issue
Block a user