1 | #!/usr/bin/python |
---|
2 | |
---|
3 | import subprocess |
---|
4 | import os |
---|
5 | import sys |
---|
6 | import shutil |
---|
7 | |
---|
8 | from gen_hdd import * |
---|
9 | from gen_hard_config import * |
---|
10 | from 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 |
---|
17 | bscpu = 0 |
---|
18 | #nb_procs = [ 4 ] |
---|
19 | nb_procs = [ 1, 4, 8, 16, 32, 64, 128, 256 ] |
---|
20 | rerun_stats = True |
---|
21 | use_omp = True |
---|
22 | protocol = 'rwt' |
---|
23 | cpu_per_cluster = 4 |
---|
24 | # mode must be one of 'test' and 'simu' |
---|
25 | mode = 'simu' |
---|
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' ] |
---|
30 | |
---|
31 | |
---|
32 | # Variables which could be changed but ought not to because they are reflected in the create_graphs.py script |
---|
33 | if mode == 'test': |
---|
34 | data_dir = 'data_test' |
---|
35 | else: |
---|
36 | data_dir = 'data' |
---|
37 | log_init_name = protocol + '_stdo_' |
---|
38 | log_term_name = protocol + '_term_' |
---|
39 | |
---|
40 | # Global Variables |
---|
41 | |
---|
42 | all_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', ] |
---|
43 | # to come: 'barnes', 'fmm', 'ocean', 'raytrace', 'radiosity', 'waters', 'watern' |
---|
44 | |
---|
45 | all_protocols = [ 'dhccp', 'rwt', 'hmesi', 'wtidl', 'snoop' ] |
---|
46 | |
---|
47 | top_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..") |
---|
48 | config_name = os.path.join(os.path.dirname(os.path.realpath(__file__)), "config.py") |
---|
49 | |
---|
50 | scripts_path = os.path.join(top_path, 'scripts') |
---|
51 | almos_path = os.path.join(top_path, 'almos') |
---|
52 | soclib_conf_name = os.path.join(top_path, "soclib.conf") |
---|
53 | topcell_name = os.path.join(top_path, "top.cpp") |
---|
54 | partition_root_path = os.path.join(top_path, "hdd_root") |
---|
55 | arch_info_name = os.path.join(almos_path, "arch-info-gen.info") |
---|
56 | arch_info_bib_name = os.path.join(almos_path, 'arch-info.bib') |
---|
57 | hdd_img_file_name = os.path.join(almos_path, "hdd-img.bin") |
---|
58 | shrc_file_name = os.path.join(almos_path, "shrc") |
---|
59 | hard_config_name = os.path.join(almos_path, "hard_config.h") |
---|
60 | bootloader_link_name = os.path.join(almos_path, "bootloader-tsar-mipsel.bin") |
---|
61 | |
---|
62 | |
---|
63 | # Checks |
---|
64 | if 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 | |
---|
71 | if protocol not in all_protocols: |
---|
72 | help_str = ''' |
---|
73 | *** Error: variable protocol has an unsupported value |
---|
74 | ''' |
---|
75 | print help_str |
---|
76 | sys.exit() |
---|
77 | |
---|
78 | for the_app in apps: |
---|
79 | if the_app not in all_apps: |
---|
80 | print "*** Error: application %s is not defined" % (the_app) |
---|
81 | sys.exit() |
---|
82 | |
---|
83 | if not os.path.isfile(config_name): |
---|
84 | help_str = ''' |
---|
85 | You should create a file named config.py in this directory with the following definitions: |
---|
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 |
---|
91 | Optional definitions (necessary if you want to use alternative protocols): |
---|
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 |
---|
95 | *** Stopping execution |
---|
96 | ''' |
---|
97 | print help_str |
---|
98 | sys.exit() |
---|
99 | |
---|
100 | # Loading config |
---|
101 | exec(file(config_name)) |
---|
102 | |
---|
103 | # Check that variables and paths exist |
---|
104 | for var in [ 'apps_dir', 'almos_src_dir', 'hdd_img_name', 'tsar_dir' ]: |
---|
105 | if eval(var) == "": |
---|
106 | print "*** Error: variable %s not defined in config file" % (var) |
---|
107 | sys.exit() |
---|
108 | if not os.path.exists(eval(var)): |
---|
109 | print "*** Error: variable %s does not define a valid path" % (var) |
---|
110 | sys.exit() |
---|
111 | |
---|
112 | if protocol == "rwt": |
---|
113 | if rwt_dir == "": |
---|
114 | print "*** Error: variable rwt_dir not defined in config file" |
---|
115 | sys.exit() |
---|
116 | if not os.path.exists(rwt_dir): |
---|
117 | print "*** Error: variable rwt_dir does not define a valid path" |
---|
118 | sys.exit() |
---|
119 | |
---|
120 | if protocol == "hmesi": |
---|
121 | if hmesi_dir == "": |
---|
122 | print "*** Error: variable hmesi_dir not defined in config file" |
---|
123 | sys.exit() |
---|
124 | if not os.path.exists(hmesi_dir): |
---|
125 | print "*** Error: variable hmesi_dir does not define a valid path" |
---|
126 | sys.exit() |
---|
127 | |
---|
128 | if protocol == "wtidl": |
---|
129 | if wtidl_dir == "": |
---|
130 | print "*** Error: variable wtidl_dir not defined in config file" |
---|
131 | sys.exit() |
---|
132 | if not os.path.exists(wtidl_dir): |
---|
133 | print "*** Error: variable wtidl_dir does not define a valid path" |
---|
134 | sys.exit() |
---|
135 | |
---|
136 | |
---|
137 | |
---|
138 | |
---|
139 | #splash_app_dir = {} |
---|
140 | #splash_app_dir['barnes'] = 'apps/barnes' |
---|
141 | #splash_app_dir['fmm'] = 'apps/fmm' |
---|
142 | #splash_app_dir['ocean'] = 'apps/ocean/contiguous_partitions' |
---|
143 | #splash_app_dir['raytrace'] = 'apps/raytrace' |
---|
144 | #splash_app_dir['radiosity'] = 'apps/radiosity' |
---|
145 | #splash_app_dir['volrend'] = 'apps/volrend' |
---|
146 | #splash_app_dir['watern'] = 'apps/water-nsquared' |
---|
147 | #splash_app_dir['waters'] = 'apps/water-spatial' |
---|
148 | |
---|
149 | |
---|
150 | def print_and_call(cmd): |
---|
151 | print subprocess.list2cmdline(cmd) |
---|
152 | retval = subprocess.call(cmd) |
---|
153 | return retval |
---|
154 | |
---|
155 | def 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 | |
---|
162 | def get_x_y(nb_procs, cpu_per_cluster): |
---|
163 | x = 1 |
---|
164 | y = 1 |
---|
165 | to_x = True |
---|
166 | while (x * y * cpu_per_cluster < nb_procs): |
---|
167 | if to_x: |
---|
168 | x = x * 2 |
---|
169 | else: |
---|
170 | y = y * 2 |
---|
171 | to_x = not to_x |
---|
172 | return x, y |
---|
173 | |
---|
174 | |
---|
175 | def get_nb_bits(size): |
---|
176 | i = 0 |
---|
177 | while 2**i < size: |
---|
178 | i += 1 |
---|
179 | return i |
---|
180 | |
---|
181 | |
---|
182 | |
---|
183 | def gen_soclib_conf(): |
---|
184 | if os.path.isfile(soclib_conf_name): |
---|
185 | print "Updating file %s" % (soclib_conf_name) |
---|
186 | # First, remove lines containing "addDescPath" |
---|
187 | f = open(soclib_conf_name, "r") |
---|
188 | lines = f.readlines() |
---|
189 | f.close() |
---|
190 | |
---|
191 | f = open(soclib_conf_name, "w") |
---|
192 | |
---|
193 | for line in lines: |
---|
194 | if not ("addDescPath" in line): |
---|
195 | f.write(line) |
---|
196 | f.close() |
---|
197 | else: |
---|
198 | print "Creating file %s" % (soclib_conf_name) |
---|
199 | f = open(soclib_conf_name, "w") |
---|
200 | f.close() |
---|
201 | |
---|
202 | # Defining common and specific modules |
---|
203 | common_modules = [ |
---|
204 | 'lib/generic_llsc_global_table', |
---|
205 | 'modules/dspin_router_tsar', |
---|
206 | 'modules/sdmmc', |
---|
207 | 'modules/vci_block_device_tsar', |
---|
208 | 'modules/vci_ethernet_tsar', |
---|
209 | 'modules/vci_io_bridge', |
---|
210 | 'modules/vci_iox_network', |
---|
211 | 'modules/vci_spi', |
---|
212 | 'platforms/tsar_generic_xbar/tsar_xbar_cluster' |
---|
213 | ] |
---|
214 | |
---|
215 | specific_modules = [ |
---|
216 | 'communication', |
---|
217 | 'lib/generic_cache_tsar', |
---|
218 | 'modules/vci_cc_vcache_wrapper', |
---|
219 | 'modules/vci_mem_cache', |
---|
220 | ] |
---|
221 | |
---|
222 | f = open(soclib_conf_name, "a") |
---|
223 | # Adding common modules |
---|
224 | for common_module in common_modules: |
---|
225 | f.write("config.addDescPath(\"%s/%s\")\n" % (tsar_dir, common_module)) |
---|
226 | #f.write("\n") |
---|
227 | |
---|
228 | if protocol == "dhccp": |
---|
229 | arch_dir = tsar_dir |
---|
230 | elif protocol == "rwt": |
---|
231 | arch_dir = rwt_dir |
---|
232 | elif protocol == "hmesi": |
---|
233 | arch_dir = hmesi_dir |
---|
234 | elif protocol == "wtidl": |
---|
235 | arch_dir = wtidl_dir |
---|
236 | else: |
---|
237 | assert(False) |
---|
238 | |
---|
239 | for specific_module in specific_modules: |
---|
240 | f.write("config.addDescPath(\"%s/%s\")\n" % (arch_dir, specific_module)) |
---|
241 | |
---|
242 | #f.write("\n") |
---|
243 | f.close() |
---|
244 | |
---|
245 | |
---|
246 | |
---|
247 | def 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) |
---|
254 | |
---|
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 | |
---|
261 | |
---|
262 | def gen_sym_links(): |
---|
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 | |
---|
275 | def 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 | |
---|
291 | def 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 | |
---|
307 | def 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) |
---|
315 | |
---|
316 | |
---|
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) |
---|
354 | # end of compile_app |
---|
355 | |
---|
356 | |
---|
357 | |
---|
358 | |
---|
359 | def 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 | |
---|
486 | cmd = ['mkdir', '-p', os.path.join(scripts_path, data_dir)] |
---|
487 | print_and_call(cmd) |
---|
488 | |
---|
489 | gen_sym_links() |
---|
490 | gen_soclib_conf() |
---|
491 | compile_preloader() |
---|
492 | compile_almos() |
---|
493 | # Compile application once at the beginning not to intererfere with |
---|
494 | # other simulations |
---|
495 | for 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 | |
---|
502 | print "cd", top_path |
---|
503 | os.chdir(top_path) |
---|
504 | |
---|
505 | for i in nb_procs: |
---|
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() |
---|
583 | |
---|
584 | |
---|
585 | ## End of simulations |
---|
586 | |
---|
587 | |
---|
588 | |
---|