Note
Go to the end to download the full example code.
DTT performance benchmarks#
This example benchmarks the DTT performance for the different algorithms available in Shamrock
9 import random
10 import time
11
12 import matplotlib.pyplot as plt
13 import numpy as np
14 from matplotlib import colors
15
16 import shamrock
17
18 # If we use the shamrock executable to run this script instead of the python interpreter,
19 # we should not initialize the system as the shamrock executable needs to handle specific MPI logic
20 if not shamrock.sys.is_initialized():
21 shamrock.change_loglevel(1)
22 shamrock.sys.init("0:0")
Use shamrock documentation style for matplotlib
28 shamrock.matplotlib.set_shamrock_mpl_style()
Main benchmark functions
33 bounding_box = shamrock.math.AABB_f64_3((0.0, 0.0, 0.0), (1.0, 1.0, 1.0))
34
35
36 def benchmark_dtt_core(N, theta_crit, compression_level, ordered_result, nb_repeat=10):
37 times = []
38 random.seed(111)
39 max_mem_delta = 0
40 for i in range(nb_repeat):
41 positions = shamrock.algs.mock_buffer_f64_3(
42 random.randint(0, 1000000), N, bounding_box.lower, bounding_box.upper
43 )
44 tree = shamrock.tree.CLBVH_u64_f64_3()
45 tree.rebuild_from_positions(positions, bounding_box, compression_level)
46 shamrock.backends.reset_mem_info_max()
47 mem_info_before = shamrock.backends.get_mem_perf_info()
48 times.append(
49 shamrock.tree.benchmark_clbvh_dual_tree_traversal(tree, theta_crit, ordered_result)
50 * 1000
51 )
52 mem_info_after = shamrock.backends.get_mem_perf_info()
53
54 mem_delta = (
55 mem_info_after.max_allocated_byte_device - mem_info_before.max_allocated_byte_device
56 )
57 max_mem_delta = max(max_mem_delta, mem_delta)
58 return times, max_mem_delta
59
60
61 def benchmark_dtt(N, theta_crit, compression_level, ordered_result, nb_repeat=10):
62 times, max_mem_delta = benchmark_dtt_core(
63 N, theta_crit, compression_level, ordered_result, nb_repeat
64 )
65 return min(times), max(times), sum(times) / nb_repeat, max_mem_delta
Run the performance test for all parameters
70 def run_performance_sweep(compression_level, threshold_run, ordered_result):
71 # Define parameter ranges
72 # logspace as array
73 particle_counts = np.logspace(2, 7, 10).astype(int).tolist()
74 theta_crits = [0.1, 0.3, 0.5, 0.7, 0.9]
75
76 # Initialize results matrix
77 results_mean = np.zeros((len(theta_crits), len(particle_counts)))
78 results_min = np.zeros((len(theta_crits), len(particle_counts)))
79 results_max = np.zeros((len(theta_crits), len(particle_counts)))
80 results_max_mem_delta = np.zeros((len(theta_crits), len(particle_counts)))
81
82 print(f"Particle counts: {particle_counts}")
83 print(f"Theta_crit values: {theta_crits}")
84 print(f"Compression level: {compression_level}")
85
86 total_runs = len(particle_counts) * len(theta_crits)
87 current_run = 0
88
89 for i, theta_crit in enumerate(theta_crits):
90 exceed_mem = False
91 for j, N in enumerate(particle_counts):
92 current_run += 1
93
94 if exceed_mem:
95 print(
96 f"[{current_run:2d}/{total_runs}] Skipping N={N:5d}, theta_crit={theta_crit:.1f}"
97 )
98 results_mean[i, j] = np.nan
99 results_min[i, j] = np.nan
100 results_max[i, j] = np.nan
101 continue
102
103 print(
104 f"[{current_run:2d}/{total_runs}] Running N={N:5d}, theta_crit={theta_crit:.1f}...",
105 end=" ",
106 )
107
108 start_time = time.time()
109 min_time, max_time, mean_time, max_mem_delta = benchmark_dtt(
110 N, theta_crit, compression_level, ordered_result
111 )
112 elapsed = time.time() - start_time
113
114 results_mean[i, j] = mean_time
115 results_min[i, j] = min_time
116 results_max[i, j] = max_time
117 results_max_mem_delta[i, j] = max_mem_delta
118
119 print(f"mean={mean_time:.3f}ms (took {elapsed:.1f}s)")
120
121 if max_mem_delta > threshold_run:
122 exceed_mem = True
123
124 return (
125 particle_counts,
126 theta_crits,
127 results_mean,
128 results_min,
129 results_max,
130 results_max_mem_delta,
131 )
Create checkerboard plot with execution times and relative performance to reference algorithm
136 def create_checkerboard_plot(
137 particle_counts,
138 theta_crits,
139 results_data,
140 compression_level,
141 algname,
142 max_axis_value,
143 reference_data,
144 results_max_mem_delta,
145 ):
146 """Create checkerboard plot with execution times"""
147
148 fig, ax = plt.subplots(figsize=(12, 8))
149
150 # Calculate relative performance compared to reference algorithm
151 # results_data / reference_data gives the ratio (>1 means slower, <1 means faster)
152 relative_performance = results_data / reference_data
153
154 # Create the heatmap with relative performance values
155 # Create a masked array to handle NaN values (skipped benchmarks) as white
156 masked_relative = np.ma.masked_invalid(relative_performance)
157
158 # Use a diverging colormap: red for better performance (<1), green for worse (>1)
159 # RdYlGn_r (reversed) has green for high values (worse) and red for low values (better)
160 cmap = plt.cm.RdYlGn_r.copy() # Green for >1 (slower), Red for <1 (faster)
161 cmap.set_bad(color="white") # Set NaN values to white
162
163 # Set the color scale limits for relative performance
164 vmin = 0.5
165 vmax = 1.5
166
167 im = ax.imshow(
168 masked_relative, cmap=cmap, aspect="auto", interpolation="nearest", vmin=vmin, vmax=vmax
169 )
170
171 # Set ticks and labels
172 ax.set_xticks(range(len(particle_counts)))
173 ax.set_yticks(range(len(theta_crits)))
174 ax.set_xticklabels([f"{N // 1000}k" if N >= 1000 else str(N) for N in particle_counts])
175 ax.set_yticklabels([f"{theta:.1f}" for theta in theta_crits])
176
177 # Add labels
178 ax.set_xlabel("Particle Count")
179 ax.set_ylabel("Theta Critical")
180 ax.set_title(
181 f"Dual Tree Traversal Performance\n(Colors: Relative to Reference, Text: Absolute Time in ms)\ncompression level = {compression_level} algorithm = {algname}",
182 pad=20,
183 )
184
185 # Add text annotations showing the values
186 for i in range(len(theta_crits)):
187 for j in range(len(particle_counts)):
188 value = results_data[i, j]
189
190 if np.isnan(value):
191 # For skipped benchmarks, show "SKIPPED" in black on white background
192 # ax.text(j, i, 'SKIPPED', ha='center', va='center',
193 # color='black', fontweight='bold', fontsize=8)
194 pass
195 else:
196 perf = relative_performance[i, j]
197 mem_delta = results_max_mem_delta[i, j] / 1e6
198 text_color = "black"
199 ax.text(
200 j,
201 i,
202 f"{value:.2f}ms\n{perf:.2f}\n{mem_delta:.2f}MB",
203 ha="center",
204 va="center",
205 color=text_color,
206 fontweight="bold",
207 fontsize=10,
208 )
209
210 # Add colorbar for relative performance
211 cbar = plt.colorbar(im, ax=ax, shrink=0.8)
212 cbar.set_label("Relative performance (time / reference time)")
213 cbar.ax.tick_params(labelsize=10)
214
215 # Add custom tick labels for better interpretation
216 tick_positions = [0.1, 0.2, 0.5, 1.0, 2.0, 3.0]
217 cbar.set_ticks([pos for pos in tick_positions if vmin <= pos <= vmax])
218
219 # Improve layout
220 plt.tight_layout()
221
222 # Add grid for better readability
223 ax.set_xticks(np.arange(len(particle_counts)) - 0.5, minor=True)
224 ax.set_yticks(np.arange(len(theta_crits)) - 0.5, minor=True)
225 ax.grid(which="minor", color="black", linestyle="-", linewidth=1, alpha=0.3)
226
227 return fig, ax
List current implementation
232 current_impl = shamrock.tree.get_current_impl_clbvh_dual_tree_traversal_impl()
233
234 print(current_impl)
impl_param(impl_name="scan_multipass", params="")
List all implementations available
238 all_default_impls = shamrock.tree.get_default_impl_list_clbvh_dual_tree_traversal()
239
240 print(all_default_impls)
[impl_param(impl_name="reference", params=""), impl_param(impl_name="parallel_select", params=""), impl_param(impl_name="scan_multipass", params="")]
Run the performance benchmarks for all implementations
244 results = {}
245
246
247 for ordered_result in [True, False]:
248 for default_impl in all_default_impls:
249 shamrock.tree.set_impl_clbvh_dual_tree_traversal(
250 default_impl.impl_name, default_impl.params
251 )
252
253 n = default_impl.impl_name + " " + default_impl.params + "ordered=" + str(ordered_result)
254
255 print(f"Running DTT performance benchmarks for {n}...")
256
257 compression_level = 4
258
259 threshold_run = 5e6
260 # Run the performance sweep
261 (
262 particle_counts,
263 theta_crits,
264 results_mean,
265 results_min,
266 results_max,
267 results_max_mem_delta,
268 ) = run_performance_sweep(compression_level, threshold_run, ordered_result)
269
270 results[n] = {
271 "particle_counts": particle_counts,
272 "theta_crits": theta_crits,
273 "results_mean": results_mean,
274 "results_min": results_min,
275 "results_max": results_max,
276 "results_max_mem_delta": results_max_mem_delta,
277 "name": n,
278 }
Info: setting dtt implementation to impl : reference [tree][rank=0]
Running DTT performance benchmarks for reference ordered=True...
Particle counts: [100, 359, 1291, 4641, 16681, 59948, 215443, 774263, 2782559, 10000000]
Theta_crit values: [0.1, 0.3, 0.5, 0.7, 0.9]
Compression level: 4
[ 1/50] Running N= 100, theta_crit=0.1... mean=2.704ms (took 0.1s)
[ 2/50] Running N= 359, theta_crit=0.1... mean=2.077ms (took 0.0s)
[ 3/50] Running N= 1291, theta_crit=0.1... mean=2.795ms (took 0.1s)
[ 4/50] Running N= 4641, theta_crit=0.1... mean=5.917ms (took 0.1s)
[ 5/50] Running N=16681, theta_crit=0.1... mean=50.673ms (took 0.7s)
[ 6/50] Skipping N=59948, theta_crit=0.1
[ 7/50] Skipping N=215443, theta_crit=0.1
[ 8/50] Skipping N=774263, theta_crit=0.1
[ 9/50] Skipping N=2782559, theta_crit=0.1
[10/50] Skipping N=10000000, theta_crit=0.1
[11/50] Running N= 100, theta_crit=0.3... mean=2.424ms (took 0.0s)
[12/50] Running N= 359, theta_crit=0.3... mean=2.268ms (took 0.0s)
[13/50] Running N= 1291, theta_crit=0.3... mean=2.933ms (took 0.1s)
[14/50] Running N= 4641, theta_crit=0.3... mean=5.224ms (took 0.1s)
[15/50] Running N=16681, theta_crit=0.3... mean=17.568ms (took 0.3s)
[16/50] Running N=59948, theta_crit=0.3... mean=97.107ms (took 1.4s)
[17/50] Skipping N=215443, theta_crit=0.3
[18/50] Skipping N=774263, theta_crit=0.3
[19/50] Skipping N=2782559, theta_crit=0.3
[20/50] Skipping N=10000000, theta_crit=0.3
[21/50] Running N= 100, theta_crit=0.5... mean=2.141ms (took 0.0s)
[22/50] Running N= 359, theta_crit=0.5... mean=2.683ms (took 0.0s)
[23/50] Running N= 1291, theta_crit=0.5... mean=2.913ms (took 0.1s)
[24/50] Running N= 4641, theta_crit=0.5... mean=3.662ms (took 0.1s)
[25/50] Running N=16681, theta_crit=0.5... mean=7.847ms (took 0.2s)
[26/50] Running N=59948, theta_crit=0.5... mean=27.036ms (took 0.7s)
[27/50] Skipping N=215443, theta_crit=0.5
[28/50] Skipping N=774263, theta_crit=0.5
[29/50] Skipping N=2782559, theta_crit=0.5
[30/50] Skipping N=10000000, theta_crit=0.5
[31/50] Running N= 100, theta_crit=0.7... mean=2.273ms (took 0.0s)
[32/50] Running N= 359, theta_crit=0.7... mean=2.477ms (took 0.0s)
[33/50] Running N= 1291, theta_crit=0.7... mean=2.706ms (took 0.1s)
[34/50] Running N= 4641, theta_crit=0.7... mean=3.088ms (took 0.1s)
[35/50] Running N=16681, theta_crit=0.7... mean=5.088ms (took 0.2s)
[36/50] Running N=59948, theta_crit=0.7... mean=14.081ms (took 0.6s)
[37/50] Running N=215443, theta_crit=0.7... mean=40.476ms (took 2.0s)
[38/50] Skipping N=774263, theta_crit=0.7
[39/50] Skipping N=2782559, theta_crit=0.7
[40/50] Skipping N=10000000, theta_crit=0.7
[41/50] Running N= 100, theta_crit=0.9... mean=2.469ms (took 0.0s)
[42/50] Running N= 359, theta_crit=0.9... mean=2.622ms (took 0.0s)
[43/50] Running N= 1291, theta_crit=0.9... mean=2.755ms (took 0.1s)
[44/50] Running N= 4641, theta_crit=0.9... mean=3.103ms (took 0.1s)
[45/50] Running N=16681, theta_crit=0.9... mean=4.486ms (took 0.2s)
[46/50] Running N=59948, theta_crit=0.9... mean=10.199ms (took 0.5s)
[47/50] Running N=215443, theta_crit=0.9... mean=28.544ms (took 1.8s)
[48/50] Running N=774263, theta_crit=0.9... mean=79.710ms (took 5.4s)
[49/50] Skipping N=2782559, theta_crit=0.9
[50/50] Skipping N=10000000, theta_crit=0.9
Info: setting dtt implementation to impl : parallel_select [tree][rank=0]
Running DTT performance benchmarks for parallel_select ordered=True...
Particle counts: [100, 359, 1291, 4641, 16681, 59948, 215443, 774263, 2782559, 10000000]
Theta_crit values: [0.1, 0.3, 0.5, 0.7, 0.9]
Compression level: 4
[ 1/50] Running N= 100, theta_crit=0.1... mean=1.965ms (took 0.0s)
[ 2/50] Running N= 359, theta_crit=0.1... mean=1.976ms (took 0.0s)
[ 3/50] Running N= 1291, theta_crit=0.1... mean=2.893ms (took 0.1s)
[ 4/50] Running N= 4641, theta_crit=0.1... mean=10.032ms (took 0.1s)
[ 5/50] Running N=16681, theta_crit=0.1... mean=95.709ms (took 1.1s)
[ 6/50] Skipping N=59948, theta_crit=0.1
[ 7/50] Skipping N=215443, theta_crit=0.1
[ 8/50] Skipping N=774263, theta_crit=0.1
[ 9/50] Skipping N=2782559, theta_crit=0.1
[10/50] Skipping N=10000000, theta_crit=0.1
[11/50] Running N= 100, theta_crit=0.3... mean=1.194ms (took 0.0s)
[12/50] Running N= 359, theta_crit=0.3... mean=1.239ms (took 0.0s)
[13/50] Running N= 1291, theta_crit=0.3... mean=1.797ms (took 0.0s)
[14/50] Running N= 4641, theta_crit=0.3... mean=7.522ms (took 0.1s)
[15/50] Running N=16681, theta_crit=0.3... mean=52.401ms (took 0.6s)
[16/50] Running N=59948, theta_crit=0.3... mean=352.428ms (took 3.9s)
[17/50] Skipping N=215443, theta_crit=0.3
[18/50] Skipping N=774263, theta_crit=0.3
[19/50] Skipping N=2782559, theta_crit=0.3
[20/50] Skipping N=10000000, theta_crit=0.3
[21/50] Running N= 100, theta_crit=0.5... mean=1.205ms (took 0.0s)
[22/50] Running N= 359, theta_crit=0.5... mean=1.244ms (took 0.0s)
[23/50] Running N= 1291, theta_crit=0.5... mean=1.749ms (took 0.0s)
[24/50] Running N= 4641, theta_crit=0.5... mean=4.871ms (took 0.1s)
[25/50] Running N=16681, theta_crit=0.5... mean=21.531ms (took 0.3s)
[26/50] Running N=59948, theta_crit=0.5... mean=112.432ms (took 1.5s)
[27/50] Running N=215443, theta_crit=0.5... mean=504.910ms (took 6.3s)
[28/50] Skipping N=774263, theta_crit=0.5
[29/50] Skipping N=2782559, theta_crit=0.5
[30/50] Skipping N=10000000, theta_crit=0.5
[31/50] Running N= 100, theta_crit=0.7... mean=1.251ms (took 0.0s)
[32/50] Running N= 359, theta_crit=0.7... mean=1.248ms (took 0.0s)
[33/50] Running N= 1291, theta_crit=0.7... mean=1.574ms (took 0.0s)
[34/50] Running N= 4641, theta_crit=0.7... mean=3.335ms (took 0.1s)
[35/50] Running N=16681, theta_crit=0.7... mean=13.506ms (took 0.3s)
[36/50] Running N=59948, theta_crit=0.7... mean=65.204ms (took 1.0s)
[37/50] Running N=215443, theta_crit=0.7... mean=294.237ms (took 4.3s)
[38/50] Skipping N=774263, theta_crit=0.7
[39/50] Skipping N=2782559, theta_crit=0.7
[40/50] Skipping N=10000000, theta_crit=0.7
[41/50] Running N= 100, theta_crit=0.9... mean=1.202ms (took 0.0s)
[42/50] Running N= 359, theta_crit=0.9... mean=1.273ms (took 0.0s)
[43/50] Running N= 1291, theta_crit=0.9... mean=1.463ms (took 0.0s)
[44/50] Running N= 4641, theta_crit=0.9... mean=2.523ms (took 0.1s)
[45/50] Running N=16681, theta_crit=0.9... mean=7.721ms (took 0.2s)
[46/50] Running N=59948, theta_crit=0.9... mean=32.550ms (took 0.7s)
[47/50] Running N=215443, theta_crit=0.9... mean=133.849ms (took 2.6s)
[48/50] Running N=774263, theta_crit=0.9... mean=572.406ms (took 10.4s)
[49/50] Skipping N=2782559, theta_crit=0.9
[50/50] Skipping N=10000000, theta_crit=0.9
Info: setting dtt implementation to impl : scan_multipass [tree][rank=0]
Running DTT performance benchmarks for scan_multipass ordered=True...
Particle counts: [100, 359, 1291, 4641, 16681, 59948, 215443, 774263, 2782559, 10000000]
Theta_crit values: [0.1, 0.3, 0.5, 0.7, 0.9]
Compression level: 4
[ 1/50] Running N= 100, theta_crit=0.1... mean=5.533ms (took 0.1s)
[ 2/50] Running N= 359, theta_crit=0.1... mean=7.791ms (took 0.1s)
[ 3/50] Running N= 1291, theta_crit=0.1... mean=9.854ms (took 0.1s)
[ 4/50] Running N= 4641, theta_crit=0.1... mean=15.238ms (took 0.2s)
[ 5/50] Skipping N=16681, theta_crit=0.1
[ 6/50] Skipping N=59948, theta_crit=0.1
[ 7/50] Skipping N=215443, theta_crit=0.1
[ 8/50] Skipping N=774263, theta_crit=0.1
[ 9/50] Skipping N=2782559, theta_crit=0.1
[10/50] Skipping N=10000000, theta_crit=0.1
[11/50] Running N= 100, theta_crit=0.3... mean=5.398ms (took 0.1s)
[12/50] Running N= 359, theta_crit=0.3... mean=7.380ms (took 0.1s)
[13/50] Running N= 1291, theta_crit=0.3... mean=10.108ms (took 0.1s)
[14/50] Running N= 4641, theta_crit=0.3... mean=14.451ms (took 0.2s)
[15/50] Running N=16681, theta_crit=0.3... mean=28.242ms (took 0.4s)
[16/50] Skipping N=59948, theta_crit=0.3
[17/50] Skipping N=215443, theta_crit=0.3
[18/50] Skipping N=774263, theta_crit=0.3
[19/50] Skipping N=2782559, theta_crit=0.3
[20/50] Skipping N=10000000, theta_crit=0.3
[21/50] Running N= 100, theta_crit=0.5... mean=5.368ms (took 0.1s)
[22/50] Running N= 359, theta_crit=0.5... mean=7.870ms (took 0.1s)
[23/50] Running N= 1291, theta_crit=0.5... mean=10.234ms (took 0.1s)
[24/50] Running N= 4641, theta_crit=0.5... mean=12.917ms (took 0.2s)
[25/50] Running N=16681, theta_crit=0.5... mean=18.262ms (took 0.3s)
[26/50] Skipping N=59948, theta_crit=0.5
[27/50] Skipping N=215443, theta_crit=0.5
[28/50] Skipping N=774263, theta_crit=0.5
[29/50] Skipping N=2782559, theta_crit=0.5
[30/50] Skipping N=10000000, theta_crit=0.5
[31/50] Running N= 100, theta_crit=0.7... mean=5.521ms (took 0.1s)
[32/50] Running N= 359, theta_crit=0.7... mean=7.813ms (took 0.1s)
[33/50] Running N= 1291, theta_crit=0.7... mean=10.107ms (took 0.1s)
[34/50] Running N= 4641, theta_crit=0.7... mean=13.639ms (took 0.2s)
[35/50] Running N=16681, theta_crit=0.7... mean=16.708ms (took 0.3s)
[36/50] Running N=59948, theta_crit=0.7... mean=27.360ms (took 0.7s)
[37/50] Skipping N=215443, theta_crit=0.7
[38/50] Skipping N=774263, theta_crit=0.7
[39/50] Skipping N=2782559, theta_crit=0.7
[40/50] Skipping N=10000000, theta_crit=0.7
[41/50] Running N= 100, theta_crit=0.9... mean=5.601ms (took 0.1s)
[42/50] Running N= 359, theta_crit=0.9... mean=8.061ms (took 0.1s)
[43/50] Running N= 1291, theta_crit=0.9... mean=10.862ms (took 0.1s)
[44/50] Running N= 4641, theta_crit=0.9... mean=12.838ms (took 0.2s)
[45/50] Running N=16681, theta_crit=0.9... mean=15.327ms (took 0.3s)
[46/50] Running N=59948, theta_crit=0.9... mean=21.295ms (took 0.6s)
[47/50] Skipping N=215443, theta_crit=0.9
[48/50] Skipping N=774263, theta_crit=0.9
[49/50] Skipping N=2782559, theta_crit=0.9
[50/50] Skipping N=10000000, theta_crit=0.9
Info: setting dtt implementation to impl : reference [tree][rank=0]
Running DTT performance benchmarks for reference ordered=False...
Particle counts: [100, 359, 1291, 4641, 16681, 59948, 215443, 774263, 2782559, 10000000]
Theta_crit values: [0.1, 0.3, 0.5, 0.7, 0.9]
Compression level: 4
[ 1/50] Running N= 100, theta_crit=0.1... mean=1.428ms (took 0.0s)
[ 2/50] Running N= 359, theta_crit=0.1... mean=1.464ms (took 0.0s)
[ 3/50] Running N= 1291, theta_crit=0.1... mean=1.613ms (took 0.0s)
[ 4/50] Running N= 4641, theta_crit=0.1... mean=3.302ms (took 0.1s)
[ 5/50] Running N=16681, theta_crit=0.1... mean=23.501ms (took 0.4s)
[ 6/50] Skipping N=59948, theta_crit=0.1
[ 7/50] Skipping N=215443, theta_crit=0.1
[ 8/50] Skipping N=774263, theta_crit=0.1
[ 9/50] Skipping N=2782559, theta_crit=0.1
[10/50] Skipping N=10000000, theta_crit=0.1
[11/50] Running N= 100, theta_crit=0.3... mean=0.988ms (took 0.0s)
[12/50] Running N= 359, theta_crit=0.3... mean=1.019ms (took 0.0s)
[13/50] Running N= 1291, theta_crit=0.3... mean=1.222ms (took 0.0s)
[14/50] Running N= 4641, theta_crit=0.3... mean=2.619ms (took 0.1s)
[15/50] Running N=16681, theta_crit=0.3... mean=9.120ms (took 0.2s)
[16/50] Running N=59948, theta_crit=0.3... mean=50.796ms (took 0.9s)
[17/50] Skipping N=215443, theta_crit=0.3
[18/50] Skipping N=774263, theta_crit=0.3
[19/50] Skipping N=2782559, theta_crit=0.3
[20/50] Skipping N=10000000, theta_crit=0.3
[21/50] Running N= 100, theta_crit=0.5... mean=1.022ms (took 0.0s)
[22/50] Running N= 359, theta_crit=0.5... mean=1.052ms (took 0.0s)
[23/50] Running N= 1291, theta_crit=0.5... mean=1.179ms (took 0.0s)
[24/50] Running N= 4641, theta_crit=0.5... mean=1.844ms (took 0.1s)
[25/50] Running N=16681, theta_crit=0.5... mean=3.911ms (took 0.2s)
[26/50] Running N=59948, theta_crit=0.5... mean=15.654ms (took 0.5s)
[27/50] Running N=215443, theta_crit=0.5... mean=47.544ms (took 1.8s)
[28/50] Skipping N=774263, theta_crit=0.5
[29/50] Skipping N=2782559, theta_crit=0.5
[30/50] Skipping N=10000000, theta_crit=0.5
[31/50] Running N= 100, theta_crit=0.7... mean=1.026ms (took 0.0s)
[32/50] Running N= 359, theta_crit=0.7... mean=1.115ms (took 0.0s)
[33/50] Running N= 1291, theta_crit=0.7... mean=1.132ms (took 0.0s)
[34/50] Running N= 4641, theta_crit=0.7... mean=1.476ms (took 0.1s)
[35/50] Running N=16681, theta_crit=0.7... mean=2.794ms (took 0.1s)
[36/50] Running N=59948, theta_crit=0.7... mean=8.942ms (took 0.4s)
[37/50] Running N=215443, theta_crit=0.7... mean=26.039ms (took 1.6s)
[38/50] Running N=774263, theta_crit=0.7... mean=103.025ms (took 5.5s)
[39/50] Skipping N=2782559, theta_crit=0.7
[40/50] Skipping N=10000000, theta_crit=0.7
[41/50] Running N= 100, theta_crit=0.9... mean=1.007ms (took 0.0s)
[42/50] Running N= 359, theta_crit=0.9... mean=1.056ms (took 0.0s)
[43/50] Running N= 1291, theta_crit=0.9... mean=1.084ms (took 0.0s)
[44/50] Running N= 4641, theta_crit=0.9... mean=1.387ms (took 0.1s)
[45/50] Running N=16681, theta_crit=0.9... mean=2.089ms (took 0.1s)
[46/50] Running N=59948, theta_crit=0.9... mean=6.011ms (took 0.4s)
[47/50] Running N=215443, theta_crit=0.9... mean=17.762ms (took 1.5s)
[48/50] Running N=774263, theta_crit=0.9... mean=64.351ms (took 5.3s)
[49/50] Skipping N=2782559, theta_crit=0.9
[50/50] Skipping N=10000000, theta_crit=0.9
Info: setting dtt implementation to impl : parallel_select [tree][rank=0]
Running DTT performance benchmarks for parallel_select ordered=False...
Particle counts: [100, 359, 1291, 4641, 16681, 59948, 215443, 774263, 2782559, 10000000]
Theta_crit values: [0.1, 0.3, 0.5, 0.7, 0.9]
Compression level: 4
[ 1/50] Running N= 100, theta_crit=0.1... mean=2.251ms (took 0.0s)
[ 2/50] Running N= 359, theta_crit=0.1... mean=1.474ms (took 0.0s)
[ 3/50] Running N= 1291, theta_crit=0.1... mean=1.795ms (took 0.0s)
[ 4/50] Running N= 4641, theta_crit=0.1... mean=8.580ms (took 0.1s)
[ 5/50] Running N=16681, theta_crit=0.1... mean=95.642ms (took 1.1s)
[ 6/50] Skipping N=59948, theta_crit=0.1
[ 7/50] Skipping N=215443, theta_crit=0.1
[ 8/50] Skipping N=774263, theta_crit=0.1
[ 9/50] Skipping N=2782559, theta_crit=0.1
[10/50] Skipping N=10000000, theta_crit=0.1
[11/50] Running N= 100, theta_crit=0.3... mean=1.198ms (took 0.0s)
[12/50] Running N= 359, theta_crit=0.3... mean=1.242ms (took 0.0s)
[13/50] Running N= 1291, theta_crit=0.3... mean=1.801ms (took 0.0s)
[14/50] Running N= 4641, theta_crit=0.3... mean=7.569ms (took 0.1s)
[15/50] Running N=16681, theta_crit=0.3... mean=52.350ms (took 0.6s)
[16/50] Running N=59948, theta_crit=0.3... mean=352.025ms (took 3.9s)
[17/50] Skipping N=215443, theta_crit=0.3
[18/50] Skipping N=774263, theta_crit=0.3
[19/50] Skipping N=2782559, theta_crit=0.3
[20/50] Skipping N=10000000, theta_crit=0.3
[21/50] Running N= 100, theta_crit=0.5... mean=1.185ms (took 0.0s)
[22/50] Running N= 359, theta_crit=0.5... mean=1.272ms (took 0.0s)
[23/50] Running N= 1291, theta_crit=0.5... mean=1.745ms (took 0.0s)
[24/50] Running N= 4641, theta_crit=0.5... mean=4.503ms (took 0.1s)
[25/50] Running N=16681, theta_crit=0.5... mean=21.299ms (took 0.3s)
[26/50] Running N=59948, theta_crit=0.5... mean=111.895ms (took 1.5s)
[27/50] Running N=215443, theta_crit=0.5... mean=500.498ms (took 6.3s)
[28/50] Skipping N=774263, theta_crit=0.5
[29/50] Skipping N=2782559, theta_crit=0.5
[30/50] Skipping N=10000000, theta_crit=0.5
[31/50] Running N= 100, theta_crit=0.7... mean=1.206ms (took 0.0s)
[32/50] Running N= 359, theta_crit=0.7... mean=1.281ms (took 0.0s)
[33/50] Running N= 1291, theta_crit=0.7... mean=1.577ms (took 0.0s)
[34/50] Running N= 4641, theta_crit=0.7... mean=3.229ms (took 0.1s)
[35/50] Running N=16681, theta_crit=0.7... mean=13.024ms (took 0.3s)
[36/50] Running N=59948, theta_crit=0.7... mean=63.012ms (took 1.0s)
[37/50] Running N=215443, theta_crit=0.7... mean=291.951ms (took 4.2s)
[38/50] Skipping N=774263, theta_crit=0.7
[39/50] Skipping N=2782559, theta_crit=0.7
[40/50] Skipping N=10000000, theta_crit=0.7
[41/50] Running N= 100, theta_crit=0.9... mean=1.216ms (took 0.0s)
[42/50] Running N= 359, theta_crit=0.9... mean=1.214ms (took 0.0s)
[43/50] Running N= 1291, theta_crit=0.9... mean=1.440ms (took 0.0s)
[44/50] Running N= 4641, theta_crit=0.9... mean=2.486ms (took 0.1s)
[45/50] Running N=16681, theta_crit=0.9... mean=7.447ms (took 0.2s)
[46/50] Running N=59948, theta_crit=0.9... mean=31.383ms (took 0.7s)
[47/50] Running N=215443, theta_crit=0.9... mean=131.064ms (took 2.6s)
[48/50] Running N=774263, theta_crit=0.9... mean=563.296ms (took 10.4s)
[49/50] Skipping N=2782559, theta_crit=0.9
[50/50] Skipping N=10000000, theta_crit=0.9
Info: setting dtt implementation to impl : scan_multipass [tree][rank=0]
Running DTT performance benchmarks for scan_multipass ordered=False...
Particle counts: [100, 359, 1291, 4641, 16681, 59948, 215443, 774263, 2782559, 10000000]
Theta_crit values: [0.1, 0.3, 0.5, 0.7, 0.9]
Compression level: 4
[ 1/50] Running N= 100, theta_crit=0.1... mean=4.279ms (took 0.1s)
[ 2/50] Running N= 359, theta_crit=0.1... mean=6.283ms (took 0.1s)
[ 3/50] Running N= 1291, theta_crit=0.1... mean=8.118ms (took 0.1s)
[ 4/50] Running N= 4641, theta_crit=0.1... mean=10.494ms (took 0.2s)
[ 5/50] Skipping N=16681, theta_crit=0.1
[ 6/50] Skipping N=59948, theta_crit=0.1
[ 7/50] Skipping N=215443, theta_crit=0.1
[ 8/50] Skipping N=774263, theta_crit=0.1
[ 9/50] Skipping N=2782559, theta_crit=0.1
[10/50] Skipping N=10000000, theta_crit=0.1
[11/50] Running N= 100, theta_crit=0.3... mean=4.197ms (took 0.1s)
[12/50] Running N= 359, theta_crit=0.3... mean=6.031ms (took 0.1s)
[13/50] Running N= 1291, theta_crit=0.3... mean=8.574ms (took 0.1s)
[14/50] Running N= 4641, theta_crit=0.3... mean=11.482ms (took 0.2s)
[15/50] Running N=16681, theta_crit=0.3... mean=17.567ms (took 0.3s)
[16/50] Skipping N=59948, theta_crit=0.3
[17/50] Skipping N=215443, theta_crit=0.3
[18/50] Skipping N=774263, theta_crit=0.3
[19/50] Skipping N=2782559, theta_crit=0.3
[20/50] Skipping N=10000000, theta_crit=0.3
[21/50] Running N= 100, theta_crit=0.5... mean=4.247ms (took 0.1s)
[22/50] Running N= 359, theta_crit=0.5... mean=6.192ms (took 0.1s)
[23/50] Running N= 1291, theta_crit=0.5... mean=8.406ms (took 0.1s)
[24/50] Running N= 4641, theta_crit=0.5... mean=9.943ms (took 0.1s)
[25/50] Running N=16681, theta_crit=0.5... mean=14.389ms (took 0.3s)
[26/50] Skipping N=59948, theta_crit=0.5
[27/50] Skipping N=215443, theta_crit=0.5
[28/50] Skipping N=774263, theta_crit=0.5
[29/50] Skipping N=2782559, theta_crit=0.5
[30/50] Skipping N=10000000, theta_crit=0.5
[31/50] Running N= 100, theta_crit=0.7... mean=4.424ms (took 0.1s)
[32/50] Running N= 359, theta_crit=0.7... mean=6.017ms (took 0.1s)
[33/50] Running N= 1291, theta_crit=0.7... mean=8.517ms (took 0.1s)
[34/50] Running N= 4641, theta_crit=0.7... mean=10.499ms (took 0.2s)
[35/50] Running N=16681, theta_crit=0.7... mean=13.337ms (took 0.3s)
[36/50] Running N=59948, theta_crit=0.7... mean=19.690ms (took 0.5s)
[37/50] Skipping N=215443, theta_crit=0.7
[38/50] Skipping N=774263, theta_crit=0.7
[39/50] Skipping N=2782559, theta_crit=0.7
[40/50] Skipping N=10000000, theta_crit=0.7
[41/50] Running N= 100, theta_crit=0.9... mean=4.279ms (took 0.1s)
[42/50] Running N= 359, theta_crit=0.9... mean=6.160ms (took 0.1s)
[43/50] Running N= 1291, theta_crit=0.9... mean=7.865ms (took 0.1s)
[44/50] Running N= 4641, theta_crit=0.9... mean=9.669ms (took 0.1s)
[45/50] Running N=16681, theta_crit=0.9... mean=12.887ms (took 0.3s)
[46/50] Running N=59948, theta_crit=0.9... mean=18.201ms (took 0.5s)
[47/50] Skipping N=215443, theta_crit=0.9
[48/50] Skipping N=774263, theta_crit=0.9
[49/50] Skipping N=2782559, theta_crit=0.9
[50/50] Skipping N=10000000, theta_crit=0.9
Plot the performance benchmarks for all implementations
282 dump_folder = "_to_trash"
283
284 import os
285
286 # Create the dump directory if it does not exist
287 if shamrock.sys.world_rank() == 0:
288 os.makedirs(dump_folder, exist_ok=True)
289
290 ref_key = "reference ordered=False"
291 largest_refalg_value = np.nanmax(results[ref_key]["results_min"])
292
293 i = 0
294 # iterate over the results
295 for k, v in results.items():
296 # Get the results for this algorithm
297 particle_counts = v["particle_counts"]
298 theta_crits = v["theta_crits"]
299 results_min = v["results_min"]
300 results_max_mem_delta = v["results_max_mem_delta"]
301
302 # Get reference algorithm results for comparison
303 reference_min = results[ref_key]["results_min"]
304
305 # Create and display the plot
306 fig, ax = create_checkerboard_plot(
307 particle_counts,
308 theta_crits,
309 results_min,
310 compression_level,
311 v["name"],
312 largest_refalg_value,
313 reference_min,
314 results_max_mem_delta,
315 )
316
317 plt.savefig(f"{dump_folder}/benchmark-dtt-performance-{i}.pdf")
318 i += 1
319
320 plt.show()
Total running time of the script: (1 minutes 57.772 seconds)
Estimated memory usage: 260 MB





