Commit 55b363c9 authored by Paul's avatar Paul
Browse files

Format

parent c0e26328
...@@ -46,6 +46,7 @@ def get_device_time(s): ...@@ -46,6 +46,7 @@ def get_device_time(s):
fields = s.split(',') fields = s.split(',')
return convert_to_float(fields[-1].strip()) return convert_to_float(fields[-1].strip())
def run_driver_ck(config, tuning, iterations): def run_driver_ck(config, tuning, iterations):
b = { b = {
'settings': { 'settings': {
...@@ -60,6 +61,7 @@ def run_driver_ck(config, tuning, iterations): ...@@ -60,6 +61,7 @@ def run_driver_ck(config, tuning, iterations):
} }
return run_driver(b) return run_driver(b)
def benchmark_ck(config, tuning): def benchmark_ck(config, tuning):
try: try:
for line in run_driver_ck(config, tuning, 100): for line in run_driver_ck(config, tuning, 100):
...@@ -71,6 +73,7 @@ def benchmark_ck(config, tuning): ...@@ -71,6 +73,7 @@ def benchmark_ck(config, tuning):
except: except:
return sys.float_info.max return sys.float_info.max
def benchmark(config, size): def benchmark(config, size):
times = [benchmark_ck(config, i) for i in range(size)] times = [benchmark_ck(config, i) for i in range(size)]
return times.index(min(times)) return times.index(min(times))
...@@ -85,17 +88,20 @@ def parse_log(f): ...@@ -85,17 +88,20 @@ def parse_log(f):
config = json.loads(line) config = json.loads(line)
yield config yield config
def precompile(x): def precompile(x):
try: try:
list(run_driver_ck(x[0], x[1], 0)) list(run_driver_ck(x[0], x[1], 0))
except: except:
pass pass
def precompile_log(f, n): def precompile_log(f, n):
solutions = ((config, i) for config in parse_log(f) for i in range(n)) solutions = ((config, i) for config in parse_log(f) for i in range(n))
with multiprocessing.Pool(24) as p: with multiprocessing.Pool(24) as p:
list(p.imap(precompile, solutions)) list(p.imap(precompile, solutions))
def benchmark_log(f, n): def benchmark_log(f, n):
result = [] result = []
for config in parse_log(f): for config in parse_log(f):
...@@ -127,7 +133,7 @@ def parse_args(): ...@@ -127,7 +133,7 @@ def parse_args():
def run(args): def run(args):
if(args.precompile): if (args.precompile):
precompile_log(args.log, args.n) precompile_log(args.log, args.n)
tuned = benchmark_log(args.log, args.n) tuned = benchmark_log(args.log, args.n)
json.dump(tuned, open(args.out, 'w+')) json.dump(tuned, open(args.out, 'w+'))
......
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