Skip to content

Fix north/south buffer swap in CommunicationBuffers#5427

Open
briochemc wants to merge 6 commits intomainfrom
bp-claude/adapt_structure-fix-swap
Open

Fix north/south buffer swap in CommunicationBuffers#5427
briochemc wants to merge 6 commits intomainfrom
bp-claude/adapt_structure-fix-swap

Conversation

@briochemc
Copy link
Copy Markdown
Collaborator

Remove Adapt.adapt_structure for CommunicationBuffers (unused since individual buffer types all adapt to nothing) and fix the south/north argument order in on_architecture to match the struct field order (west, east, south, north, ...), as per #5422 (comment).

Closes #5422

… adapt_structure

Remove `Adapt.adapt_structure` for `CommunicationBuffers` (unused since individual
buffer types all adapt to `nothing`) and fix the south/north argument order in
`on_architecture` to match the struct field order (west, east, south, north, ...).

Closes #5422

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Copy link
Copy Markdown
Member

@glwagner glwagner left a comment

Choose a reason for hiding this comment

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

nice find @briochemc

@simone-silvestri
Copy link
Copy Markdown
Collaborator

@briochemc the adapt is needed because the buffers are passed in the kernels in MultiRegion boundary conditions here

function BoundaryConditions.fill_halo_regions!(c::MultiRegionObject, bcs, indices, loc, mrg::MultiRegionGrid, buffers, args...; fill_open_bcs=true, kwargs...)
buff_ref = Reference(buffers.regional_objects)
apply_regionally!(fill_send_buffers!, c, buffers, mrg)
apply_regionally!(fill_halo_regions!, c, bcs, indices, loc, mrg, buff_ref, args...; fill_open_bcs, kwargs...)
apply_regionally!(fill_send_buffers!, c, buffers, mrg)
apply_regionally!(fill_halo_regions!, c, bcs, indices, loc, mrg, buff_ref, args...; fill_open_bcs, kwargs...)
return nothing

However, these buffers are only passed for syntax convenience and thrown away inside GPU kernels. So if you find a clever way to detangle the buffers you can remove the adapt. It would require rewriting a custom fill_halo_regions!.

@briochemc
Copy link
Copy Markdown
Collaborator Author

OK so I have no clever ideas here so just reverting the method removal, and just keeping the swap fix.

@briochemc
Copy link
Copy Markdown
Collaborator Author

@simone-silvestri @glwagner Are you happy to merge this? I could run the CI and wait for it to pass but I don't think that's needed here 🤷 (I can't merge without CI passing)

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.

Bug: Adapt.adapt_structure swaps north/south in CommunicationBuffers

4 participants