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

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

reconfiguration/tsar_generic_iob: adding script for plotting

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