1 | #!/usr/bin/python |
---|
2 | # @author Cesar Fuguet <cesar.fuguet-tortolero@lip6.fr> |
---|
3 | # @date 28 August, 2014 |
---|
4 | # @desc generate output file containing a table with the format below: |
---|
5 | # |
---|
6 | # fault configurations |
---|
7 | # | faultconfig 0 | faultconfig 1 | faultconfig M |
---|
8 | # ---------------------------------------------------- |
---|
9 | # 4 | cycles | cycles | cycles |
---|
10 | # # clusters 16 | cycles | cycles | cycles |
---|
11 | # 64 | cycles | cycles | cycles |
---|
12 | # N | cycles | cycles | cycles |
---|
13 | |
---|
14 | import os |
---|
15 | import sys |
---|
16 | |
---|
17 | def parse_ffstend(configs, faultconfigs, confpath, outpath): |
---|
18 | # write header |
---|
19 | ffst_end = open(outpath, "w") |
---|
20 | ffst_end.write("# ffst end (cycles)\n") |
---|
21 | ffst_end.write("{0}\n".format(len(faultconfigs))) |
---|
22 | for config in faultconfigs: |
---|
23 | ffst_end.write("{0}\n".format(config)) |
---|
24 | |
---|
25 | # repeat while configurations is not empty |
---|
26 | quit = 0 |
---|
27 | for x,y in configs: |
---|
28 | ffst_end.write("\n{0:<6}".format(str(x*y))) |
---|
29 | for f in xrange(len(faultconfigs)): |
---|
30 | temp = "config_{0}c{1}f/".format(x*y, f) |
---|
31 | confdir = os.path.join(confpath, temp) |
---|
32 | |
---|
33 | # parse term log and get relevant information |
---|
34 | termname = os.path.join(confdir, "term") |
---|
35 | try: |
---|
36 | termlog = open(termname, "r") |
---|
37 | except IOError as e: |
---|
38 | print "IOError {0}: {1}".format(termname, e.strerror) |
---|
39 | quit = 1 |
---|
40 | break |
---|
41 | |
---|
42 | found = False |
---|
43 | for line in termlog: |
---|
44 | partitions = line.partition(':') |
---|
45 | if partitions[0].strip() == "FFST (END)": |
---|
46 | found = True |
---|
47 | value = int(partitions[2]) |
---|
48 | ffst_end.write(" {0:<8}".format(value)) |
---|
49 | break |
---|
50 | |
---|
51 | if not found: ffst_end.write(" {0:<8}".format(-1)) |
---|
52 | # end for faultconfig |
---|
53 | |
---|
54 | if quit: break |
---|
55 | # end for configs |
---|
56 | |
---|
57 | ffst_end.close() |
---|
58 | # end def parse_ffstend |
---|
59 | |
---|
60 | if __name__ == "__main__": |
---|
61 | configs = [] |
---|
62 | configs.append([2 , 2 ]) |
---|
63 | configs.append([4 , 2 ]) |
---|
64 | configs.append([4 , 4 ]) |
---|
65 | configs.append([8 , 4 ]) |
---|
66 | configs.append([8 , 8 ]) |
---|
67 | configs.append([16, 8 ]) |
---|
68 | configs.append([16, 16]) |
---|
69 | |
---|
70 | faultconfigs = [] |
---|
71 | faultconfigs.append('0 faulty core') |
---|
72 | faultconfigs.append('1 faulty core') |
---|
73 | faultconfigs.append('2 faulty cores') |
---|
74 | faultconfigs.append('1 faulty cluster (3 cores)') |
---|
75 | faultconfigs.append('2 faulty clusters (6 cores)') |
---|
76 | |
---|
77 | assert len(sys.argv) > 2, "Introduce config path and output path" |
---|
78 | |
---|
79 | parse_ffstend(configs, faultconfigs, sys.argv[1], sys.argv[2]) |
---|
80 | |
---|
81 | # vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab |
---|