Skip to content

[WIP] Unified MPI for C / SST

Podhorszki, Norbert requested to merge github/fork/germasch/pr/unified_mpi into master

Created by: germasch

So maybe this should have been part of the previous PR #1466, because it turned out I had to change the SMPI_ wrappers are generated a bit to make this all work from C as well...

This PR adds MPI wrapping support for plain C, and uses it in SST, both to get rid of sstmpidummy.h and to make SST work serially on a parallel build with MPI_Init.

I add some comments, too:

// Overview of the MPI wrapping:
// =============================
//
// Including this header provides a unified way of dealing with the
// building against an actual MPI library (ADIOS2_HAVE_MPI) vs using
// a dummy implementation, and also deals with running serially
// when built against MPI, but not calling MPI_Init
//
// MPI types / constants
// ---------------------
//
// If ADIOS2_HAVE_MPI is defined, the actual MPI types (in particular MPI_Comm)
// from the real MPI are always used, even in the dummy implementations that are
// used when MPI hasn't been initialized.
// Otherwise, the definitions from mpidummy.h are used. These types are in the
// global namespace.
//
// MPI_* functions
// -------------
//
// The usual MPI functions are always defined in the global namespace (extern
// "C"). If ADIOS2_HAVE_MPI is defined, the declarations come from mpi.h.
// Otherwise, these functions are declared in mpidummy.h, also extern "C".
//
// If ADIOS2_HAVE_MPI is defined, the declarations in mpidummy.h are put into
// adios2::helper::mpidummy in order to not interfere with the extern "C" ones,
// but this way they are still available to use in the SMPI_* wrappers
//
// SMPI_* wrappers
// ---------------
// The SMPI wrappers provide a way to write code that works in all three of the
// following cases:
// - If ADIOS2_HAVE_MPI is undefined, these wrappers call the corresponding
//   extern "C" MPI functions, which in this case are the mpidummy
//   implementations.
// - If ADIOS2_HAVE_MPI is defined, and MPI has been initialized, these wrappers
//   call the corresponding extern "C" MPI functions, which in this case are the
//   real MPI implementations.
// - If ADIOS2_HAVE_MPI is defined, and MPI has not been initialized, these wrappers
//   call the corresponding adios2::helper::mpidummy MPI functions, which are
//   serial only but don't require the real MPI to be initialized.

I guess I can't request reviewers, so I'll just mention @pnorbert @eisenhauer @williamfgc .

Merge request reports