Skip to content

Conversation

@efaulhaber
Copy link
Member

@efaulhaber efaulhaber commented Nov 5, 2025

Here is a benchmark of interact! on an A4500 with FP32. I ran the periodic_channel_2d.jl example with 125k particles and benchmarked with:

@b TrixiParticles.interact!($(copy(ode.u0.x[1])), $(ode.u0.x)..., $(ode.p.systems[1]), $(ode.p.systems[1]), $(ode.p)) seconds=1
Setup Time
No shifting 297.812 μs
main with ConsistentShiftingSun2019 3.117 ms
inlining continuity_equation_shifting! 431.567 μs
@propagate_inbounds 360.704 μs
vdiff_shifting instead of continuity_equation_shifting! 347.360 μs

@efaulhaber efaulhaber marked this pull request as ready for review November 17, 2025 14:43
@efaulhaber efaulhaber requested a review from Copilot November 17, 2025 14:44
Copilot finished reviewing on behalf of efaulhaber November 17, 2025 14:46
Copy link

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

This PR improves GPU performance for particle shifting operations by refactoring from mutating to non-mutating functions and adding @propagate_inbounds annotations. The benchmark shows a ~9x performance improvement (from 3.117 ms to 347.360 μs) for ConsistentShiftingSun2019 on an A4500 GPU.

Key changes:

  • Refactored continuity_equation_shifting! to non-mutating continuity_equation_shifting_term that returns values instead of mutating arrays
  • Added @propagate_inbounds annotations to performance-critical functions
  • Reorganized timing instrumentation for better profiling granularity

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/schemes/fluid/shifting_techniques.jl Refactored continuity equation shifting from mutating to non-mutating pattern, added @propagate_inbounds annotations, and split timing blocks
src/schemes/fluid/fluid.jl Integrated non-mutating continuity_equation_shifting_term into continuity equation calculation
src/schemes/boundary/open_boundary/system.jl Added timing instrumentation wrapper around open boundary update
src/preprocessing/particle_packing/system.jl Added timing instrumentation for particle packing operations
src/callbacks/update.jl Removed redundant timing wrappers (moved to individual functions)

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

@svchb svchb closed this Nov 18, 2025
@svchb svchb reopened this Nov 18, 2025
@svchb svchb closed this Nov 18, 2025
@svchb svchb reopened this Nov 18, 2025
@codecov
Copy link

codecov bot commented Nov 18, 2025

Codecov Report

❌ Patch coverage is 7.50000% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 64.83%. Comparing base (4725885) to head (ef9d65d).

Files with missing lines Patch % Lines
src/schemes/fluid/shifting_techniques.jl 10.00% 18 Missing ⚠️
src/preprocessing/particle_packing/system.jl 0.00% 8 Missing ⚠️
src/schemes/boundary/open_boundary/system.jl 0.00% 7 Missing ⚠️
src/callbacks/update.jl 0.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #974      +/-   ##
==========================================
- Coverage   64.84%   64.83%   -0.01%     
==========================================
  Files         120      120              
  Lines        8565     8566       +1     
==========================================
  Hits         5554     5554              
- Misses       3011     3012       +1     
Flag Coverage Δ
unit 64.83% <7.50%> (-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.

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