source: branches/reconfiguration/platforms/tsar_generic_iob/scripts/onerun.py @ 855

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

reconf: introducing a -FAULTY_ROUTER argument in tsar_generic_iob platform

  • This argument passes the XY id of the router to disable before the simulation.
  • Using the reconf:dspin_router instead of the soclib:dspin_router component in tsar_iob_cluster.
  • Property svn:executable set to *
File size: 4.4 KB
Line 
1#!/usr/bin/python
2# @date   22 September, 2014
3# @author cfuguet <cesar.fuguet-tortolero@lip6.fr>
4
5import os
6import subprocess
7import arch
8import faultyprocs
9import argparse
10
11# get command-line arguments
12parser = argparse.ArgumentParser(description='Run simulation')
13
14parser.add_argument(
15    '--path', '-p', type=str, dest='path', default=os.getcwd(),
16    help='relative or absolute path to the platform')
17
18parser.add_argument(
19    '--output', '-o', type=str, dest='outpath', default='./output',
20    help='relative or absolute path to the output directory')
21
22parser.add_argument(
23    '--xsize', '-x', type=int, dest='x', default=2,
24    help='# of clusters in a row')
25
26parser.add_argument(
27    '--ysize', '-y', type=int, dest='y', default=2,
28    help='# of clusters in a column')
29
30parser.add_argument(
31    '--nprocs', '-n', type=int, dest='nprocs', default=4,
32    help='# of processors per cluster')
33
34parser.add_argument(
35    '--compile-only', '-c', dest='compileonly', action='store_true',
36    help='generate config files and compile the platform. Do not simulate')
37
38parser.add_argument(
39    '--batch-mode', '-b', dest='batchmode', action='store_true',
40    help='run simulation in batch mode: no interactive TTY or FrameBuffer')
41
42parser.add_argument(
43    '--faulty-router', '-f', dest='faultyrouter', default=-1,
44    help='ID (X,Y) of faulty router')
45
46parser.add_argument(
47    '--debug', '-g', dest='debug', nargs=4,
48    help='needs four arguments: from, to, procid, memcid')
49
50args = parser.parse_args()
51
52# faulty processor list
53faultylist = [(0, 0, 1), (0, 0, 2), (0, 1, 2)]
54
55# translate the relative path (if needed) into an absolute path
56basedir = os.path.abspath(args.path)
57outdir = os.path.abspath(args.outpath)
58print "[ run.py ] platform base directory: {0}".format(basedir)
59print "[ run.py ] output directory: {0}".format(outdir)
60
61# 1. generate configuration and ouput directories
62try:
63    os.makedirs(os.path.join(outdir, "config"), 0755)
64except OSError:
65    pass # directory already exists => do nothing
66
67# 2. generate hard_config.h and fault_config.h files
68faultpath = os.path.join(outdir, "config/fault_config.h")
69hardpath = os.path.join(outdir, "config/hard_config.h")
70xmlpath = os.path.join(outdir, "config/map.xml")
71arch.main(args.x, args.y, args.nprocs, hardpath, xmlpath)
72faultyprocs.generate(faultylist, faultpath)
73
74# create a log file
75logfile = open(os.path.join(outdir, "log"), "w")
76
77# 3. compile simulator executable
78dst = os.path.join(basedir, "hard_config.h")
79if os.path.lexists(dst):
80    os.unlink(dst)
81
82os.symlink(hardpath, dst)
83
84print "[ run.py ] compiling simulator"
85command = []
86command.extend(['make'])
87command.extend(['-C', basedir])
88subprocess.call(command, stdout=logfile, stderr=logfile)
89
90# 4. compile distributed boot executable
91dst = os.path.join(outdir, "config/boot_config.h")
92if os.path.lexists(dst):
93    os.unlink(dst)
94
95os.symlink(os.path.join(basedir, "soft/config/boot_config.h"), dst)
96
97# stop after compiling the platform when the compile-only option is activated
98if args.compileonly == True:
99    exit(0)
100
101print "[ run.py ] compiling distributed boot procedure"
102command = []
103command.extend(['make'])
104command.extend(['-C', os.path.join(basedir, "soft")])
105command.extend(["CONFDIR=" + outdir])
106subprocess.call(command, stdout=logfile, stderr=logfile)
107
108# 5. execute simulator
109os.environ["DISTRIBUTED_BOOT"] = "1"
110if args.batchmode:
111    os.environ["SOCLIB_FB"] = "HEADLESS"
112    os.environ["SOCLIB_TTY"] = "FILES"
113
114if (args.x * args.y) <= 4:
115    ompthreads = args.x * args.y
116elif (args.x * args.y) <= 16:
117    ompthreads = 4
118else:
119    ompthreads = 8
120
121print "[ run.py ] starting simulation"
122command = []
123command.extend([os.path.join(basedir, "simul.x")])
124command.extend(["-SOFT", os.path.join(basedir, "soft/build/soft.elf")])
125command.extend(["-DISK", "/dev/null"])
126command.extend(["-THREADS", str(ompthreads)])
127
128if args.faultyrouter != -1:
129    command.extend(["-FAULTY_ROUTER", str(args.faultyrouter)])
130
131if args.debug != None:
132    command.extend(["-DEBUG", str(args.debug[0])]);
133    command.extend(["-NCYCLES", str(args.debug[1])]);
134    command.extend(["-PROCID", str(args.debug[2])]);
135    command.extend(["-MEMCID", str(args.debug[3])]);
136else:
137    command.extend(["-NCYCLES", "1000000"])
138
139subprocess.call(command, stdout=logfile, stderr=logfile)
140
141logfile.close()
142
143# 6. move simulation terminal output into the target config dir
144os.rename("term0", os.path.join(outdir, "term"))
145
146# vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab
Note: See TracBrowser for help on using the repository browser.