Skip to content

Define result of scalar allreduce and gather helpers in non-MPI builds - #2127

Open
sbryngelson wants to merge 1 commit into
MFlowCode:masterfrom
sbryngelson:wave1/allreduce-nompi
Open

sbryngelson wants to merge 1 commit into
MFlowCode:masterfrom
sbryngelson:wave1/allreduce-nompi

Conversation

@sbryngelson

Copy link
Copy Markdown
Member

What

In non-MPI builds the scalar allreduce min/max/sum helpers and the gather helper in m_mpi_common never assigned their output argument (the body was only inside #ifdef MFC_MPI), so callers got an undefined result. Add the serial #else branches: var_glb = var_loc for the reductions and gathered_vector = my_vector for the gather.

Verification

Testing. Built with GPU offload (OpenMP, AMD) and ran the full test suite with this fix and seven other independent fixes applied together: 729 tests in 4 shards, 0 failures (two shards on MI300A, two on MI250X).

Prepared with Claude Code (AI-assisted); I reviewed the change and ran the tests.

@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Claude Code Review

Head SHA: 054f641

Files changed:

  • 1
  • src/common/m_mpi_common.fpp

Findings:

  • medium src/common/m_mpi_common.fpp: In s_mpi_gather_data, the new #else branch does gathered_vector = my_vector. gathered_vector is allocatable, intent(out) and is never explicitly allocated in the non-MPI path. This relies on F2003 automatic (re)allocation on assignment. gfortran and ifx enable it by default, but nvfortran needs -Mallocatable=03 and some Cray/legacy flag sets disable it. To be portable, write allocate (gathered_vector(counts)); gathered_vector = my_vector. This would also match the MPI branch, which allocates explicitly. Confidence: moderate, because it depends on the compiler flags in use.

The s_mpi_allreduce_sum, s_mpi_allreduce_min and s_mpi_allreduce_max #else copies (var_glb = var_loc) look correct for the serial case.

Note: .claude-review/context was empty, so I checked the hunks against the working-tree src/common/m_mpi_common.fpp.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

Lines of Code

File Lines Diff
src/common/m_mpi_common.fpp 1502 +8
Directory Lines Diff
common 10552 +8
total 47638 +8

@sbryngelson
sbryngelson marked this pull request as ready for review November 3, 2026 14:17
@sbryngelson
sbryngelson requested a review from a team as a code owner November 3, 2026 14:17
@sbryngelson
sbryngelson requested review from danieljvickers and removed request for a team November 3, 2026 14:17

This branch has not been deployed

No deployments
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.

1 participant