Peano
Loading...
Searching...
No Matches
print-kernel-throughput-2.py
Go to the documentation of this file.
1import matplotlib.pyplot as plt
2import matplotlib as mpl
3import numpy as np
4import re
5from math import log
6import sys
7import os.path
8import math
9from matplotlib.lines import Line2D
10
11
12params = {
13 "axes.labelsize": 20,
14 "axes.titlesize": 20,
15 "font.size": 20,
16 "font.family": "serif",
17 "legend.fontsize": 20,
18 "xtick.labelsize": 16,
19 "ytick.labelsize": 16,
20 "xtick.direction": "in",
21 "ytick.direction": "in",
22 "xtick.top": True,
23 "ytick.right": True,
24 "xtick.major.width": 1.5,
25 "ytick.major.width": 1.5,
26 "axes.linewidth": 1.5,
27 "axes.labelsize": 20,
28 "text.usetex": True,
29 "figure.dpi": 300,
30 "figure.autolayout": True,
31 # 'figure.figsize': (10,10),
32}
33
34mpl.rcParams.update(params)
35
36CELL_SIZES = ['0064', '0128', '0256', '0512', '1024']
37
38def read_data(folder_name,
39 kernel_name,
40 ):
41 """!
42
43 returns {
44 'cell size' : [ (xdata, ydata) for aos, (xdata, ydata) for soa ],
45 }
46
47 """
48
49 results = {}
50
51 for CELL_SIZE in CELL_SIZES:
52 result = []
53 for SOA in [False, True]:
54 particle_counts = []
55 timings = []
56
57 file_name = f"{folder_name}/out-{'x64' if 'gi001' in folder_name else 'aarch64'}-soa{'true' if SOA else 'false'}-cell{CELL_SIZE}.log"
58 file = open( file_name, "r" )
59
60 for line in file:
61 if "Experiment:" in line:
62 number_of_particles = line.split( "Experiment:" )[1].split( "particles" )[0]
63 particle_counts.append( float(number_of_particles) )
64 if kernel_name in line:
65 time = line.split( kernel_name + ":" )[1].split( "(" )[0]
66 timings.append( float(time) )
67
68 assert len(particle_counts)==len(timings) or len(timings)==0, "array dimensions don't match: {} vs {} for kernel {} in {}".format(particle_counts, timings, kernel_name, file_name)
69 result += [(particle_counts, timings)]
70 results[CELL_SIZE] = result
71 return results
72
73def read_data_gpu(folder_name,
74 kernel_name,
75 ):
76 """!
77
78 returns {
79 'cell size' : [ (xdata, ydata) for aos - always empty, (xdata, ydata) for soa ],
80 }
81
82 """
83
84 results = {}
85
86 for CELL_SIZE in CELL_SIZES:
87 result = [[]]
88 particle_counts = []
89 timings = []
90
91 file_name = f"{folder_name}/out-{'gh' if 'gn003' in folder_name else 'mi300a'}-soatrue-cell{CELL_SIZE}.log"
92 file = open( file_name, "r" )
93
94 for line in file:
95 if "Experiment:" in line:
96 number_of_particles = line.split( "Experiment:" )[1].split( "particles" )[0]
97 particle_counts.append( float(number_of_particles) )
98 if kernel_name in line:
99 time = line.split( kernel_name + ":" )[1].split( "(" )[0]
100 timings.append( float(time) )
101
102 assert len(particle_counts)==len(timings), "array dimensions don't match: {} vs {} for kernel {} in {}".format(particle_counts, timings, kernel_name, file_name)
103 result += [(particle_counts, timings)]
104 results[CELL_SIZE] = result
105 return results
106
107def read_data_gpu_shmem(folder_name,
108 kernel_name,
109 ):
110 """!
111
112 returns {
113 'cell size' : [ (xdata, ydata) for aos - always empty, (xdata, ydata) for soa ],
114 }
115
116 """
117
118 results = {}
119
120 for CELL_SIZE in CELL_SIZES:
121 result = [[]]
122 particle_counts = []
123 timings = []
124
125 file_name = f"{folder_name}/out-{'gh' if 'gn003' in folder_name else 'mi300a'}-soatrue-cell{CELL_SIZE}-shmem.log"
126 file = open( file_name, "r" )
127
128 for line in file:
129 if "Experiment:" in line:
130 number_of_particles = line.split( "Experiment:" )[1].split( "particles" )[0]
131 particle_counts.append( float(number_of_particles) )
132 if kernel_name in line:
133 time = line.split( kernel_name + ":" )[1].split( "(" )[0]
134 timings.append( float(time) )
135
136 assert len(particle_counts)==len(timings), "array dimensions don't match: {} vs {} for kernel {} in {}".format(particle_counts, timings, kernel_name, file_name)
137 result += [(particle_counts, timings)]
138 results[CELL_SIZE] = result
139 return results
140
141
142Kernels = [ "density", "force", "kick1", "kick2", "drift" ]
143
144KernelName = {
145 'density' : 'density',
146 'force' : 'force',
147 'kick1' : '1st kick',
148 'kick2' : '2nd kick',
149 'drift' : 'drift',
150}
151
152ImplementationVariant = {
153 'force': ['(scattered,generic,dist-check)',
154 '(continuous,generic,dist-check)',
155 '(continuous,local-active-coalesced,dist-check)',
156 '(continuous,active-local-coalesced,dist-check)',
157 '(continuous,local-active-preamble,dist-check)',
158 '(continuous,active-local-preamble,dist-check)',
159 '(scattered,generic,no-dist-check)',
160 '(continuous,generic,no-dist-check)',
161 '(continuous,local-active-coalesced,no-dist-check)',
162 '(continuous,active-local-coalesced,no-dist-check)'],
163 'density': ['(scattered,generic,dist-check)',
164 '(continuous,generic,dist-check)',
165 '(continuous,local-active-coalesced,dist-check)',
166 '(continuous,active-local-coalesced,dist-check)',
167 '(continuous,local-active-preamble,dist-check)',
168 '(continuous,active-local-preamble,dist-check)',
169 '(scattered,generic,no-dist-check)',
170 '(continuous,generic,no-dist-check)',
171 '(continuous,local-active-coalesced,no-dist-check)',
172 '(continuous,active-local-coalesced,no-dist-check)'],
173 'kick1': ['(scattered,generic)',
174 '(continuous,generic)',
175 '(continuous,coalesced)',
176 '(continuous,preamble)'],
177 'kick2': ['(scattered,generic)',
178 '(continuous,generic)',
179 '(continuous,coalesced)',
180 '(continuous,preamble)'],
181 'drift': ['(scattered,generic)',
182 '(continuous,generic)',
183 '(continuous,coalesced)',
184 '(continuous,preamble)'],
185}
186
187ImplementationVariant_FixedPPC = {
188 'force': ['(scattered,generic,dist-check)',
189 '(continuous,generic,dist-check)',
190 '(continuous,local-active-coalesced,dist-check)',
191 '(continuous,active-local-coalesced,dist-check)',
192 '#', # (continuous,local-active-preamble,dist-check) skipped, placeholder to keep colors etc consistent
193 '#', # (continuous,active-local-preamble,dist-check) skipped, placeholder to keep colors etc consistent
194 '(scattered,generic,no-dist-check)',
195 '(continuous,generic,no-dist-check)',
196 '(continuous,local-active-coalesced,no-dist-check)',
197 '(continuous,active-local-coalesced,no-dist-check)'],
198 'density': ['(scattered,generic,dist-check)',
199 '(continuous,generic,dist-check)',
200 '(continuous,local-active-coalesced,dist-check)',
201 '(continuous,active-local-coalesced,dist-check)',
202 '#', # (continuous,local-active-preamble,dist-check) skipped, placeholder to keep colors etc consistent
203 '#', # (continuous,active-local-preamble,dist-check) skipped, placeholder to keep colors etc consistent
204 '(scattered,generic,no-dist-check)',
205 '(continuous,generic,no-dist-check)',
206 '(continuous,local-active-coalesced,no-dist-check)',
207 '(continuous,active-local-coalesced,no-dist-check)'],
208 'kick1': ['(scattered,generic)',
209 '(continuous,generic)',
210 '(continuous,coalesced)',
211 '#' # (continuous,preamble) skipped, placeholder ...
212 ],
213 'kick2': ['(scattered,generic)',
214 '(continuous,generic)',
215 '(continuous,coalesced)',
216 '#' # (continuous,preamble) skipped, placeholder ...
217 ],
218 'drift': ['(scattered,generic)',
219 '(continuous,generic)',
220 '(continuous,coalesced)',
221 '#' # (continuous,preamble) skipped, placeholder ...
222 ],
223}
224
225ImplementationVariant_GPU = {
226 'force': ['(scattered,generic,dist-check)',
227 '(continuous,generic,dist-check)',
228 '(continuous,local-active-coalesced,dist-check)',
229 '(continuous,active-local-coalesced,dist-check)',
230 '#', # (continuous,local-active-preamble,dist-check) skipped, placeholder to keep colors etc consistent
231 '#', # (continuous,active-local-preamble,dist-check) skipped, placeholder to keep colors etc consistent
232 '(scattered,generic,no-dist-check)',
233 '(continuous,generic,no-dist-check)',
234 '(continuous,local-active-coalesced,no-dist-check)',
235 '(continuous,active-local-coalesced,no-dist-check)'],
236 'density': ['(scattered,generic,dist-check)',
237 '(continuous,generic,dist-check)',
238 '(continuous,local-active-coalesced,dist-check)',
239 '(continuous,active-local-coalesced,dist-check)',
240 '#', # (continuous,local-active-preamble,dist-check) skipped, placeholder to keep colors etc consistent
241 '#', # (continuous,active-local-preamble,dist-check) skipped, placeholder to keep colors etc consistent
242 '(scattered,generic,no-dist-check)',
243 '(continuous,generic,no-dist-check)',
244 '(continuous,local-active-coalesced,no-dist-check)',
245 '(continuous,active-local-coalesced,no-dist-check)'],
246 'kick1': ['(scattered,generic)',
247 '(continuous,generic)',
248 '(continuous,coalesced)',
249 '#' # (continuous,preamble) skipped, placeholder ...
250 ],
251 'kick2': ['(scattered,generic)',
252 '(continuous,generic)',
253 '(continuous,coalesced)',
254 '#' # (continuous,preamble) skipped, placeholder ...
255 ],
256 'drift': ['(scattered,generic)',
257 '(continuous,generic)',
258 '(continuous,coalesced)',
259 '#' # (continuous,preamble) skipped, placeholder ...
260 ],
261}
262
263
264ImplementationVariantName = {
265 '(scattered,generic)': 'generic (scat.)',
266 '(continuous,generic)': 'generic (cont.)',
267 '(continuous,coalesced)': 'coalesced (cont.)',
268 '(continuous,preamble)': 'coalesced (prea.)',
269 '(scattered,generic,dist-check)': 'generic (scat. with branching)',
270 '(continuous,generic,dist-check)': 'generic (cont. with branching)',
271 '(continuous,local-active-coalesced,dist-check)': 'coalesced local-active (cont. with branching)',
272 '(continuous,active-local-coalesced,dist-check)': 'coalesced active-local (cont. with branching)',
273 '(continuous,active-local-preamble,dist-check)': 'coalesced active-local (cont. with branching and preamble)',
274 '(continuous,local-active-preamble,dist-check)': 'coalesced local-active (cont. with branching and preamble)',
275 '(scattered,generic,no-dist-check)': 'generic (scat. with masking)',
276 '(continuous,generic,no-dist-check)': 'generic (cont. with masking)',
277 '(continuous,local-active-coalesced,no-dist-check)': 'coalesced local-active (cont. with masking)',
278 '(continuous,active-local-coalesced,no-dist-check)': 'coalesced active-local (cont. with masking)',
279}
280
281Colors = [ "#20a040", "#a04020", "#4020a0", "#f0a0f0", "#f06030", "#6030f0", "#2080a0", "#a0a020", "#a020a0", "#20a080", "#a08020" ]
282Symbols = [ "s", "o", "^", "v", "<", ">", "1", "2", "3", "4", "p" ]
283LineStyles = { 'aos': '--', 'soa': ':'}
284
285ParticleSize = 272
286
287L2CacheSizeMap = {
288 'gi001': 1024*1024*2*56,
289 'gn003': 1024*1024*72,
290}
291
292def process_folder(folder_name):
293 print( f"process folder {folder_name}" )
294
295 for k, kernel in enumerate(Kernels):
296 for im, implementation in enumerate(ImplementationVariant[kernel]):
297 if '#' in implementation: continue
298
299 impl_data_all = read_data(folder_name, f"{kernel} {implementation}")
300
301 plt.clf()
302 mpl.rcParams.update(params)
303
304 cell_size_legend_handles = []
305 cell_size_legend_labels = []
306 for cs, CELL_SIZE in enumerate(CELL_SIZES):
307 cell_size_legend_handles += [Line2D([0], [0], marker=Symbols[cs], color=Colors[cs], label=f'{int(CELL_SIZE)}', linestyle='-')]
308 cell_size_legend_labels += [f'{int(CELL_SIZE)}']
309
310 impl_data_aos = impl_data_all[CELL_SIZE][0]
311 plt.plot( impl_data_aos[0],
312 impl_data_aos[1],
313 Symbols[cs],
314 color=Colors[cs],
315 # label=label,
316 linestyle=LineStyles['aos']
317 )
318
319 impl_data_soa = impl_data_all[CELL_SIZE][1]
320 plt.plot( impl_data_soa[0],
321 impl_data_soa[1],
322 Symbols[cs],
323 color=Colors[cs],
324 # label=label,
325 linestyle=LineStyles['soa']
326 )
327
328 plt.xlabel("Particles")
329 plt.ylabel("Time per particle update [t]=s")
330
331 plt.xscale('log', base=10)
332 plt.yscale('log', base=10)
333
334 if 'density' in kernel: plt.ylim(2e-7, 2e-5)
335
336 plt.minorticks_on()
337 plt.grid(True, which='both')
338
339 filename = f"/{kernel}_{implementation}".replace('(', '').replace(')', '').replace(',', '_').replace('-', '_')
340 filename = f"{folder_name}/{filename}"
341
342 if 'gi001' in filename:
343 plt.axvline(x = L2CacheSizeMap['gi001']/ParticleSize, color = 'k', linestyle = '--')
344 elif 'gn003' in filename:
345 plt.axvline(x = L2CacheSizeMap['gn003']/ParticleSize, color = 'k', linestyle = '--')
346 else:
347 raise Exception("I don't know what CPU I'm working on!")
348
349 plt.savefig(f"{filename}.pdf")
350 plt.savefig(f"{filename}.png")
351
352 plt.close('all')
353 plt.rcdefaults()
354
355 fig_legend = plt.figure(figsize=(10, 1))
356 ax_legend = fig_legend.add_subplot(111)
357 ax_legend.axis("off")
358 ax_legend.legend(handles=cell_size_legend_handles, labels=cell_size_legend_labels, loc="center", ncol=5, frameon=False)
359 fig_legend.savefig(f"{folder_name}/cell_legend.pdf", bbox_inches='tight', dpi=300)
360 fig_legend.savefig(f"{folder_name}/cell_legend.png", bbox_inches='tight', dpi=300)
361
362 fig_legend = plt.figure(figsize=(4, 1))
363 ax_legend = fig_legend.add_subplot(111)
364 ax_legend.axis("off")
365 ax_legend.legend(handles=[
366 Line2D([0], [0], color='black', label='AoS', linestyle=LineStyles['aos']),
367 Line2D([0], [0], color='black', label='SoA', linestyle=LineStyles['soa'])
368 ], labels=['AoS', 'SoA'], loc="center", ncol=2, frameon=False)
369 fig_legend.savefig(f"{folder_name}/layout_legend.pdf", bbox_inches='tight', dpi=300)
370 fig_legend.savefig(f"{folder_name}/layout_legend.png", bbox_inches='tight', dpi=300)
371
372 plt.close('all')
373 plt.close()
374 plt.rcdefaults()
375
376def process_folder_gpu(folder_name):
377 print( f"process folder {folder_name}" )
378
379 for k, kernel in enumerate(Kernels):
380 for im, implementation in enumerate(ImplementationVariant_GPU[kernel]):
381 if '#' in implementation: continue
382
383 impl_data_all = read_data_gpu(folder_name, f"{kernel}-gpu {implementation}")
384
385 plt.clf()
386 mpl.rcParams.update(params)
387
388 cell_size_legend_handles = []
389 cell_size_legend_labels = []
390 for cs, CELL_SIZE in enumerate(CELL_SIZES):
391 cell_size_legend_handles += [Line2D([0], [0], marker=Symbols[cs], color=Colors[cs], label=f'{int(CELL_SIZE)}', linestyle='-')]
392 cell_size_legend_labels += [f'{int(CELL_SIZE)}']
393
394 # impl_data_aos = impl_data_all[CELL_SIZE][0]
395 # plt.plot( impl_data_aos[0],
396 # impl_data_aos[1],
397 # Symbols[cs],
398 # color=Colors[cs],
399 # # label=label,
400 # linestyle=LineStyles['aos']
401 # )
402
403 impl_data_soa = impl_data_all[CELL_SIZE][1]
404 plt.plot( impl_data_soa[0],
405 impl_data_soa[1],
406 Symbols[cs],
407 color=Colors[cs],
408 # label=label,
409 linestyle=LineStyles['soa']
410 )
411
412 plt.xlabel("Particles")
413 plt.ylabel("Time per particle update [t]=s")
414
415 plt.xscale('log', base=10)
416 plt.yscale('log', base=10)
417
418 if 'density' in kernel: plt.ylim(2e-7, 2e-5)
419 if 'drift' in kernel: plt.ylim(7e-8, 4e-6)
420
421 plt.minorticks_on()
422 plt.grid(True, which='both')
423
424 filename = f"/{kernel}_gpu_{implementation}".replace('(', '').replace(')', '').replace(',', '_').replace('-', '_')
425 filename = f"{folder_name}/{filename}"
426
427 if 'gi001' in filename:
428 plt.axvline(x = L2CacheSizeMap['gi001']/ParticleSize, color = 'k', linestyle = '--')
429 elif 'gn003' in filename:
430 plt.axvline(x = L2CacheSizeMap['gn003']/ParticleSize, color = 'k', linestyle = '--')
431 elif 'mi300a' in filename:
432 pass
433 else:
434 raise Exception("I don't know what CPU I'm working on!")
435
436 plt.savefig(f"{filename}.pdf")
437 plt.savefig(f"{filename}.png")
438
439 plt.close('all')
440 plt.rcdefaults()
441
442 fig_legend = plt.figure(figsize=(10, 1))
443 ax_legend = fig_legend.add_subplot(111)
444 ax_legend.axis("off")
445 ax_legend.legend(handles=cell_size_legend_handles, labels=cell_size_legend_labels, loc="center", ncol=5, frameon=False)
446 fig_legend.savefig(f"{folder_name}/cell_legend.pdf", bbox_inches='tight', dpi=300)
447 fig_legend.savefig(f"{folder_name}/cell_legend.png", bbox_inches='tight', dpi=300)
448
449 fig_legend = plt.figure(figsize=(4, 1))
450 ax_legend = fig_legend.add_subplot(111)
451 ax_legend.axis("off")
452 ax_legend.legend(handles=[
453 Line2D([0], [0], color='black', label='AoS', linestyle=LineStyles['aos']),
454 Line2D([0], [0], color='black', label='SoA', linestyle=LineStyles['soa'])
455 ], labels=['AoS', 'SoA'], loc="center", ncol=2, frameon=False)
456 fig_legend.savefig(f"{folder_name}/layout_legend.pdf", bbox_inches='tight', dpi=300)
457 fig_legend.savefig(f"{folder_name}/layout_legend.png", bbox_inches='tight', dpi=300)
458
459 plt.close('all')
460 plt.close()
461 plt.rcdefaults()
462
464 print( f"process folder {folder_name}" )
465
466 for k, kernel in enumerate(Kernels):
467 for im, implementation in enumerate(ImplementationVariant_GPU[kernel]):
468 if '#' in implementation: continue
469
470 impl_data_all = read_data_gpu_shmem(folder_name, f"{kernel}-gpu {implementation}")
471
472 plt.clf()
473 mpl.rcParams.update(params)
474
475 cell_size_legend_handles = []
476 cell_size_legend_labels = []
477 for cs, CELL_SIZE in enumerate(CELL_SIZES):
478 cell_size_legend_handles += [Line2D([0], [0], marker=Symbols[cs], color=Colors[cs], label=f'{int(CELL_SIZE)}', linestyle='-')]
479 cell_size_legend_labels += [f'{int(CELL_SIZE)}']
480
481 # impl_data_aos = impl_data_all[CELL_SIZE][0]
482 # plt.plot( impl_data_aos[0],
483 # impl_data_aos[1],
484 # Symbols[cs],
485 # color=Colors[cs],
486 # # label=label,
487 # linestyle=LineStyles['aos']
488 # )
489
490 impl_data_soa = impl_data_all[CELL_SIZE][1]
491 plt.plot( impl_data_soa[0],
492 impl_data_soa[1],
493 Symbols[cs],
494 color=Colors[cs],
495 # label=label,
496 linestyle=LineStyles['soa']
497 )
498
499 plt.xlabel("Particles")
500 plt.ylabel("Time per particle update [t]=s")
501
502 plt.xscale('log', base=10)
503 plt.yscale('log', base=10)
504
505 if 'density' in kernel: plt.ylim(2e-7, 2e-5)
506 if 'drift' in kernel: plt.ylim(7e-8, 4e-6)
507
508 plt.minorticks_on()
509 plt.grid(True, which='both')
510
511 filename = f"/{kernel}_gpu_{implementation}_shmem".replace('(', '').replace(')', '').replace(',', '_').replace('-', '_')
512 filename = f"{folder_name}/{filename}"
513
514 if 'gi001' in filename:
515 plt.axvline(x = L2CacheSizeMap['gi001']/ParticleSize, color = 'k', linestyle = '--')
516 elif 'gn003' in filename:
517 plt.axvline(x = L2CacheSizeMap['gn003']/ParticleSize, color = 'k', linestyle = '--')
518 elif 'mi300a' in filename:
519 pass
520 else:
521 raise Exception("I don't know what CPU I'm working on!")
522
523 plt.savefig(f"{filename}.pdf")
524 plt.savefig(f"{filename}.png")
525
526 plt.close('all')
527 plt.rcdefaults()
528
529 fig_legend = plt.figure(figsize=(10, 1))
530 ax_legend = fig_legend.add_subplot(111)
531 ax_legend.axis("off")
532 ax_legend.legend(handles=cell_size_legend_handles, labels=cell_size_legend_labels, loc="center", ncol=5, frameon=False)
533 fig_legend.savefig(f"{folder_name}/cell_legend.pdf", bbox_inches='tight', dpi=300)
534 fig_legend.savefig(f"{folder_name}/cell_legend.png", bbox_inches='tight', dpi=300)
535
536 fig_legend = plt.figure(figsize=(4, 1))
537 ax_legend = fig_legend.add_subplot(111)
538 ax_legend.axis("off")
539 ax_legend.legend(handles=[
540 Line2D([0], [0], color='black', label='AoS', linestyle=LineStyles['aos']),
541 Line2D([0], [0], color='black', label='SoA', linestyle=LineStyles['soa'])
542 ], labels=['AoS', 'SoA'], loc="center", ncol=2, frameon=False)
543 fig_legend.savefig(f"{folder_name}/layout_legend.pdf", bbox_inches='tight', dpi=300)
544 fig_legend.savefig(f"{folder_name}/layout_legend.png", bbox_inches='tight', dpi=300)
545
546 plt.close('all')
547 plt.close()
548 plt.rcdefaults()
549
550
551def process_folder_speedup(folder_name):
552 print( f"process folder {folder_name}" )
553
554 for k, kernel in enumerate(Kernels):
555 for im, implementation in enumerate(ImplementationVariant[kernel]):
556 if '#' in implementation: continue
557
558 impl_data_all = read_data(folder_name, f"{kernel} {implementation}")
559
560 plt.clf()
561 mpl.rcParams.update(params)
562
563 cell_size_legend_handles = []
564 cell_size_legend_labels = []
565 for cs, CELL_SIZE in enumerate(CELL_SIZES):
566 cell_size_legend_handles += [Line2D([0], [0], marker=Symbols[cs], color=Colors[cs], label=f'{int(CELL_SIZE)}', linestyle='-')]
567 cell_size_legend_labels += [f'{int(CELL_SIZE)}']
568
569 impl_data_aos = impl_data_all[CELL_SIZE][0]
570
571 impl_data_soa = impl_data_all[CELL_SIZE][1]
572
573 x_data = impl_data_aos[0]
574 y_data = np.array(impl_data_aos[1]) / np.array(impl_data_soa[1])
575
576 plt.ylim(0.4, 3.4)
577 plt.plot( x_data,
578 y_data,
579 Symbols[cs],
580 color=Colors[cs],
581 # label=label,
582 linestyle='-'
583 )
584
585 plt.xlabel("Particles")
586 plt.ylabel("Relative speedup")
587
588 plt.xscale('log', base=10)
589 if 'density' in kernel or 'drift' in kernel: plt.ylim(0.1, 3)
590
591 plt.minorticks_on()
592 plt.grid(True, which='both')
593
594 filename = f"/{kernel}_{implementation}".replace('(', '').replace(')', '').replace(',', '_').replace('-', '_')
595 filename = f"{folder_name}/{filename}-relative"
596
597 if 'gi001' in filename:
598 plt.axvline(x = L2CacheSizeMap['gi001']/ParticleSize, color = 'k', linestyle = '--')
599 elif 'gn003' in filename:
600 plt.axvline(x = L2CacheSizeMap['gn003']/ParticleSize, color = 'k', linestyle = '--')
601 else:
602 raise Exception("I don't know what CPU I'm working on!")
603
604 plt.axhline(y = 1, color = 'k', linestyle = '--')
605
606 plt.savefig(f"{filename}.pdf")
607 plt.savefig(f"{filename}.png")
608
609 plt.close('all')
610 plt.rcdefaults()
611
612 plt.close('all')
613 plt.close()
614 plt.rcdefaults()
615
617 print( f"process folder {folder_name}" )
618
619 for k, kernel in enumerate(Kernels):
620 for cs, CELL_SIZE in enumerate(CELL_SIZES):
621 cell_size_legend_handles = []
622 cell_size_legend_labels = []
623
624 plt.clf()
625 mpl.rcParams.update(params)
626
627 for im, implementation in enumerate(ImplementationVariant_FixedPPC[kernel]):
628 if '#' in implementation: continue
629
630 impl_data_all = read_data(folder_name, f"{kernel} {implementation}")
631
632 cell_size_legend_handles += [Line2D([0], [0], marker=Symbols[im], color=Colors[im], linestyle=LineStyles['aos'])]
633 cell_size_legend_labels += [f'{ImplementationVariantName[implementation]}']
634
635 impl_data_aos = impl_data_all[CELL_SIZE][0]
636
637 x_data = impl_data_aos[0]
638 y_data = impl_data_aos[1]
639
640 plt.plot( x_data,
641 y_data,
642 Symbols[im],
643 color=Colors[im],
644 # label=label,
645 linestyle=LineStyles['aos']
646 )
647
648 plt.xlabel("Particles")
649 plt.ylabel("Time per particle update [t]=s")
650
651 plt.xscale('log', base=10)
652
653 if 'drift' in kernel:
654 plt.ylim(5e-10, 5e-7)
655 plt.yscale('log', base=10)
656
657 if 'density' in kernel and int(CELL_SIZE) == 64: plt.ylim(0, 1.3e-6)
658 if 'density' in kernel and int(CELL_SIZE) == 1024: plt.ylim(0, 2e-5)
659
660 plt.minorticks_on()
661 plt.grid(True, which='both')
662
663 filename = f"/{kernel}".replace('(', '').replace(')', '').replace(',', '_').replace('-', '_')
664 filename = f"{folder_name}/{filename}_cell{CELL_SIZE}_aos"
665
666 if 'gi001' in filename:
667 plt.axvline(x = L2CacheSizeMap['gi001']/ParticleSize, color = 'k', linestyle = '--')
668 elif 'gn003' in filename:
669 plt.axvline(x = L2CacheSizeMap['gn003']/ParticleSize, color = 'k', linestyle = '--')
670 else:
671 raise Exception("I don't know what CPU I'm working on!")
672
673 plt.savefig(f"{filename}.pdf")
674 plt.savefig(f"{filename}.png")
675
676 plt.close('all')
677 plt.rcdefaults()
678
679 plt.clf()
680 mpl.rcParams.update(params)
681
682 cell_size_legend_handles = []
683 cell_size_legend_labels = []
684
685 for im, implementation in enumerate(ImplementationVariant_FixedPPC[kernel]):
686 if '#' in implementation: continue
687
688 cell_size_legend_handles += [Line2D([0], [0], marker=Symbols[im], color=Colors[im], linestyle=LineStyles['soa'])]
689 cell_size_legend_labels += [f'{ImplementationVariantName[implementation]}']
690
691 impl_data_all = read_data(folder_name, f"{kernel} {implementation}")
692
693 impl_data_soa = impl_data_all[CELL_SIZE][1]
694
695 x_data = impl_data_soa[0]
696 y_data = impl_data_soa[1]
697
698 plt.plot( x_data,
699 y_data,
700 Symbols[im],
701 color=Colors[im],
702 # label=label,
703 linestyle=LineStyles['soa']
704 )
705
706 plt.xlabel("Particles")
707 plt.ylabel("Time per particle update [t]=s")
708
709 plt.xscale('log', base=10)
710
711 plt.minorticks_on()
712 plt.grid(True, which='both')
713
714 filename = f"/{kernel}".replace('(', '').replace(')', '').replace(',', '_').replace('-', '_')
715 filename = f"{folder_name}/{filename}_cell{CELL_SIZE}_soa"
716
717 if 'gi001' in filename:
718 plt.axvline(x = L2CacheSizeMap['gi001']/ParticleSize, color = 'k', linestyle = '--')
719 elif 'gn003' in filename:
720 plt.axvline(x = L2CacheSizeMap['gn003']/ParticleSize, color = 'k', linestyle = '--')
721 else:
722 raise Exception("I don't know what CPU I'm working on!")
723
724 plt.savefig(f"{filename}.pdf")
725 plt.savefig(f"{filename}.png")
726
727 plt.close('all')
728 plt.rcdefaults()
729
730 fig_legend = plt.figure(figsize=(10, 2))
731 ax_legend = fig_legend.add_subplot(111)
732 ax_legend.axis("off")
733 ax_legend.legend(handles=cell_size_legend_handles, labels=cell_size_legend_labels, loc="center", ncol=2, frameon=False)
734 fig_legend.savefig(f"{folder_name}/{kernel}_variants_legend.pdf", bbox_inches='tight', dpi=300)
735 fig_legend.savefig(f"{folder_name}/{kernel}_variants_legend.png", bbox_inches='tight', dpi=300)
736
737 plt.close('all')
738 plt.close()
739 plt.rcdefaults()
740
741 plt.close('all')
742 plt.close()
743 plt.rcdefaults()
744
745
747 print( f"process folder {folder_name}" )
748
749 for k, kernel in enumerate(Kernels):
750 for cs, CELL_SIZE in enumerate(CELL_SIZES):
751 cell_size_legend_handles = []
752 cell_size_legend_labels = []
753
754 plt.clf()
755 mpl.rcParams.update(params)
756
757 impl_data_all_baseline = read_data(folder_name, f"{kernel} {ImplementationVariant[kernel][0]}")
758
759 for im, implementation in enumerate(ImplementationVariant[kernel]):
760 if '#' in implementation: continue
761
762 impl_data_all = read_data(folder_name, f"{kernel} {implementation}")
763
764 cell_size_legend_handles += [Line2D([0], [0], marker=Symbols[im], color=Colors[im], linestyle=LineStyles['aos'])]
765 cell_size_legend_labels += [f'{implementation}']
766
767 impl_data_aos_baseline = impl_data_all_baseline[CELL_SIZE][0]
768 impl_data_aos = impl_data_all[CELL_SIZE][0]
769
770 x_data = impl_data_aos_baseline[0]
771 y_data = np.array(impl_data_aos_baseline[1]) / np.array(impl_data_aos[1])
772
773 plt.ylim(0.4, 3.4)
774 plt.plot( x_data,
775 y_data,
776 Symbols[im],
777 color=Colors[im],
778 # label=label,
779 linestyle=LineStyles['aos']
780 )
781
782 plt.xlabel("Particles")
783 plt.ylabel(f"Relative performance")
784
785 plt.xscale('log', base=10)
786
787 plt.minorticks_on()
788 plt.grid(True, which='both')
789
790 filename = f"/{kernel}".replace('(', '').replace(')', '').replace(',', '_').replace('-', '_')
791 filename = f"{folder_name}/{filename}_cell{CELL_SIZE}_aos_relative"
792
793 if 'gi001' in filename:
794 plt.axvline(x = L2CacheSizeMap['gi001']/ParticleSize, color = 'k', linestyle = '--')
795 elif 'gn003' in filename:
796 plt.axvline(x = L2CacheSizeMap['gn003']/ParticleSize, color = 'k', linestyle = '--')
797 else:
798 raise Exception("I don't know what CPU I'm working on!")
799
800 plt.axhline(y = 1, color = 'k', linestyle = '--')
801
802 plt.savefig(f"{filename}.pdf")
803 plt.savefig(f"{filename}.png")
804
805 plt.close('all')
806 plt.rcdefaults()
807
808 plt.clf()
809 mpl.rcParams.update(params)
810
811 cell_size_legend_handles = []
812 cell_size_legend_labels = []
813
814 for im, implementation in enumerate(ImplementationVariant[kernel]):
815 if '#' in implementation: continue
816
817 cell_size_legend_handles += [Line2D([0], [0], marker=Symbols[im], color=Colors[im], linestyle=LineStyles['soa'])]
818 cell_size_legend_labels += [f'{implementation}']
819
820 impl_data_all = read_data(folder_name, f"{kernel} {implementation}")
821
822 impl_data_soa_baseline = impl_data_all_baseline[CELL_SIZE][1]
823 impl_data_soa = impl_data_all[CELL_SIZE][1]
824
825 x_data = impl_data_soa_baseline[0]
826 y_data = np.array(impl_data_soa_baseline[1]) / np.array(impl_data_soa[1])
827
828 plt.ylim(0.4, 3.4)
829 plt.plot( x_data,
830 y_data,
831 Symbols[im],
832 color=Colors[im],
833 # label=label,
834 linestyle=LineStyles['soa']
835 )
836
837 plt.xlabel("Particles")
838 plt.ylabel(f"Relative performance")
839
840 plt.xscale('log', base=10)
841
842 plt.minorticks_on()
843 plt.grid(True, which='both')
844
845 filename = f"/{kernel}".replace('(', '').replace(')', '').replace(',', '_').replace('-', '_')
846 filename = f"{folder_name}/{filename}_cell{CELL_SIZE}_soa_relative"
847
848 if 'gi001' in filename:
849 plt.axvline(x = L2CacheSizeMap['gi001']/ParticleSize, color = 'k', linestyle = '--')
850 elif 'gn003' in filename:
851 plt.axvline(x = L2CacheSizeMap['gn003']/ParticleSize, color = 'k', linestyle = '--')
852 else:
853 raise Exception("I don't know what CPU I'm working on!")
854
855 plt.axhline(y = 1, color = 'k', linestyle = '--')
856
857 plt.savefig(f"{filename}.pdf")
858 plt.savefig(f"{filename}.png")
859
860 plt.close('all')
861 plt.rcdefaults()
862
863 plt.close('all')
864 plt.close()
865 plt.rcdefaults()
866
867if __name__== "__main__":
868 if len(sys.argv) < 2:
869 print( "ERROR: Please pass in file to work on. ")
870 else:
871 for folder in sys.argv[1:]:
872 process_folder(folder)
876 try:
877 process_folder_gpu(folder)
879 except:
880 pass
read_data(folder_name, kernel_name)
returns { 'cell size' : [ (xdata, ydata) for aos, (xdata, ydata) for soa ], }
read_data_gpu(folder_name, kernel_name)
returns { 'cell size' : [ (xdata, ydata) for aos - always empty, (xdata, ydata) for soa ],...
read_data_gpu_shmem(folder_name, kernel_name)
returns { 'cell size' : [ (xdata, ydata) for aos - always empty, (xdata, ydata) for soa ],...