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