-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bad scaling when 2 sets of particles are used. #108
Comments
The issue, as explained in trixi-framework/PointNeighbors.jl#8 (comment) is that when using 2 sets of particles we are not using the projection-based approach to avoid computing distances for particles that are not within the cutoff. As a very early test, here is an implementation in which we just duplicate the particles and construct the cell lists for all duplicated set, and use the single-set approach. This is far from ideal, since we are still looping over much more particles than needed, but nevertheless it scales much better already: julia> run(;n=10^5)
CellListMap (t1): 0.097850265 s
CellListMap different (t2/t1): 1.755102543667102
CellListMap single_list (t5/t1): 2.697372194137645
Test Passed
julia> run(;n=5*10^5)
CellListMap (t1): 0.45006516 s
CellListMap different (t2/t1): 2.006997344562285
CellListMap single_list (t5/t1): 2.740345904579683
Test Passed
julia> run(;n=10^6)
CellListMap (t1): 0.90805197 s
CellListMap different (t2/t1): 2.940807859268231
CellListMap single_list (t5/t1): 2.605681498604094
Test Passed
julia> run(;n=5*10^6)
CellListMap (t1): 4.56837243 s
CellListMap different (t2/t1): 5.094499038906073
CellListMap single_list (t5/t1): 2.7785865216772616
Test Passed Note that here we are using a triclinic cell, thus ideally we should expect that all runs were comparable to julia> x, box = CellListMap.xatomic(10^5);
julia> @b ParticleSystem(positions=x, cutoff=box.cutoff, output=similar(x), unitcell=box.input_unit_cell.matrix)
16.301 ms (47290 allocs: 92.691 MiB)
julia> x, box = CellListMap.xatomic(5*10^5);
julia> @b ParticleSystem(positions=x, cutoff=box.cutoff, output=similar(x), unitcell=box.input_unit_cell.matrix)
107.122 ms (139089 allocs: 403.936 MiB, 28.82% gc time)
julia> x, box = CellListMap.xatomic(10^6);
julia> @b ParticleSystem(positions=x, cutoff=box.cutoff, output=similar(x), unitcell=box.input_unit_cell.matrix)
209.146 ms (237622 allocs: 789.580 MiB, 18.13% gc time, without a warmup)
julia> x, box = CellListMap.xatomic(5*10^6);
julia> @b ParticleSystem(positions=x, cutoff=box.cutoff, output=similar(x), unitcell=box.input_unit_cell.matrix)
1.685 s (1036615 allocs: 3.685 GiB, 31.67% gc time, without a warmup) Which, we see, are not negligible. The fraction of time spent on initialization relative to the time spent on mapping, in these examples, are, thus:
Remembering that this initialization time is largely dependent on the size of the smallest set, reason why it is avoided now: julia> x, box = CellListMap.xatomic(5*10^6);
julia> xypositions = vcat(x,y);
julia> @b ParticleSystem(positions=xypositions, cutoff=box.cutoff, output=similar(x), unitcell=box.input_unit_cell.matrix)
2.381 s (1322650 allocs: 4.989 GiB, 35.57% gc time, without a warmup)
julia> y = x[1:10^4];
julia> @b ParticleSystem(xpositions=x, ypositions=y, cutoff=box.cutoff, output=similar(x), unitcell=box.input_unit_cell.matrix)
981.499 ms (46537 allocs: 2.475 GiB, 29.04% gc time, without a warmup) Code:
```julia
using CellListMap, PointNeighbors, StaticArrays
using Chairmarks
using Test
function test_celllistmap(_, sys)
end function test_celllistmap_single_list(_, sys) function test_celllistmap_different(_, sys) function test_pointneighbors(x, f, nhs) function run(;n=10^5)
b3 = @b test_pointneighbors($xmat, $f3, $nhs1)println("PointNeighbors nhs1 (t3/t1): ", b3.time / b1.time)b4 = @b test_pointneighbors($xmat, $f4, $nhs2)println("PointNeighbors nhs2 (t4/t1): ", b4.time / b1.time)@test f ≈ f2 ≈ f3 ≈ f4
end
|
See: trixi-framework/PointNeighbors.jl#8 (comment)
The text was updated successfully, but these errors were encountered: