Skip to content

Improve GPU performance of fluid-* interact#1116

Draft
efaulhaber wants to merge 10 commits intotrixi-framework:mainfrom
efaulhaber:performance-fluid
Draft

Improve GPU performance of fluid-* interact#1116
efaulhaber wants to merge 10 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 80.39216% with 10 lines in your changes missing coverage. Please review.
✅ Project coverage is 67.15%. Comparing base (379db88) to head (20c77c5).

Files with missing lines Patch % Lines
src/schemes/fluid/weakly_compressible_sph/rhs.jl 83.72% 7 Missing ⚠️
src/general/neighborhood_search.jl 50.00% 2 Missing ⚠️
src/general/corrections.jl 50.00% 1 Missing ⚠️

❗ There is a different number of reports uploaded between BASE (379db88) and HEAD (20c77c5). Click for more details.

HEAD has 1 upload less than BASE
Flag BASE (379db88) HEAD (20c77c5)
total 1 0
Additional details and impacted files
@@             Coverage Diff             @@
##             main    #1116       +/-   ##
===========================================
- Coverage   89.06%   67.15%   -21.91%     
===========================================
  Files         128      128               
  Lines        9868     9866        -2     
===========================================
- Hits         8789     6626     -2163     
- Misses       1079     3240     +2161     
Flag Coverage Δ
total ?
unit 67.15% <80.39%> (-0.03%) ⬇️

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
Comment thread src/schemes/fluid/weakly_compressible_sph/rhs.jl
@efaulhaber
Copy link
Copy Markdown
Member Author

/run-gpu-tests

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.

2 participants