WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

Commit ff79fd19 authored by John Zhang's avatar John Zhang
Browse files

debug perfevent; some refactoring

parent 8cb84785
fib:
iterations: 5
benchmark:
name: micro/fib
args:
- 10 # scale factor
- 35
callback:
name: perfevent
param: "cycles"
include_dirs:
- libpfm4/include
- libpfm4/perf_examples
library_dirs:
- libpfm4/lib
libraries:
- pfm
extra_srcs:
- libpfm4/perf_examples/perf_util.c
flags:
- -pthread
tasks:
c_O3:
language: c
source: fib.c
compiler:
flags:
- -O3
......@@ -160,8 +160,8 @@ void cb_report(void* p) {
// reset
int i, ret;
for(i=0; i < perfevent_num_fds; i++) {
ret = ioctl(perfevent_fds[i].fd, PERF_EVENT_IOC_RESET, 0);
for(i=0; i < cb->perfevent_num_fds; i++) {
ret = ioctl(cb->perfevent_fds[i].fd, PERF_EVENT_IOC_RESET, 0);
if (ret)
err(1, "ioctl(reset) failed");
}
......
......@@ -21,6 +21,7 @@ from pathlib import Path
from mubench.lang import Language
from mubench import CALLBACKS_DIR
from mubench.util import expandenv, run_in_subproc
from mubench.util import add_path_to_ld_library_path
class RPython(Language):
......@@ -103,10 +104,8 @@ class RPython(Language):
@classmethod
def check_runner(cls, rc, lc, task):
env = task.env
if lc['backend'] == 'mu':
suplibdir = str(task.output_dir)
libpath_var = 'DYLD_LIBRARY_PATH' if sys.platform == 'darwin' else 'LD_LIBRARY_PATH'
env[libpath_var] = "%s:%s" % (suplibdir, env[libpath_var])
if lc['backend'] == 'mu':
add_path_to_ld_library_path(str(task.output_dir), env)
if lc['impl'] == 'holstein':
mu_holstein_dir = Path(env['MU_HOLSTEIN'])
......
......@@ -26,6 +26,7 @@ from types import SimpleNamespace
from mubench import SUITE_DIR, CALLBACKS_DIR
from mubench.conf import settings
from mubench.util import expandenv, dictify, run_in_subproc, ExecutionFailure
from mubench.util import add_path_to_ld_library_path
from mubench.lang import get_lang, Language
from mubench.models.result import Result
......@@ -67,15 +68,17 @@ class TaskSet:
callback['param'] = expandenv(callback['param'], self.env)
# compiled callback shared library
if sys.platform == 'darwin':
libpath_var = 'DYLD_LIBRARY_PATH'
libext = '.dylib'
else:
libpath_var = 'LD_LIBRARY_PATH'
libext = '.so'
self.env[libpath_var] = '%s:%s' % (self.output_dir, self.env.get(libpath_var, ""))
libext = '.dylib' if sys.platform == 'darwin' else '.so'
add_path_to_ld_library_path(str(self.output_dir), self.env)
self.callback['dylib'] = self.output_dir / ('libcb_%(name)s' % self.callback + libext)
# TODO: refactor this!
for d in self.callback['library_dirs']:
p = Path(expandenv(d, self.env))
if not p.is_absolute():
p = CALLBACKS_DIR / p # default relative to CALLBACKS_DIR
add_path_to_ld_library_path(str(p), self.env)
@staticmethod
def from_config_dict(name, conf_d, conf_dir=None):
# output directory
......@@ -232,13 +235,21 @@ class TaskSet:
# libraries
for lib in self.callback['libraries']:
cmd.append('-l %s' % lib)
cmd.append('-l%s' % lib)
# flags
cmd.extend(self.callback.get('flags', []))
# output
cmd.extend(['-o', self.callback['dylib']])
# source
cmd.append(CALLBACKS_DIR / ('cb_%(name)s.c' % self.callback))
for src in self.callback.get('extra_srcs', []):
p = Path(expandenv(src, self.env))
if not p.is_absolute():
p = CALLBACKS_DIR / p # default relative to CALLBACKS_DIR
cmd.append(p)
run_in_subproc(cmd, self.env)
......
......@@ -54,7 +54,7 @@ class ExecutionFailure(Exception):
def run_in_subproc(cmd, env=None, **kwds):
cmd = list(map(str, cmd))
logger.info(" ".join(cmd))
import resource
ru0 = resource.getrusage(resource.RUSAGE_CHILDREN)
t0 = ru0.ru_utime + ru0.ru_stime
......@@ -69,4 +69,9 @@ def run_in_subproc(cmd, env=None, **kwds):
if res.returncode != 0:
raise ExecutionFailure(cmd, res)
return res, (t1 - t0)
\ No newline at end of file
return res, (t1 - t0)
def add_path_to_ld_library_path(path_s, env):
import sys
libpath_var = 'DYLD_LIBRARY_PATH' if sys.platform == 'darwin' else 'LD_LIBRARY_PATH'
env[libpath_var] = "%s:%s" % (path_s, env.get(libpath_var, ""))
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