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

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