Skip to content

helper: Do not always duplicate MPI_Comm on Comm construction

Created by: bradking

Through a series of commits:

  • f7fec28f (core: Refactor ADIOS factory to use Comm encapsulation, 2019-06-21, v2.5.0~66^2~35)
  • 29177b01 (engine: Construct with Comm encapsulation, 2019-06-18, v2.5.0~66^2~31)
  • 33715618 (helper: Factor out MPI-specific Comm interfaces, 2019-09-12)
  • 89891238 (core: Replace MPI with Comm in ADIOS, IO, and Stream interfaces, 2019-10-07)

we converted the core::ADIOS constructor from taking a MPI_Comm and calling MPI_Comm_dup internally to taking an instance of helper::Comm by value, typically moved from an instance created by helper::CommFromMPI. Therefore helper::CommFromMPI calls MPI_Comm_dup to preserve the existing semantics.

However, two commits introduced uses of helper::CommFromMPI in places that did not previously use MPI_Comm_dup:

  • 554a756f (utils: Port adios_reorganize to Comm encapsulation, 2019-09-19)
  • 1ec1ec43 (sst: Re-implement SMPI_ interfaces as C wrappers of Comm encapsulation, 2020-02-11)

The calls updated by those commits are intend to create a helper::Comm that uses MPI_COMM_WORLD without duplicating it.

In order to distinguish the cases that duplicate from those that do not, replace helper::CommFromMPI with two variants:

  • helper::CommDupMPI to duplicate the given MPI_Comm
  • helper::CommWithMPI to take ownership of the given MPI_Comm

Update all the call sites to use the variant with appropriate semantics.

Fixes: #2008 (closed)

Merge request reports

Loading