source: trunk/platforms/tsar_generic_xbar/scripts/run_simus.py @ 1064

Last change on this file since 1064 was 1048, checked in by meunier, 8 years ago
  • Update of tsar_xbar_cluster (scripts and openmp support)
  • Property svn:executable set to *
File size: 24.0 KB
Line 
1#!/usr/bin/python
2
3import subprocess
4import os
5import sys
6import shutil
7
8from gen_hdd import *
9from gen_hard_config import *
10from gen_arch_info import *
11
12#TODO (?): recopier les fichiers d'entrees dans le script en fonction de l'appli selectionnee
13# Par exemple, tk14.O pour LU, img.raw pour ep_filter, etc.
14
15
16# User parameters
17bscpu = 0 # bootstrap CPU
18nb_procs = [ 4 ]
19#nb_procs = [ 1, 2, 4, 8, 16, 32, 64, 128, 256 ]
20rerun_stats = False
21use_omp = True
22protocol = 'dhccp'
23cpu_per_cluster = 4
24# mode must be one of 'test' and 'simu'
25mode = 'test'
26
27#apps = [ 'cholesky', 'fft', 'fft_ga', 'filter', 'filt_ga', 'histogram', 'kmeans', 'lu', 'mandel', 'mat_mult', 'pca', 'radix_ga' ]
28#apps = [ 'histogram', 'mandel', 'filter', 'radix_ga', 'fft_ga', 'kmeans' ]
29apps = [ 'fal_sh_2' ]
30
31#apps = [ 'pca-opt', 'blackscholes', 'fft_ga', 'filt_ga', 'histo-opt', 'kmeans-opt', 'linear_regression', 'lu', 'mandel', 'radix_ga', 'string_match' ]
32#apps = [ 'pca-opt', 'blackscholes', 'fft_ga', 'filt_ga', 'histo-opt', 'kmeans-opt', 'linear_regression', 'lu', 'mandel', 'mat_mult-opt', 'radix_ga', 'string_match' ]
33
34if mode == 'test':
35    data_dir = 'data_test'
36else:
37    data_dir = 'data'
38
39# Variables which could be changed but ought not to because they are reflected in the create_graphs.py script
40
41log_stdo_name = protocol + '_stdo_'
42log_term_name = protocol + '_term_'
43
44
45# Global Variables
46
47all_modes = ['simu', 'test']
48all_apps = [ 'blackscholes', 'boot_only', 'cholesky', 'fal_sh_1', 'fal_sh_2', 'fft', 'fft_ga', 'filter', 'filt_ga', 'fluidanimate', 'hello', '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', ]
49# to come: 'barnes', 'fmm', 'ocean', 'raytrace', 'radiosity', 'waters', 'watern'
50
51all_protocols = [ 'dhccp', 'rwt', 'hmesi', 'wtidl', 'snoop' ]
52
53top_path = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), ".."))
54config_name = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.py")
55
56scripts_path          = os.path.join(top_path, 'scripts')
57almos_path            = os.path.join(top_path, 'almos')
58soclib_conf_name      = os.path.join(top_path, "soclib.conf")
59topcell_name          = os.path.join(top_path, "top.cpp")
60partition_root_path   = os.path.join(top_path, "hdd_root")
61arch_info_name        = os.path.join(almos_path, "arch-info.info")
62arch_info_bib_name    = os.path.join(almos_path, 'arch-info.bib')
63hdd_img_file_name     = os.path.join(almos_path, "hdd-img.bin")
64shrc_file_name        = os.path.join(almos_path, "shrc")
65hard_config_name      = os.path.join(almos_path, "hard_config.h")
66bootloader_file_name  = os.path.join(almos_path, "bootloader-tsar-mipsel.bin")
67#preloader_file_name   = os.path.join(almos_path, "preloader.elf")
68preloader_build_path  = os.path.join(almos_path, "build_preloader")
69bootloader_build_path = os.path.join(almos_path, "build_bootloader")
70
71
72# Checks
73if mode != 'test' and mode != 'simu':
74    help_str = '''
75*** Error: variable mode must be one either 'test' (testing purpose, small data sets) or 'simu' (performance evaluation, large data sets)
76'''
77    print help_str
78    sys.exit()
79
80if protocol not in all_protocols:
81    help_str = '''
82*** Error: variable protocol has an unsupported value
83'''
84    print help_str
85    sys.exit()
86
87for the_app in apps:
88    if the_app not in all_apps:
89        print "*** Error: application %s is not defined" % (the_app)
90        sys.exit()
91
92if not os.path.isfile(config_name):
93    help_str = '''
94You should create a file named config.py in this directory with the following definitions:
95 - apps_dir:          path to almos-tsar-mipsel/apps directory
96 - almos_src_dir:     path to almos source directory (for kernel and bootloader binaries)
97 - preloader_src_dir: path to the preloader main directory (where to run make)
98 - tsar_dir:          path to tsar repository
99Optional definitions (necessary if you want to use alternative protocols):
100 - rwt_dir:           path to the RWT repository
101 - hmesi_dir:         path to HMESI directory
102 - wtidl_dir:         path to the ideal write-through protocol directory
103*** Stopping execution
104'''
105    print help_str
106    sys.exit()
107
108# Loading config
109exec(file(config_name))
110
111# Check that variables and paths exist
112for var in [ 'apps_dir', 'almos_src_dir', 'tsar_dir' ]:
113    if eval(var) == "":
114        print "*** Error: variable %s not defined in config file" % (var)
115        sys.exit()
116    if not os.path.exists(eval(var)):
117        print "*** Error: variable %s does not define a valid path" % (var)
118        sys.exit()
119
120if protocol == "rwt":
121    if rwt_dir == "":
122        print "*** Error: variable rwt_dir not defined in config file"
123        sys.exit()
124    if not os.path.exists(rwt_dir):
125        print "*** Error: variable rwt_dir does not define a valid path"
126        sys.exit()
127
128if protocol == "hmesi":
129    if hmesi_dir == "":
130        print "*** Error: variable hmesi_dir not defined in config file"
131        sys.exit()
132    if not os.path.exists(hmesi_dir):
133        print "*** Error: variable hmesi_dir does not define a valid path"
134        sys.exit()
135
136if protocol == "wtidl":
137    if wtidl_dir == "":
138        print "*** Error: variable wtidl_dir not defined in config file"
139        sys.exit()
140    if not os.path.exists(wtidl_dir):
141        print "*** Error: variable wtidl_dir does not define a valid path"
142        sys.exit()
143
144
145
146
147#splash_app_dir = {}
148#splash_app_dir['barnes'] = 'apps/barnes'
149#splash_app_dir['fmm'] = 'apps/fmm'
150#splash_app_dir['ocean'] = 'apps/ocean/contiguous_partitions'
151#splash_app_dir['raytrace'] = 'apps/raytrace'
152#splash_app_dir['radiosity'] = 'apps/radiosity'
153#splash_app_dir['volrend'] = 'apps/volrend'
154#splash_app_dir['watern'] = 'apps/water-nsquared'
155#splash_app_dir['waters'] = 'apps/water-spatial'
156
157
158def print_and_call(cmd):
159    print subprocess.list2cmdline(cmd)
160    retval = subprocess.call(cmd)
161    return retval
162
163def print_and_popen(cmd, outfile):
164    print subprocess.list2cmdline(cmd),
165    print " >", outfile
166    output = subprocess.Popen(cmd, stdout = subprocess.PIPE).communicate()[0]
167    return output
168
169
170def get_x_y(nb_procs, cpu_per_cluster):
171    x = 1
172    y = 1
173    to_x = True
174    while (x * y * cpu_per_cluster < nb_procs):
175        if to_x:
176            x = x * 2
177        else:
178            y = y * 2
179        to_x = not to_x
180    return x, y
181
182
183def get_nb_bits(size):
184    i = 0
185    while 2**i < size:
186        i += 1
187    return i
188
189
190
191def gen_soclib_conf():
192    if os.path.isfile(soclib_conf_name):
193        print "# Updating file %s" % (soclib_conf_name)
194        # First, remove lines containing "addDescPath"
195        f = open(soclib_conf_name, "r")
196        lines = f.readlines()
197        f.close()
198
199        f = open(soclib_conf_name, "w")
200
201        for line in lines:
202            if not ("addDescPath" in line):
203                f.write(line)
204        f.close()
205    else:
206        print "# Creating file %s" % (soclib_conf_name)
207        f = open(soclib_conf_name, "w")
208        f.close()
209
210    # Defining common and specific modules
211    common_modules = [
212            'lib/generic_llsc_global_table',
213            'modules/dspin_router_tsar', 
214            'modules/sdmmc',
215            'modules/vci_block_device_tsar',
216            'modules/vci_ethernet_tsar',
217            'modules/vci_io_bridge',
218            'modules/vci_iox_network',
219            'modules/vci_spi',
220            'platforms/tsar_generic_xbar/tsar_xbar_cluster'
221    ]
222
223    specific_modules = [
224            'communication',
225            'lib/generic_cache_tsar',
226            'modules/vci_cc_vcache_wrapper',
227            'modules/vci_mem_cache',
228    ]
229
230    f = open(soclib_conf_name, "a")
231    # Adding common modules
232    for common_module in common_modules:
233        f.write("config.addDescPath(\"%s/%s\")\n" % (tsar_dir, common_module))
234
235    if protocol == "dhccp":
236        arch_dir = tsar_dir
237    elif protocol == "rwt":
238        arch_dir = rwt_dir
239    elif protocol == "hmesi":
240        arch_dir = hmesi_dir
241    elif protocol == "wtidl":
242        arch_dir = wtidl_dir
243    else:
244        assert(False)
245
246    for specific_module in specific_modules:
247        f.write("config.addDescPath(\"%s/%s\")\n" % (arch_dir, specific_module))
248
249    f.close()
250
251
252
253def gen_arch_info_bib(x, y, x_width, y_width):
254    print "### Generating arch-info files"
255    old_path = os.getcwd()
256
257    print "cd", scripts_path
258    os.chdir(scripts_path)
259    gen_arch_info(x, y, x_width, y_width, cpu_per_cluster, bscpu, arch_info_name)
260    os.chdir(almos_path)
261   
262    cmd = ['./info2bib', '-i', arch_info_name, '-o', arch_info_bib_name]
263    print_and_call(cmd)
264
265    print "cd", old_path
266    os.chdir(old_path)
267
268    print "### End of arch-info files generation"
269   
270
271#def gen_sym_links():
272#    print "### Generating symbolic links"
273#    target = os.path.join(almos_src_dir, 'tools/soclib-bootloader/bootloader-tsar-mipsel.bin')
274#    if not os.path.isfile(bootloader_link_name):
275#        print "ln -s", target, bootloader_link_name
276#        os.symlink(target, bootloader_link_name)
277#
278#    print "### End of symbolic links generation"
279#    #target = os.path.join(almos_src_dir, 'kernel/obj.tsar/almix-tsar-mipsel.bin')
280#    #link_name = 'kernel-soclib.bin'
281#    #if not os.path.isfile(link_name):
282#    #    print "ln -s", target, link_name
283#    #    os.symlink(target, link_name)
284
285
286def compile_almos():
287    print "### Compiling Almos"
288    old_path = os.getcwd()
289
290    print "cd", almos_src_dir
291    os.chdir(almos_src_dir)
292    cmd = ['make']
293    retval = print_and_call(cmd)
294    if retval != 0:
295        sys.exit()
296
297    print "cd", old_path
298    os.chdir(old_path)
299
300    print "### End of Almos compilation"
301 
302
303def compile_bootloader():
304    # This function depends upon the file arch-info.bib and should be called
305    # every time it is modified
306    print "### Compiling Almos bootloader"
307    old_path = os.getcwd()
308
309    bootloader_dir = os.path.join(almos_src_dir, 'tools/soclib-bootloader')
310    print "cd", bootloader_dir
311    os.chdir(bootloader_dir)
312    cmd = ['make', 'ARCH_BIB=%s' % (arch_info_bib_name), 'BUILD_DIR=%s' % (bootloader_build_path), 'TARGET_DIR=%s' % (almos_path)]
313    retval = print_and_call(cmd)
314    if retval != 0:
315        sys.exit()
316
317    print "cd", old_path
318    os.chdir(old_path)
319
320    print "### End of Almos bootloader compilation"
321 
322
323
324def compile_preloader():
325    # This function depends upon the file hard_config.h, and should be called
326    # every time it is modified
327    print "### Compiling preloader"
328    old_path = os.getcwd()
329
330    hard_conf_path_set = "HARD_CONFIG_PATH=" + almos_path
331    bscpu_set = "BS_PROC=%d" % bscpu
332
333    print "cd", preloader_src_dir
334    os.chdir(preloader_src_dir)
335    cmd = ['make', hard_conf_path_set, bscpu_set, 'BLOCK_SIZE=4096', 'USE_32BIT=1', 'USE_DT=0', 'BUILD_DIR=%s' % (preloader_build_path)]
336    retval = print_and_call(cmd)
337    if retval != 0:
338        sys.exit()
339
340    print "cd", old_path
341    os.chdir(old_path)
342
343    print "### End of preloader compilation"
344
345
346
347
348def compile_app(app_name):
349    print "### Compiling application %s" % (app_name)
350
351    #if app_name in splash2:
352    #   app_dir_name = os.path.join(splash2_dir, splash_app_dir[app_name])
353    #elif app_name in splash2_ga:
354    #   app_dir_name = os.path.join(splash2_ga_dir, splash_ga_app_dir[app_name])
355    #else:
356    #   app_dir_name = os.path.join(apps_dir, app_name)
357
358     
359    app_dir_name = os.path.join(apps_dir, app_name)
360
361    old_path = os.getcwd()
362    print "cd", app_dir_name
363    os.chdir(app_dir_name)
364
365    # Compilation process is different in splash and other apps
366    #if app_name in splash2:
367    #   print "make clean"
368    #   subprocess.call([ 'make', 'clean' ])
369
370    #   print "rm Makefile"
371    #   subprocess.call([ 'rm', 'Makefile' ])
372
373    #   print "ln -s Makefile.soclib Makefile"
374    #   subprocess.call([ 'ln', '-s', 'Makefile.soclib', 'Makefile' ])
375
376    #   print "make"
377    #   subprocess.call([ 'make' ])
378
379    #else:
380    #   print "make clean"
381    #   subprocess.call([ 'make', 'clean' ])
382 
383    #   print "make TARGET=tsar"
384    #   subprocess.call([ 'make', 'TARGET=tsar' ])
385
386    cmd = ['make', 'clean']
387    print_and_call(cmd)
388 
389    cmd = ['make', 'TARGET=tsar']
390    retval = print_and_call(cmd)
391    if retval != 0:
392        sys.exit()
393
394    print "cd", old_path
395    os.chdir(old_path)
396
397    print "### End of compilation for application %s" % (app_name)
398# end of compile_app
399
400
401
402
403def gen_shrc(app_name, nprocs):
404    # Creation/Modification of almos shrc file
405    print "### Generating shrc for application %s and %d threads" % (app_name, nprocs)
406    if mode == 'test':
407        if (app_name == "blackscholes"):
408            shrc = "exec -p 0 /bin/blacksch -n%(nproc)d /etc/black_16.txt\n" % dict(nproc = nprocs)
409        elif (app_name == "boot_only"):
410            shrc = "exec -p 0 /bin/boot_onl\n"
411        elif (app_name == "fal_sh_1"):
412            shrc = "exec -p 0 /bin/fal_sh_1 -n %(nproc)d -p %(niter)d\n" % dict(nproc = nprocs, niter = 100)
413        elif (app_name == "fal_sh_2"):
414            shrc = "exec -p 0 /bin/fal_sh_2 -n %(nproc)d -p %(niter)d\n" % dict(nproc = nprocs, niter = 100)
415        elif (app_name == "filter"):
416            shrc = "exec -p 0 /bin/filter -l 128 -c 128 -n %(nproc)d -i /etc/img128.raw\n" % dict(nproc = nprocs)
417        elif (app_name == "filt_ga"):
418            shrc = "exec -p 0 /bin/filt_ga -l 128 -c 128 -n %(nproc)d -i /etc/img128.raw\n" % dict(nproc = nprocs)
419        elif (app_name == "fft"):
420            shrc = "exec -p 0 /bin/fft -n%(nproc)d -m4\n" % dict(nproc = nprocs)
421        elif (app_name == "fft_ga"):
422            shrc = "exec -p 0 /bin/fft_ga -n%(nproc)d -m4\n" % dict(nproc = nprocs) # m = vector size
423        elif (app_name == "fluidanimate"):
424            shrc = "exec -p 0 /bin/fluidani -n%(nproc)d -i /etc/flui_15K.flu\n" % dict(nproc = nprocs)
425        elif (app_name == "hello"):
426            shrc = "exec -p 0 /bin/hello -n%(nproc)d\n" % dict(nproc = nprocs)
427        elif (app_name == "histogram"):
428            shrc = "exec -p 0 /bin/histogra -n%(nproc)d /etc/histo_s.bmp\n" % dict(nproc = nprocs)
429        elif (app_name == "histo-opt"):
430            shrc = "exec -p 0 /bin/histo-op -n%(nproc)d /etc/histo_s.bmp\n" % dict(nproc = nprocs)
431        elif (app_name == "kmeans"):
432            shrc = "exec -p 0 /bin/kmeans -n %(nproc)d -p %(npoints)d\n" % dict(nproc = nprocs, npoints = 1000)
433        elif (app_name == "kmeans-opt"):
434            shrc = "exec -p 0 /bin/kmeans-o -n %(nproc)d -p %(npoints)d\n" % dict(nproc = nprocs, npoints = 1000)
435        elif (app_name == "linear_regression"):
436            shrc = "exec -p 0 /bin/linear_r -n%(nproc)d /etc/key_1MB.txt\n" % dict(nproc = nprocs)
437        elif (app_name == "lu"):
438            shrc = "exec -p 0 /bin/lu -n%(nproc)d -m16\n" % dict(nproc = nprocs)
439        elif (app_name == "mandel"):
440            shrc = "exec -p 0 /bin/mandel -n%(nproc)d -x 30 -y 20\n" % dict(nproc = nprocs)
441        elif (app_name == "mat_mult"):
442            shrc = "exec -p 0 /bin/mat_mult -n%(nproc)d -s 10\n" % dict(nproc = nprocs) # s = matrix size
443        elif (app_name == "mat_mult-opt"):
444            shrc = "exec -p 0 /bin/mat_mult -n%(nproc)d -s 10\n" % dict(nproc = nprocs)
445        elif (app_name == "pca"):
446            shrc = "exec -p 0 /bin/pca -n%(nproc)d -r 16 -c 8\n" % dict(nproc = nprocs) # r = num rows, c = num cols
447        elif (app_name == "pca-opt"):
448            shrc = "exec -p 0 /bin/pca-opt -n%(nproc)d -r 16 -c 8\n" % dict(nproc = nprocs)
449        elif (app_name == "radix"):
450            shrc = "exec -p 0 /bin/radix -n%(nproc)d -k1024\n" % dict(nproc = nprocs)
451        elif (app_name == "radix_ga"):
452            shrc = "exec -p 0 /bin/radix_ga -n%(nproc)d -k1024\n" % dict(nproc = nprocs) # n = num_keys
453        elif (app_name == "string_match"):
454            shrc = "exec -p 0 /bin/string_m -n%(nproc)d /etc/key_1MB.txt\n" % dict(nproc = nprocs)
455        elif (app_name == "swaptions"):
456            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)
457        else:
458            print "*** Error: The application %s is not available in test mode", app_name
459            sys.exit()
460    else:
461        if (app_name == "barnes"):
462            shrc = "exec -p 0 /bin/barnes -n%(nproc)d -b%(nbody)d\n" % dict(nproc = nprocs, nbody = 1024)
463        elif (app_name == "blackscholes"):
464            shrc = "exec -p 0 /bin/blacksch -n %(nproc)d /etc/black_4K.txt\n" % dict(nproc = nprocs)
465        elif (app_name == "boot_only"):
466            shrc = "exec -p 0 /bin/boot_onl\n"
467        elif (app_name == "cholesky"):
468            shrc = "exec -p 0 /bin/cholesky -n%(nproc)d /etc/tk14.O\n" % dict(nproc = nprocs)
469        elif (app_name == "fal_sh_1"):
470            shrc = "exec -p 0 /bin/fal_sh_1 -n %(nproc)d -p %(niter)d\n" % dict(nproc = nprocs, niter = 10000)
471        elif (app_name == "fal_sh_2"):
472            shrc = "exec -p 0 /bin/fal_sh_2 -n %(nproc)d -p %(niter)d\n" % dict(nproc = nprocs, niter = 10000)
473        elif (app_name == "fft"):
474            shrc = "exec -p 0 /bin/fft -n%(nproc)d -m18\n" % dict(nproc = nprocs)
475        elif (app_name == "fft_ga"):
476            shrc = "exec -p 0 /bin/fft_ga -n%(nproc)d -m18\n" % dict(nproc = nprocs)
477        elif (app_name == "fluidanimate"):
478            shrc = "exec -p 0 /bin/fluidani -n%(nproc)d -i /etc/flui_35K.flu\n" % dict(nproc = nprocs)
479        elif (app_name == "filter"):
480            shrc = "exec -p 0 /bin/filter -l 1024 -c 1024 -n %(nproc)d -i /etc/img1024.raw\n" % dict(nproc = nprocs)
481        elif (app_name == "filt_ga"):
482            shrc = "exec -p 0 /bin/filt_ga -l 1024 -c 1024 -n %(nproc)d -i /etc/img1024.raw\n" % dict(nproc = nprocs)
483        elif (app_name == "histogram"):
484            shrc = "exec -p 0 /bin/histogra -n%(nproc)d /etc/histo.bmp\n" % dict(nproc = nprocs)
485        elif (app_name == "histo-opt"):
486            shrc = "exec -p 0 /bin/histo-op -n%(nproc)d /etc/histo.bmp\n" % dict(nproc = nprocs)
487        elif (app_name == "kmeans"):
488            shrc = "exec -p 0 /bin/kmeans -n %(nproc)d -p %(npoints)d\n" % dict(nproc = nprocs, npoints = 10000) # default npoints = 100000
489        elif (app_name == "kmeans-opt"):
490            shrc = "exec -p 0 /bin/kmeans-o -n %(nproc)d -p %(npoints)d\n" % dict(nproc = nprocs, npoints = 10000) # default npoints = 100000
491        elif (app_name == "linear_regression"):
492            shrc = "exec -p 0 /bin/linear_r -n%(nproc)d /etc/key_50MB.txt\n" % dict(nproc = nprocs)
493        elif (app_name == "lu"):
494            shrc = "exec -p 0 /bin/lu -n%(nproc)d -m512\n" % dict(nproc = nprocs)
495        elif (app_name == "mandel"):
496            shrc = "exec -p 0 /bin/mandel -n%(nproc)d\n" % dict(nproc = nprocs)
497        elif (app_name == "mat_mult"):
498            shrc = "exec -p 0 /bin/mat_mult -n%(nproc)d\n" % dict(nproc = nprocs)
499        elif (app_name == "mat_mult-opt"):
500            shrc = "exec -p 0 /bin/mat_mult -n%(nproc)d\n" % dict(nproc = nprocs)
501        elif (app_name == "pca"):
502            shrc = "exec -p 0 /bin/pca -n%(nproc)d\n" % dict(nproc = nprocs)
503        elif (app_name == "pca-opt"):
504            shrc = "exec -p 0 /bin/pca-opt -n%(nproc)d\n" % dict(nproc = nprocs)
505        elif (app_name == "fmm"):
506            shrc = "exec -p 0 /bin/fmm -n%(nproc)d -p%(nparticles)d\n" % dict(nproc = nprocs, nparticles = 1024)
507        elif (app_name == "ocean"):
508            shrc = "exec -p 0 /bin/ocean -n%(nproc)d -m%(gridsize)d\n" % dict(nproc = nprocs, gridsize = 66)
509        elif (app_name == "radiosity"):
510            shrc = "exec -p 0 /bin/radiosit -n %(nproc)d -batch\n" % dict(nproc = nprocs)
511        elif (app_name == "radix"):
512            shrc = "exec -p 0 /bin/radix -n%(nproc)d -k2097152\n" % dict(nproc = nprocs)
513        elif (app_name == "radix_ga"):
514            shrc = "exec -p 0 /bin/radix_ga -n%(nproc)d -k2097152\n" % dict(nproc = nprocs) # k = num_keys
515        elif (app_name == "string_match"):
516            shrc = "exec -p 0 /bin/string_m -n%(nproc)d /etc/key_50MB.txt\n" % dict(nproc = nprocs)
517        elif (app_name == "raytrace"):
518            shrc = "exec -p 0 /bin/raytrace -n%(nproc)d /etc/tea.env\n" % dict(nproc = nprocs)
519        elif (app_name == "showimg"):
520            shrc = "exec -p 0 /bin/showimg -i /etc/lena.sgi\n"
521        elif (app_name == "swaptions"):
522            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)
523        elif (app_name == "watern"):
524            shrc = "exec -p 0 /bin/watern -n%(nproc)d -m512\n" % dict(nproc = nprocs)
525        elif (app_name == "waters"):
526            shrc = "exec -p 0 /bin/waters -n%(nproc)d -m512\n" % dict(nproc = nprocs)
527        else:
528            assert(False)
529   
530    file = open(shrc_file_name, 'w')
531    file.write(shrc)
532    file.close()
533
534    # Copie du shrc dans la future image disque
535    cmd = ['cp', shrc_file_name, os.path.join(partition_root_path, "etc", "shrc")]
536    print_and_call(cmd)
537
538    print "### End of shrc generation for application %s and %d threads" % (app_name, nprocs)
539# end of gen_shrc
540
541
542
543cmd = ['mkdir', '-p', os.path.join(scripts_path, data_dir)]
544print_and_call(cmd)
545
546gen_soclib_conf()
547compile_almos()
548# Compile application once at the beginning not to intererfere with
549# other simulations
550for app in apps:
551    compile_app(app)
552    full_app_name = os.path.join(apps_dir, app, app)
553    cmd = ['cp', full_app_name, os.path.join(partition_root_path, "bin", app)]
554    print_and_call(cmd)
555
556 
557print "cd", top_path
558os.chdir(top_path)
559
560for i in nb_procs:
561    x, y = get_x_y(i, cpu_per_cluster)
562    x_width = get_nb_bits(x)
563    y_width = get_nb_bits(y)
564    nthreads = min(4, x * y) # thread number for parallel systemcass
565    hard_config(x, y, x_width, y_width, cpu_per_cluster, hard_config_name, protocol)
566    gen_arch_info_bib(x, y, x_width, y_width)
567    # We must recompile the preloader because we modified the hard_config file
568    # and the bootloader because we modified the arch-info.bib file
569    compile_preloader()
570    compile_bootloader()
571
572    cmd = ['touch', topcell_name]
573    print_and_call(cmd)
574
575    cmd = ['make']
576    retval = print_and_call(cmd)
577    if retval != 0:
578        sys.exit()
579 
580    for app in apps:
581        # Generate shrc
582        gen_shrc(app, i)
583
584        # Regenerate disk image
585        hdd_img(partition_root_path, hdd_img_file_name, "fat32", bootloader_file_name)
586
587        # Launch simulation
588        if use_omp:
589            cmd = ['./simul.x', '-THREADS', str(nthreads)]
590        else:
591            cmd = ['./simul.x']
592        filename = os.path.join(scripts_path, data_dir, app + '_' + log_stdo_name + str(i))
593        output = print_and_popen(cmd, filename)
594 
595        # Write simulation results to data directory
596        file = open(filename, 'w')
597        file.write(output)
598        file.close()
599 
600        filename = os.path.join(scripts_path, data_dir, app + '_' + log_term_name + str(i))
601       
602        cmd = ['mv', os.path.join(top_path, 'term1'), filename]
603        print_and_call(cmd)
604 
605        if rerun_stats:
606            start2_found = False
607            end_found = False
608            for line in open(filename):
609                if "[THREAD_COMPUTE_START]" in line:
610                    start2 = line.split()[-1]
611                    start2_found = True
612                if "[THREAD_COMPUTE_END]" in line:
613                    end = line.split()[-1]
614                    end_found = True
615            assert(start2_found and end_found)
616         
617            # Regenerate hdd to ensure having the same hdd image
618            hdd_img(partition_root_path, hdd_img_file_name, "fat32", bootloader_file_name)
619 
620            # Relauching simulation with reset and dump of counters
621            if use_omp:
622                cmd = ['./simul.x', '-THREADS', str(nthreads), '--reset-counters', start2, '--dump-counters', end]
623            else:
624                cmd = ['./simul.x', '--reset-counters', start2, '--dump-counters', end]
625            filename = os.path.join(scripts_path, data_dir, app + '_' + log_stdo_name + str(i))
626            output = print_and_popen(cmd, filename)
627           
628            # Checking that the two terms obtained are identical
629            import filecmp
630            term_orig_file = os.path.join(scripts_path, data_dir, app + '_' + log_term_name + str(i))
631            term_new_file = os.path.join(top_path, 'term1')
632            assert(filecmp.cmp(term_orig_file, term_new_file))
633 
634            # Write simulation results (counters) to data directory
635            file = open(filename, 'w')
636            file.write(output)
637            file.close()
638
639## End of simulations
640
641
642
Note: See TracBrowser for help on using the repository browser.