Ignore:
Timestamp:
Sep 11, 2015, 3:44:14 PM (9 years ago)
Author:
meunier
Message:
  • Update of simulation scripts for tsar_generic_xbar
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/platforms/tsar_generic_xbar/scripts/run_simus.py

    r836 r1012  
    66import shutil
    77
     8from gen_hdd import *
     9from gen_hard_config import *
     10from gen_arch_info import *
     11
    812#TODO (?): recopier les fichiers d'entrees dans le script en fonction de l'appli selectionnee
    913# Par exemple, tk14.O pour LU, img.raw pour ep_filter, etc.
     
    1115
    1216# User parameters
    13 nb_procs = [ 4 ]
    14 #nb_procs = [ 1, 4, 8, 16, 32, 64, 128, 256 ]
    15 rerun_stats = False
    16 use_omp = False
    17 protocol = 'wtidl'
    18 
     17bscpu = 0
     18#nb_procs = [ 4 ]
     19nb_procs = [ 1, 4, 8, 16, 32, 64, 128, 256 ]
     20rerun_stats = True
     21use_omp = True
     22protocol = 'rwt'
     23cpu_per_cluster = 4
     24# mode must be one of 'test' and 'simu'
     25mode = 'simu'
     26
     27#apps = [ 'cholesky', 'fft', 'fft_ga', 'filter', 'filt_ga', 'histogram', 'kmeans', 'lu', 'mandel', 'mat_mult', 'pca', 'radix_ga' ]
    1928#apps = [ 'histogram', 'mandel', 'filter', 'radix_ga', 'fft_ga', 'kmeans' ]
    20 #apps = [ 'histogram', 'mandel', 'filter', 'radix_ga', 'fft_ga' ]
    21 apps = [ 'radix' ]
     29apps = [ 'blackscholes', 'linear_regression', 'string_match', 'swaptions', 'fluidanimate' ]
    2230
    2331
    2432# Variables which could be changed but ought not to because they are reflected in the create_graphs.py script
    25 data_dir = 'data'
     33if mode == 'test':
     34    data_dir = 'data_test'
     35else:
     36    data_dir = 'data'
    2637log_init_name = protocol + '_stdo_'
    2738log_term_name = protocol + '_term_'
     
    2940# Global Variables
    3041
    31 all_apps = [ 'cholesky', 'fft', 'fft_ga', 'filter', 'filt_ga', 'histogram', 'kmeans', 'lu', 'mandel', 'mat_mult', 'pca', 'radix', 'radix_ga', 'showimg', ]
     42all_apps = [ 'blackscholes', 'boot_only', 'cholesky', 'fft', 'fft_ga', 'filter', 'filt_ga', 'fluidanimate', 'histogram', 'histo-opt', 'kmeans', 'kmeans-opt', 'linear_regression', 'lu', 'mandel', 'mat_mult', 'mat_mult-opt', 'pca', 'pca-opt', 'radix', 'radix_ga', 'showimg', 'string_match', 'swaptions', ]
    3243# to come: 'barnes', 'fmm', 'ocean', 'raytrace', 'radiosity', 'waters', 'watern'
    3344
    34 all_protocols = [ 'dhccp', 'rwt', 'hmesi', 'wtidl' ]
     45all_protocols = [ 'dhccp', 'rwt', 'hmesi', 'wtidl', 'snoop' ]
    3546
    3647top_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..")
    3748config_name = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.py")
    3849
    39 scripts_path       = os.path.join(top_path, 'scripts')
    40 almos_path         = os.path.join(top_path, 'almos')
    41 soclib_conf_name   = os.path.join(top_path, "soclib.conf")
    42 topcell_name       = os.path.join(top_path, "top.cpp")
    43 arch_info_name     = os.path.join(almos_path, "arch-info-gen.info")
    44 arch_info_bib_name = os.path.join(almos_path, 'arch-info.bib')
    45 hdd_img_file_name  = os.path.join(almos_path, "hdd-img.bin")
    46 shrc_file_name     = os.path.join(almos_path, "shrc")
    47 hard_config_name   = os.path.join(almos_path, "hard_config.h")
     50scripts_path         = os.path.join(top_path, 'scripts')
     51almos_path           = os.path.join(top_path, 'almos')
     52soclib_conf_name     = os.path.join(top_path, "soclib.conf")
     53topcell_name         = os.path.join(top_path, "top.cpp")
     54partition_root_path  = os.path.join(top_path, "hdd_root")
     55arch_info_name       = os.path.join(almos_path, "arch-info-gen.info")
     56arch_info_bib_name   = os.path.join(almos_path, 'arch-info.bib')
     57hdd_img_file_name    = os.path.join(almos_path, "hdd-img.bin")
     58shrc_file_name       = os.path.join(almos_path, "shrc")
     59hard_config_name     = os.path.join(almos_path, "hard_config.h")
     60bootloader_link_name = os.path.join(almos_path, "bootloader-tsar-mipsel.bin")
    4861
    4962
    5063# Checks
     64if mode != 'test' and mode != 'simu':
     65    help_str = '''
     66*** Error: variable mode must be one either 'test' (testing purpose, small data sets) or 'simu' (performance evaluation, large data sets)
     67'''
     68    print help_str
     69    sys.exit()
     70
    5171if protocol not in all_protocols:
    5272    help_str = '''
     
    6484    help_str = '''
    6585You should create a file named config.py in this directory with the following definitions:
    66  - apps_dir:      path to almos-tsar-mipsel/apps directory
    67  - almos_src_dir: path to almos source directory (for kernel and bootloader binaries)
    68  - hdd_img_name:  path to the hdd image to use (will be copied but not modified)
    69  - tsar_dir:      path to tsar repository
     86 - apps_dir:          path to almos-tsar-mipsel/apps directory
     87 - almos_src_dir:     path to almos source directory (for kernel and bootloader binaries)
     88 - preloader_src_dir: path to the preloader main directory (where to run make)
     89 - hdd_img_name:      path to the hdd image to use (will be copied but not modified)
     90 - tsar_dir:          path to tsar repository
    7091Optional definitions (necessary if you want to use alternative protocols):
    71  - rwt_dir:       path to the RWT repository
    72  - hmesi_dir:     path to HMESI directory
    73  - wtidl_dir:     path to the ideal write-through protocol directory
     92 - rwt_dir:           path to the RWT repository
     93 - hmesi_dir:         path to HMESI directory
     94 - wtidl_dir:         path to the ideal write-through protocol directory
    7495*** Stopping execution
    7596'''
     
    127148
    128149
    129 def get_x_y(nb_procs):
     150def print_and_call(cmd):
     151    print subprocess.list2cmdline(cmd)
     152    retval = subprocess.call(cmd)
     153    return retval
     154
     155def print_and_popen(cmd, outfile):
     156    print subprocess.list2cmdline(cmd),
     157    print " >", outfile
     158    output = subprocess.Popen(cmd, stdout = subprocess.PIPE).communicate()[0]
     159    return output
     160
     161
     162def get_x_y(nb_procs, cpu_per_cluster):
    130163    x = 1
    131164    y = 1
    132165    to_x = True
    133     while (x * y * 4 < nb_procs):
     166    while (x * y * cpu_per_cluster < nb_procs):
    134167        if to_x:
    135168            x = x * 2
     
    140173
    141174
     175def get_nb_bits(size):
     176    i = 0
     177    while 2**i < size:
     178        i += 1
     179    return i
     180
     181
     182
    142183def gen_soclib_conf():
    143 
    144184    if os.path.isfile(soclib_conf_name):
    145185        print "Updating file %s" % (soclib_conf_name)
     
    204244
    205245
    206 def gen_hard_config(x, y, hard_config):
    207    header = '''
    208 /* Generated from run_simus.py */
    209 
    210 #ifndef _HD_CONFIG_H
    211 #define _HD_CONFIG_H
    212 
    213 #define X_SIZE              %(x)d
    214 #define Y_SIZE              %(y)d
    215 #define NB_CLUSTERS         %(nb_clus)d
    216 #define NB_PROCS_MAX        4
    217 #define NB_TASKS_MAX        8
    218 
    219 #define NB_TIM_CHANNELS     32
    220 #define NB_DMA_CHANNELS     1
    221 
    222 #define NB_TTY_CHANNELS     4
    223 #define NB_IOC_CHANNELS     1
    224 #define NB_NIC_CHANNELS     0
    225 #define NB_CMA_CHANNELS     0
    226 
    227 #define USE_XICU            1
    228 #define IOMMU_ACTIVE        0
    229 
    230 #define IRQ_PER_PROCESSOR   1
    231 ''' % dict(x = x, y = y, nb_clus = x * y)
    232 
    233    if protocol == 'wtidl':
    234        header += '#define WT_IDL\n'
    235 
    236    header += '#endif //_HD_CONFIG_H\n'
    237 
    238    file = open(hard_config, 'w')
    239    file.write(header)
    240    file.close()
    241 
    242 
    243 
    244 def gen_arch_info(x, y, arch_info, arch_info_bib):
    245    old_path = os.getcwd()
    246    print "cd", scripts_path
    247    os.chdir(scripts_path)
    248    print "./gen_arch_info_large.sh", str(x), str(y), ">", arch_info
    249    output = subprocess.Popen([ './gen_arch_info_large.sh', str(x), str(y) ], stdout = subprocess.PIPE).communicate()[0]
    250    os.chdir(almos_path)
    251    file = open(arch_info, 'w')
    252    file.write(output)
    253    file.close()
    254    print "./info2bib -i", arch_info, "-o", arch_info_bib
    255    subprocess.call([ './info2bib', '-i', arch_info, '-o', arch_info_bib ])
    256    print "cd", old_path
    257    os.chdir(old_path)
     246
     247def gen_arch_info_bib(x, y, arch_info, arch_info_bib):
     248    old_path = os.getcwd()
     249
     250    print "cd", scripts_path
     251    os.chdir(scripts_path)
     252    gen_arch_info(x, y, x_width, y_width, bscpu, arch_info)
     253    os.chdir(almos_path)
    258254   
     255    cmd = ['./info2bib', '-i', arch_info, '-o', arch_info_bib]
     256    print_and_call(cmd)
     257
     258    print "cd", old_path
     259    os.chdir(old_path)
     260   
    259261
    260262def gen_sym_links():
    261    old_path = os.getcwd()
    262    print "cd", almos_path
    263    os.chdir(almos_path)
    264 
    265    target = os.path.join(almos_src_dir, 'tools/soclib-bootloader/bootloader-tsar-mipsel.bin')
    266    link_name = 'bootloader-tsar-mipsel.bin'
    267    if not os.path.isfile(link_name):
    268       print "ln -s", target, link_name
    269       os.symlink(target, link_name)
    270 
    271    target = os.path.join(almos_src_dir, 'kernel/obj.tsar/almix-tsar-mipsel.bin')
    272    link_name = 'kernel-soclib.bin'
    273    if not os.path.isfile(link_name):
    274       print "ln -s", target, link_name
    275       os.symlink(target, link_name)
    276 
    277    copied_hdd = 'hdd-img.bin'
    278    print "cp", hdd_img_name, copied_hdd
    279    shutil.copy(hdd_img_name, copied_hdd)
    280 
    281    os.chdir(old_path)
    282 
    283 
    284 
    285 def compile_app(app_name, nprocs):
    286 
    287    #if app_name in splash2:
    288    #   app_dir_name = os.path.join(splash2_dir, splash_app_dir[app_name])
    289    #elif app_name in splash2_ga:
    290    #   app_dir_name = os.path.join(splash2_ga_dir, splash_ga_app_dir[app_name])
    291    #else:
    292    #   app_dir_name = os.path.join(apps_dir, app_name)
     263    target = os.path.join(almos_src_dir, 'tools/soclib-bootloader/bootloader-tsar-mipsel.bin')
     264    if not os.path.isfile(bootloader_link_name):
     265        print "ln -s", target, bootloader_link_name
     266        os.symlink(target, bootloader_link_name)
     267
     268    #target = os.path.join(almos_src_dir, 'kernel/obj.tsar/almix-tsar-mipsel.bin')
     269    #link_name = 'kernel-soclib.bin'
     270    #if not os.path.isfile(link_name):
     271    #    print "ln -s", target, link_name
     272    #    os.symlink(target, link_name)
     273
     274
     275def compile_almos():
     276    old_path = os.getcwd()
     277
     278    print "cd", almos_src_dir
     279    os.chdir(almos_src_dir)
     280    cmd = ['make']
     281    print_and_call(cmd)
     282    bootloader_dir = os.path.join(almos_src_dir, 'tools/soclib-bootloader')
     283    print "cd", bootloader_dir
     284    os.chdir(bootloader_dir)
     285    print_and_call(cmd)
     286
     287    print "cd", old_path
     288    os.chdir(old_path)
     289 
     290
     291def compile_preloader():
     292    old_path = os.getcwd()
     293    hard_conf_path_set = "HARD_CONFIG_PATH=" + almos_path
     294    bscpu_set = "BS_PROC=%d" % bscpu
     295
     296    print "cd", preloader_src_dir
     297    os.chdir(preloader_src_dir)
     298    cmd = ['make', hard_conf_path_set, bscpu_set, 'USE_DT=0']
     299    print_and_call(cmd)
     300
     301    print "cd", old_path
     302    os.chdir(old_path)
     303
     304
     305
     306
     307def compile_app(app_name):
     308
     309    #if app_name in splash2:
     310    #   app_dir_name = os.path.join(splash2_dir, splash_app_dir[app_name])
     311    #elif app_name in splash2_ga:
     312    #   app_dir_name = os.path.join(splash2_ga_dir, splash_ga_app_dir[app_name])
     313    #else:
     314    #   app_dir_name = os.path.join(apps_dir, app_name)
    293315
    294316     
    295    app_dir_name = os.path.join(apps_dir, app_name)
    296 
    297    old_path = os.getcwd()
    298    print "cd", app_dir_name
    299    os.chdir(app_dir_name)
    300 
    301    # Compilation process is different in splash and other apps
    302    #if app_name in splash2:
    303    #   print "make clean"
    304    #   subprocess.call([ 'make', 'clean' ])
    305 
    306    #   print "rm Makefile"
    307    #   subprocess.call([ 'rm', 'Makefile' ])
    308 
    309    #   print "ln -s Makefile.soclib Makefile"
    310    #   subprocess.call([ 'ln', '-s', 'Makefile.soclib', 'Makefile' ])
    311 
    312    #   print "make"
    313    #   subprocess.call([ 'make' ])
    314 
    315    #else:
    316    #   print "make clean"
    317    #   subprocess.call([ 'make', 'clean' ])
    318  
    319    #   print "make TARGET=tsar"
    320    #   subprocess.call([ 'make', 'TARGET=tsar' ])
    321 
    322    print "make clean"
    323    subprocess.call([ 'make', 'clean' ])
    324  
    325    print "make TARGET=tsar"
    326    retval = subprocess.call([ 'make', 'TARGET=tsar' ])
    327    if retval != 0:
    328        sys.exit()
    329    
    330    # Creation/Modification du shrc de almos
    331    if (app_name == "boot_only"):
    332       shrc = "exec -p 0 /bin/boot_onl\n"
    333    elif (app_name == "mandel"):
    334       shrc = "exec -p 0 /bin/mandel -n%(nproc)d\n" % dict(nproc = nprocs)
    335    elif (app_name == "filter"):
    336       shrc = "exec -p 0 /bin/filter -l1024 -c1024 -n%(nproc)d /etc/img.raw\n" % dict(nproc = nprocs)
    337    elif (app_name == "filt_ga"):
    338       shrc = "exec -p 0 /bin/filt_ga -n%(nproc)d -i /etc/img.raw\n" % dict(nproc = nprocs)
    339    elif (app_name == "histogram"):
    340       shrc = "exec -p 0 /bin/histogra -n%(nproc)d /etc/histo.bmp\n" % dict(nproc = nprocs)
    341    elif (app_name == "kmeans"):
    342       shrc = "exec -p 0 /bin/kmeans -n %(nproc)d -p %(npoints)d\n" % dict(nproc = nprocs, npoints = 10000) # default npoints = 100000
    343    elif (app_name == "pca"):
    344       shrc = "exec -p 0 /bin/pca -n%(nproc)d\n" % dict(nproc = nprocs)
    345    elif (app_name == "mat_mult"):
    346       shrc = "exec -p 0 /bin/mat_mult -n%(nproc)d\n" % dict(nproc = nprocs)
    347    elif (app_name == "showimg"):
    348       shrc = "exec -p 0 /bin/showimg -i /etc/lena.sgi\n"
    349    elif (app_name == "barnes"):
    350       shrc = "exec -p 0 /bin/barnes -n%(nproc)d -b%(nbody)d\n" % dict(nproc = nprocs, nbody = 1024)
    351    elif (app_name == "fmm"):
    352       shrc = "exec -p 0 /bin/fmm -n%(nproc)d -p%(nparticles)d\n" % dict(nproc = nprocs, nparticles = 1024)
    353    elif (app_name == "ocean"):
    354       shrc = "exec -p 0 /bin/ocean -n%(nproc)d -m%(gridsize)d\n" % dict(nproc = nprocs, gridsize = 66)
    355    elif (app_name == "radiosity"):
    356       shrc = "exec -p 0 /bin/radiosit -n %(nproc)d -batch\n" % dict(nproc = nprocs)
    357    elif (app_name == "raytrace"):
    358       shrc = "exec -p 0 /bin/raytrace -n%(nproc)d /etc/tea.env\n" % dict(nproc = nprocs)
    359    elif (app_name == "watern"):
    360       shrc = "exec -p 0 /bin/watern -n%(nproc)d -m512\n" % dict(nproc = nprocs)
    361    elif (app_name == "waters"):
    362       shrc = "exec -p 0 /bin/waters -n%(nproc)d -m512\n" % dict(nproc = nprocs)
    363    elif (app_name == "cholesky"):
    364       shrc = "exec -p 0 /bin/cholesky -n%(nproc)d /etc/tk14.O\n" % dict(nproc = nprocs)
    365    elif (app_name == "fft"):
    366       shrc = "exec -p 0 /bin/fft -n%(nproc)d -m18\n" % dict(nproc = nprocs)
    367    elif (app_name == "lu"):
    368       shrc = "exec -p 0 /bin/lu -n%(nproc)d -m512\n" % dict(nproc = nprocs)
    369    elif (app_name == "radix"):
    370       shrc = "exec -p 0 /bin/radix -n%(nproc)d -k1024\n" % dict(nproc = nprocs) # test : 1024 ; simu : 2097152
    371    elif (app_name == "radix_ga"):
    372       shrc = "exec -p 0 /bin/radix_ga -n%(nproc)d -k2097152\n" % dict(nproc = nprocs) # p = proc, n = num_keys
    373    elif (app_name == "fft_ga"):
    374       shrc = "exec -p 0 /bin/fft_ga -n%(nproc)d -m18\n" % dict(nproc = nprocs)
    375    else:
    376       assert(False)
    377    
    378    file = open(shrc_file_name, 'w')
    379    file.write(shrc)
    380    file.close()
    381 
    382    # Copie du binaire et du shrc dans l'image disque
    383    print "mcopy -o -i", hdd_img_file_name, shrc_file_name, "::/etc/"
    384    subprocess.call([ 'mcopy', '-o', '-i', hdd_img_file_name, shrc_file_name, '::/etc/' ])
    385    print "mcopy -o -i", hdd_img_file_name, app_name, "::/bin/"
    386    subprocess.call([ 'mcopy', '-o', '-i', hdd_img_file_name, app_name, '::/bin/' ])
    387 
    388    print "cd", old_path
    389    os.chdir(old_path)
     317    app_dir_name = os.path.join(apps_dir, app_name)
     318
     319    old_path = os.getcwd()
     320    print "cd", app_dir_name
     321    os.chdir(app_dir_name)
     322
     323    # Compilation process is different in splash and other apps
     324    #if app_name in splash2:
     325    #   print "make clean"
     326    #   subprocess.call([ 'make', 'clean' ])
     327
     328    #   print "rm Makefile"
     329    #   subprocess.call([ 'rm', 'Makefile' ])
     330
     331    #   print "ln -s Makefile.soclib Makefile"
     332    #   subprocess.call([ 'ln', '-s', 'Makefile.soclib', 'Makefile' ])
     333
     334    #   print "make"
     335    #   subprocess.call([ 'make' ])
     336
     337    #else:
     338    #   print "make clean"
     339    #   subprocess.call([ 'make', 'clean' ])
     340 
     341    #   print "make TARGET=tsar"
     342    #   subprocess.call([ 'make', 'TARGET=tsar' ])
     343
     344    cmd = ['make', 'clean']
     345    print_and_call(cmd)
     346 
     347    cmd = ['make', 'TARGET=tsar']
     348    retval = print_and_call(cmd)
     349    if retval != 0:
     350        sys.exit()
     351
     352    print "cd", old_path
     353    os.chdir(old_path)
    390354# end of compile_app
    391355
    392356
    393 print "mkdir -p", os.path.join(scripts_path, data_dir)
    394 subprocess.call([ 'mkdir', '-p', os.path.join(scripts_path, data_dir) ])
     357
     358
     359def gen_shrc(app_name, nprocs):
     360    # Creation/Modification du shrc de almos
     361    if mode == 'test':
     362        if (app_name == "blackscholes"):
     363            shrc = "exec -p 0 /bin/blacksch -n%(nproc)d /etc/black_16.txt\n" % dict(nproc = nprocs)
     364        elif (app_name == "boot_only"):
     365            shrc = "exec -p 0 /bin/boot_onl\n"
     366        elif (app_name == "filter"):
     367            shrc = "exec -p 0 /bin/filter -l 128 -c 128 -n %(nproc)d -i /etc/img128.raw\n" % dict(nproc = nprocs)
     368        elif (app_name == "filt_ga"):
     369            shrc = "exec -p 0 /bin/filt_ga -l 128 -c 128 -n %(nproc)d -i /etc/img128.raw\n" % dict(nproc = nprocs)
     370        elif (app_name == "fft"):
     371            shrc = "exec -p 0 /bin/fft -n%(nproc)d -m4\n" % dict(nproc = nprocs)
     372        elif (app_name == "fft_ga"):
     373            shrc = "exec -p 0 /bin/fft_ga -n%(nproc)d -m4\n" % dict(nproc = nprocs) # m = vector size
     374        elif (app_name == "fluidanimate"):
     375            shrc = "exec -p 0 /bin/fluidani -n%(nproc)d -i /etc/flui_15K.flu\n" % dict(nproc = nprocs)
     376        elif (app_name == "histogram"):
     377            shrc = "exec -p 0 /bin/histogra -n%(nproc)d /etc/histo_s.bmp\n" % dict(nproc = nprocs)
     378        elif (app_name == "histo-opt"):
     379            shrc = "exec -p 0 /bin/histo-op -n%(nproc)d /etc/histo_s.bmp\n" % dict(nproc = nprocs)
     380        elif (app_name == "kmeans"):
     381            shrc = "exec -p 0 /bin/kmeans -n %(nproc)d -p %(npoints)d\n" % dict(nproc = nprocs, npoints = 1000)
     382        elif (app_name == "kmeans-opt"):
     383            shrc = "exec -p 0 /bin/kmeans-o -n %(nproc)d -p %(npoints)d\n" % dict(nproc = nprocs, npoints = 1000)
     384        elif (app_name == "linear_regression"):
     385            shrc = "exec -p 0 /bin/linear_r -n%(nproc)d /etc/key_1MB.txt\n" % dict(nproc = nprocs)
     386        elif (app_name == "lu"):
     387            shrc = "exec -p 0 /bin/lu -n%(nproc)d -m16\n" % dict(nproc = nprocs)
     388        elif (app_name == "mandel"):
     389            shrc = "exec -p 0 /bin/mandel -n%(nproc)d -x 30 -y 20\n" % dict(nproc = nprocs)
     390        elif (app_name == "mat_mult"):
     391            shrc = "exec -p 0 /bin/mat_mult -n%(nproc)d -s 10\n" % dict(nproc = nprocs) # s = matrix size
     392        elif (app_name == "mat_mult-opt"):
     393            shrc = "exec -p 0 /bin/mat_mult -n%(nproc)d -s 10\n" % dict(nproc = nprocs)
     394        elif (app_name == "pca"):
     395            shrc = "exec -p 0 /bin/pca -n%(nproc)d -r 16 -c 8\n" % dict(nproc = nprocs) # r = num rows, c = num cols
     396        elif (app_name == "pca-opt"):
     397            shrc = "exec -p 0 /bin/pca-opt -n%(nproc)d -r 16 -c 8\n" % dict(nproc = nprocs)
     398        elif (app_name == "radix"):
     399            shrc = "exec -p 0 /bin/radix -n%(nproc)d -k1024\n" % dict(nproc = nprocs)
     400        elif (app_name == "radix_ga"):
     401            shrc = "exec -p 0 /bin/radix_ga -n%(nproc)d -k1024\n" % dict(nproc = nprocs) # n = num_keys
     402        elif (app_name == "string_match"):
     403            shrc = "exec -p 0 /bin/string_m -n%(nproc)d /etc/key_1MB.txt\n" % dict(nproc = nprocs)
     404        elif (app_name == "swaptions"):
     405            shrc = "exec -p 0 /bin/swaption -n%(nproc)d -s 16 -t 1000\n" % dict(nproc = nprocs) # s = num swaptions (default 16), t = num simus (default 10000)
     406        else:
     407            print "*** Error: The application %s is not available in test mode", app_name
     408            sys.exit()
     409    else:
     410        if (app_name == "barnes"):
     411            shrc = "exec -p 0 /bin/barnes -n%(nproc)d -b%(nbody)d\n" % dict(nproc = nprocs, nbody = 1024)
     412        elif (app_name == "blackscholes"):
     413            shrc = "exec -p 0 /bin/blacksch -n %(nproc)d /etc/black_4K.txt\n" % dict(nproc = nprocs)
     414        elif (app_name == "boot_only"):
     415            shrc = "exec -p 0 /bin/boot_onl\n"
     416        elif (app_name == "cholesky"):
     417            shrc = "exec -p 0 /bin/cholesky -n%(nproc)d /etc/tk14.O\n" % dict(nproc = nprocs)
     418        elif (app_name == "fft"):
     419            shrc = "exec -p 0 /bin/fft -n%(nproc)d -m18\n" % dict(nproc = nprocs)
     420        elif (app_name == "fft_ga"):
     421            shrc = "exec -p 0 /bin/fft_ga -n%(nproc)d -m18\n" % dict(nproc = nprocs)
     422        elif (app_name == "fluidanimate"):
     423            shrc = "exec -p 0 /bin/fluidani -n%(nproc)d -i /etc/flui_35K.flu\n" % dict(nproc = nprocs)
     424        elif (app_name == "filter"):
     425            shrc = "exec -p 0 /bin/filter -l 1024 -c 1024 -n %(nproc)d -i /etc/img1024.raw\n" % dict(nproc = nprocs)
     426        elif (app_name == "filt_ga"):
     427            shrc = "exec -p 0 /bin/filt_ga -l 1024 -c 1024 -n %(nproc)d -i /etc/img1024.raw\n" % dict(nproc = nprocs)
     428        elif (app_name == "histogram"):
     429            shrc = "exec -p 0 /bin/histogra -n%(nproc)d /etc/histo.bmp\n" % dict(nproc = nprocs)
     430        elif (app_name == "histo-opt"):
     431            shrc = "exec -p 0 /bin/histo-op -n%(nproc)d /etc/histo.bmp\n" % dict(nproc = nprocs)
     432        elif (app_name == "kmeans"):
     433            shrc = "exec -p 0 /bin/kmeans -n %(nproc)d -p %(npoints)d\n" % dict(nproc = nprocs, npoints = 10000) # default npoints = 100000
     434        elif (app_name == "kmeans-opt"):
     435            shrc = "exec -p 0 /bin/kmeans-o -n %(nproc)d -p %(npoints)d\n" % dict(nproc = nprocs, npoints = 10000) # default npoints = 100000
     436        elif (app_name == "linear_regression"):
     437            shrc = "exec -p 0 /bin/linear_r -n%(nproc)d /etc/key_50MB.txt\n" % dict(nproc = nprocs)
     438        elif (app_name == "lu"):
     439            shrc = "exec -p 0 /bin/lu -n%(nproc)d -m512\n" % dict(nproc = nprocs)
     440        elif (app_name == "mandel"):
     441            shrc = "exec -p 0 /bin/mandel -n%(nproc)d\n" % dict(nproc = nprocs)
     442        elif (app_name == "mat_mult"):
     443            shrc = "exec -p 0 /bin/mat_mult -n%(nproc)d\n" % dict(nproc = nprocs)
     444        elif (app_name == "mat_mult-opt"):
     445            shrc = "exec -p 0 /bin/mat_mult -n%(nproc)d\n" % dict(nproc = nprocs)
     446        elif (app_name == "pca"):
     447            shrc = "exec -p 0 /bin/pca -n%(nproc)d\n" % dict(nproc = nprocs)
     448        elif (app_name == "pca-opt"):
     449            shrc = "exec -p 0 /bin/pca-opt -n%(nproc)d\n" % dict(nproc = nprocs)
     450        elif (app_name == "fmm"):
     451            shrc = "exec -p 0 /bin/fmm -n%(nproc)d -p%(nparticles)d\n" % dict(nproc = nprocs, nparticles = 1024)
     452        elif (app_name == "ocean"):
     453            shrc = "exec -p 0 /bin/ocean -n%(nproc)d -m%(gridsize)d\n" % dict(nproc = nprocs, gridsize = 66)
     454        elif (app_name == "radiosity"):
     455            shrc = "exec -p 0 /bin/radiosit -n %(nproc)d -batch\n" % dict(nproc = nprocs)
     456        elif (app_name == "radix"):
     457            shrc = "exec -p 0 /bin/radix -n%(nproc)d -k2097152\n" % dict(nproc = nprocs)
     458        elif (app_name == "radix_ga"):
     459            shrc = "exec -p 0 /bin/radix_ga -n%(nproc)d -k2097152\n" % dict(nproc = nprocs) # k = num_keys
     460        elif (app_name == "string_match"):
     461            shrc = "exec -p 0 /bin/string_m -n%(nproc)d /etc/key_50MB.txt\n" % dict(nproc = nprocs)
     462        elif (app_name == "raytrace"):
     463            shrc = "exec -p 0 /bin/raytrace -n%(nproc)d /etc/tea.env\n" % dict(nproc = nprocs)
     464        elif (app_name == "showimg"):
     465            shrc = "exec -p 0 /bin/showimg -i /etc/lena.sgi\n"
     466        elif (app_name == "swaptions"):
     467            shrc = "exec -p 0 /bin/swaption -n%(nproc)d -s 256 -t 1000\n" % dict(nproc = nprocs) # s = num swaptions (default 16), t = num simus (default 10000)
     468        elif (app_name == "watern"):
     469            shrc = "exec -p 0 /bin/watern -n%(nproc)d -m512\n" % dict(nproc = nprocs)
     470        elif (app_name == "waters"):
     471            shrc = "exec -p 0 /bin/waters -n%(nproc)d -m512\n" % dict(nproc = nprocs)
     472        else:
     473            assert(False)
     474   
     475    file = open(shrc_file_name, 'w')
     476    file.write(shrc)
     477    file.close()
     478
     479    # Copie du shrc dans la future image disque
     480    cmd = ['cp', shrc_file_name, os.path.join(partition_root_path, "etc", "shrc")]
     481    print_and_call(cmd)
     482# end of gen_shrc
     483
     484
     485
     486cmd = ['mkdir', '-p', os.path.join(scripts_path, data_dir)]
     487print_and_call(cmd)
    395488
    396489gen_sym_links()
    397490gen_soclib_conf()
     491compile_preloader()
     492compile_almos()
     493# Compile application once at the beginning not to intererfere with
     494# other simulations
     495for app in apps:
     496    compile_app(app)
     497    full_app_name = os.path.join(apps_dir, app, app)
     498    cmd = ['cp', full_app_name, os.path.join(partition_root_path, "bin", app)]
     499    print_and_call(cmd)
     500
     501 
     502print "cd", top_path
     503os.chdir(top_path)
    398504
    399505for i in nb_procs:
    400    x, y = get_x_y(i)
    401    nthreads = min(4, x * y)
    402    gen_hard_config(x, y, hard_config_name)
    403    gen_arch_info(x, y, arch_info_name, arch_info_bib_name)
    404 
    405    print "cd", top_path
    406    os.chdir(top_path)
    407    print "touch", topcell_name
    408    subprocess.call([ 'touch', topcell_name ])
    409    print "make"
    410    retval = subprocess.call([ 'make' ])
    411    if retval != 0:
    412        sys.exit()
    413 
    414    for app in apps:
    415       print "cd", top_path
    416       os.chdir(top_path)
    417 
    418       compile_app(app, i)
    419 
    420       # Launch simulation
    421       if use_omp:
    422          print "./simul.x -THREADS", nthreads, ">", os.path.join(scripts_path, data_dir, app + '_' + log_init_name + str(i))
    423          output = subprocess.Popen([ './simul.x', '-THREADS', str(nthreads) ], stdout = subprocess.PIPE).communicate()[0]
    424       else:
    425          print "./simul.x >", os.path.join(scripts_path, data_dir, app + '_' + log_init_name + str(i))
    426          output = subprocess.Popen([ './simul.x' ], stdout = subprocess.PIPE).communicate()[0]
    427 
    428 
    429       # Write simulation results to data directory
    430       print "cd", scripts_path
    431       os.chdir(scripts_path)
    432       filename = os.path.join(data_dir, app + '_' + log_init_name + str(i))
    433       file = open(filename, 'w')
    434       file.write(output)
    435       file.close()
    436 
    437       filename = os.path.join(scripts_path, data_dir, app + '_' + log_term_name + str(i))
    438       print "mv", os.path.join(top_path, 'term1'), filename
    439       subprocess.call([ 'mv', os.path.join(top_path, 'term1'), filename ])
    440 
    441       if rerun_stats:
    442          start2_found = False
    443          end_found = False
    444          for line in open(filename):
    445             if "[THREAD_COMPUTE_START]" in line:
    446                start2 = line.split()[-1]
    447                start2_found = True
    448             if "[THREAD_COMPUTE_END]" in line:
    449                end = line.split()[-1]
    450                end_found = True
    451          assert(start2_found and end_found)
    452          
    453          print "cd", top_path
    454          os.chdir(top_path)
    455 
    456          # Relauching simulation with reset and dump of counters
    457          if use_omp:
    458             print "./simul.x -THREADS", nthreads, "--reset-counters %s --dump-counters %s >" % (start2, end), os.path.join(scripts_path, data_dir, app + '_' + log_init_name + str(i))
    459             output = subprocess.Popen([ './simul.x', '-THREADS', str(nthreads), '--reset-counters', start2, '--dump-counters', end ], stdout = subprocess.PIPE).communicate()[0]
    460          else:
    461             print "./simul.x --reset-counters %s --dump-counters %s >" % (start2, end), os.path.join(scripts_path, data_dir, app + '_' + log_init_name + str(i))
    462             output = subprocess.Popen([ './simul.x', '--reset-counters', start2, '--dump-counters', end ], stdout = subprocess.PIPE).communicate()[0]
    463          
    464          # Write simulation results (counters) to data directory
    465          print "cd", scripts_path
    466          os.chdir(scripts_path)
    467          filename = os.path.join(data_dir, app + '_' + log_init_name + str(i))
    468          file = open(filename, 'w')
    469          file.write(output)
    470          file.close()
     506    x, y = get_x_y(i, cpu_per_cluster)
     507    x_width = get_nb_bits(x)
     508    y_width = get_nb_bits(y)
     509    nthreads = min(4, x * y)
     510    hard_config(x, y, x_width, y_width, cpu_per_cluster, hard_config_name, protocol)
     511    gen_arch_info_bib(x, y, arch_info_name, arch_info_bib_name)
     512
     513    cmd = ['touch', topcell_name]
     514    print_and_call(cmd)
     515
     516    cmd = ['make']
     517    retval = print_and_call(cmd)
     518    if retval != 0:
     519        sys.exit()
     520 
     521    for app in apps:
     522        # Generate shrc
     523        gen_shrc(app, i)
     524
     525        # Remove current disk image
     526        print "rm", hdd_img_file_name
     527        os.remove(hdd_img_file_name)
     528
     529        # Regenerate disk image
     530        hdd_img(partition_root_path, hdd_img_file_name, "fat32", bootloader_link_name)
     531
     532        # Launch simulation
     533        if use_omp:
     534            cmd = ['./simul.x', '-THREADS', str(nthreads)]
     535        else:
     536            cmd = ['./simul.x']
     537        filename = os.path.join(scripts_path, data_dir, app + '_' + log_init_name + str(i))
     538        output = print_and_popen(cmd, filename)
     539 
     540        # Write simulation results to data directory
     541        file = open(filename, 'w')
     542        file.write(output)
     543        file.close()
     544 
     545        filename = os.path.join(scripts_path, data_dir, app + '_' + log_term_name + str(i))
     546       
     547        cmd = ['mv', os.path.join(top_path, 'term1'), filename]
     548        print_and_call(cmd)
     549 
     550        if rerun_stats:
     551            start2_found = False
     552            end_found = False
     553            for line in open(filename):
     554                if "[THREAD_COMPUTE_START]" in line:
     555                    start2 = line.split()[-1]
     556                    start2_found = True
     557                if "[THREAD_COMPUTE_END]" in line:
     558                    end = line.split()[-1]
     559                    end_found = True
     560            assert(start2_found and end_found)
     561         
     562            # Regenerate shrc and hdd to ensure having the same hdd image
     563            gen_shrc(app, i)
     564 
     565            # Relauching simulation with reset and dump of counters
     566            if use_omp:
     567                cmd = ['./simul.x', '-THREADS', str(nthreads), '--reset-counters', start2, '--dump-counters', end]
     568            else:
     569                cmd = ['./simul.x', '--reset-counters', start2, '--dump-counters', end]
     570            filename = os.path.join(scripts_path, data_dir, app + '_' + log_init_name + str(i))
     571            output = print_and_popen(cmd, filename)
     572           
     573            # Checking that the two terms obtained are identical
     574            import filecmp
     575            term_orig_file = os.path.join(scripts_path, data_dir, app + '_' + log_term_name + str(i))
     576            term_new_file = os.path.join(top_path, 'term1')
     577            assert(filecmp.cmp(term_orig_file, term_new_file))
     578 
     579            # Write simulation results (counters) to data directory
     580            file = open(filename, 'w')
     581            file.write(output)
     582            file.close()
    471583 
    472584
Note: See TracChangeset for help on using the changeset viewer.