source: branches/reconfiguration/platforms/tsar_generic_iob/scripts/run.py @ 776

Last change on this file since 776 was 776, checked in by cfuguet, 10 years ago

reconfiguration/tsar_generic_iob: using abspath instead of relpath

  • Using absolute paths in the run.py script to allow placing this script anywhere. When passing as argument relpaths, the absolute paths are computed internally
  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#!/usr/bin/python
2# @date   25 August, 2014
3# @author cfuguet <cesar.fuguet-tortolero@lip6.fr>
4
5import sys
6import os
7import subprocess
8import arch
9import faultyprocs
10
11# define constants
12configs = []
13configs.append([2 ,2 ])
14configs.append([4 ,4 ])
15configs.append([8 ,8 ])
16configs.append([16,16])
17
18faultylist = [[(0,0,1), (0,1,1), (1,0,1), (1,0,2), (1,0,3), (1,1,1), (1,1,3)]]
19
20nprocs = 4
21
22assert len(sys.argv) > 1, "Introduce platform base directory path"
23
24# translate the relative path (if needed) into an absolute path
25basedir = os.path.abspath(sys.argv[1])
26print "[ run.py ] platform base directory: {}".format(basedir)
27
28# repeat while configurations is not empty
29for 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
Note: See TracBrowser for help on using the repository browser.