@@ -5,24 +5,36 @@ using BenchmarkTools
55include (" ../test/point_cloud.jl" )
66
77"""
8- plot_benchmarks(benchmark, n_points_per_dimension, iterations;
9- seed = 1, perturbation_factor_position = 1.0,
10- parallel = true, title = "")
8+ run_benchmarks(benchmark, n_points_per_dimension, iterations, neighborhood_searches;
9+ parallelization_backend = PolyesterBackend(),
10+ names = ["NeighborhoodSearch 1" "NeighborhoodSearch 2" ...],
11+ seed = 1, perturbation_factor_position = 1.0)
1112
1213Run a benchmark with several neighborhood searches multiple times for increasing numbers
13- of points and plot the results.
14+ of points and return the results as `(n_particles_vec, times)`, where `n_particles_vec`
15+ is a vector containing the number of particles for each iteration and `times` is a matrix
16+ containing the runtimes for each neighborhood search and iteration.
17+
18+ See also
19+ - [`plot_benchmark`](@ref) to plot the results,
20+ - [`run_benchmark_default`](@ref) to run the benchmark with the most commonly used
21+ neighborhood search implementations,
22+ - [`run_benchmark_gpu`](@ref) to run the benchmark with all GPU-compatible neighborhood
23+ search implementations.
1424
1525# Arguments
16- - `benchmark`: The benchmark function. See [`benchmark_count_neighbors`](@ref)
17- and [`benchmark_n_body`](@ref).
26+ - `benchmark`: The benchmark function. See [`benchmark_count_neighbors`](@ref),
27+ [`benchmark_n_body`](@ref), [`benchmark_wcsph`](@ref),
28+ [`benchmark_wcsph_fp32`](@ref) and [`benchmark_tlsph`](@ref).
1829- `n_points_per_dimension`: Initial resolution as tuple. The product is the initial number
1930 of points. For example, use `(100, 100)` for a 2D benchmark or
2031 `(10, 10, 10)` for a 3D benchmark.
2132- `iterations`: Number of refinement iterations
2233
2334# Keywords
24- - `parallel = true`: Loop over all points in parallel
25- - `title = ""`: Title of the plot
35+ - `parallelization_backend = PolyesterBackend()`: Parallelization strategy to use. See
36+ [`@threaded`](@ref) for a list of available
37+ backends.
2638- `seed = 1`: Seed to perturb the point positions. Different seeds yield
2739 slightly different point positions.
2840- `perturbation_factor_position = 1.0`: Scale the point position perturbation by this factor.
@@ -33,12 +45,14 @@ of points and plot the results.
3345```julia
3446include("benchmarks/benchmarks.jl")
3547
36- plot_benchmarks(benchmark_count_neighbors, (10, 10), 3)
48+ run_benchmark(benchmark_count_neighbors, (10, 10), 3,
49+ [TrivialNeighborhoodSearch{2}(), GridNeighborhoodSearch{2}()])
50+ ```
3751"""
3852function run_benchmark (benchmark, n_points_per_dimension, iterations, neighborhood_searches;
39- names = [" NeighborhoodSearch $i "
40- for i in 1 : length (neighborhood_searches)]' ,
4153 parallelization_backend = PolyesterBackend (),
54+ names = [" Neighborhood search $i "
55+ for i in 1 : length (neighborhood_searches)]' ,
4256 seed = 1 , perturbation_factor_position = 1.0 )
4357 # Multiply number of points in each iteration (roughly) by this factor
4458 scaling_factor = 4
@@ -80,7 +94,34 @@ function run_benchmark(benchmark, n_points_per_dimension, iterations, neighborho
8094 return n_particles_vec, times
8195end
8296
83- # Rum the benchmark with the most commonly used neighborhood search implementations
97+ """
98+ run_benchmark_default(benchmark, n_points_per_dimension, iterations; kwargs...)
99+
100+ Shortcut to call [`run_benchmark`](@ref) with the most commonly used neighborhood search
101+ implementations:
102+ - `GridNeighborhoodSearch`
103+ - `GridNeighborhoodSearch` with `FullGridCellList`
104+ - `PrecomputedNeighborhoodSearch`
105+
106+ # Arguments
107+ - `benchmark`: The benchmark function. See [`benchmark_count_neighbors`](@ref),
108+ [`benchmark_n_body`](@ref), [`benchmark_wcsph`](@ref),
109+ [`benchmark_wcsph_fp32`](@ref) and [`benchmark_tlsph`](@ref).
110+ - `n_points_per_dimension`: Initial resolution as tuple. The product is the initial number
111+ of points. For example, use `(100, 100)` for a 2D benchmark or
112+ `(10, 10, 10)` for a 3D benchmark.
113+ - `iterations`: Number of refinement iterations
114+
115+ # Keywords
116+ See [`run_benchmark`](@ref) for a list of available keywords.
117+
118+ # Examples
119+ ```julia
120+ include("benchmarks/benchmarks.jl")
121+
122+ run_benchmark_default(benchmark_n_body, (10, 10), 3)
123+ ```
124+ """
84125function run_benchmark_default (benchmark, n_points_per_dimension, iterations; kwargs... )
85126 NDIMS = length (n_points_per_dimension)
86127 min_corner = 0.0f0 .* n_points_per_dimension
@@ -102,7 +143,32 @@ function run_benchmark_default(benchmark, n_points_per_dimension, iterations; kw
102143 neighborhood_searches; names, kwargs... )
103144end
104145
105- # Rum the benchmark with all GPU-compatible neighborhood search implementations
146+ """
147+ run_benchmark_gpu(benchmark, n_points_per_dimension, iterations; kwargs...)
148+
149+ Shortcut to call [`run_benchmark`](@ref) with all GPU-compatible neighborhood search
150+ implementations:
151+ - `GridNeighborhoodSearch` with `FullGridCellList`
152+
153+ # Arguments
154+ - `benchmark`: The benchmark function. See [`benchmark_count_neighbors`](@ref),
155+ [`benchmark_n_body`](@ref), [`benchmark_wcsph`](@ref),
156+ [`benchmark_wcsph_fp32`](@ref) and [`benchmark_tlsph`](@ref).
157+ - `n_points_per_dimension`: Initial resolution as tuple. The product is the initial number
158+ of points. For example, use `(100, 100)` for a 2D benchmark or
159+ `(10, 10, 10)` for a 3D benchmark.
160+ - `iterations`: Number of refinement iterations
161+
162+ # Keywords
163+ See [`run_benchmark`](@ref) for a list of available keywords.
164+
165+ # Examples
166+ ```julia
167+ include("benchmarks/benchmarks.jl")
168+
169+ run_benchmark_gpu(benchmark_n_body, (10, 10), 3)
170+ ```
171+ """
106172function run_benchmark_gpu (benchmark, n_points_per_dimension, iterations; kwargs... )
107173 NDIMS = length (n_points_per_dimension)
108174
@@ -120,6 +186,27 @@ function run_benchmark_gpu(benchmark, n_points_per_dimension, iterations; kwargs
120186 neighborhood_searches; names, kwargs... )
121187end
122188
189+ """
190+ plot_benchmark(n_particles_vec, times; kwargs...)
191+
192+ Plot the results of a benchmark run with [`run_benchmark`](@ref).
193+ Note that the arguments are the outputs of that function.
194+
195+ # Arguments
196+ - `n_particles_vec`: Vector containing the number of particles for each iteration.
197+ - `times`: Matrix containing the runtimes for each neighborhood search and iteration.
198+
199+ # Keywords
200+ Keyword arguments are passed to `Plots.plot`. For example, use `title = "My title"`.
201+
202+ # Examples
203+ ```julia
204+ include("benchmarks/benchmarks.jl")
205+
206+ n_particles_vec, times = run_benchmark_default(benchmark_count_neighbors, (10, 10), 3)
207+ plot_benchmark(n_particles_vec, times; title = "Count neighbors benchmark")
208+ ```
209+ """
123210function plot_benchmark (n_particles_vec, times; kwargs... )
124211 function format_n_particles (n)
125212 if n >= 1_000_000
0 commit comments