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

Last change on this file since 907 was 902, checked in by cfuguet, 9 years ago

reconf: improve the random fault generation

  • Improve portability of python scripts by using env
  • Property svn:executable set to *
File size: 4.1 KB
RevLine 
[902]1#!/usr/bin/env python
[768]2# @date   25 August, 2014
3# @author cfuguet <cesar.fuguet-tortolero@lip6.fr>
4
[774]5import sys
[768]6import os
7import subprocess
[774]8import arch
[775]9import faultyprocs
[782]10from parse import parse_ffstend
[768]11
[774]12# define constants
[782]13# list of mesh dimensions
[768]14configs = []
[782]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
[768]22
[782]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
[893]29faultylist.append([(1,0,0), (1,0,2), (1,0,3),
[782]30                   (1,1,1), (1,1,2), (1,1,3)])  # 2 faulty cluster
[775]31
[784]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
[782]39# number of processors per cluster
[774]40nprocs = 4
41
42assert len(sys.argv) > 1, "Introduce platform base directory path"
43
[776]44# translate the relative path (if needed) into an absolute path
45basedir = os.path.abspath(sys.argv[1])
[778]46print "[ run.py ] platform base directory: {0}".format(basedir)
[774]47
[768]48# repeat while configurations is not empty
[782]49for f in xrange(len(faultylist)):
[775]50    for x,y in configs:
[782]51        confname = "conf/config_{0}c{1}f".format(x*y, f)
52        confdir  = os.path.join(basedir, confname)
[778]53        print "[ run.py ] generating files for {0}".format(confdir)
[768]54
[775]55        # 1. generate configuration and ouput directories
56        try:
[782]57            os.makedirs(os.path.join(confdir, "config"), 0755)
[775]58        except OSError:
59            pass # directory already exists => do nothing
[768]60
[775]61        # 2. generate hard_config.h and fault_config.h files
[782]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)
[768]67
[775]68        # 3. compile simulator executable
[782]69        dst = os.path.join(basedir, "hard_config.h")
[776]70        if os.path.lexists(dst): os.unlink(dst)
[782]71        os.symlink(hardpath, dst)
[776]72        subprocess.call(["make",
73            "-C", basedir
74            ])
[768]75
[775]76        # 4. compile distributed boot executable
[782]77        dst = os.path.join(confdir, "config/boot_config.h")
[776]78        if os.path.lexists(dst): os.unlink(dst)
[782]79        os.symlink(os.path.join(basedir, "soft/config/boot_config.h"), dst)
[775]80        subprocess.call(["make",
[782]81            "-C", os.path.join(basedir, "soft"),
[775]82            "CONFDIR=" + confdir
83            ])
[768]84
[775]85        # 5. execute simulator
86        os.environ["DISTRIBUTED_BOOT"] = "1"
87        os.environ["SOCLIB_TTY"] = "FILES"
[778]88
[782]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:
[778]93            print "executing simul.x"
[782]94            subprocess.call([os.path.join(basedir, "simul.x"),
95                "-SOFT"   , os.path.join(basedir, "soft/build/soft.elf"),
[775]96                "-DISK"   , "/dev/null",
[778]97                "-THREADS", str(ompthreads),
98                "-NCYCLES", "1000000"],
99                stdout=logfile,
100                stderr=logfile,
[775]101                )
[768]102
[775]103        # 6. move simulation terminal output into the target config dir
[782]104        os.rename("term0", os.path.join(confdir, "term"))
[768]105
[775]106        # end for each config
107    #end for each faulty
[768]108
[782]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,
[784]117             faultynames,
[782]118             os.path.join(basedir, 'conf'),
119             os.path.join(statsdir, 'ffst_stats.dat'))
120
[768]121# vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab
Note: See TracBrowser for help on using the repository browser.