Commit 20484f8a authored by John Zhang's avatar John Zhang

vmargs improvement

parent 4f62d0be
...@@ -221,6 +221,7 @@ language: ...@@ -221,6 +221,7 @@ language:
compiler: compiler:
exec: # optional, string exec: # optional, string
args: # optional, list of string args: # optional, list of string
vmargs: # optional, list of string
runner: runner:
flags: # optional flags: # optional
``` ```
...@@ -250,6 +251,15 @@ def target(driver, args): ...@@ -250,6 +251,15 @@ def target(driver, args):
# target definition # 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. 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. By default [PyPy](http://pypy.org/) is used because of its speed.
...@@ -277,7 +287,7 @@ language: ...@@ -277,7 +287,7 @@ language:
source: build_(benchname).c # required, string source: build_(benchname).c # required, string
compiler: compiler:
exec: # optional, string 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, 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. 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 ...@@ -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. `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. The meaning and requirement for `vmargs` key is the same with RPython.
Note that in the case of Holstein, since the option items are joined with `'\n'`, it needs be `'\\n'` in the string here.
Same requirements for `environ` and `runner` from [RPython](#rpython) apply. Same requirements for `environ` and `runner` from [RPython](#rpython) apply.
...@@ -14,7 +14,7 @@ btree: ...@@ -14,7 +14,7 @@ btree:
backend: c backend: c
source: targetbtree.py source: targetbtree.py
environ: environ:
PYPY_USESSION_BASENAME: &basename "${MUBENCH_TASKSET_NAME}_${MUBENCH_TASK_NAME}" PYPY_USESSION_BASENAME: "${MUBENCH_TASKSET_NAME}_${MUBENCH_TASK_NAME}"
rpyzebu: rpyzebu:
language: language:
name: rpython name: rpython
...@@ -22,4 +22,8 @@ btree: ...@@ -22,4 +22,8 @@ btree:
impl: zebu impl: zebu
source: targetbtree.py source: targetbtree.py
environ: 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
...@@ -74,7 +74,26 @@ class Mu(Language): ...@@ -74,7 +74,26 @@ class Mu(Language):
cc.setdefault('libmu_link_name', libname) cc.setdefault('libmu_link_name', libname)
# vmarg # 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 return cc
@classmethod @classmethod
...@@ -134,7 +153,7 @@ class Mu(Language): ...@@ -134,7 +153,7 @@ class Mu(Language):
# Then run the build program to get the boot image # Then run the build program to get the boot image
target = target_dir / target_name target = target_dir / target_name
cmd = [build_target] cmd = [build_target]
cmd.append(cc['vmarg']) cmd.append(cc['vmarg_s'])
cmd.append(target) cmd.append(target)
cls.run_in_subproc(cmd, task.env) cls.run_in_subproc(cmd, task.env)
......
...@@ -76,6 +76,29 @@ class RPython(Language): ...@@ -76,6 +76,29 @@ class RPython(Language):
# flags # flags
cc['flags'] = list(map(lambda a: expandenv(a, task.env), cc.get('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 return cc
@classmethod @classmethod
...@@ -115,9 +138,7 @@ class RPython(Language): ...@@ -115,9 +138,7 @@ class RPython(Language):
if bk == 'mu': if bk == 'mu':
flags.append('--mu-impl=%(impl)s' % task.lang) flags.append('--mu-impl=%(impl)s' % task.lang)
flags.append('--mu-suplibdir=%s' % task.output_dir) flags.append('--mu-suplibdir=%s' % task.output_dir)
if task.lang['impl'] == 'zebu': flags.append("--mu-vmargs=%(vmarg_s)s" % task.compiler)
emit_dir = task.output_dir / ('%s_%s-emit' % (task.taskset.name, task.name))
flags.append('--mu-vmargs=--aot-emit-dir=%s' % emit_dir)
flags.extend(task.compiler['flags']) flags.extend(task.compiler['flags'])
target_dir = task.output_dir target_dir = task.output_dir
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment