| 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 | # 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) |
|---|
| 27 | |
|---|
| 28 | # repeat while configurations is not empty |
|---|
| 29 | for faulty in faultylist: |
|---|
| 30 | for x,y in configs: |
|---|
| 31 | confdir = "{}/conf/config_{}c".format(basedir, x*y) |
|---|
| 32 | print "[ run.py ] generating files for {}".format(confdir) |
|---|
| 33 | |
|---|
| 34 | # 1. generate configuration and ouput directories |
|---|
| 35 | try: |
|---|
| 36 | os.makedirs(confdir + "/config", 0755) |
|---|
| 37 | except OSError: |
|---|
| 38 | pass # directory already exists => do nothing |
|---|
| 39 | |
|---|
| 40 | # 2. generate hard_config.h and fault_config.h files |
|---|
| 41 | arch.main( x = x, y = y, p = nprocs, |
|---|
| 42 | hard_path = confdir + "/config/hard_config.h", |
|---|
| 43 | xml_path = confdir + "/config/map.xml" ) |
|---|
| 44 | faultyprocs.generate(faulty, confdir + "/config/fault_config.h") |
|---|
| 45 | |
|---|
| 46 | # 3. compile simulator executable |
|---|
| 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 | ]) |
|---|
| 53 | |
|---|
| 54 | # 4. compile distributed boot executable |
|---|
| 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) |
|---|
| 58 | subprocess.call(["make", |
|---|
| 59 | "-C", basedir + "/soft", |
|---|
| 60 | "CONFDIR=" + confdir |
|---|
| 61 | ]) |
|---|
| 62 | |
|---|
| 63 | # 5. execute simulator |
|---|
| 64 | os.environ["DISTRIBUTED_BOOT"] = "1" |
|---|
| 65 | os.environ["SOCLIB_TTY"] = "FILES" |
|---|
| 66 | with open(confdir + "/log", "w") as log_file: |
|---|
| 67 | subprocess.call([basedir + "/simul.x", |
|---|
| 68 | "-SOFT" , basedir + "/soft/build/soft.elf", |
|---|
| 69 | "-DISK" , "/dev/null", |
|---|
| 70 | "-NCYCLES", "10000000"], |
|---|
| 71 | stdout=log_file, |
|---|
| 72 | stderr=log_file, |
|---|
| 73 | ) |
|---|
| 74 | |
|---|
| 75 | # 6. move simulation terminal output into the target config dir |
|---|
| 76 | os.rename("term0", confdir + "/term") |
|---|
| 77 | |
|---|
| 78 | # end for each config |
|---|
| 79 | #end for each faulty |
|---|
| 80 | |
|---|
| 81 | # vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab |
|---|