rteval: Make use of systopology instead of misc in hackbench
PATCH v2 2/6 rteval: Make use of systopology instead of misc in hackbench
- Make use of systopology instead of misc in hackbench
- Add a module docstring
- Make use of f-strings
Signed-off-by John Kacur <[email protected]>
- Add missing "f" from f-string in __starton in hackbench.py
Signed-off-by John Kacur <[email protected]>
--- rteval/modules/loads/hackbench.py | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-)
rteval/modules/loads/hackbench.py +14 -16
@@ -24,6 +24,7 @@ # including keys needed to generate an equivalently functional executable # are deemed to be part of the source code. # +""" Load module - run the hackbench program from rt-tests ad a load """ import sys import os
@@ -34,8 +35,9 @@ import errno from signal import SIGKILL from rteval.modules.loads import CommandLineLoad from rteval.Log import Log -from rteval.misc import expand_cpulist -from rteval.systopology import SysTopology +from rteval.systopology import CpuList, SysTopology + +expand_cpulist = CpuList.expand_cpulist class Hackbench(CommandLineLoad): def __init__(self, config, logger):
@@ -46,7 +48,7 @@ class Hackbench(CommandLineLoad): if self._donotrun: return - 'calculate arguments based on input parameters' + # calculate arguments based on input parameters (mem, units) = self.memsize if units == 'KB': mem = mem / (1024.0 * 1024.0)
@@ -58,9 +60,9 @@ class Hackbench(CommandLineLoad): ratio = float(mem) / float(self.num_cpus) if ratio < 0.75: if self.__cfg.runlowmem: - self._log(Log.WARN, "Low memory system (%f GB/core)!" % ratio) + self._log(Log.WARN, f"Low memory system ({ratio} GB/core)!") else: - self._log(Log.WARN, "Low memory system (%f GB/core)! Not running hackbench" % ratio) + self._log(Log.WARN, f"Low memory system ({ratio} GB/core)! Not running hackbench") self._donotrun = True sysTop = SysTopology()
@@ -85,7 +87,7 @@ class Hackbench(CommandLineLoad): for node, cpus in list(self.cpus.items()): if not cpus: self.nodes.remove(node) - self._log(Log.DEBUG, "node %s has no available cpus, removing" % node) + self._log(Log.DEBUG, f"node {node} has no available cpus, removing") # setup jobs based on the number of cores available per node self.jobs = biggest * 3
@@ -95,7 +97,7 @@ class Hackbench(CommandLineLoad): self.__multinodes = False if len(self.nodes) > 1: self.__multinodes = True - self._log(Log.INFO, "running with multiple nodes (%d)" % len(self.nodes)) + self._log(Log.INFO, f"running with multiple nodes ({len(self.nodes)})") if os.path.exists('/usr/bin/numactl') and not self.cpulist: self.__usenumactl = True self._log(Log.INFO, "using numactl for thread affinity")
@@ -121,7 +123,7 @@ class Hackbench(CommandLineLoad): self.tasks = {} - self._log(Log.DEBUG, "starting loop (jobs: %d)" % self.jobs) + self._log(Log.DEBUG, f"starting loop (jobs: {self.jobs})") self.started = False
@@ -135,14 +137,14 @@ class Hackbench(CommandLineLoad): else: args = self.args - self._log(Log.DEBUG, "starting on node %s: args = %s" % (node, args)) + self._log(Log.DEBUG, f"starting on node {node}: args = {args}") p = subprocess.Popen(args, stdin=self.__nullfp, stdout=self.__out, stderr=self.__err) if not p: - self._log(Log.DEBUG, "hackbench failed to start on node %s" % node) - raise RuntimeError("hackbench failed to start on node %s" % node) + self._log(Log.DEBUG, f"hackbench failed to start on node {node}") + raise RuntimeError(f"hackbench failed to start on node {node}") return p def _WorkloadTask(self):
@@ -181,7 +183,7 @@ class Hackbench(CommandLineLoad): for node in self.nodes: if node in self.tasks and self.tasks[node].poll() is None: - self._log(Log.INFO, "cleaning up hackbench on node %s" % node) + self._log(Log.INFO, f"cleaning up hackbench on node {node}") self.tasks[node].send_signal(SIGKILL) if self.tasks[node].poll() is None: time.sleep(2)
@@ -213,7 +215,3 @@ def ModuleParameters(): def create(config, logger): return Hackbench(config, logger) -# TODO: The following test is broken -#if __name__ == '__main__': -# h = Hackbench(params={'debugging':True, 'verbose':True}) -# h.run()
Signature · 1 line
2.37.1
PATCH 1/1 rteval: cyclictest: Reset cpulist from newly calculated cpus
After we recalculate self.__cpus to only include online cpus, we also need to reset the self.__cpulist which is the collapsed form of the list that we pass as parameters to cyclictest, otherwise we can potentially pass an offline cpu as a parameter cyclictest which will then fail
Signed-off-by John Kacur <[email protected]>
--- rteval/modules/measurement/cyclictest.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
rteval/modules/measurement/cyclictest.py +3 -1
@@ -36,7 +36,7 @@ import libxml2 from rteval.Log import Log from rteval.modules import rtevalModulePrototype from rteval.misc import cpuinfo -from rteval.systopology import CpuList, SysTopology +from rteval.systopology import CpuList, SysTopology, collapse_cpulist expand_cpulist = CpuList.expand_cpulist
@@ -220,6 +220,8 @@ class Cyclictest(rtevalModulePrototype): self.__cpus = expand_cpulist(self.__cpulist) # Only include online cpus self.__cpus = CpuList(self.__cpus).cpulist + # Reset cpulist from the newly calculated self.__cpus + self.__cpulist = collapse_cpulist(self.__cpus) self.__cpus = [str(c) for c in self.__cpus] self.__sparse = True else:
Signature · 1 line
2.37.1