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.colors as colors
13 import matplotlib.pyplot as plt
14 import numpy as np
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")
Main benchmark functions
28 bounding_box = shamrock.math.AABB_f64_3((0.0, 0.0, 0.0), (1.0, 1.0, 1.0))
29
30
31 def benchmark_dtt_core(N, theta_crit, compression_level, ordered_result, nb_repeat=10):
32 times = []
33 random.seed(111)
34 max_mem_delta = 0
35 for i in range(nb_repeat):
36 positions = shamrock.algs.mock_buffer_f64_3(
37 random.randint(0, 1000000), N, bounding_box.lower, bounding_box.upper
38 )
39 tree = shamrock.tree.CLBVH_u64_f64_3()
40 tree.rebuild_from_positions(positions, bounding_box, compression_level)
41 shamrock.backends.reset_mem_info_max()
42 mem_info_before = shamrock.backends.get_mem_perf_info()
43 times.append(
44 shamrock.tree.benchmark_clbvh_dual_tree_traversal(tree, theta_crit, ordered_result)
45 * 1000
46 )
47 mem_info_after = shamrock.backends.get_mem_perf_info()
48
49 mem_delta = (
50 mem_info_after.max_allocated_byte_device - mem_info_before.max_allocated_byte_device
51 )
52 max_mem_delta = max(max_mem_delta, mem_delta)
53 return times, max_mem_delta
54
55
56 def benchmark_dtt(N, theta_crit, compression_level, ordered_result, nb_repeat=10):
57 times, max_mem_delta = benchmark_dtt_core(
58 N, theta_crit, compression_level, ordered_result, nb_repeat
59 )
60 return min(times), max(times), sum(times) / nb_repeat, max_mem_delta
Run the performance test for all parameters
65 def run_performance_sweep(compression_level, threshold_run, ordered_result):
66
67 # Define parameter ranges
68 # logspace as array
69 particle_counts = np.logspace(2, 7, 10).astype(int).tolist()
70 theta_crits = [0.1, 0.3, 0.5, 0.7, 0.9]
71
72 # Initialize results matrix
73 results_mean = np.zeros((len(theta_crits), len(particle_counts)))
74 results_min = np.zeros((len(theta_crits), len(particle_counts)))
75 results_max = np.zeros((len(theta_crits), len(particle_counts)))
76 results_max_mem_delta = np.zeros((len(theta_crits), len(particle_counts)))
77
78 print(f"Particle counts: {particle_counts}")
79 print(f"Theta_crit values: {theta_crits}")
80 print(f"Compression level: {compression_level}")
81
82 total_runs = len(particle_counts) * len(theta_crits)
83 current_run = 0
84
85 for i, theta_crit in enumerate(theta_crits):
86 exceed_mem = False
87 for j, N in enumerate(particle_counts):
88 current_run += 1
89
90 if exceed_mem:
91 print(
92 f"[{current_run:2d}/{total_runs}] Skipping N={N:5d}, theta_crit={theta_crit:.1f}"
93 )
94 results_mean[i, j] = np.nan
95 results_min[i, j] = np.nan
96 results_max[i, j] = np.nan
97 continue
98
99 print(
100 f"[{current_run:2d}/{total_runs}] Running N={N:5d}, theta_crit={theta_crit:.1f}...",
101 end=" ",
102 )
103
104 start_time = time.time()
105 min_time, max_time, mean_time, max_mem_delta = benchmark_dtt(
106 N, theta_crit, compression_level, ordered_result
107 )
108 elapsed = time.time() - start_time
109
110 results_mean[i, j] = mean_time
111 results_min[i, j] = min_time
112 results_max[i, j] = max_time
113 results_max_mem_delta[i, j] = max_mem_delta
114
115 print(f"mean={mean_time:.3f}ms (took {elapsed:.1f}s)")
116
117 if max_mem_delta > threshold_run:
118 exceed_mem = True
119
120 return (
121 particle_counts,
122 theta_crits,
123 results_mean,
124 results_min,
125 results_max,
126 results_max_mem_delta,
127 )
Create checkerboard plot with execution times and relative performance to reference algorithm
132 def create_checkerboard_plot(
133 particle_counts,
134 theta_crits,
135 results_data,
136 compression_level,
137 algname,
138 max_axis_value,
139 reference_data,
140 results_max_mem_delta,
141 ):
142 """Create checkerboard plot with execution times"""
143
144 fig, ax = plt.subplots(figsize=(12, 8))
145
146 # Calculate relative performance compared to reference algorithm
147 # results_data / reference_data gives the ratio (>1 means slower, <1 means faster)
148 relative_performance = results_data / reference_data
149
150 # Create the heatmap with relative performance values
151 # Create a masked array to handle NaN values (skipped benchmarks) as white
152 masked_relative = np.ma.masked_invalid(relative_performance)
153
154 # Use a diverging colormap: red for better performance (<1), green for worse (>1)
155 # RdYlGn_r (reversed) has green for high values (worse) and red for low values (better)
156 cmap = plt.cm.RdYlGn_r.copy() # Green for >1 (slower), Red for <1 (faster)
157 cmap.set_bad(color="white") # Set NaN values to white
158
159 # Set the color scale limits for relative performance
160 vmin = 0.5
161 vmax = 1.5
162
163 im = ax.imshow(
164 masked_relative, cmap=cmap, aspect="auto", interpolation="nearest", vmin=vmin, vmax=vmax
165 )
166
167 # Set ticks and labels
168 ax.set_xticks(range(len(particle_counts)))
169 ax.set_yticks(range(len(theta_crits)))
170 ax.set_xticklabels([f"{N//1000}k" if N >= 1000 else str(N) for N in particle_counts])
171 ax.set_yticklabels([f"{theta:.1f}" for theta in theta_crits])
172
173 # Add labels
174 ax.set_xlabel("Particle Count")
175 ax.set_ylabel("Theta Critical")
176 ax.set_title(
177 f"Dual Tree Traversal Performance\n(Colors: Relative to Reference, Text: Absolute Time in ms)\ncompression level = {compression_level} algorithm = {algname}",
178 pad=20,
179 )
180
181 # Add text annotations showing the values
182 for i in range(len(theta_crits)):
183 for j in range(len(particle_counts)):
184 value = results_data[i, j]
185
186 if np.isnan(value):
187 # For skipped benchmarks, show "SKIPPED" in black on white background
188 # ax.text(j, i, 'SKIPPED', ha='center', va='center',
189 # color='black', fontweight='bold', fontsize=8)
190 pass
191 else:
192 perf = relative_performance[i, j]
193 mem_delta = results_max_mem_delta[i, j] / 1e6
194 text_color = "black"
195 ax.text(
196 j,
197 i,
198 f"{value:.2f}ms\n{perf:.2f}\n{mem_delta:.2f}MB",
199 ha="center",
200 va="center",
201 color=text_color,
202 fontweight="bold",
203 fontsize=10,
204 )
205
206 # Add colorbar for relative performance
207 cbar = plt.colorbar(im, ax=ax, shrink=0.8)
208 cbar.set_label("Relative performance (time / reference time)")
209 cbar.ax.tick_params(labelsize=10)
210
211 # Add custom tick labels for better interpretation
212 tick_positions = [0.1, 0.2, 0.5, 1.0, 2.0, 3.0]
213 cbar.set_ticks([pos for pos in tick_positions if vmin <= pos <= vmax])
214
215 # Improve layout
216 plt.tight_layout()
217
218 # Add grid for better readability
219 ax.set_xticks(np.arange(len(particle_counts)) - 0.5, minor=True)
220 ax.set_yticks(np.arange(len(theta_crits)) - 0.5, minor=True)
221 ax.grid(which="minor", color="black", linestyle="-", linewidth=1, alpha=0.3)
222
223 return fig, ax
List current implementation
228 current_impl = shamrock.tree.get_current_impl_clbvh_dual_tree_traversal_impl()
229
230 print(current_impl)
impl_param(impl_name="scan_multipass", params="")
List all implementations available
234 all_default_impls = shamrock.tree.get_default_impl_list_clbvh_dual_tree_traversal()
235
236 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
240 results = {}
241
242
243 for ordered_result in [True, False]:
244 for default_impl in all_default_impls:
245 shamrock.tree.set_impl_clbvh_dual_tree_traversal(
246 default_impl.impl_name, default_impl.params
247 )
248
249 n = default_impl.impl_name + " " + default_impl.params + "ordered=" + str(ordered_result)
250
251 print(f"Running DTT performance benchmarks for {n}...")
252
253 compression_level = 4
254
255 threshold_run = 5e6
256 # Run the performance sweep
257 (
258 particle_counts,
259 theta_crits,
260 results_mean,
261 results_min,
262 results_max,
263 results_max_mem_delta,
264 ) = run_performance_sweep(compression_level, threshold_run, ordered_result)
265
266 results[n] = {
267 "particle_counts": particle_counts,
268 "theta_crits": theta_crits,
269 "results_mean": results_mean,
270 "results_min": results_min,
271 "results_max": results_max,
272 "results_max_mem_delta": results_max_mem_delta,
273 "name": n,
274 }
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.287ms (took 0.0s)
[ 2/50] Running N= 359, theta_crit=0.1... mean=2.277ms (took 0.0s)
[ 3/50] Running N= 1291, theta_crit=0.1... mean=2.680ms (took 0.1s)
[ 4/50] Running N= 4641, theta_crit=0.1... mean=7.827ms (took 0.2s)
[ 5/50] Running N=16681, theta_crit=0.1... mean=74.332ms (took 1.0s)
[ 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.615ms (took 0.1s)
[12/50] Running N= 359, theta_crit=0.3... mean=2.252ms (took 0.0s)
[13/50] Running N= 1291, theta_crit=0.3... mean=2.626ms (took 0.1s)
[14/50] Running N= 4641, theta_crit=0.3... mean=7.565ms (took 0.2s)
[15/50] Running N=16681, theta_crit=0.3... mean=58.487ms (took 0.8s)
[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=2.178ms (took 0.0s)
[22/50] Running N= 359, theta_crit=0.5... mean=3.159ms (took 0.1s)
[23/50] Running N= 1291, theta_crit=0.5... mean=3.907ms (took 0.1s)
[24/50] Running N= 4641, theta_crit=0.5... mean=7.750ms (took 0.2s)
[25/50] Running N=16681, theta_crit=0.5... mean=39.260ms (took 0.6s)
[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=2.983ms (took 0.1s)
[32/50] Running N= 359, theta_crit=0.7... mean=3.112ms (took 0.1s)
[33/50] Running N= 1291, theta_crit=0.7... mean=2.794ms (took 0.1s)
[34/50] Running N= 4641, theta_crit=0.7... mean=6.317ms (took 0.1s)
[35/50] Running N=16681, theta_crit=0.7... mean=16.164ms (took 0.4s)
[36/50] Running N=59948, theta_crit=0.7... mean=73.924ms (took 1.3s)
[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=1.850ms (took 0.0s)
[42/50] Running N= 359, theta_crit=0.9... mean=2.226ms (took 0.0s)
[43/50] Running N= 1291, theta_crit=0.9... mean=2.429ms (took 0.1s)
[44/50] Running N= 4641, theta_crit=0.9... mean=3.581ms (took 0.1s)
[45/50] Running N=16681, theta_crit=0.9... mean=8.492ms (took 0.2s)
[46/50] Running N=59948, theta_crit=0.9... mean=38.277ms (took 0.9s)
[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 : 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=2.041ms (took 0.0s)
[ 2/50] Running N= 359, theta_crit=0.1... mean=2.089ms (took 0.0s)
[ 3/50] Running N= 1291, theta_crit=0.1... mean=3.102ms (took 0.1s)
[ 4/50] Running N= 4641, theta_crit=0.1... mean=10.638ms (took 0.2s)
[ 5/50] Running N=16681, theta_crit=0.1... mean=91.366ms (took 1.0s)
[ 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.146ms (took 0.0s)
[12/50] Running N= 359, theta_crit=0.3... mean=1.177ms (took 0.0s)
[13/50] Running N= 1291, theta_crit=0.3... mean=1.699ms (took 0.0s)
[14/50] Running N= 4641, theta_crit=0.3... mean=8.336ms (took 0.1s)
[15/50] Running N=16681, theta_crit=0.3... mean=92.717ms (took 1.0s)
[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=1.107ms (took 0.0s)
[22/50] Running N= 359, theta_crit=0.5... mean=1.173ms (took 0.0s)
[23/50] Running N= 1291, theta_crit=0.5... mean=1.706ms (took 0.0s)
[24/50] Running N= 4641, theta_crit=0.5... mean=8.583ms (took 0.1s)
[25/50] Running N=16681, theta_crit=0.5... mean=67.601ms (took 0.8s)
[26/50] Running N=59948, theta_crit=0.5... mean=502.605ms (took 5.4s)
[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=1.134ms (took 0.0s)
[32/50] Running N= 359, theta_crit=0.7... mean=1.159ms (took 0.0s)
[33/50] Running N= 1291, theta_crit=0.7... mean=1.803ms (took 0.0s)
[34/50] Running N= 4641, theta_crit=0.7... mean=7.259ms (took 0.1s)
[35/50] Running N=16681, theta_crit=0.7... mean=44.093ms (took 0.6s)
[36/50] Running N=59948, theta_crit=0.7... mean=272.417ms (took 3.1s)
[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=1.136ms (took 0.0s)
[42/50] Running N= 359, theta_crit=0.9... mean=1.200ms (took 0.0s)
[43/50] Running N= 1291, theta_crit=0.9... mean=1.751ms (took 0.0s)
[44/50] Running N= 4641, theta_crit=0.9... mean=7.027ms (took 0.1s)
[45/50] Running N=16681, theta_crit=0.9... mean=30.733ms (took 0.4s)
[46/50] Running N=59948, theta_crit=0.9... mean=166.739ms (took 2.0s)
[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 : 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=7.124ms (took 0.1s)
[ 2/50] Running N= 359, theta_crit=0.1... mean=10.584ms (took 0.1s)
[ 3/50] Running N= 1291, theta_crit=0.1... mean=13.948ms (took 0.2s)
[ 4/50] Running N= 4641, theta_crit=0.1... mean=20.790ms (took 0.3s)
[ 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=8.662ms (took 0.1s)
[12/50] Running N= 359, theta_crit=0.3... mean=11.787ms (took 0.1s)
[13/50] Running N= 1291, theta_crit=0.3... mean=13.737ms (took 0.2s)
[14/50] Running N= 4641, theta_crit=0.3... mean=17.903ms (took 0.3s)
[15/50] Skipping N=16681, theta_crit=0.3
[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=6.420ms (took 0.1s)
[22/50] Running N= 359, theta_crit=0.5... mean=8.800ms (took 0.1s)
[23/50] Running N= 1291, theta_crit=0.5... mean=12.065ms (took 0.2s)
[24/50] Running N= 4641, theta_crit=0.5... mean=17.254ms (took 0.3s)
[25/50] Skipping N=16681, theta_crit=0.5
[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=6.397ms (took 0.1s)
[32/50] Running N= 359, theta_crit=0.7... mean=9.044ms (took 0.1s)
[33/50] Running N= 1291, theta_crit=0.7... mean=11.904ms (took 0.2s)
[34/50] Running N= 4641, theta_crit=0.7... mean=15.936ms (took 0.2s)
[35/50] Running N=16681, theta_crit=0.7... mean=30.276ms (took 0.5s)
[36/50] Skipping N=59948, theta_crit=0.7
[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=6.371ms (took 0.1s)
[42/50] Running N= 359, theta_crit=0.9... mean=9.724ms (took 0.1s)
[43/50] Running N= 1291, theta_crit=0.9... mean=12.196ms (took 0.2s)
[44/50] Running N= 4641, theta_crit=0.9... mean=15.235ms (took 0.2s)
[45/50] Running N=16681, theta_crit=0.9... mean=32.770ms (took 0.6s)
[46/50] Skipping N=59948, theta_crit=0.9
[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.711ms (took 0.0s)
[ 2/50] Running N= 359, theta_crit=0.1... mean=1.728ms (took 0.0s)
[ 3/50] Running N= 1291, theta_crit=0.1... mean=1.988ms (took 0.1s)
[ 4/50] Running N= 4641, theta_crit=0.1... mean=3.536ms (took 0.1s)
[ 5/50] Running N=16681, theta_crit=0.1... mean=19.867ms (took 0.3s)
[ 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.104ms (took 0.0s)
[12/50] Running N= 359, theta_crit=0.3... mean=1.018ms (took 0.0s)
[13/50] Running N= 1291, theta_crit=0.3... mean=1.099ms (took 0.0s)
[14/50] Running N= 4641, theta_crit=0.3... mean=2.734ms (took 0.1s)
[15/50] Running N=16681, theta_crit=0.3... mean=19.843ms (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=1.108ms (took 0.0s)
[22/50] Running N= 359, theta_crit=0.5... mean=1.049ms (took 0.0s)
[23/50] Running N= 1291, theta_crit=0.5... mean=1.153ms (took 0.0s)
[24/50] Running N= 4641, theta_crit=0.5... mean=2.560ms (took 0.1s)
[25/50] Running N=16681, theta_crit=0.5... mean=11.820ms (took 0.2s)
[26/50] Running N=59948, theta_crit=0.5... mean=68.770ms (took 1.0s)
[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=1.033ms (took 0.0s)
[32/50] Running N= 359, theta_crit=0.7... mean=0.982ms (took 0.0s)
[33/50] Running N= 1291, theta_crit=0.7... mean=1.120ms (took 0.0s)
[34/50] Running N= 4641, theta_crit=0.7... mean=2.156ms (took 0.1s)
[35/50] Running N=16681, theta_crit=0.7... mean=7.123ms (took 0.2s)
[36/50] Running N=59948, theta_crit=0.7... mean=32.247ms (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=1.066ms (took 0.0s)
[42/50] Running N= 359, theta_crit=0.9... mean=1.018ms (took 0.0s)
[43/50] Running N= 1291, theta_crit=0.9... mean=1.180ms (took 0.0s)
[44/50] Running N= 4641, theta_crit=0.9... mean=1.837ms (took 0.1s)
[45/50] Running N=16681, theta_crit=0.9... mean=4.853ms (took 0.2s)
[46/50] Running N=59948, theta_crit=0.9... mean=19.249ms (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
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=1.252ms (took 0.0s)
[ 2/50] Running N= 359, theta_crit=0.1... mean=1.170ms (took 0.0s)
[ 3/50] Running N= 1291, theta_crit=0.1... mean=1.697ms (took 0.0s)
[ 4/50] Running N= 4641, theta_crit=0.1... mean=8.417ms (took 0.1s)
[ 5/50] Running N=16681, theta_crit=0.1... mean=93.847ms (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.152ms (took 0.0s)
[12/50] Running N= 359, theta_crit=0.3... mean=1.179ms (took 0.0s)
[13/50] Running N= 1291, theta_crit=0.3... mean=1.722ms (took 0.0s)
[14/50] Running N= 4641, theta_crit=0.3... mean=8.577ms (took 0.1s)
[15/50] Running N=16681, theta_crit=0.3... mean=93.968ms (took 1.1s)
[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=1.149ms (took 0.0s)
[22/50] Running N= 359, theta_crit=0.5... mean=1.158ms (took 0.0s)
[23/50] Running N= 1291, theta_crit=0.5... mean=1.762ms (took 0.0s)
[24/50] Running N= 4641, theta_crit=0.5... mean=8.681ms (took 0.1s)
[25/50] Running N=16681, theta_crit=0.5... mean=68.701ms (took 0.8s)
[26/50] Running N=59948, theta_crit=0.5... mean=507.418ms (took 5.4s)
[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=1.143ms (took 0.0s)
[32/50] Running N= 359, theta_crit=0.7... mean=1.221ms (took 0.0s)
[33/50] Running N= 1291, theta_crit=0.7... mean=1.719ms (took 0.0s)
[34/50] Running N= 4641, theta_crit=0.7... mean=7.452ms (took 0.1s)
[35/50] Running N=16681, theta_crit=0.7... mean=44.685ms (took 0.6s)
[36/50] Running N=59948, theta_crit=0.7... mean=274.371ms (took 3.1s)
[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=1.157ms (took 0.0s)
[42/50] Running N= 359, theta_crit=0.9... mean=1.191ms (took 0.0s)
[43/50] Running N= 1291, theta_crit=0.9... mean=1.849ms (took 0.0s)
[44/50] Running N= 4641, theta_crit=0.9... mean=5.762ms (took 0.1s)
[45/50] Running N=16681, theta_crit=0.9... mean=30.905ms (took 0.4s)
[46/50] Running N=59948, theta_crit=0.9... mean=167.306ms (took 2.0s)
[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 : 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.303ms (took 0.1s)
[ 2/50] Running N= 359, theta_crit=0.1... mean=5.759ms (took 0.1s)
[ 3/50] Running N= 1291, theta_crit=0.1... mean=7.517ms (took 0.1s)
[ 4/50] Running N= 4641, theta_crit=0.1... mean=10.549ms (took 0.1s)
[ 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.033ms (took 0.1s)
[12/50] Running N= 359, theta_crit=0.3... mean=5.743ms (took 0.1s)
[13/50] Running N= 1291, theta_crit=0.3... mean=7.787ms (took 0.1s)
[14/50] Running N= 4641, theta_crit=0.3... mean=10.609ms (took 0.2s)
[15/50] Skipping N=16681, theta_crit=0.3
[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=3.872ms (took 0.1s)
[22/50] Running N= 359, theta_crit=0.5... mean=5.578ms (took 0.1s)
[23/50] Running N= 1291, theta_crit=0.5... mean=7.496ms (took 0.1s)
[24/50] Running N= 4641, theta_crit=0.5... mean=10.531ms (took 0.1s)
[25/50] Skipping N=16681, theta_crit=0.5
[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.028ms (took 0.1s)
[32/50] Running N= 359, theta_crit=0.7... mean=5.613ms (took 0.1s)
[33/50] Running N= 1291, theta_crit=0.7... mean=7.597ms (took 0.1s)
[34/50] Running N= 4641, theta_crit=0.7... mean=10.203ms (took 0.1s)
[35/50] Running N=16681, theta_crit=0.7... mean=15.453ms (took 0.3s)
[36/50] Skipping N=59948, theta_crit=0.7
[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=3.846ms (took 0.1s)
[42/50] Running N= 359, theta_crit=0.9... mean=5.625ms (took 0.1s)
[43/50] Running N= 1291, theta_crit=0.9... mean=7.557ms (took 0.1s)
[44/50] Running N= 4641, theta_crit=0.9... mean=10.276ms (took 0.1s)
[45/50] Running N=16681, theta_crit=0.9... mean=13.754ms (took 0.3s)
[46/50] Skipping N=59948, theta_crit=0.9
[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
278 dump_folder = "_to_trash"
279
280 import os
281
282 # Create the dump directory if it does not exist
283 if shamrock.sys.world_rank() == 0:
284 os.makedirs(dump_folder, exist_ok=True)
285
286 ref_key = "reference ordered=False"
287 largest_refalg_value = np.nanmax(results[ref_key]["results_min"])
288
289 i = 0
290 # iterate over the results
291 for k, v in results.items():
292
293 # Get the results for this algorithm
294 particle_counts = v["particle_counts"]
295 theta_crits = v["theta_crits"]
296 results_min = v["results_min"]
297 results_max_mem_delta = v["results_max_mem_delta"]
298
299 # Get reference algorithm results for comparison
300 reference_min = results[ref_key]["results_min"]
301
302 # Create and display the plot
303 fig, ax = create_checkerboard_plot(
304 particle_counts,
305 theta_crits,
306 results_min,
307 compression_level,
308 v["name"],
309 largest_refalg_value,
310 reference_min,
311 results_max_mem_delta,
312 )
313
314 plt.savefig(f"{dump_folder}/benchmark-dtt-performance-{i}.pdf")
315 i += 1
316
317 plt.show()
Total running time of the script: (0 minutes 52.370 seconds)
Estimated memory usage: 120 MB





