Skip to content

IBM: transfer only patch_ib(1:num_ibs) in the ownership handoff - #2353

Merged
sbryngelson merged 1 commit into
MFlowCode:masterfrom
sbryngelson:ib-handoff-patch-range
Nov 21, 2026
Merged

sbryngelson merged 1 commit into
MFlowCode:masterfrom
sbryngelson:ib-handoff-patch-range

Conversation

@sbryngelson

Copy link
Copy Markdown
Member

Contribution Policy

All contributions are expected to demonstrate:

  • A clear understanding of the codebase
  • Alignment with product direction
  • Thoughtful reasoning behind changes
  • Evidence of real-world usage or hands-on experience with the problem

If these expectations are not met, we would prefer to implement the changes ourselves rather than spend time reviewing low-effort submissions.

Summary

s_handoff_ib_ownership runs every step whenever a body moves, and on more than one rank it copies the whole patch_ib array between host and device three times: GPU_UPDATE(host='[patch_ib]') before the compaction, and GPU_UPDATE(device='[patch_ib, num_ibs]') after the compaction and after the neighbor unpack. patch_ib has num_ib_patches_max_namelist = 810000 entries of roughly 1 kB, so these are several GB of transfers per step whatever the number of bodies. Only entries 1:num_ibs are ever read (s_get_neighborhood_idx and every loop are bounded by num_ibs), so the three updates now name patch_ib(1:num_ibs). Three lines, no behavior change.

Evidence

Periodic 2D box of free circles (moving_ibm = 2, 4 cells per diameter, 12.5 % area fraction), MI250X, Cray compiler, OpenACC, one GCD per rank. Wall time per step, mean over steps 5 to 30 (steps 5 to 15 at 1e5), before and after this change. Both builds also carry #2335 and #2340, which this case needs to run at all.

bodies ranks before after
1000 8 109.7 ms 17.5 ms
3000 8 110.9 ms 19.1 ms
1000 64 109.4 ms 17.1 ms
10000 64 110.5 ms 18.6 ms
100000 64 124.0 ms 35.3 ms

Attribution (timers around the call sites, not committed): of the 111 ms step, the wrap plus handoff takes 90 ms at 2 ranks and 92 ms at 8 ranks, and 0.02 ms at 1 rank (where the handoff does not run); the RHS takes 6 to 8 ms, of which the halo exchange is 2 ms. The same case with fixed bodies (moving_ibm = 0) takes 12 ms at 2 ranks, with no bodies 7 ms, and with moving bodies on 2 nodes 96 ms, so the cost is in this path and not in MPI or GPU staging in general.

Correctness: six free spinning circles on and across the seams of a 2x2 split, 100 steps, 4 ranks: the force and torque history agrees with the build before this change to 1e-14 (GPU atomics are not bitwise reproducible, so the files are not byte-identical).

Tests

./mfc.sh precheck passes. Not run: the full test suite and other compilers or CPU builds (host and device share memory there, so the ranges change nothing but the amount copied).

Limitations

The remaining per-step work in the handoff is still proportional to num_ibs (the bodies a rank holds). I did not look at whether the three updates are needed every step at all.

This PR was made with Claude Code (AI).

@sbryngelson sbryngelson added the ci:phoenix Run the Phoenix (NVHPC GPU) jobs on this PR; push after adding label Nov 20, 2026
@github-actions

github-actions Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Claude Code Review

Head SHA: 82182ed

Files changed:

  • 1
  • src/simulation/m_ibm.fpp

Findings:
No issues found. Checked in step 4: src/simulation/m_ibm.fpp (the three GPU_UPDATE hunks around the IB compaction and neighborhood handoff). num_ibs has the correct host value at each update, and the sections contain no commas, so the macro argument parsing is unaffected.

@sbryngelson
sbryngelson marked this pull request as ready for review November 20, 2026 13:05
@sbryngelson
sbryngelson requested a review from a team as a code owner November 20, 2026 13:05
@sbryngelson
sbryngelson requested review from danieljvickers and removed request for a team November 20, 2026 13:05
@codecov

codecov Bot commented Nov 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.69%. Comparing base (1e3f1be) to head (82182ed).
⚠️ Report is 7 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #2353   +/-   ##
=======================================
  Coverage   65.69%   65.69%           
=======================================
  Files         111      111           
  Lines       30333    30333           
  Branches     4631     4629    -2     
=======================================
  Hits        19927    19927           
  Misses       6682     6682           
  Partials     3724     3724           

☔ View full report in Codecov by Harness.
📢 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.

@sbryngelson
sbryngelson merged commit 581fcbc into MFlowCode:master Nov 21, 2026
114 of 119 checks passed
@sbryngelson

Copy link
Copy Markdown
Member Author

Independent NVIDIA verification of current master (aad80b3c3, which contains this PR).

  • Machine: NVIDIA A100 80GB (Georgia Tech wingtip)
  • Compiler: NVHPC 25.5, OpenACC, CI-style fat build (cc 70,75,80,89,90)
  • Flags: ./mfc.sh test -v --max-attempts 1 --no-build -o IBM --no-chemistry -j 2 -g <gpus> --gpu acc --mpi --no-debug --no-reldebug --no-single
  • Whole IBM label (chemistry excluded): 118 passed, 0 failed (one 1-GPU run, one 2-GPU run). 909 skipped by the filter, including the NVHPC<25.11 skip 124D7972 (Test: skip 124D7972 on NVHPC < 25.11 GPU builds (known difference, #2181) #2380).
  • Wall time of the full IBM label at -j 2 (machine shared, load varies): 829 s on one GPU, 661 s on two GPUs. Per-test times in the tables are single-test wall times including pre_process/simulation launch and golden compare, not per-step times.

Rows for the ownership handoff (#2353, and #2331/#2335 neighborhood/periodic-wrap fixes), all PASS on one and two GPUs:

Test Result 1 GPU Result 2 GPUs (2-rank tests split across GPUs) Time 1 GPU / 2 GPUs (s)
50B98DBF Centroid On Periodic Domain End 2 MPI Ranks (#2335) PASS PASS 12.7 / 10.1
9C0CAF25 Translating Circle 2 MPI Ranks PASS PASS 12.4 / 9.8
ED2D5C0A / FB3F47C0 Periodic Bodies (many_ib_patch_parallelism) PASS PASS 13.9 / 11.1, 13.4 / 12.3
04FB9E91 Moving Circle ib_mass_relax PASS PASS 25.7 / 25.1

There is no dedicated test for the #2331 duplicate-patch case; none of the above fails. 118/118 IBM-label tests pass.

Not run: chemistry tests, OpenMP-offload build, CPU build, any NVHPC other than 25.5, before/after timing of the changes.

AI-assisted (Claude Code).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:phoenix Run the Phoenix (NVHPC GPU) jobs on this PR; push after adding

Development

Successfully merging this pull request may close these issues.

1 participant