1 | #!/usr/bin/python |
---|
2 | # @date 25 August, 2014 |
---|
3 | # @author cfuguet <cesar.fuguet-tortolero@lip6.fr> |
---|
4 | |
---|
5 | import sys |
---|
6 | import os |
---|
7 | import subprocess |
---|
8 | import arch |
---|
9 | import faultyprocs |
---|
10 | |
---|
11 | # define constants |
---|
12 | configs = [] |
---|
13 | configs.append([2 ,2 ]) |
---|
14 | configs.append([4 ,4 ]) |
---|
15 | configs.append([8 ,8 ]) |
---|
16 | configs.append([16,16]) |
---|
17 | |
---|
18 | faultylist = [[(0,0,1), (0,1,1), (1,0,1), (1,0,2), (1,0,3), (1,1,1), (1,1,3)]] |
---|
19 | |
---|
20 | nprocs = 4 |
---|
21 | |
---|
22 | assert len(sys.argv) > 1, "Introduce platform base directory path" |
---|
23 | |
---|
24 | # goto platform base directory |
---|
25 | os.chdir(sys.argv[1]) |
---|
26 | |
---|
27 | # repeat while configurations is not empty |
---|
28 | for faulty in faultylist: |
---|
29 | for x,y in configs: |
---|
30 | confdir = os.getcwd() + "conf/config_{}c/".format(x*y) |
---|
31 | |
---|
32 | # 1. generate configuration and ouput directories |
---|
33 | try: |
---|
34 | os.makedirs(confdir + "config", 0755) |
---|
35 | except OSError: |
---|
36 | pass # directory already exists => do nothing |
---|
37 | |
---|
38 | # 2. generate hard_config.h and fault_config.h files |
---|
39 | arch.main( x = x, y = y, p = nprocs, |
---|
40 | hard_path = confdir + "config/hard_config.h", |
---|
41 | xml_path = confdir + "config/map.xml" ) |
---|
42 | faultyprocs.generate(faulty, confdir + "config/fault_config.h") |
---|
43 | |
---|
44 | # 3. compile simulator executable |
---|
45 | if os.path.exists("hard_config.h"): os.unlink("hard_config.h") |
---|
46 | os.symlink(confdir + "config/hard_config.h", "hard_config.h") |
---|
47 | subprocess.call("make") |
---|
48 | |
---|
49 | # 4. compile distributed boot executable |
---|
50 | dst = confdir + "config/boot_config.h" |
---|
51 | if not os.path.exists(dst): |
---|
52 | os.symlink(os.getcwd() + "/soft/config/boot_config.h", dst) |
---|
53 | subprocess.call(["make", |
---|
54 | "-C", "soft", |
---|
55 | "CONFDIR=" + confdir |
---|
56 | ]) |
---|
57 | |
---|
58 | # 5. execute simulator |
---|
59 | os.environ["DISTRIBUTED_BOOT"] = "1" |
---|
60 | os.environ["SOCLIB_TTY"] = "FILES" |
---|
61 | with open(confdir + "log", "w") as log_file: |
---|
62 | subprocess.call(["./simul.x", |
---|
63 | "-SOFT" , "soft/build/soft.elf", |
---|
64 | "-DISK" , "/dev/null", |
---|
65 | "-NCYCLES", "10000000"], |
---|
66 | stdout=log_file, |
---|
67 | stderr=log_file, |
---|
68 | ) |
---|
69 | |
---|
70 | # 6. move simulation terminal output into the target config dir |
---|
71 | os.rename("term0", confdir + "term") |
---|
72 | |
---|
73 | # end for each config |
---|
74 | #end for each faulty |
---|
75 | |
---|
76 | # vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab |
---|