Ignore:
Timestamp:
Nov 26, 2014, 6:54:56 PM (10 years ago)
Author:
cfuguet
Message:

reconf: improve the onerun.py script in the tsar_generic_iob

  • Now, this module defines a run function which can be either called by the onerun's main function or by another module, if it has been imported.
  • Faulty cores are now passed as an argument. For each faulty core, pass the argument -fc X Y L, where X Y L are the core's coordinates.
  • Faulty routers are now passed as a pair X Y instead of XY integer. For each faulty router, pass the argument -fr X Y. This modification affects both, the top.cpp and onerun.py files.
Location:
branches/reconfiguration/platforms/tsar_generic_iob
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/reconfiguration/platforms/tsar_generic_iob/Makefile

    r776 r890  
    1515
    1616distclean: clean
     17        rm -f $(TAGS) hard_config.h
    1718        find . -name "*.pyc" -exec rm -f {} \;
    1819
  • branches/reconfiguration/platforms/tsar_generic_iob/scripts/faultyprocs.py

    r778 r890  
    1313                    "    /*  X    |    Y     | L  */\n")
    1414
    15     for x, y, l in faulty:
    16         content.append("    ({0} << 6) | ({1} << 2) | {2},\n".format(x, y, l))
     15    if faulty != None:
     16        for x, y, l in faulty:
     17            content.append("    ({0} << 6) | ({1} << 2) | {2},\n".format(x, y, l))
    1718
    1819    content.append( "};\n"
  • branches/reconfiguration/platforms/tsar_generic_iob/scripts/onerun.py

    r889 r890  
    99import argparse
    1010
     11def run(args):
     12    """ Execute the distributed bootloader providing permanent fault-recovery on
     13    the TSAR platform.
     14
     15    Keyword arguments:
     16    path         -- platform's base directory path
     17    outpath      -- output's base directory path
     18    x            -- number of clusters on the X coordinate
     19    y            -- number of clusters on the Y coordinate
     20    nprocs       -- number of processors per cluster
     21    compileonly  -- stops after platform's compilation
     22    batchmode    -- TTY and FB are only redirected to FILES
     23    faultyrouter -- a list containing faulty routers' coordinates (x, y)
     24    faultymask   -- a mask of disabled routers' interfaces
     25    faultycore   -- a list containing faulty cores' coordinates (x, y, l)
     26    debug        -- a list with debug's start cycle, stop cycle, PID and MID
     27    """
     28
     29    # translate the relative path (if needed) into an absolute path
     30    basedir = os.path.abspath(args.path)
     31    outdir = os.path.abspath(args.outpath)
     32    print "[ run.py ] platform base directory: {0}".format(basedir)
     33    print "[ run.py ] output directory: {0}".format(outdir)
     34
     35    # 1. generate configuration and ouput directories
     36    try:
     37        os.makedirs(os.path.join(outdir, "config"), 0755)
     38    except OSError:
     39        pass # directory already exists => do nothing
     40
     41    # 2. generate hard_config.h and fault_config.h files
     42    faultpath = os.path.join(outdir, "config/fault_config.h")
     43    hardpath = os.path.join(outdir, "config/hard_config.h")
     44    xmlpath = os.path.join(outdir, "config/map.xml")
     45    arch.main(args.x, args.y, args.nprocs, hardpath, xmlpath)
     46    faultyprocs.generate(args.faultycore, faultpath)
     47
     48    # create a log file
     49    logfile = open(os.path.join(outdir, "log"), "w")
     50
     51    # 3. compile simulator executable
     52    dst = os.path.join(basedir, "hard_config.h")
     53    if os.path.lexists(dst):
     54        os.unlink(dst)
     55
     56    os.symlink(hardpath, dst)
     57
     58    print "[ run.py ] compiling simulator"
     59    command = []
     60    command.extend(['make'])
     61    command.extend(['-C', basedir])
     62    subprocess.call(command, stdout=logfile, stderr=logfile)
     63
     64    # 4. compile distributed boot executable
     65    dst = os.path.join(outdir, "config/boot_config.h")
     66    if os.path.lexists(dst):
     67        os.unlink(dst)
     68
     69    os.symlink(os.path.join(basedir, "soft/config/boot_config.h"), dst)
     70
     71    # stop after compiling the platform when the compile-only option is activated
     72    if args.compileonly == True:
     73        exit(0)
     74
     75    print "[ run.py ] compiling distributed boot procedure"
     76    command = []
     77    command.extend(['make'])
     78    command.extend(['-C', os.path.join(basedir, "soft")])
     79    command.extend(["CONFDIR=" + outdir])
     80    subprocess.call(command, stdout=logfile, stderr=logfile)
     81
     82    # 5. execute simulator
     83    os.environ["DISTRIBUTED_BOOT"] = "1"
     84    if args.batchmode:
     85        os.environ["SOCLIB_FB"] = "HEADLESS"
     86        os.environ["SOCLIB_TTY"] = "FILES"
     87
     88    if (args.x * args.y) <= 4:
     89        ompthreads = args.x * args.y
     90    elif (args.x * args.y) <= 16:
     91        ompthreads = 4
     92    else:
     93        ompthreads = 8
     94
     95    print "[ run.py ] starting simulation"
     96    command = []
     97    command.extend([os.path.join(basedir, "simul.x")])
     98    command.extend(["-SOFT", os.path.join(basedir, "soft/build/soft.elf")])
     99    command.extend(["-DISK", "/dev/null"])
     100    command.extend(["-THREADS", str(ompthreads)])
     101
     102    if args.faultyrouter != None:
     103        command.extend(["-FAULTY_MASK", str(args.faultymask)])
     104        for f in args.faultyrouter:
     105            command.extend(["-FAULTY_ROUTER", str(f[0]), str(f[1])])
     106
     107    if args.debug != None:
     108        command.extend(["-DEBUG", str(args.debug[0])]);
     109        command.extend(["-NCYCLES", str(args.debug[1])]);
     110        command.extend(["-PROCID", str(args.debug[2])]);
     111        command.extend(["-MEMCID", str(args.debug[3])]);
     112    else:
     113        command.extend(["-NCYCLES", "1000000"])
     114
     115    print command
     116    subprocess.call(command, stdout=logfile, stderr=logfile)
     117
     118    logfile.close()
     119
     120    # 6. move simulation terminal output into the target config dir
     121    os.rename("term0", os.path.join(outdir, "term"))
     122
    11123# get command-line arguments
    12 parser = argparse.ArgumentParser(description='Run simulation')
     124if __name__ == "__main__":
     125    parser = argparse.ArgumentParser(description='Run simulation')
    13126
    14 parser.add_argument(
    15     '--path', '-p', type=str, dest='path', default=os.getcwd(),
    16     help='relative or absolute path to the platform')
     127    parser.add_argument(
     128        '--path', '-p', type=str, dest='path', default=os.getcwd(),
     129        help='relative or absolute path to the platform')
    17130
    18 parser.add_argument(
    19     '--output', '-o', type=str, dest='outpath', default='./output',
    20     help='relative or absolute path to the output directory')
     131    parser.add_argument(
     132        '--output', '-o', type=str, dest='outpath', default='./output',
     133        help='relative or absolute path to the output directory')
    21134
    22 parser.add_argument(
    23     '--xsize', '-x', type=int, dest='x', default=2,
    24     help='# of clusters in a row')
     135    parser.add_argument(
     136        '--xsize', '-x', type=int, dest='x', default=2,
     137        help='# of clusters in a row')
    25138
    26 parser.add_argument(
    27     '--ysize', '-y', type=int, dest='y', default=2,
    28     help='# of clusters in a column')
     139    parser.add_argument(
     140        '--ysize', '-y', type=int, dest='y', default=2,
     141        help='# of clusters in a column')
    29142
    30 parser.add_argument(
    31     '--nprocs', '-n', type=int, dest='nprocs', default=4,
    32     help='# of processors per cluster')
     143    parser.add_argument(
     144        '--nprocs', '-n', type=int, dest='nprocs', default=4,
     145        help='# of processors per cluster')
    33146
    34 parser.add_argument(
    35     '--compile-only', '-c', dest='compileonly', action='store_true',
    36     help='generate config files and compile the platform. Do not simulate')
     147    parser.add_argument(
     148        '--compile-only', '-c', dest='compileonly', action='store_true',
     149        help='generate config files and compile the platform. Do not simulate')
    37150
    38 parser.add_argument(
    39     '--batch-mode', '-b', dest='batchmode', action='store_true',
    40     help='run simulation in batch mode: no interactive TTY or FrameBuffer')
     151    parser.add_argument(
     152        '--batch-mode', '-b', dest='batchmode', action='store_true',
     153        help='run simulation in batch mode: no interactive TTY or FrameBuffer')
    41154
    42 parser.add_argument(
    43     '--faulty-router', '-f', dest='faultyrouter', action='append',
    44     help='ID (X,Y) of faulty router')
     155    parser.add_argument(
     156        '--faulty-router', '-fr', dest='faultyrouter', action='append', nargs=2,
     157        help='ID (X,Y) of faulty router')
    45158
    46 parser.add_argument(
    47     '--faulty-mask', '-m', dest='faultymask', default=0x1F,
    48     help='Disable mask for faulty router interfaces')
     159    parser.add_argument(
     160        '--faulty-mask', '-m', dest='faultymask', default=0x1F,
     161        help='Disable mask for faulty router interfaces')
    49162
    50 parser.add_argument(
    51     '--debug', '-g', dest='debug', nargs=4,
    52     help='needs four arguments: from, to, procid, memcid')
     163    parser.add_argument(
     164        '--faulty-core', '-fc', dest='faultycore', action='append', nargs=3,
     165        help='ID (X,Y,L) of faulty processor')
    53166
    54 args = parser.parse_args()
     167    parser.add_argument(
     168        '--debug', '-g', dest='debug', nargs=4,
     169        help='needs four arguments: from, to, procid, memcid')
    55170
    56 # faulty processor list
    57 faultylist = [(0, 0, 1), (0, 0, 2), (0, 1, 2)]
    58 
    59 # translate the relative path (if needed) into an absolute path
    60 basedir = os.path.abspath(args.path)
    61 outdir = os.path.abspath(args.outpath)
    62 print "[ run.py ] platform base directory: {0}".format(basedir)
    63 print "[ run.py ] output directory: {0}".format(outdir)
    64 
    65 # 1. generate configuration and ouput directories
    66 try:
    67     os.makedirs(os.path.join(outdir, "config"), 0755)
    68 except OSError:
    69     pass # directory already exists => do nothing
    70 
    71 # 2. generate hard_config.h and fault_config.h files
    72 faultpath = os.path.join(outdir, "config/fault_config.h")
    73 hardpath = os.path.join(outdir, "config/hard_config.h")
    74 xmlpath = os.path.join(outdir, "config/map.xml")
    75 arch.main(args.x, args.y, args.nprocs, hardpath, xmlpath)
    76 faultyprocs.generate(faultylist, faultpath)
    77 
    78 # create a log file
    79 logfile = open(os.path.join(outdir, "log"), "w")
    80 
    81 # 3. compile simulator executable
    82 dst = os.path.join(basedir, "hard_config.h")
    83 if os.path.lexists(dst):
    84     os.unlink(dst)
    85 
    86 os.symlink(hardpath, dst)
    87 
    88 print "[ run.py ] compiling simulator"
    89 command = []
    90 command.extend(['make'])
    91 command.extend(['-C', basedir])
    92 subprocess.call(command, stdout=logfile, stderr=logfile)
    93 
    94 # 4. compile distributed boot executable
    95 dst = os.path.join(outdir, "config/boot_config.h")
    96 if os.path.lexists(dst):
    97     os.unlink(dst)
    98 
    99 os.symlink(os.path.join(basedir, "soft/config/boot_config.h"), dst)
    100 
    101 # stop after compiling the platform when the compile-only option is activated
    102 if args.compileonly == True:
    103     exit(0)
    104 
    105 print "[ run.py ] compiling distributed boot procedure"
    106 command = []
    107 command.extend(['make'])
    108 command.extend(['-C', os.path.join(basedir, "soft")])
    109 command.extend(["CONFDIR=" + outdir])
    110 subprocess.call(command, stdout=logfile, stderr=logfile)
    111 
    112 # 5. execute simulator
    113 os.environ["DISTRIBUTED_BOOT"] = "1"
    114 if args.batchmode:
    115     os.environ["SOCLIB_FB"] = "HEADLESS"
    116     os.environ["SOCLIB_TTY"] = "FILES"
    117 
    118 if (args.x * args.y) <= 4:
    119     ompthreads = args.x * args.y
    120 elif (args.x * args.y) <= 16:
    121     ompthreads = 4
    122 else:
    123     ompthreads = 8
    124 
    125 print "[ run.py ] starting simulation"
    126 command = []
    127 command.extend([os.path.join(basedir, "simul.x")])
    128 command.extend(["-SOFT", os.path.join(basedir, "soft/build/soft.elf")])
    129 command.extend(["-DISK", "/dev/null"])
    130 command.extend(["-THREADS", str(ompthreads)])
    131 
    132 if args.faultyrouter != None:
    133     command.extend(["-FAULTY_MASK", str(args.faultymask)])
    134     for f in args.faultyrouter:
    135         command.extend(["-FAULTY_ROUTER", str(f)])
    136 
    137 if args.debug != None:
    138     command.extend(["-DEBUG", str(args.debug[0])]);
    139     command.extend(["-NCYCLES", str(args.debug[1])]);
    140     command.extend(["-PROCID", str(args.debug[2])]);
    141     command.extend(["-MEMCID", str(args.debug[3])]);
    142 else:
    143     command.extend(["-NCYCLES", "1000000"])
    144 
    145 subprocess.call(command, stdout=logfile, stderr=logfile)
    146 
    147 logfile.close()
    148 
    149 # 6. move simulation terminal output into the target config dir
    150 os.rename("term0", os.path.join(outdir, "term"))
     171    run(parser.parse_args())
    151172
    152173# vim: tabstop=4 : softtabstop=4 : shiftwidth=4 : expandtab
  • branches/reconfiguration/platforms/tsar_generic_iob/top.cpp

    r889 r890  
    415415            debug_period = strtol(argv[n+1], NULL, 0);
    416416         }
    417          else if ((strcmp(argv[n], "-FAULTY_ROUTER") == 0) && (n+1 < argc) )
    418          {
    419             size_t faulty_router_id = strtol(argv[n+1], NULL, 0);
    420             size_t x = faulty_router_id >> Y_WIDTH;
    421             size_t y = faulty_router_id & ((1 << Y_WIDTH) - 1);
     417         else if ((strcmp(argv[n], "-FAULTY_ROUTER") == 0) && (n+2 < argc) )
     418         {
     419            size_t x = strtol(argv[n+1], NULL, 0);
     420            size_t y = strtol(argv[n+2], NULL, 0);
     421            n++;
    422422            if( (x>=X_SIZE) || (y>=Y_SIZE) )
    423423            {
     
    425425                exit(0);
    426426            }
    427             faulty_routers.push_back(faulty_router_id);
     427            faulty_routers.push_back((x << Y_WIDTH) | y);
    428428         }
    429429         else if ((strcmp(argv[n], "-FAULTY_MASK") == 0) && (n+1 < argc) )
Note: See TracChangeset for help on using the changeset viewer.