OLD | NEW |
1 #!/usr/bin/env python2 | 1 #!/usr/bin/env python2 |
2 | 2 |
3 import argparse | 3 import argparse |
4 import os | 4 import os |
5 import sys | 5 import sys |
6 | 6 |
7 import szbuild | 7 import szbuild |
8 | 8 |
9 from utils import FindBaseNaCl, shellcmd | 9 from utils import FindBaseNaCl, shellcmd |
10 | 10 |
11 def main(): | 11 def main(): |
12 """Build native gcc-style executables for one or all Spec2K components. | 12 """Build native gcc-style executables for one or all Spec2K components. |
13 | 13 |
14 Afterwards, the executables can be run from the | 14 Afterwards, the executables can be run from the |
15 native_client/tests/spec2k/ directory as: | 15 native_client/tests/spec2k/ directory as: |
16 './run_all.sh RunBenchmarks SetupGccX8632Opt {train|ref} ...' | 16 './run_all.sh RunBenchmarks SetupGccX8632Opt {train|ref} ...' |
17 -- or -- | 17 -- or -- |
18 './run_all.sh RunBenchmarks SetupPnaclX8632Opt {train|ref} ...' | 18 './run_all.sh RunBenchmarks SetupPnaclX8632Opt {train|ref} ...' |
| 19 -- or -- |
| 20 './run_all.sh RunBenchmarks SetupNonsfiX8632Opt {train|ref} ...' |
19 """ | 21 """ |
20 nacl_root = FindBaseNaCl() | 22 nacl_root = FindBaseNaCl() |
21 # Use the same default ordering as spec2k/run_all.sh. | 23 # Use the same default ordering as spec2k/run_all.sh. |
22 components = [ '177.mesa', '179.art', '183.equake', '188.ammp', '164.gzip', | 24 components = [ '177.mesa', '179.art', '183.equake', '188.ammp', '164.gzip', |
23 '175.vpr', '176.gcc', '181.mcf', '186.crafty', '197.parser', | 25 '175.vpr', '176.gcc', '181.mcf', '186.crafty', '197.parser', |
24 '253.perlbmk', '254.gap', '255.vortex', '256.bzip2', | 26 '253.perlbmk', '254.gap', '255.vortex', '256.bzip2', |
25 '300.twolf', '252.eon' ] | 27 '300.twolf', '252.eon' ] |
26 | 28 |
27 argparser = argparse.ArgumentParser(description=main.__doc__) | 29 argparser = argparse.ArgumentParser(description=main.__doc__) |
28 szbuild.AddOptionalArgs(argparser) | 30 szbuild.AddOptionalArgs(argparser) |
29 argparser.add_argument('--run', dest='run', action='store_true', | 31 argparser.add_argument('--run', dest='run', action='store_true', |
30 help='Run after building') | 32 help='Run after building') |
31 argparser.add_argument('comps', nargs='*', default=components) | 33 argparser.add_argument('comps', nargs='*', default=components) |
32 args = argparser.parse_args() | 34 args = argparser.parse_args() |
33 bad = set(args.comps) - set(components) | 35 bad = set(args.comps) - set(components) |
34 if bad: | 36 if bad: |
35 print 'Unknown component{s}: '.format(s='s' if len(bad) > 1 else '') + \ | 37 print 'Unknown component{s}: '.format(s='s' if len(bad) > 1 else '') + \ |
36 ' '.join(x for x in bad) | 38 ' '.join(x for x in bad) |
37 sys.exit(1) | 39 sys.exit(1) |
38 | 40 |
39 # Fix up Subzero target strings for the run_all.sh script. | 41 # Fix up Subzero target strings for the run_all.sh script. |
40 target_map = { | 42 target_map = { |
41 'arm32':'arm', | 43 'arm32':'arm', |
42 'x8632':'x8632', | 44 'x8632':'x8632', |
43 'x8664':'x8664' | 45 'x8664':'x8664' |
44 } | 46 } |
45 run_all_target = target_map[args.target] # fail if target not listed above | 47 run_all_target = target_map[args.target] # fail if target not listed above |
46 | 48 |
47 suffix = ( | 49 suffix = ( |
48 'pnacl.opt.{target}' if args.sandbox else 'gcc.opt.{target}').format( | 50 'pnacl.opt.{target}' if args.sandbox else |
| 51 'nonsfi.opt.{target}' if args.nonsfi else |
| 52 'gcc.opt.{target}').format( |
49 target=run_all_target); | 53 target=run_all_target); |
50 for comp in args.comps: | 54 for comp in args.comps: |
51 name = os.path.splitext(comp)[1] or comp | 55 name = os.path.splitext(comp)[1] or comp |
52 if name[0] == '.': | 56 if name[0] == '.': |
53 name = name[1:] | 57 name = name[1:] |
54 szbuild.ProcessPexe(args, | 58 szbuild.ProcessPexe(args, |
55 ('{root}/tests/spec2k/{comp}/' + | 59 ('{root}/tests/spec2k/{comp}/' + |
56 '{name}.opt.stripped.pexe' | 60 '{name}.opt.stripped.pexe' |
57 ).format(root=nacl_root, comp=comp, name=name), | 61 ).format(root=nacl_root, comp=comp, name=name), |
58 ('{root}/tests/spec2k/{comp}/' + | 62 ('{root}/tests/spec2k/{comp}/' + |
59 '{name}.{suffix}' | 63 '{name}.{suffix}' |
60 ).format(root=nacl_root, comp=comp, name=name, | 64 ).format(root=nacl_root, comp=comp, name=name, |
61 suffix=suffix)) | 65 suffix=suffix)) |
62 if args.run: | 66 if args.run: |
63 os.chdir('{root}/tests/spec2k'.format(root=FindBaseNaCl())) | 67 os.chdir('{root}/tests/spec2k'.format(root=FindBaseNaCl())) |
64 setup = 'SetupGcc' + { | 68 setup = 'Setup' + ('Pnacl' if args.sandbox else |
| 69 'Nonsfi' if args.nonsfi else |
| 70 'Gcc') + { |
65 'arm32': 'Arm', | 71 'arm32': 'Arm', |
66 'x8632': 'X8632', | 72 'x8632': 'X8632', |
67 'x8664': 'X8664'}[args.target] + 'Opt' | 73 'x8664': 'X8664'}[args.target] + 'Opt' |
68 shellcmd(['./run_all.sh', | 74 shellcmd(['./run_all.sh', |
69 'RunTimedBenchmarks', | 75 'RunTimedBenchmarks', |
70 setup, | 76 setup, |
71 'train'] + args.comps) | 77 'train'] + args.comps) |
72 | 78 |
73 if __name__ == '__main__': | 79 if __name__ == '__main__': |
74 main() | 80 main() |
OLD | NEW |