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

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

reconf: force the python version 2.7 in simulation scripts.

  • Property svn:executable set to *
File size: 4.1 KB
Line 
1#!/usr/bin/env python2.7
2# @date   25 August, 2014
3# @author cfuguet <cesar.fuguet-tortolero@lip6.fr>
4
5import sys
6import os
7import subprocess
8import arch
9import faultyprocs
10from parse import parse_ffstend
11
12# define constants
13# list of mesh dimensions
14configs = []
15configs.append([2 , 2 ]) # 4   clusters
16configs.append([4 , 2 ]) # 8   clusters
17configs.append([4 , 4 ]) # 16  clusters
18configs.append([8 , 4 ]) # 32  clusters
19configs.append([8 , 8 ]) # 64  clusters
20configs.append([16, 8 ]) # 128 clusters
21configs.append([16, 16]) # 256 clusters
22
23# list of faulty cores
24faultylist = []
25faultylist.append([])                           # 0 faulty core
26faultylist.append([(0,0,1)])                    # 1 faulty core
27faultylist.append([(0,0,1), (0,0,3)])           # 2 faulty cores
28faultylist.append([(1,0,0), (1,0,2), (1,0,3)])  # 1 faulty cluster
29faultylist.append([(1,0,0), (1,0,2), (1,0,3),
30                   (1,1,1), (1,1,2), (1,1,3)])  # 2 faulty cluster
31
32faultynames = []
33faultynames.append("0 faulty core")
34faultynames.append("1 faulty core")
35faultynames.append("2 faulty cores")
36faultynames.append("1 faulty cluster")
37faultynames.append("2 faulty clusters")
38
39# number of processors per cluster
40nprocs = 4
41
42assert len(sys.argv) > 1, "Introduce platform base directory path"
43
44# translate the relative path (if needed) into an absolute path
45basedir = os.path.abspath(sys.argv[1])
46print "[ run.py ] platform base directory: {0}".format(basedir)
47
48# repeat while configurations is not empty
49for f in xrange(len(faultylist)):
50    for x,y in configs:
51        confname = "conf/config_{0}c{1}f".format(x*y, f)
52        confdir  = os.path.join(basedir, confname)
53        print "[ run.py ] generating files for {0}".format(confdir)
54
55        # 1. generate configuration and ouput directories
56        try:
57            os.makedirs(os.path.join(confdir, "config"), 0755)
58        except OSError:
59            pass # directory already exists => do nothing
60
61        # 2. generate hard_config.h and fault_config.h files
62        hardpath  = os.path.join(confdir, "config/hard_config.h")
63        xmlpath   = os.path.join(confdir, "config/map.xml")
64        faultpath = os.path.join(confdir, "config/fault_config.h") 
65        arch.main( x, y, nprocs, hardpath, xmlpath)
66        faultyprocs.generate(faultylist[f], faultpath)
67
68        # 3. compile simulator executable
69        dst = os.path.join(basedir, "hard_config.h")
70        if os.path.lexists(dst): os.unlink(dst)
71        os.symlink(hardpath, dst)
72        subprocess.call(["make",
73            "-C", basedir
74            ])
75
76        # 4. compile distributed boot executable
77        dst = os.path.join(confdir, "config/boot_config.h")
78        if os.path.lexists(dst): os.unlink(dst)
79        os.symlink(os.path.join(basedir, "soft/config/boot_config.h"), dst)
80        subprocess.call(["make",
81            "-C", os.path.join(basedir, "soft"),
82            "CONFDIR=" + confdir
83            ])
84
85        # 5. execute simulator
86        os.environ["DISTRIBUTED_BOOT"] = "1"
87        os.environ["SOCLIB_TTY"] = "FILES"
88
89        if   x*y <= 4 : ompthreads = x*y
90        elif x*y <= 16: ompthreads = 4
91        else:           ompthreads = 8
92        with open(os.path.join(confdir, "log"), "w") as logfile:
93            print "executing simul.x"
94            subprocess.call([os.path.join(basedir, "simul.x"),
95                "-SOFT"   , os.path.join(basedir, "soft/build/soft.elf"),
96                "-DISK"   , "/dev/null",
97                "-THREADS", str(ompthreads),
98                "-NCYCLES", "1000000"],
99                stdout=logfile,
100                stderr=logfile,
101                )
102
103        # 6. move simulation terminal output into the target config dir
104        os.rename("term0", os.path.join(confdir, "term"))
105
106        # end for each config
107    #end for each faulty
108
109# parse terminal logs to obtain statistics
110statsdir = os.path.join(basedir, 'stats')
111try:
112    os.makedirs(statsdir, 0755)
113except OSError:
114    pass # directory already exists => do nothing
115
116parse_ffstend(configs,
117             faultynames,
118             os.path.join(basedir, 'conf'),
119             os.path.join(statsdir, 'ffst_stats.dat'))
120
121# vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab
Note: See TracBrowser for help on using the repository browser.