Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bindings: Help C++11 clients avoid calling serial constructor with MPI_Comm #2434

Merged
merged 2 commits into from
Aug 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions bindings/CXX11/adios2/cxx11/ADIOS.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,20 @@ class ADIOS
*/
ADIOS(const std::string &configFile, MPI_Comm comm,
const bool debugMode = true);
#else
// Client code that does not enable ADIOS2_USE_MPI may accidentally
// try to pass a MPI_Comm instance to our constructor. If the type
// the MPI library uses to implement MPI_Comm happens to be convertible
// to one of the types offered by our serial constructors (e.g. 'bool'),
// the invocation will appear to succeed but will ignore the
// communicator passed. Add explicitly deleted constructors that have
// better conversions for common MPI_Comm types.

// openmpi uses 'ompi_communicator_t*' for MPI_Comm
ADIOS(void *define_ADIOS2_USE_MPI_to_use_MPI_constructor) = delete;

// mpich uses 'int' for MPI_Comm
ADIOS(int define_ADIOS2_USE_MPI_to_use_MPI_constructor) = delete;
#endif

/**
Expand Down
5 changes: 4 additions & 1 deletion examples/hello/sstWriter/helloSstWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ int main(int argc, char *argv[])
#else
rank = 0;
size = 1;
#define MPI_COMM_WORLD 0
#endif

std::vector<float> myFloats = {
Expand All @@ -42,7 +41,11 @@ int main(int argc, char *argv[])

try
{
#if ADIOS2_USE_MPI
adios2::ADIOS adios(MPI_COMM_WORLD);
#else
adios2::ADIOS adios;
#endif
adios2::IO sstIO = adios.DeclareIO("myIO");
sstIO.SetEngine("Sst");

Expand Down