Note
Go to the end to download the full example code.
Dusty disc performance results#
Solver rate of the dusty disc perf test (dustydisc_perftest.py) on an
H200, as a function of the number of dust species.
9 import matplotlib as mpl
10 import matplotlib.pyplot as plt
11 import numpy as np
12
13 mpl.rcParams.update(
14 {
15 "font.family": "serif",
16 "mathtext.fontset": "cm",
17 "font.size": 14,
18 "axes.labelsize": 16,
19 "axes.titlesize": 16,
20 "xtick.labelsize": 13,
21 "ytick.labelsize": 13,
22 "legend.fontsize": 13,
23 "axes.facecolor": "white",
24 "axes.linewidth": 1.0,
25 "xtick.direction": "in",
26 "ytick.direction": "in",
27 "xtick.top": True,
28 "ytick.right": True,
29 "xtick.major.size": 8,
30 "ytick.major.size": 8,
31 "xtick.minor.visible": True,
32 "ytick.minor.visible": True,
33 "legend.frameon": True,
34 "legend.fancybox": False,
35 "legend.edgecolor": "black",
36 }
37 )
38
39 RESULTS_H200_BASELINE = [
40 {"kernel": "M4", "ndust": 0, "rate": np.float64(20743174.163988266)},
41 {"kernel": "M6", "ndust": 0, "rate": np.float64(13799390.088761112)},
42 {"kernel": "M6", "ndust": 1, "rate": np.float64(12633702.042326497)},
43 {"kernel": "M6", "ndust": 2, "rate": np.float64(12087424.370965026)},
44 {"kernel": "M6", "ndust": 3, "rate": np.float64(11881595.212850157)},
45 {"kernel": "M6", "ndust": 4, "rate": np.float64(11300411.830739705)},
46 {"kernel": "M6", "ndust": 5, "rate": np.float64(11222855.348508552)},
47 {"kernel": "M6", "ndust": 6, "rate": np.float64(10755208.603137823)},
48 {"kernel": "M6", "ndust": 7, "rate": np.float64(10688006.42580047)},
49 {"kernel": "M6", "ndust": 8, "rate": np.float64(10142698.857492624)},
50 {"kernel": "M6", "ndust": 9, "rate": np.float64(10214823.874985265)},
51 {"kernel": "M6", "ndust": 10, "rate": np.float64(9761393.55028728)},
52 {"kernel": "M6", "ndust": 11, "rate": np.float64(9792483.14187795)},
53 {"kernel": "M6", "ndust": 12, "rate": np.float64(9219263.745632991)},
54 {"kernel": "M6", "ndust": 13, "rate": np.float64(9388890.664223792)},
55 {"kernel": "M6", "ndust": 14, "rate": np.float64(8948305.414125301)},
56 {"kernel": "M6", "ndust": 15, "rate": np.float64(9006443.219386235)},
57 {"kernel": "M6", "ndust": 16, "rate": np.float64(8591518.90067488)},
58 {"kernel": "M6", "ndust": 17, "rate": np.float64(8663145.798459316)},
59 {"kernel": "M6", "ndust": 18, "rate": np.float64(8252145.146574976)},
60 {"kernel": "M6", "ndust": 19, "rate": np.float64(8367198.978522308)},
61 {"kernel": "M6", "ndust": 20, "rate": np.float64(7823688.987683165)},
62 {"kernel": "M6", "ndust": 21, "rate": np.float64(8078987.197870458)},
63 {"kernel": "M6", "ndust": 22, "rate": np.float64(7692061.528587866)},
64 {"kernel": "M6", "ndust": 23, "rate": np.float64(7820297.588177133)},
65 {"kernel": "M6", "ndust": 24, "rate": np.float64(7334507.940110926)},
66 {"kernel": "M6", "ndust": 25, "rate": np.float64(7578401.6513876775)},
67 {"kernel": "M6", "ndust": 26, "rate": np.float64(7200301.321665853)},
68 {"kernel": "M6", "ndust": 27, "rate": np.float64(7341230.143859156)},
69 {"kernel": "M6", "ndust": 28, "rate": np.float64(6858490.479193717)},
70 {"kernel": "M6", "ndust": 29, "rate": np.float64(7151851.505432058)},
71 {"kernel": "M6", "ndust": 30, "rate": np.float64(6780589.608352743)},
72 {"kernel": "M6", "ndust": 31, "rate": np.float64(6957826.151235339)},
73 {"kernel": "M6", "ndust": 32, "rate": np.float64(6871322.974704008)},
74 {"kernel": "M6", "ndust": 33, "rate": np.float64(6766758.272378567)},
75 {"kernel": "M6", "ndust": 34, "rate": np.float64(6416124.696613544)},
76 {"kernel": "M6", "ndust": 35, "rate": np.float64(6595107.764492851)},
77 {"kernel": "M6", "ndust": 36, "rate": np.float64(6124688.97834106)},
78 {"kernel": "M6", "ndust": 37, "rate": np.float64(6428013.769450867)},
79 {"kernel": "M6", "ndust": 38, "rate": np.float64(6106585.969761499)},
80 {"kernel": "M6", "ndust": 39, "rate": np.float64(6261067.583511858)},
81 {"kernel": "M6", "ndust": 40, "rate": np.float64(5846567.91142668)},
82 {"kernel": "M6", "ndust": 41, "rate": np.float64(6130846.680557474)},
83 {"kernel": "M6", "ndust": 42, "rate": np.float64(5781410.068906898)},
84 {"kernel": "M6", "ndust": 43, "rate": np.float64(5978457.374960809)},
85 {"kernel": "M6", "ndust": 44, "rate": np.float64(5510755.835376551)},
86 {"kernel": "M6", "ndust": 45, "rate": np.float64(5847274.351241548)},
87 {"kernel": "M6", "ndust": 46, "rate": np.float64(5533625.961877414)},
88 {"kernel": "M6", "ndust": 47, "rate": np.float64(5712080.273564)},
89 {"kernel": "M6", "ndust": 48, "rate": np.float64(5405527.541108767)},
90 {"kernel": "M6", "ndust": 49, "rate": np.float64(5590447.5575348595)},
91 {"kernel": "M6", "ndust": 50, "rate": np.float64(5307054.447021384)},
92 {"kernel": "M6", "ndust": 51, "rate": np.float64(5474498.7673062915)},
93 {"kernel": "M6", "ndust": 52, "rate": np.float64(5065365.2100912845)},
94 {"kernel": "M6", "ndust": 53, "rate": np.float64(5353810.653996148)},
95 {"kernel": "M6", "ndust": 54, "rate": np.float64(5066047.936317459)},
96 {"kernel": "M6", "ndust": 55, "rate": np.float64(5242961.026497445)},
97 {"kernel": "M6", "ndust": 56, "rate": np.float64(4883427.61396701)},
98 {"kernel": "M6", "ndust": 57, "rate": np.float64(5132179.980544963)},
99 {"kernel": "M6", "ndust": 58, "rate": np.float64(4853087.799315191)},
100 {"kernel": "M6", "ndust": 59, "rate": np.float64(5020866.021284079)},
101 {"kernel": "M6", "ndust": 60, "rate": np.float64(4618314.988822764)},
102 {"kernel": "M6", "ndust": 61, "rate": np.float64(4921603.58455902)},
103 {"kernel": "M6", "ndust": 62, "rate": np.float64(4648092.049223436)},
104 ]
105
106
107 def _lookup_rate(results, kernel, ndust):
108 for entry in results:
109 if entry["kernel"] == kernel and entry["ndust"] == ndust:
110 return float(entry["rate"])
111 return None
112
113
114 def plot_perf_results(results, title="Dusty disc performance"):
115 visible_ndust = {1, 5, 10, 20, 30, 40, 50, 60, 70}
116 labels = ["gas only M4", "gas only M6"]
117 rates_off = [
118 _lookup_rate(results, "M4", 0),
119 _lookup_rate(results, "M6", 0),
120 ]
121
122 ndust_values = sorted({entry["ndust"] for entry in results if entry["ndust"] > 0})
123 for ndust in ndust_values:
124 labels.append(str(ndust))
125 rates_off.append(_lookup_rate(results, "M6", ndust))
126
127 fig, ax = plt.subplots(figsize=(6.4, 6))
128 gas_count = 2
129 gas_spread = 2.0
130 ndust_gap = 4.0
131 x = np.arange(len(labels), dtype=float)
132 x[1:] += gas_spread
133 x[gas_count:] += ndust_gap
134 width = 2
135
136 gas_x = x[:gas_count]
137 gas_y = rates_off[:gas_count]
138 dust_x = x[gas_count:]
139 dust_y = rates_off[gas_count:]
140
141 ax.bar(gas_x, gas_y, width, label="coala off", color="C0")
142 ax.plot(dust_x, dust_y, color="C0", marker="o", markersize=3)
143
144 separator_x = (x[gas_count - 1] + x[gas_count]) / 2
145 ax.axvline(separator_x, color="0.4", linewidth=1.2, linestyle="-", zorder=0)
146
147 # ax.set_yscale("log")
148 # ax.set_ylim(1e6,3e7)
149 ax.set_ylabel("rate (particles/s)")
150 ax.set_xlabel("dust species", labelpad=-16)
151 ax.set_title(title)
152
153 baseline_rate = _lookup_rate(results, "M6", 0)
154 if baseline_rate:
155 ax.tick_params(axis="y", right=False, which="both")
156 secax = ax.secondary_yaxis(
157 "right", functions=(lambda r: r / baseline_rate, lambda s: s * baseline_rate)
158 )
159 secax.set_ylabel("speedup relative to M6 (gas only)")
160 for frac in (1.00, 0.75, 0.5):
161 y = frac * baseline_rate
162 ax.axhline(y, color="red", linewidth=1.0, linestyle="--", zorder=0)
163 ax.text(
164 x[-1],
165 y,
166 f"{frac:.0%}",
167 color="red",
168 fontsize=11,
169 va="bottom",
170 ha="right",
171 )
172 ax.set_xticks(x)
173 visible_indices = {0, 1}
174 for ndust in visible_ndust:
175 visible_indices.add(1 + ndust)
176 tick_labels = [labels[i] if i in visible_indices else "" for i in range(len(labels))]
177 ax.set_xticklabels(tick_labels, rotation=90, fontsize=12)
178 for i, tick in enumerate(ax.xaxis.get_major_ticks()):
179 if i not in visible_indices:
180 tick.tick1line.set_visible(False)
181 tick.tick2line.set_visible(False)
182 # ax.legend()
183 ax.grid(axis="y", which="both", linestyle=":", alpha=0.5)
184 fig.tight_layout()
185 return fig, ax
Plot the results
190 fig, ax = plot_perf_results(RESULTS_H200_BASELINE, title="Dusty disc performance (H200)")
191 plt.show()

Total running time of the script: (0 minutes 0.477 seconds)
Estimated memory usage: 162 MB