To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.7% of users enabled 2FA.

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