-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfaros-config.py
executable file
·108 lines (98 loc) · 4.3 KB
/
faros-config.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/usr/bin/env python3
#
# Copyright 2020 Lawrence Livermore National Security, LLC
# and project developers
#
# LLNL release number LLNL-CODE-813267
#
# Author: Giorgis Georgakoudis, [email protected]
#
# SPDX-License-Identifier: "Apache-2.0 WITH LLVM-exception"
#
# See top-level files LICENSE and NOTICE for details.
#
import argparse
import yaml
from libs.faros import faroslib as faros
def main():
parser = argparse.ArgumentParser(
description='Benchmark and analyze programs compiled with different compilation options.')
parser.add_argument('-i', '--input', dest='input', type=str,
help='configuration YAML input file for programs', required=True)
parser.add_argument('-f', '--fetch', dest='fetch', action='store_true',
help='fetch program repos (without building)')
parser.add_argument('-b', '--build', dest='build',
action='store_true', help='build programs (will fetch too)')
parser.add_argument('-r', '--run', dest='run',
type=int, help='run <repetitions>')
parser.add_argument('-g', '--generate', dest='generate',
action='store_true', help='generate compilation reports')
parser.add_argument('-p', '--programs', dest='programs',
type=str, nargs='+', help='programs to run from the config')
parser.add_argument('-t', '--tags', dest='tags', type=str,
nargs='+', help='tagged program to use from the config')
parser.add_argument('-s', '--stats', dest='stats',
action='store_true', help='show run statistics')
parser.add_argument('-d', '--dry-run', dest='dry',
action='store_true', help='enable dry run')
parser.add_argument('-v', '--verbose', dest='verbose',
action='store_true', help='verbose printing')
args = parser.parse_args()
with open(args.input, 'r') as f:
config = yaml.load(f, Loader=CLoader)
print('# apps: ', len(config), ' selected ', args.programs)
if args.verbose:
print('args.programs', args.programs)
print('args.tags', args.tags)
print('args.fetch', args.fetch)
print('args.build', args.build)
print('args.run', args.run)
print('args.generate', args.generate)
programs = []
if args.programs:
if args.programs == ['all']:
programs += config.keys()
else:
programs += args.programs
if args.tags:
for t in args.tags:
programs += [p for p in config.keys() if t in config[p]
['tags'] and p not in programs]
for p in programs:
if args.fetch:
repo_dir = './repos'
fetch_cmd = config[p]['fetch']
faros.fetch(repo_dir, fetch_cmd)
print('Fetched', p, 'successfully under directory', repo_dir)
if args.build:
build_dict = config[p]['build']
fetch_cmd = config[p]['fetch']
repo_dir = './repos'
report_dir = './reports/' + p
build_dir = config[p]['build_dir']
bin_output = config[p]['bin']
clean_cmd = config[p]['clean']
copy_list = config[p]['copy']
for build_kind in build_dict:
bin_dir = './bin/' + p + '/' + build_kind
build_cmd = build_dict[build_kind]
faros.build(fetch_cmd, repo_dir, build_dir, bin_dir, report_dir, bin_output,
build_kind, build_cmd, clean_cmd, copy_list, p)
if args.run:
run_cmd = config[p]['run']
run_input = config[p]['input']
build_list = config[p]['build'].keys()
bin_output = config[p]['bin']
metric_regex = config[p]['measure']
faros.run(run_cmd, run_input, build_list, bin_output,
metric_regex, p, args.run, args.dry)
if args.generate:
report_dir = './reports/' + p
build_dir = './repos/' + config[p]['build_dir']
build_list = config[p]['build'].keys()
faros.generate_remark_reports(report_dir, build_dir, build_list)
if args.stats:
build_list = config[p]['build'].keys()
faros.show_stats(build_list, p)
if __name__ == '__main__':
main()