-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsimulate_all.py
More file actions
79 lines (58 loc) · 2.16 KB
/
simulate_all.py
File metadata and controls
79 lines (58 loc) · 2.16 KB
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
#!/usr/bin/env python
#
# Copyright (c) 2013-2016, ETH Zurich.
# All rights reserved.
#
# This file is distributed under the terms in the attached LICENSE file.
# If you do not find this file, copies can be found by writing to:
# ETH Zurich D-INFK, Universitaetstr. 6, CH-8092 Zurich. Attn: Systems Group.
import sys
import os
sys.path.append(os.getenv('HOME') + '/bin/')
import subprocess
def main():
import config
sys.path.append(config.MACHINE_DATABASE)
from machineinfo import machines
topos = [ 'adaptivetree-min', \
'adaptivetree-shuffle', \
'adaptivetree-shuffle-sort' ] # Don't include adaptivetree itself
print 'machine adaptiv ',
for t in topos:
print '%-15s ' % (t.replace('adaptivetree', 'a')),
print ''
for s in [ s for (s, _, _) in machines ]:
res = {}
complete = True
# ridx is the index of the Cost output to be considered.
#
# 0 is normally ab, 1 reduction, 2 barriers, but in some
# cases, ab is executed twice and we actually want index 1
# (i.e. the second cost)
for t in topos + [ 'adaptivetree' ]:
cmd = [ './simulator.py', s, t ] #, '--visu']
try:
for l in subprocess.check_output(cmd, stderr=subprocess.STDOUT).split('\n'):
if l.startswith('Cost atomic broadcast'):
e = l.split(':')[1].split()
res[t] = int(e[1].strip("(),"))
except subprocess.CalledProcessError:
complete = False
except:
raise
# --------------------------------------------------
if not 'adaptivetree' in res:
continue
# Print machine name
print '%-30s ' % s,
if complete:
# Print cost of basic adaptive tree
baseline = res['adaptivetree']
print '%6d' % baseline,
for t in topos:
cost = res[t]
factor = float(cost)/float(baseline)
print ' %6d %5.2f' % (cost, factor),
print ''
if __name__ == "__main__":
main()