Skip to content
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

Use PrecomputedNeighborhoodSearch for the oscillating beam #544

Merged
merged 6 commits into from
Jul 24, 2024

Conversation

efaulhaber
Copy link
Member

@efaulhaber efaulhaber commented Jun 11, 2024

Based on trixi-framework/PointNeighbors.jl#9 and trixi-framework/PointNeighbors.jl#35.

1.8x speedup in an isolated interaction benchmark of the default oscillating beam:

julia> @btime TrixiParticles.interact!($dv_ode, $v_ode, $u_ode, $solid_system, $solid_system, $semi);
  16.708 μs (1 allocation: 496 bytes)

julia> @btime TrixiParticles.interact!($dv_ode, $v_ode, $u_ode, $solid_system, $solid_system, $semi);
  9.250 μs (1 allocation: 496 bytes)

Large simulation with n_particles_y = 65:

julia> @btime TrixiParticles.interact!($dv_ode, $v_ode, $u_ode, $solid_system, $solid_system, $semi);
  4.971 ms (1 allocation: 496 bytes)

julia> @btime TrixiParticles.interact!($dv_ode, $v_ode, $u_ode, $solid_system, $solid_system, $semi);
  2.024 ms (1 allocation: 496 bytes)

3D:

julia> @btime TrixiParticles.interact!($dv_ode, $v_ode, $u_ode, $solid_system, $solid_system, $semi);
  375.000 μs (1 allocation: 496 bytes)

julia> @btime TrixiParticles.interact!($dv_ode, $v_ode, $u_ode, $solid_system, $solid_system, $semi);
  228.000 μs (1 allocation: 496 bytes)

Here is the timer output of the default oscillating beam:

julia> trixi_include("examples/solid/oscillating_beam_2d.jl", saving_callback=nothing, neighborhood_search=GridNeighborhoodSearch{2}());

[...]
────────────────────────────────────────────────────────────────────────────────────────────────────
Trixi simulation finished.  Final time: 5.0  Time steps: 15826 (accepted), 16871 (total)
────────────────────────────────────────────────────────────────────────────────────────────────────

 ─────────────────────────────────────────────────────────────────────────────────────────
            TrixiParticles.jl                    Time                    Allocations      
                                        ───────────────────────   ────────────────────────
            Tot / % measured:                12.4s /  86.7%            326MiB /  77.4%    

 Section                        ncalls     time    %tot     avg     alloc    %tot      avg
 ─────────────────────────────────────────────────────────────────────────────────────────
 kick!                            152k    10.5s   97.9%  69.1μs    222MiB   88.1%  1.50KiB
   update systems and nhs         152k    6.58s   61.4%  43.3μs   69.5MiB   27.5%     480B
     stress tensor                152k    6.39s   59.7%  42.1μs   69.5MiB   27.5%     480B
     ~update systems and nhs~     152k    177ms    1.7%  1.16μs   1.47KiB    0.0%    0.01B
     update nhs                   152k   8.61ms    0.1%  56.7ns     0.00B    0.0%    0.00B
   system interaction             152k    3.48s   32.5%  22.9μs    120MiB   47.7%     832B
     solid1-solid1                152k    3.39s   31.6%  22.3μs   71.8MiB   28.4%     496B
     ~system interaction~         152k   93.7ms    0.9%   617ns   48.7MiB   19.3%     336B
   reset ∂v/∂t                    152k    213ms    2.0%  1.40μs     0.00B    0.0%    0.00B
   source terms                   152k    170ms    1.6%  1.12μs   32.4MiB   12.8%     224B
   ~kick!~                        152k   40.0ms    0.4%   264ns   2.94KiB    0.0%    0.02B
 drift!                           152k    230ms    2.1%  1.51μs   30.1MiB   11.9%     208B
   velocity                       152k    152ms    1.4%  1.00μs   30.1MiB   11.9%     208B
   reset ∂u/∂t                    152k   55.8ms    0.5%   367ns     0.00B    0.0%    0.00B
   ~drift!~                       152k   21.8ms    0.2%   144ns   1.47KiB    0.0%    0.01B
 ─────────────────────────────────────────────────────────────────────────────────────────
trixi_include("examples/solid/oscillating_beam_2d.jl", saving_callback=nothing);

[...]
────────────────────────────────────────────────────────────────────────────────────────────────────
Trixi simulation finished.  Final time: 5.0  Time steps: 15726 (accepted), 16676 (total)
────────────────────────────────────────────────────────────────────────────────────────────────────

 ─────────────────────────────────────────────────────────────────────────────────────────
            TrixiParticles.jl                    Time                    Allocations      
                                        ───────────────────────   ────────────────────────
            Tot / % measured:                8.47s /  83.1%            311MiB /  80.2%    

 Section                        ncalls     time    %tot     avg     alloc    %tot      avg
 ─────────────────────────────────────────────────────────────────────────────────────────
 kick!                            150k    6.76s   96.1%  45.0μs    220MiB   88.1%  1.50KiB
   update systems and nhs         150k    3.98s   56.5%  26.5μs   68.7MiB   27.5%     480B
     stress tensor                150k    3.81s   54.1%  25.4μs   68.7MiB   27.5%     480B
     ~update systems and nhs~     150k    161ms    2.3%  1.07μs   1.47KiB    0.0%    0.01B
     update nhs                   150k   8.69ms    0.1%  57.9ns     0.00B    0.0%    0.00B
   system interaction             150k    2.33s   33.2%  15.5μs    119MiB   47.7%     832B
     solid1-solid1                150k    2.24s   31.8%  14.9μs   71.0MiB   28.4%     496B
     ~system interaction~         150k   94.8ms    1.3%   631ns   48.1MiB   19.3%     336B
   source terms                   150k    205ms    2.9%  1.37μs   32.1MiB   12.8%     224B
   reset ∂v/∂t                    150k    201ms    2.9%  1.34μs     0.00B    0.0%    0.00B
   ~kick!~                        150k   45.1ms    0.6%   301ns   2.94KiB    0.0%    0.02B
 drift!                           150k    276ms    3.9%  1.84μs   29.8MiB   11.9%     208B
   velocity                       150k    174ms    2.5%  1.16μs   29.8MiB   11.9%     208B
   reset ∂u/∂t                    150k   58.1ms    0.8%   387ns     0.00B    0.0%    0.00B
   ~drift!~                       150k   43.9ms    0.6%   292ns   1.47KiB    0.0%    0.01B
 ─────────────────────────────────────────────────────────────────────────────────────────

@efaulhaber efaulhaber changed the title Add create_neighborhood_search for NeighborListsNeighborhoodSearch Use PrecomputedNeighborhoodSearch for the oscillating beam Jun 24, 2024
Copy link

codecov bot commented Jun 24, 2024

Codecov Report

Attention: Patch coverage is 0% with 3 lines in your changes missing coverage. Please review.

Project coverage is 69.50%. Comparing base (c38804c) to head (e8bc21f).

Files Patch % Lines
test/count_allocations.jl 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #544   +/-   ##
=======================================
  Coverage   69.50%   69.50%           
=======================================
  Files          76       76           
  Lines        4611     4611           
=======================================
  Hits         3205     3205           
  Misses       1406     1406           
Flag Coverage Δ
unit 69.50% <0.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@efaulhaber efaulhaber marked this pull request as ready for review July 23, 2024 16:26
@LasNikas LasNikas merged commit 8273cbe into trixi-framework:main Jul 24, 2024
9 of 10 checks passed
@efaulhaber efaulhaber deleted the neighbor-lists-nhs branch July 24, 2024 12:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants