Skip to content

Commit 5dec7fe

Browse files
brownbaerchenThomas Baumann
andauthored
Slight changes to plots in thesis (#546)
Co-authored-by: Thomas Baumann <[email protected]>
1 parent 2f6043f commit 5dec7fe

File tree

3 files changed

+65
-32
lines changed

3 files changed

+65
-32
lines changed

pySDC/projects/GPU/analysis_scripts/parallel_scaling.py

Lines changed: 58 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,17 @@ def run_scaling_test(self, **kwargs):
8181
**kwargs,
8282
)
8383

84-
def plot_scaling_test(self, ax, quantity='time', **plotting_params): # pragma: no cover
84+
def plot_scaling_test(self, ax, quantity='time', space_time=None, **plotting_params): # pragma: no cover
8585
from matplotlib.colors import TABLEAU_COLORS
8686

8787
cmap = TABLEAU_COLORS
8888
colors = list(cmap.values())
8989

9090
for experiment in self.experiments:
91+
if space_time is not None:
92+
if not experiment.PinT == space_time:
93+
continue
94+
9195
tasks_time = self.tasks_time if experiment.PinT else 1
9296
timings = {}
9397

@@ -141,20 +145,30 @@ def plot_scaling_test(self, ax, quantity='time', **plotting_params): # pragma:
141145
elif quantity == 'throughput_per_task':
142146
timings[np.prod(procs)] = experiment.res**self.ndim / t_mean
143147
elif quantity == 'efficiency':
148+
if type(config).__name__ == 'GrayScottScaling3D':
149+
norm = 13216322.909
150+
else:
151+
norm = 1
144152
timings[np.prod(procs) / self.tasks_per_node] = (
145-
experiment.res**self.ndim / t_mean / np.prod(procs)
153+
experiment.res**self.ndim / t_mean / np.prod(procs) / norm
146154
)
147155
elif quantity == 'time':
148156
timings[np.prod(procs) / self.tasks_per_node] = t_mean
149157
elif quantity == 'time_per_task':
150158
timings[np.prod(procs)] = t_mean
151159
elif quantity == 'min_time_per_task':
152160
timings[np.prod(procs)] = t_min
161+
elif quantity == 'min_time':
162+
timings[np.prod(procs) / self.tasks_per_node] = t_min
153163
else:
154164
raise NotImplementedError
155165
except (FileNotFoundError, ValueError):
156166
pass
157167

168+
if quantity == 'efficiency' and type(config).__name__ == 'RayleighBenard_scaling':
169+
norm = max(timings.values())
170+
timings = {key: value / norm for key, value in timings.items()}
171+
158172
ax.loglog(
159173
timings.keys(),
160174
timings.values(),
@@ -171,7 +185,8 @@ def plot_scaling_test(self, ax, quantity='time', **plotting_params): # pragma:
171185
'time': r'$t_\mathrm{step}$ / s',
172186
'time_per_task': r'$t_\mathrm{step}$ / s',
173187
'min_time_per_task': r'minimal $t_\mathrm{step}$ / s',
174-
'efficiency': 'efficiency / DoF/s/task',
188+
'min_time': r'minimal $t_\mathrm{step}$ / s',
189+
'efficiency': r'parallel efficiency / \%',
175190
}
176191
ax.set_ylabel(labels[quantity])
177192

@@ -331,17 +346,28 @@ class RayleighBenardDedalusComparisonGPU(GPUConfig, ScalingConfig):
331346
]
332347

333348

334-
def plot_scalings(problem, **kwargs): # pragma: no cover
349+
def plot_scalings(problem, XPU=None, space_time=None, **kwargs): # pragma: no cover
335350
if problem == 'GS3D':
336-
configs = [
337-
GrayScottSpaceScalingCPU3D(),
338-
GrayScottSpaceScalingGPU3D(),
339-
]
351+
if XPU == 'CPU':
352+
configs = [GrayScottSpaceScalingCPU3D()]
353+
elif XPU == 'GPU':
354+
configs = [GrayScottSpaceScalingGPU3D()]
355+
else:
356+
configs = [GrayScottSpaceScalingCPU3D(), GrayScottSpaceScalingGPU3D()]
340357
elif problem == 'RBC':
341-
configs = [
342-
RayleighBenardSpaceScalingGPU(),
343-
RayleighBenardSpaceScalingCPU(),
344-
]
358+
if XPU == 'CPU':
359+
configs = [
360+
RayleighBenardSpaceScalingCPU(),
361+
]
362+
elif XPU == 'GPU':
363+
configs = [
364+
RayleighBenardSpaceScalingGPU(),
365+
]
366+
else:
367+
configs = [
368+
RayleighBenardSpaceScalingGPU(),
369+
RayleighBenardSpaceScalingCPU(),
370+
]
345371
elif problem == 'RBC_dedalus':
346372
configs = [
347373
RayleighBenardDedalusComparison(),
@@ -358,31 +384,26 @@ def plot_scalings(problem, **kwargs): # pragma: no cover
358384
('RBC', 'time'): {'x': [1 / 10, 64], 'y': [60, 60 / 640]},
359385
('RBC', 'time_per_task'): {'x': [1, 640], 'y': [60, 60 / 640]},
360386
('RBC', 'min_time_per_task'): {'x': [1, 640], 'y': [60, 60 / 640]},
387+
('RBC', 'min_time'): {'x': [1, 640], 'y': [60, 60 / 640]},
361388
('RBC', 'throughput_per_task'): {'x': [1 / 1, 640], 'y': [2e4, 2e4 * 640]},
362389
}
363390

364-
fig, ax = plt.subplots(figsize=figsize_by_journal('TUHH_thesis', 1, 0.6))
365-
configs[1].plot_scaling_test(ax=ax, quantity='efficiency')
366-
# ax.legend(frameon=False)
367-
box = ax.get_position()
368-
ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
369-
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
370-
371-
ax.set_yscale('linear')
372-
path = f'{PROJECT_PATH}/plots/scaling_{problem}_efficiency.pdf'
373-
fig.savefig(path, bbox_inches='tight')
374-
print(f'Saved {path!r}', flush=True)
375-
376-
for quantity in ['time', 'throughput', 'time_per_task', 'throughput_per_task', 'min_time_per_task'][::-1]:
391+
for quantity in ['time', 'throughput', 'time_per_task', 'throughput_per_task', 'min_time_per_task', 'efficiency'][
392+
::-1
393+
]:
377394
fig, ax = plt.subplots(figsize=figsize_by_journal('TUHH_thesis', 1, 0.6))
378395
for config in configs:
379-
config.plot_scaling_test(ax=ax, quantity=quantity)
396+
config.plot_scaling_test(ax=ax, quantity=quantity, space_time=space_time)
380397
if (problem, quantity) in ideal_lines.keys():
381398
ax.loglog(*ideal_lines[(problem, quantity)].values(), color='black', ls=':', label='ideal')
399+
elif quantity == 'efficiency':
400+
ax.axhline(1, color='black', ls=':', label='ideal')
401+
ax.set_yscale('linear')
402+
ax.set_ylim(0, 1.1)
382403
box = ax.get_position()
383404
ax.set_position([box.x0, box.y0, box.width * 0.8, box.height])
384405
ax.legend(loc='center left', bbox_to_anchor=(1, 0.5))
385-
path = f'{PROJECT_PATH}/plots/scaling_{problem}_{quantity}.pdf'
406+
path = f'{PROJECT_PATH}/plots/scaling_{problem}_{quantity}_{XPU}_{space_time}.pdf'
386407
fig.savefig(path, bbox_inches='tight')
387408
print(f'Saved {path!r}', flush=True)
388409

@@ -393,8 +414,8 @@ def plot_scalings(problem, **kwargs): # pragma: no cover
393414
parser = argparse.ArgumentParser()
394415
parser.add_argument('--mode', type=str, choices=['run', 'plot'], default='run')
395416
parser.add_argument('--problem', type=str, default='GS')
396-
parser.add_argument('--XPU', type=str, choices=['CPU', 'GPU'], default='CPU')
397-
parser.add_argument('--space_time', type=str, choices=['True', 'False'], default='False')
417+
parser.add_argument('--XPU', type=str, choices=['CPU', 'GPU', 'both'], default='CPU')
418+
parser.add_argument('--space_time', type=str, choices=['True', 'False', 'None'], default='False')
398419
parser.add_argument('--submit', type=str, choices=['True', 'False'], default='True')
399420
parser.add_argument('--nsys_profiling', type=str, choices=['True', 'False'], default='False')
400421

@@ -403,6 +424,13 @@ def plot_scalings(problem, **kwargs): # pragma: no cover
403424
submit = args.submit == 'True'
404425
nsys_profiling = args.nsys_profiling == 'True'
405426

427+
if args.space_time == 'True':
428+
space_time = True
429+
elif args.space_time == 'False':
430+
space_time = False
431+
else:
432+
space_time = None
433+
406434
config_classes = []
407435

408436
if args.problem == 'GS3D':
@@ -429,6 +457,6 @@ def plot_scalings(problem, **kwargs): # pragma: no cover
429457
if args.mode == 'run':
430458
config.run_scaling_test(submit=submit, nsys_profiling=nsys_profiling)
431459
elif args.mode == 'plot':
432-
plot_scalings(problem=args.problem)
460+
plot_scalings(problem=args.problem, XPU=args.XPU, space_time=space_time)
433461
else:
434462
raise NotImplementedError(f'Don\'t know mode {args.mode!r}')

pySDC/projects/GPU/paper_plots.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,19 @@ def plot_scalings_separately(problem, journal='TUHH_thesis', **kwargs): # pragm
5454

5555
def make_plots_for_thesis(): # pragma: no cover
5656
from pySDC.projects.GPU.analysis_scripts.plot_RBC_matrix import plot_DCT, plot_preconditioners, plot_ultraspherical
57+
from pySDC.projects.GPU.analysis_scripts.parallel_scaling import plot_scalings
5758

5859
# small plots with no simulations
5960
plot_DCT()
6061
plot_preconditioners()
6162
plot_ultraspherical()
6263

6364
# plot space-time parallel scaling
64-
for problem in ['GS3D', 'RBC']:
65-
plot_scalings_separately(problem=problem)
65+
plot_scalings(problem='GS3D', XPU='both', space_time=False)
66+
plot_scalings(problem='GS3D', XPU='GPU', space_time=None)
67+
plot_scalings(problem='RBC', XPU='both', space_time=False)
68+
plot_scalings(problem='RBC', XPU='GPU', space_time=None)
69+
plot_scalings(problem='RBC', XPU='CPU', space_time=None)
6670

6771

6872
if __name__ == '__main__':

pySDC/projects/Resilience/paper_plots.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -813,6 +813,7 @@ def plot_recovery_rate_per_acceptance_threshold(problem, target='resilience'):
813813
else:
814814
fig, ax = plt.subplots(figsize=figsize_by_journal(JOURNAL, 0.8, 0.5))
815815

816+
ax.axvline(1.1, color='grey', ls=':', label='1.1')
816817
stats_analyser.plot_recovery_thresholds(thresh_range=np.logspace(-1, 4, 500), recoverable_only=False, ax=ax)
817818
ax.set_xscale('log')
818819
ax.set_ylim((-0.05, 1.05))

0 commit comments

Comments
 (0)