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 | |
---|
22 | # repeat while configurations is not empty |
---|
23 | quit = 0 |
---|
24 | for x,y in configs: |
---|
25 | ffst_end.write("\n") |
---|
26 | ffst_end.write(str(x*y)) |
---|
27 | for f in xrange(faultconfigs): |
---|
28 | temp = "config_{0}c{1}f/".format(x*y, f) |
---|
29 | confdir = os.path.join(confpath, temp) |
---|
30 | |
---|
31 | # parse term log and get relevant information |
---|
32 | termname = os.path.join(confdir, "term") |
---|
33 | try: |
---|
34 | termlog = open(termname, "r") |
---|
35 | except IOError as e: |
---|
36 | print "IOError {0}: {1}".format(termname, e.strerror) |
---|
37 | quit = 1 |
---|
38 | break |
---|
39 | |
---|
40 | found = False |
---|
41 | for line in termlog: |
---|
42 | partitions = line.partition(':') |
---|
43 | if partitions[0].strip() == "FFST (END)": |
---|
44 | found = True |
---|
45 | value = int(partitions[2]) |
---|
46 | ffst_end.write(" {0}".format(value)) |
---|
47 | break |
---|
48 | |
---|
49 | if not found: ffst_end.write(" -1") |
---|
50 | # end for faultconfig |
---|
51 | |
---|
52 | if quit: break |
---|
53 | # end for configs |
---|
54 | |
---|
55 | ffst_end.close() |
---|
56 | # end def parse_ffstend |
---|
57 | |
---|
58 | if __name__ == "__main__": |
---|
59 | configs = [] |
---|
60 | configs.append([2 , 2 ]) |
---|
61 | configs.append([4 , 4 ]) |
---|
62 | configs.append([8 , 8 ]) |
---|
63 | configs.append([16, 16]) |
---|
64 | |
---|
65 | assert len(sys.argv) > 3,\ |
---|
66 | "Introduce number of faulty configs, config path and output path" |
---|
67 | |
---|
68 | parse_ffstend(configs, int(sys.argv[1]), sys.argv[2], sys.argv[3]) |
---|
69 | |
---|
70 | # vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab |
---|