Skip to content
Snippets Groups Projects
Unverified Commit ff1b19df authored by René Fritze's avatar René Fritze
Browse files

[python] add script to run speedup bench on numa nodes

parent 7aed8346
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env python3
"""Run a speedup series benchmark of a given executable on a node with libnuma
Usage: numa_speedup.py MIN_CORE MAX_CORE ARG_FMT...
Arguments:
ARG_FMT A python format string to allow core count injection in args.
Example: 'mpirun -np {CORECOUNT} my_executable -global.datadir data_{CORECOUNT}'
MIN_CORE Start run at this many cores
MAX_CORE Stop run at this many cores
"""
import subprocess
import numa
import docopt
import itertools
from collections import deque
from copy import deepcopy
def coremap():
if not numa.available():
raise RuntimeError("Numa not available")
node_to_core = {int(i): deque([int(k) for k in numa.node_to_cpus(i)]) for i in range(numa.get_max_node()+1)}
total_core = max(itertools.chain(*node_to_core.values())) + 1
return node_to_core, total_core
def _single_run(cores, arg_fmt):
args = [a.format(CORES=cores, CORECOUNT=len(cores)) for a in arg_fmt]
corestring = ','.join([str(i) for i in cores])
subprocess.call(['numactl', '-C', corestring] + args)
def _assign_core(node_to_core, core_count):
cores = []
node_to_core = deepcopy(node_to_core)
nodes = deque([k for k in node_to_core.keys()])
left = True
while core_count > 0:
if left:
cores.append(node_to_core[nodes[0]].popleft())
else:
cores.append(node_to_core[nodes[0]].pop())
left = not left
nodes.rotate(1)
core_count -= 1
return cores
def run(min_core, max_core, arg_fmt):
node_to_core, total_cores = coremap()
core_count = min_core
max_core = min(max_core, total_cores)
while core_count <= max_core:
cores = _assign_core(node_to_core, core_count)
_single_run(cores, arg_fmt)
core_count *= 2
if __name__ == '__main__':
arguments = docopt.docopt(__doc__)
min_core = int(arguments['MIN_CORE'])
max_core = int(arguments['MAX_CORE'])
arg_fmt = arguments['ARG_FMT']
run(min_core, max_core, arg_fmt)
......@@ -21,8 +21,9 @@ setup(name='dune.xt',
author_email='dune-xt-dev@listserv.uni-muenster.de',
url='https://github.com/dune-community/dune-xt-common',
packages=['dune.xt'],
install_requires=['binpacking==1.3', 'jinja2'],
install_requires=['binpacking==1.3', 'cython', 'jinja2', 'numa', 'docopt'],
scripts=['./scripts/generate_compare_functions.py',
'./scripts/distribute_testing.py',
'./scripts/dxt_code_generation.py',
'./scripts/numa_speedup.py',
'./wrapper/dune_xt_execute.py'])
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment