Skip to content

MPI Parallelization MVP for Matlab Grid - #202

Merged
BenjaminRodenberg merged 6 commits into
mainfrom
mpi-parallelization-mvp-matlab
Oct 21, 2026
Merged

BenjaminRodenberg merged 6 commits into
mainfrom
mpi-parallelization-mvp-matlab

Conversation

@BenjaminRodenberg

@BenjaminRodenberg BenjaminRodenberg commented Oct 21, 2026 •

Copy link
Copy Markdown
Collaborator

Split off from #197 (#197), which has grown too large: MPI parallelization for the MATLAB grid only. Builds on the MPI usage errors of #201 and on the domain-wide values of #203.

mpirun -np N ebfm --matlab-mesh examples/dem_and_mask.mat --no-shading now splits the columns of the grid into contiguous blocks, one per rank. Rank 0 gathers the columns of all ranks and writes the output file; it is byte-identical to that of a run on a single rank, and so is --dump-reference (tested on 2, 3 and 4 ranks). The latitude mean, lapse rate and random seed are computed for the whole domain since #203.

Also in this PR:

  • Shading on several ranks is a usage error (--no-shading is required).
  • Only rank 0 logs to the console at the chosen level; the other ranks log warnings and errors.
  • CI runs the MATLAB example on 4 ranks, with timeouts for the MPI steps, and keeps Open MPI's TCP traffic on the loopback interface (on GitHub's runners it also used docker0, where large messages hung).

Output and restart files are still skipped for partitioned Elmer meshes. Everything else from #197 (splitting non-partitioned Elmer meshes, XIOS DEMs on several ranks, output of partitioned meshes, restart files in parallel runs) stays there.

🤖 Generated with Claude Code

setup-mpi makes Open MPI use TCP between ranks, and on GitHub's
runners Open MPI's TCP transport also picks the docker0 interface,
over which messages never arrive. Small messages still get through,
but large ones hang: in #197 a gather on 4 ranks hung until GitHub's
limit of 6 hours, while the same run passed locally, where the ranks
use shared memory. The next commits run the MATLAB example on up to
4 ranks, with gathers large enough to hang.

Open MPI now only uses the loopback interface in both workflows. It
is set in mca-params.conf, since tox does not pass OMPI_MCA_*
variables to the tests. In addition, the build-and-test job now stops
after 20 minutes and its MPI steps after 5, so a hang fails quickly
instead of blocking a runner for 6 hours.

Taken from 5e28f4d and 47b4c8f of #197.

Assisted-by: Claude Code:claude-opus-5-5
MATLAB and NetCDF grids now keep the flat indices of their columns in
the 2-D fields as `ind` and take every per-column field from the 2-D
fields with them, instead of applying the mask to each field again.
A subset of the columns then only needs a subset of `ind`, which the
next commits use to split a MATLAB grid over MPI ranks.

The columns, their order and the model output are unchanged.

Assisted-by: Claude Code:claude-opus-5-5
The output writer now gathers the columns of all ranks with
ColumnGather and rank 0 writes them to the file a single rank would
write, one variable at a time to limit its memory. Only structured
grids are gathered; a partitioned mesh still skips the output file.

Taken from 8b5a9eb of #197.

Assisted-by: Claude Code:claude-opus-5-5
The shading look-up table is computed by walking from every glacier
cell of the 2-D grid, not only from the columns of one rank, so a
rank holding part of the columns cannot build its rows of the table.
Shading on several ranks is now a usage error asking for --no-shading,
and _precompute_shading_matlab asserts that it is not called in such
a run.

No grid that supports shading runs on several ranks yet; the next
commits split MATLAB grids over the ranks.

Taken from 43a676e of #197.

Assisted-by: Claude Code:claude-opus-5-5
On several ranks, each rank now computes a contiguous block of the
columns of a MATLAB grid, the first block on rank 0. The 2-D fields
stay whole on every rank: the slope needs the neighbours of each cell,
and the output writer places the columns of all ranks into them.

The domain-wide latitude mean, lapse rate and random seed of #203 make
the results equal those of a single rank.

Taken from 46f47a2 of #197.

Assisted-by: Claude Code:claude-opus-5-5
The MATLAB example runs for one day on a single rank and on 2, 3 and
4 ranks under mpirun; each parallel run must give a byte-identical
output file and an equal --dump-reference snapshot. CI also runs the
MATLAB example on 4 ranks.

Taken from db2b582 and e26d3e8 of #197.

Assisted-by: Claude Code:claude-opus-5-5
@BenjaminRodenberg
BenjaminRodenberg force-pushed the mpi-parallelization-mvp-matlab branch from 704d732 to 25d7e27 Compare October 21, 2026 16:04
@BenjaminRodenberg BenjaminRodenberg changed the title Mpi Parallelization MVP for Matlab Grid MPI Parallelization MVP for Matlab Grid Oct 21, 2026
@BenjaminRodenberg
BenjaminRodenberg merged commit a0815c5 into main Oct 21, 2026
34 checks passed
@BenjaminRodenberg BenjaminRodenberg mentioned this pull request Oct 21, 2026
5 of 9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant