Skip to content

Make the IB force-reduction receive buffers device resident - #1843

Open
sbryngelson wants to merge 1 commit into
masterfrom
fix/ib-force-reduction-offload
Open

Make the IB force-reduction receive buffers device resident#1843
sbryngelson wants to merge 1 commit into
masterfrom
fix/ib-force-reduction-offload

Conversation

@sbryngelson

Copy link
Copy Markdown
Member

Fixes #1840.

s_communicate_ib_forces hands recv_forces_snap, recv_torques_snap, recv_ids and recv_ft to GPU kernels via copy/copyin, but they are allocated with a plain allocate and so are never present on the device. Under Cray OpenMP offload this aborts at the first time step for any moving immersed boundary run on more than one rank:

ACC: find_in_present_table failed for 'recv_forces_snap(:,:)' from .../m_ibm.fpp:1338
ACC: libcrayacc/acc_runtime.c:703 CRAY_ACC_ERROR - Variable not found in present table
srun: error: frontier10177: tasks 1-3: Exited with exit code 1

The send-side twins (send_ids, send_ft) are already @:ALLOCATEd and pushed with GPU_UPDATE, so this only makes the receive side consistent with them: @:ALLOCATE/@:DEALLOCATE, an explicit GPU_UPDATE(device=...) after each host write, and the corresponding copy/copyin clauses dropped.

Testing. Frontier, --gpu mp (cpe/25.03, rocm/6.3.1), 2D moving flat plate with ib_state_wrt, 4 ranks: aborts at step 1 on master, runs to completion with this patch. An OpenACC build of the same case was unaffected before and after. ./mfc.sh precheck passes.

One file, 8 insertions, 6 deletions.

https://claude.ai/code/session_01HMJ7cycfo7kTFSFq5yhHLG

`s_communicate_ib_forces` passed `recv_forces_snap`, `recv_torques_snap`, `recv_ids` and
`recv_ft` into GPU kernels through `copy`/`copyin`, but allocated them with a plain
`allocate`, so they never entered the device present table. On Cray OpenMP offload this
aborts at the first time step of any moving-IB case run on more than one rank:

    ACC: find_in_present_table failed for 'recv_forces_snap(:,:)' from m_ibm.fpp:1338
    ACC: libcrayacc/acc_runtime.c:703 CRAY_ACC_ERROR - Variable not found in present table

The sibling send buffers `send_ids`/`send_ft` are already `@:ALLOCATE`d and pushed with
`GPU_UPDATE`, so the receive side was simply inconsistent with them. Allocate the four
receive arrays the same way and update them to the device after the host writes (the
zeroing before each accumulation pass, and each `MPI_UNPACK`), which also lets the kernels
drop the `copy`/`copyin` of those arrays.

Reproduced on Frontier (`./mfc.sh build --gpu mp`, cpe/25.03, rocm/6.3.1) with a 2D moving
flat plate on 4 ranks; the same case runs to completion with this change, and an OpenACC
build was unaffected either way.

Fixes #1840

Claude-Session: https://claude.ai/code/session_01HMJ7cycfo7kTFSFq5yhHLG
Copilot AI lite review requested due to automatic review settings September 11, 2026 14:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Pull request overview

This PR fixes a GPU offload crash in multi-rank immersed boundary runs by ensuring receive-side force/torque buffers are device-resident and explicitly synchronized for OpenMP offload runtimes (e.g., Cray).

Changes:

  • Switch receive buffers to @:ALLOCATE/@:DEALLOCATE so they become device-resident like the send-side twins.
  • Add GPU_UPDATE(device=...) after host writes to recv_* receive buffers.
  • Remove copy/copyin clauses for receive buffers in GPU parallel loops to avoid present-table failures.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/simulation/m_ibm.fpp
Comment on lines +1339 to +1340
$:GPU_UPDATE(device='[recv_ids, recv_ft]')
$:GPU_PARALLEL_LOOP(private='[i, j]', copy='[forces, torques]')
Comment thread src/simulation/m_ibm.fpp
call MPI_UNPACK(ib_force_recv_buf, buf_size, unpack_pos, recv_ft, 6*recv_count, mpi_p, MPI_COMM_WORLD, ierr)
$:GPU_PARALLEL_LOOP(private='[i, j]', copyin='[recv_ft, recv_ids]', copy='[forces, torques, &
& recv_forces_snap, recv_torques_snap]')
$:GPU_UPDATE(device='[recv_ids, recv_ft]')
Comment thread src/simulation/m_ibm.fpp
Comment on lines +1385 to +1386
$:GPU_UPDATE(device='[recv_ids, recv_ft]')
$:GPU_PARALLEL_LOOP(private='[i, j]', copy='[forces, torques]')
@github-actions

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/simulation/m_ibm.fpp 1255 +2
Directory Lines Diff
simulation 28039 +2
total 46264 +2

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

Labels

None yet

Development

Successfully merging this pull request may close these issues.

Moving IB + MPI on Cray OpenMP offload: recv_forces_snap not in present table (s_communicate_ib_forces)

2 participants