Skip to content

Improve GPU performance of fluid-* interact#1116

Open
efaulhaber wants to merge 17 commits intotrixi-framework:mainfrom
efaulhaber:performance-fluid
Open

Improve GPU performance of fluid-* interact#1116
efaulhaber wants to merge 17 commits intotrixi-framework:mainfrom
efaulhaber:performance-fluid

Conversation

@efaulhaber
Copy link
Copy Markdown
Member

@efaulhaber efaulhaber commented Mar 23, 2026

This PR rewrites the interact! function for fluid-* interaction and is part of #1131.

  • The foreach_point_neighbor loop is now unrolled into an @threaded for particle and foreach_neighbor.
  • With this change, I can now load data for particle a once instead of loading it again for each neighbor.
  • This unrolled loop now also allows me to accumulate the dv values over all neighbors and write to dv only once per particle.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 94.73684% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 89.06%. Comparing base (6ee0bf4) to head (e7369d0).

Files with missing lines Patch % Lines
src/general/neighborhood_search.jl 0.00% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1116      +/-   ##
==========================================
- Coverage   89.13%   89.06%   -0.08%     
==========================================
  Files         128      128              
  Lines        9869     9869              
==========================================
- Hits         8797     8790       -7     
- Misses       1072     1079       +7     
Flag Coverage Δ
total 89.06% <94.73%> (-0.08%) ⬇️
unit 67.26% <81.57%> (+0.01%) ⬆️

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the fluid-* interact! implementation to improve GPU performance by unrolling the point-neighbor iteration into a per-particle threaded loop and reducing repeated loads/writes.

Changes:

  • Rewrites WCSPH interact! to thread over particles, use foreach_neighbor, and accumulate per-particle RHS contributions before writing.
  • Introduces foreach_neighbor wrapper with a GPU-unsafe fast path (bounds-check-free) for neighbor traversal.
  • Adds a 3D WCSPH ContinuityDensity fast path that combines velocity+density loads using SIMD wide loads; updates correction and pressure helper APIs accordingly.

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/schemes/fluid/weakly_compressible_sph/rhs.jl Main WCSPH interact! refactor; adds neighbor_pressure and velocity_and_density helpers + SIMD load fast path.
src/schemes/fluid/implicit_incompressible_sph/rhs.jl Switches to neighbor_pressure helper to avoid redundant pressure loads / enable mirroring behavior.
src/general/neighborhood_search.jl Adds foreach_neighbor wrapper with a GPU specialization calling PointNeighbors.foreach_neighbor_unsafe.
src/general/corrections.jl Adjusts free_surface_correction API to accept (rho_a, rho_b) and compute rho_mean internally.
src/TrixiParticles.jl Adds SIMD import required by the new 3D fast path.
Project.toml Adds SIMD dependency and bumps PointNeighbors compat to 0.6.6.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/general/neighborhood_search.jl
Comment thread src/schemes/fluid/weakly_compressible_sph/rhs.jl
Comment thread src/schemes/fluid/weakly_compressible_sph/rhs.jl Outdated
Comment thread src/schemes/fluid/weakly_compressible_sph/rhs.jl Outdated
@efaulhaber
Copy link
Copy Markdown
Member Author

/run-gpu-tests

@efaulhaber efaulhaber marked this pull request as ready for review April 16, 2026 08:12
@efaulhaber
Copy link
Copy Markdown
Member Author

/run-gpu-tests

@efaulhaber efaulhaber marked this pull request as draft April 16, 2026 14:45
@efaulhaber efaulhaber marked this pull request as ready for review April 16, 2026 14:59
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