Commit 0f7d5123 authored by Paul's avatar Paul
Browse files

Fixes

parent 64285523
import os, json, subprocess, tempfile, sys, argparse import os, json, subprocess, tempfile, sys, argparse, contextlib
@contextlib.contextmanager
def tmp_file(dump=None):
tmp_name = None
try:
with tempfile.NamedTemporaryFile(mode='w+', delete=False) as f:
tmp_name = f.name
if dump:
dump(f)
yield tmp_name
finally:
os.unlink(tmp_name)
def pretty_print(obj):
print(json.dumps(obj, indent=4))
def benchmark_one(config, tuning): def benchmark_one(config, tuning):
with tempfile.NamedTemporaryFile(mode="w+") as tf:
b = { b = {
'settings': { 'settings': {
'iterations': 100 'iterations': 100
...@@ -13,15 +26,17 @@ def benchmark_one(config, tuning): ...@@ -13,15 +26,17 @@ def benchmark_one(config, tuning):
'inputs': config 'inputs': config
} }
} }
json.dump(b, tf) print(b)
cp = subprocess.run('./bin/gpu-driver {}'.format(tf.name), with tmp_file(lambda tf: json.dump(b, tf)) as tf:
capture_output=True) cp = subprocess.run('./bin/gpu-driver {}'.format(tf),
capture_output=True, shell=True)
for line in cp.stdout.decode().split("\n"): for line in cp.stdout.decode().split("\n"):
s = line.strip() s = line.strip()
if not s: if not s:
continue continue
fields = s.split(',') fields = s.split(',')
dtime = fields[-1].strip() dtime = fields[-1].strip()
print(dtime)
return float(dtime[:-2]) return float(dtime[:-2])
return sys.float_info.max return sys.float_info.max
......
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