#!/usr/bin/python # @date 25 August, 2014 # @author cfuguet import sys import os import subprocess import arch import faultyprocs # define constants configs = [] configs.append([2 ,2 ]) configs.append([4 ,4 ]) configs.append([8 ,8 ]) configs.append([16,16]) faultylist = [[(0,0,1), (0,1,1), (1,0,1), (1,0,2), (1,0,3), (1,1,1), (1,1,3)]] nprocs = 4 assert len(sys.argv) > 1, "Introduce platform base directory path" # goto platform base directory os.chdir(sys.argv[1]) # repeat while configurations is not empty for faulty in faultylist: for x,y in configs: confdir = os.getcwd() + "conf/config_{}c/".format(x*y) # 1. generate configuration and ouput directories try: os.makedirs(confdir + "config", 0755) except OSError: pass # directory already exists => do nothing # 2. generate hard_config.h and fault_config.h files arch.main( x = x, y = y, p = nprocs, hard_path = confdir + "config/hard_config.h", xml_path = confdir + "config/map.xml" ) faultyprocs.generate(faulty, confdir + "config/fault_config.h") # 3. compile simulator executable if os.path.exists("hard_config.h"): os.unlink("hard_config.h") os.symlink(confdir + "config/hard_config.h", "hard_config.h") subprocess.call("make") # 4. compile distributed boot executable dst = confdir + "config/boot_config.h" if not os.path.exists(dst): os.symlink(os.getcwd() + "/soft/config/boot_config.h", dst) subprocess.call(["make", "-C", "soft", "CONFDIR=" + confdir ]) # 5. execute simulator os.environ["DISTRIBUTED_BOOT"] = "1" os.environ["SOCLIB_TTY"] = "FILES" with open(confdir + "log", "w") as log_file: subprocess.call(["./simul.x", "-SOFT" , "soft/build/soft.elf", "-DISK" , "/dev/null", "-NCYCLES", "10000000"], stdout=log_file, stderr=log_file, ) # 6. move simulation terminal output into the target config dir os.rename("term0", confdir + "term") # end for each config #end for each faulty # vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab