| 1 | #!/usr/bin/python | 
|---|
| 2 | # @date   25 August, 2014 | 
|---|
| 3 | # @author cfuguet <cesar.fuguet-tortolero@lip6.fr> | 
|---|
| 4 |  | 
|---|
| 5 | import sys | 
|---|
| 6 | import os | 
|---|
| 7 | import subprocess | 
|---|
| 8 | import arch | 
|---|
| 9 | import faultyprocs | 
|---|
| 10 | from parse import parse_ffstend | 
|---|
| 11 |  | 
|---|
| 12 | # define constants | 
|---|
| 13 | # list of mesh dimensions | 
|---|
| 14 | configs = [] | 
|---|
| 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 | 
|---|
| 22 |  | 
|---|
| 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 | 
|---|
| 29 | faultylist.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 | 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 |  | 
|---|
| 39 | # number of processors per cluster | 
|---|
| 40 | nprocs = 4 | 
|---|
| 41 |  | 
|---|
| 42 | assert len(sys.argv) > 1, "Introduce platform base directory path" | 
|---|
| 43 |  | 
|---|
| 44 | # translate the relative path (if needed) into an absolute path | 
|---|
| 45 | basedir = os.path.abspath(sys.argv[1]) | 
|---|
| 46 | print "[ run.py ] platform base directory: {0}".format(basedir) | 
|---|
| 47 |  | 
|---|
| 48 | # repeat while configurations is not empty | 
|---|
| 49 | for 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 | 
|---|
| 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, | 
|---|
| 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 | 
|---|