[902] | 1 | #!/usr/bin/env python |
---|
[768] | 2 | # @date 25 August, 2014 |
---|
| 3 | # @author cfuguet <cesar.fuguet-tortolero@lip6.fr> |
---|
| 4 | |
---|
[774] | 5 | import sys |
---|
[768] | 6 | import os |
---|
| 7 | import subprocess |
---|
[774] | 8 | import arch |
---|
[775] | 9 | import faultyprocs |
---|
[782] | 10 | from parse import parse_ffstend |
---|
[768] | 11 | |
---|
[774] | 12 | # define constants |
---|
[782] | 13 | # list of mesh dimensions |
---|
[768] | 14 | configs = [] |
---|
[782] | 15 | configs.append([2 , 2 ]) # 4 clusters |
---|
| 16 | configs.append([4 , 2 ]) # 8 clusters |
---|
| 17 | configs.append([4 , 4 ]) # 16 clusters |
---|
| 18 | configs.append([8 , 4 ]) # 32 clusters |
---|
| 19 | configs.append([8 , 8 ]) # 64 clusters |
---|
| 20 | configs.append([16, 8 ]) # 128 clusters |
---|
| 21 | configs.append([16, 16]) # 256 clusters |
---|
[768] | 22 | |
---|
[782] | 23 | # list of faulty cores |
---|
| 24 | faultylist = [] |
---|
| 25 | faultylist.append([]) # 0 faulty core |
---|
| 26 | faultylist.append([(0,0,1)]) # 1 faulty core |
---|
| 27 | faultylist.append([(0,0,1), (0,0,3)]) # 2 faulty cores |
---|
| 28 | faultylist.append([(1,0,0), (1,0,2), (1,0,3)]) # 1 faulty cluster |
---|
[893] | 29 | faultylist.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] | 32 | faultynames = [] |
---|
| 33 | faultynames.append("0 faulty core") |
---|
| 34 | faultynames.append("1 faulty core") |
---|
| 35 | faultynames.append("2 faulty cores") |
---|
| 36 | faultynames.append("1 faulty cluster") |
---|
| 37 | faultynames.append("2 faulty clusters") |
---|
| 38 | |
---|
[782] | 39 | # number of processors per cluster |
---|
[774] | 40 | nprocs = 4 |
---|
| 41 | |
---|
| 42 | assert len(sys.argv) > 1, "Introduce platform base directory path" |
---|
| 43 | |
---|
[776] | 44 | # translate the relative path (if needed) into an absolute path |
---|
| 45 | basedir = os.path.abspath(sys.argv[1]) |
---|
[778] | 46 | print "[ run.py ] platform base directory: {0}".format(basedir) |
---|
[774] | 47 | |
---|
[768] | 48 | # repeat while configurations is not empty |
---|
[782] | 49 | for 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 |
---|
| 110 | statsdir = os.path.join(basedir, 'stats') |
---|
| 111 | try: |
---|
| 112 | os.makedirs(statsdir, 0755) |
---|
| 113 | except OSError: |
---|
| 114 | pass # directory already exists => do nothing |
---|
| 115 | |
---|
| 116 | parse_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 |
---|