Skip to content

Add parallel example for HDF5 on an MPI_Comm_split sub-communicator - #6646

Merged
brtnfld merged 1 commit into
HDFGroup:developfrom
brtnfld:add-ph5-comm-split-example
Sep 1, 2026
Merged

brtnfld merged 1 commit into
HDFGroup:developfrom
brtnfld:add-ph5-comm-split-example

Conversation

@brtnfld

@brtnfld brtnfld commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

Adds HDF5Examples/C/H5PAR/ph5_comm_split.c, an example of using parallel
HDF5 on a communicator produced by MPI_Comm_split rather than on
MPI_COMM_WORLD.

Applications often divide MPI_COMM_WORLD into groups that do different
work, where only some of those groups touch the HDF5 file. None of the
existing H5PAR examples show that arrangement; they all open the file on
MPI_COMM_WORLD.

Adds HDF5Examples/C/H5PAR/ph5_comm_split.c, showing parallel HDF5 use on a
communicator produced by MPI_Comm_split rather than on MPI_COMM_WORLD.

The example splits MPI_COMM_WORLD by rank parity. The even ranks form a
writer group that collectively creates a dataset with one row per writer
rank, then reopens the file read-only on the same sub-communicator and
verifies what it wrote. The odd ranks stand in for a group with other
responsibilities and make no HDF5 calls at all.

The comments cover the two rules this pattern depends on: MPI_Comm_split is
collective over the parent communicator, so every rank must call it even if
it never opens the file; and once a file is opened with a FAPL carrying a
sub-communicator, every collective HDF5 call on that file is collective over
that sub-communicator alone.

The example runs with any number of MPI ranks.
@github-actions

github-actions Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Review Checklist

This PR touches the following areas. Each needs a sign-off
from its listed owners before merging.

✅ All areas have been signed off.

@hyoklee hyoklee added this to the Backlog milestone Aug 28, 2026
* communicator must match the set of ranks that will make the
* collective calls on the reopened file.
*/
fapl_id = make_fapl(sub_comm);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Strictly speaking this shouldn't ever be necessary, but it's also not a terrible idea.

@brtnfld
brtnfld merged commit 9b77f78 into HDFGroup:develop Sep 1, 2026
131 of 133 checks passed
@github-project-automation github-project-automation Bot moved this from In progress to Done in HDF5 - TRIAGE & TRACK Sep 1, 2026
@brtnfld
brtnfld deleted the add-ph5-comm-split-example branch September 1, 2026 20:13
brtnfld added a commit that referenced this pull request Sep 12, 2026
…6646)

Adds HDF5Examples/C/H5PAR/ph5_comm_split.c, showing parallel HDF5 use on a
communicator produced by MPI_Comm_split rather than on MPI_COMM_WORLD.

The example splits MPI_COMM_WORLD by rank parity. The even ranks form a
writer group that collectively creates a dataset with one row per writer
rank, then reopens the file read-only on the same sub-communicator and
verifies what it wrote. The odd ranks stand in for a group with other
responsibilities and make no HDF5 calls at all.

The comments cover the two rules this pattern depends on: MPI_Comm_split is
collective over the parent communicator, so every rank must call it even if
it never opens the file; and once a file is opened with a FAPL carrying a
sub-communicator, every collective HDF5 call on that file is collective over
that sub-communicator alone.

The example runs with any number of MPI ranks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants