Repository navigation
IB: check every patch is marked in one pass and one reduction - #1933
Conversation
s_check_every_patch_marked swept every local cell and ran a reduction once per global patch, and num_gbl_ibs counts every particle-cloud particle. Count markers by decoded patch id in one pass and reduce the counts in one collective. Decoding also counts the cells of a body wrapped across a periodic boundary, which the raw == gid test missed. Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
Review effort: Lite
Findings: 4
Open (8)
Counts are being accumulated and reduced inreal(wp), then compared via exact equality to… · New Counts are being accumulated and reduced inreal(wp), then compared via exact equality to… · New Counts are being accumulated and reduced inreal(wp), then compared via exact equality to… · New Counts are being accumulated and reduced inreal(wp), then compared via exact equality to… · New This introduces an unconditional MPI allreduce call where the previous code was guarded by `#ifdef… · New The per-patch counts are modeled as 2D arrays with a hard-coded second dimension of1, which… · New The per-patch counts are modeled as 2D arrays with a hard-coded second dimension of1, which… · New The per-patch counts are modeled as 2D arrays with a hard-coded second dimension of1, which… · New
What changed in this PR
Optimizes s_check_every_patch_marked to avoid per-patch grid sweeps and collectives by counting marked cells per patch in a single local pass and performing a single global reduction, while correctly handling periodic-encoded markers.
Changes:
- Replace
num_gbl_ibsrepeated sweeps/reductions with one local sweep that bins counts by patch id. - Perform a single collective reduction over the full per-patch count array.
- Decode marker periodicity before counting so wrapped images count toward their owning patch.
| File | Description |
|---|---|
src/simulation/m_ibm.fpp |
Refactors “every patch marked” validation to single-pass counting + single reduction and adds periodicity-aware marker decoding. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Use 1-D integer(kind=8) counts and a new s_mpi_allreduce_integer_sum_vec (shaped like s_mpi_allreduce_min_vec, with the same non-MPI fallback) instead of real(wp) counts in a (num_gbl_ibs, 1) array, as review suggested. Co-Authored-By: Claude <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1933 +/- ##
==========================================
- Coverage 62.82% 62.82% -0.01%
==========================================
Files 86 86
Lines 22394 22398 +4
Branches 3305 3305
==========================================
+ Hits 14070 14072 +2
- Misses 6071 6072 +1
- Partials 2253 2254 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Lines of Code
|



Summary
Follow-up to #1914, addressing its open Copilot review finding.
s_check_every_patch_markedlooped over every global patch, and for each one swept every local cell and ran an MPI reduction. That isnum_gbl_ibsgrid sweeps plusnum_gbl_ibscollectives at setup, andnum_gbl_ibscounts every particle-cloud particle (up to 54,000 with the configured limit). The check now:It also decodes each marker with
s_decode_patch_periodicitybefore counting. The old check compared the raw marker with== gid, so the cells of a body wrapped across a periodic boundary did not count toward their patch, and a fully wrapped image could wrongly abort a valid run.Counts are
integer(kind=8), reduced with a news_mpi_allreduce_integer_sum_vecinm_mpi_common(shaped likes_mpi_allreduce_min_vec, with the same non-MPI fallback). The abort and its message are unchanged, and the 16-line comment is cut to three.The check runs once, from
s_ibm_setup, not per time step. So the old cost was a setup-time cost, and the check catches a body that marks no cell at startup, not one that later leaves the domain.Verification
pre_process,simulationandpost_processbuild on masterd87a5feawith this change on Frontier, in all three configurations: CPU (--no-gpu), OpenMP offload (--gpu mp) and OpenACC (--gpu acc)../mfc.sh precheckpasses (all 7 gates).AI disclosure
Written with Claude Code (Anthropic).
Acknowledgement