-
Notifications
You must be signed in to change notification settings - Fork 27
/
run_framework.py
83 lines (76 loc) · 3.04 KB
/
run_framework.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import argparse
import os
import pathlib
import sys
from multiprocessing import Process
from npbench.infrastructure import (Benchmark, generate_framework, LineCount,
Test, utilities as util)
def run_benchmark(benchname, fname, preset, validate, repeat, timeout,
ignore_errors, save_strict, load_strict):
frmwrk = generate_framework(fname, save_strict, load_strict)
numpy = generate_framework("numpy")
bench = Benchmark(benchname)
lcount = LineCount(bench, frmwrk, numpy)
lcount.count()
test = Test(bench, frmwrk, numpy)
test.run(preset, validate, repeat, timeout, ignore_errors)
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument("-f",
"--framework",
type=str,
nargs="?",
default="numpy")
parser.add_argument("-p",
"--preset",
choices=['S', 'M', 'L', 'paper'],
nargs="?",
default='S')
parser.add_argument("-m", "--mode", type=str, nargs="?", default="main")
parser.add_argument("-v",
"--validate",
type=util.str2bool,
nargs="?",
default=True)
parser.add_argument("-r", "--repeat", type=int, nargs="?", default=10)
parser.add_argument("-t",
"--timeout",
type=float,
nargs="?",
default=200.0)
parser.add_argument("--ignore-errors",
type=util.str2bool,
nargs="?",
default=True)
parser.add_argument("-s",
"--save-strict-sdfg",
type=util.str2bool,
nargs="?",
default=False)
parser.add_argument("-l",
"--load-strict-sdfg",
type=util.str2bool,
nargs="?",
default=False)
args = vars(parser.parse_args())
parent_folder = pathlib.Path(__file__).parent.absolute()
bench_dir = parent_folder.joinpath("bench_info")
pathlist = pathlib.Path(bench_dir).rglob('*.json')
benchnames = [os.path.basename(path)[:-5] for path in pathlist]
benchnames.sort()
failed = []
for benchname in benchnames:
p = Process(target=run_benchmark,
args=(benchname, args["framework"], args["preset"],
args["validate"], args["repeat"], args["timeout"],
args["ignore_errors"], args["save_strict_sdfg"],
args["load_strict_sdfg"]))
p.start()
p.join()
exit_code = p.exitcode
if exit_code != 0:
failed.append(benchname)
if len(failed) != 0:
print(f"Failed: {len(failed)} out of {len(benchnames)}")
for bench in failed:
print(bench)