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