Commit 64285523 authored by Paul's avatar Paul
Browse files

Format

parent ad19d4dd
...@@ -4,7 +4,9 @@ import os, json, subprocess, tempfile, sys, argparse ...@@ -4,7 +4,9 @@ import os, json, subprocess, tempfile, sys, argparse
def benchmark_one(config, tuning): def benchmark_one(config, tuning):
with tempfile.NamedTemporaryFile(mode="w+") as tf: with tempfile.NamedTemporaryFile(mode="w+") as tf:
b = { b = {
'settings': {'iterations': 100}, 'settings': {
'iterations': 100
},
'compile_op': { 'compile_op': {
'name': 'ck_gemm', 'name': 'ck_gemm',
'tuning_val': tuning, 'tuning_val': tuning,
...@@ -12,7 +14,8 @@ def benchmark_one(config, tuning): ...@@ -12,7 +14,8 @@ def benchmark_one(config, tuning):
} }
} }
json.dump(b, tf) json.dump(b, tf)
cp = subprocess.run('./bin/gpu-driver {}'.format(tf.name), capture_output=True) cp = subprocess.run('./bin/gpu-driver {}'.format(tf.name),
capture_output=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:
...@@ -22,10 +25,12 @@ def benchmark_one(config, tuning): ...@@ -22,10 +25,12 @@ def benchmark_one(config, tuning):
return float(dtime[:-2]) return float(dtime[:-2])
return sys.float_info.max return sys.float_info.max
def benchmark(config, size): def benchmark(config, size):
times = [benchmark_one(config, i) for i in range(size)] times = [benchmark_one(config, i) for i in range(size)]
return times.index(max(times)) return times.index(max(times))
def benchmark_log(f): def benchmark_log(f):
result = [] result = []
for line in open(f).readlines(): for line in open(f).readlines():
...@@ -40,21 +45,24 @@ def benchmark_log(f): ...@@ -40,21 +45,24 @@ def benchmark_log(f):
def parse_args(): def parse_args():
parser = argparse.ArgumentParser( parser = argparse.ArgumentParser(description="Simple tuner for CK gemms")
description="Simple tuner for CK gemms") parser.add_argument('--log',
parser.add_argument('--log', '-l', '-l',
type=str, type=str,
metavar='file', metavar='file',
help='Path to logfile') help='Path to logfile')
parser.add_argument('--out', '-o', parser.add_argument('--out',
'-o',
type=str, type=str,
metavar='file', metavar='file',
help='Output json file to save tunings') help='Output json file to save tunings')
args = parser.parse_args() args = parser.parse_args()
return args return args
def run(args): def run(args):
tuned = benchmark_log(args.log) tuned = benchmark_log(args.log)
json.dump(tuned, open(args.out, 'w+')) json.dump(tuned, open(args.out, 'w+'))
run(parse_args()) run(parse_args())
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