From 20484f8a74277c6c7b265b7d7798078746d534e8 Mon Sep 17 00:00:00 2001 From: John Zhang Date: Thu, 22 Jun 2017 15:25:34 +1000 Subject: [PATCH] vmargs improvement --- docs/config.md | 15 ++++++++++++--- example/bm_btree.yml | 8 ++++++-- mubench/lang/mu.py | 23 +++++++++++++++++++++-- mubench/lang/rpython.py | 27 ++++++++++++++++++++++++--- 4 files changed, 63 insertions(+), 10 deletions(-) diff --git a/docs/config.md b/docs/config.md index c1f5125..5e6f480 100644 --- a/docs/config.md +++ b/docs/config.md @@ -221,6 +221,7 @@ language: compiler: exec: # optional, string args: # optional, list of string + vmargs: # optional, list of string runner: flags: # optional ``` @@ -250,6 +251,15 @@ def target(driver, args): # target definition ``` +If `backend` is `mu`, `vmargs` key can be used to specify VM options. +The value of this key is a list of strings. +The framework will join this list together with appropriate separators according to the selected Mu implementation and pass the joint string to the VM initialisation function. + +> Note, because the framework passes a list of strings to create the subprocess, +> the flag `--mu-vmargs=` to RPython displayed on the commandline omits the quotation mark (`'`). +> If the command is copied and pasted to the command line, make sure the qutation mark is added to the +> argument string. + The `exec` key can be used to specify a Python 2.7 interpreter for compiling RPython. By default [PyPy](http://pypy.org/) is used because of its speed. @@ -277,7 +287,7 @@ language: source: build_(benchname).c # required, string compiler: exec: # optional, string - vmarg: # optional, string + vmargs: # optional, string ``` Compile and run a C source file consisting of Mu API calls to construct the Mu bundle, then run the bundle on the specified Mu implementation. @@ -288,8 +298,7 @@ Generally the `source` file should be in the form of `build_(bench).c`, since th `clang` is the default C compiler. This can be changed in the optional `exec` key. -`vmarg` key can be used to pass an argument string to the VM initialiser. -Note that in the case of Holstein, since the option items are joined with `'\n'`, it needs be `'\\n'` in the string here. +The meaning and requirement for `vmargs` key is the same with RPython. Same requirements for `environ` and `runner` from [RPython](#rpython) apply. diff --git a/example/bm_btree.yml b/example/bm_btree.yml index b199cd9..1808c20 100644 --- a/example/bm_btree.yml +++ b/example/bm_btree.yml @@ -14,7 +14,7 @@ btree: backend: c source: targetbtree.py environ: - PYPY_USESSION_BASENAME: &basename "${MUBENCH_TASKSET_NAME}_${MUBENCH_TASK_NAME}" + PYPY_USESSION_BASENAME: "${MUBENCH_TASKSET_NAME}_${MUBENCH_TASK_NAME}" rpyzebu: language: name: rpython @@ -22,4 +22,8 @@ btree: impl: zebu source: targetbtree.py environ: - PYPY_USESSION_BASENAME: *basename + PYPY_USESSION_BASENAME: "${MUBENCH_TASKSET_NAME}_${MUBENCH_TASK_NAME}" + compiler: + vmargs: + - --gc-immixspace-size=524288000 # 500M + - --gc-lospace-size=104587600 # 100M diff --git a/mubench/lang/mu.py b/mubench/lang/mu.py index 3370ce1..2bf5efa 100644 --- a/mubench/lang/mu.py +++ b/mubench/lang/mu.py @@ -74,7 +74,26 @@ class Mu(Language): cc.setdefault('libmu_link_name', libname) # vmarg - cc['vmarg'] = expandenv(cc.get('vmarg', ""), task.env) + def set_default_args(defl_d, vmargs): + # include default args if not specified, otherwise use custom-defined value + for key, val in defl_d.items(): + if not any([key in arg for arg in vmargs]): + vmargs.append('%(key)s=%(val)s' % locals()) + return vmargs + + vmargs = list(map(lambda a: expandenv(a, task.env), cc.get('vmargs', []))) + if lc['impl'] == 'holstein': + separators = '\n' + default_args = {} + else: # zebu + separators = ' ' + emit_dir = task.output_dir / ('%s_%s-emit' % (task.taskset.name, task.name)) + default_args = { + '--aot-emit-dir': str(emit_dir) + } + vmargs = set_default_args(default_args, vmargs) + vmarg_s = separators.join(vmargs) + cc['vmarg_s'] = vmarg_s return cc @classmethod @@ -134,7 +153,7 @@ class Mu(Language): # Then run the build program to get the boot image target = target_dir / target_name cmd = [build_target] - cmd.append(cc['vmarg']) + cmd.append(cc['vmarg_s']) cmd.append(target) cls.run_in_subproc(cmd, task.env) diff --git a/mubench/lang/rpython.py b/mubench/lang/rpython.py index 6b76abc..99722b7 100644 --- a/mubench/lang/rpython.py +++ b/mubench/lang/rpython.py @@ -76,6 +76,29 @@ class RPython(Language): # flags cc['flags'] = list(map(lambda a: expandenv(a, task.env), cc.get('flags', []))) + if lc['backend'] == 'mu': + # vmargs + def set_default_args(defl_d, vmargs): + # include default args if not specified, otherwise use custom-defined value + for key, val in defl_d.items(): + if not any([key in arg for arg in vmargs]): + vmargs.append('%(key)s=%(val)s' % locals()) + return vmargs + + vmargs = list(map(lambda a: expandenv(a, task.env), cc.get('vmargs', []))) + if lc['impl'] == 'holstein': + separators = '\n' + default_args = {} + else: # zebu + separators = ' ' + emit_dir = task.output_dir / ('%s_%s-emit' % (task.taskset.name, task.name)) + default_args = { + '--aot-emit-dir': str(emit_dir) + } + vmargs = set_default_args(default_args, vmargs) + vmarg_s = separators.join(vmargs) + cc['vmarg_s'] = vmarg_s + return cc @classmethod @@ -115,9 +138,7 @@ class RPython(Language): if bk == 'mu': flags.append('--mu-impl=%(impl)s' % task.lang) flags.append('--mu-suplibdir=%s' % task.output_dir) - if task.lang['impl'] == 'zebu': - emit_dir = task.output_dir / ('%s_%s-emit' % (task.taskset.name, task.name)) - flags.append('--mu-vmargs=--aot-emit-dir=%s' % emit_dir) + flags.append("--mu-vmargs=%(vmarg_s)s" % task.compiler) flags.extend(task.compiler['flags']) target_dir = task.output_dir -- 2.26.2