Skip to content

Commit

Permalink
bindings: Fix Python serial program init when ADIOS2 has MPI enabled
Browse files Browse the repository at this point in the history
The one-argument `adios2.ADIOS(...)` constructor has two overloads
when MPI is enabled: `ADIOS(bool)` and `ADIOS(MPI4PY_Comm)`.  The
representation of `MPI4PY_Comm` is just an integer, so a call with
a `bool` may try to convert it (and fail).  Re-order the pybind11
definitions of these signatures so that the `ADIOS(bool)` is tried
first.  That way a call with a `bool` will use it and a call with
a `MPI4PY_Comm` will not convert and fall back to the proper variant.

Fixes: #2233
  • Loading branch information
bradking committed May 15, 2020
1 parent 278530d commit ab730bb
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions bindings/Python/py11glue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,15 @@ PYBIND11_MODULE(ADIOS2_PYTHON_MODULE_NAME, m)
const bool opBool = adios ? true : false;
return opBool;
})
.def(pybind11::init<const bool>(),
"adios2 module starting point "
"non-MPI, constructs an ADIOS class "
"object",
pybind11::arg("debugMode") = true)
.def(pybind11::init<const std::string &, const bool>(),
"adios2 module starting point non-MPI, constructs an ADIOS class "
"object",
pybind11::arg("configFile"), pybind11::arg("debugMode") = true)
#if ADIOS2_USE_MPI
.def(pybind11::init<const adios2::py11::MPI4PY_Comm, const bool>(),
"adios2 module starting point, constructs an ADIOS class object",
Expand All @@ -239,15 +248,6 @@ PYBIND11_MODULE(ADIOS2_PYTHON_MODULE_NAME, m)
pybind11::arg("configFile"), pybind11::arg("comm"),
pybind11::arg("debugMode") = true)
#endif
.def(pybind11::init<const bool>(),
"adios2 module starting point "
"non-MPI, constructs an ADIOS class "
"object",
pybind11::arg("debugMode") = true)
.def(pybind11::init<const std::string &, const bool>(),
"adios2 module starting point non-MPI, constructs an ADIOS class "
"object",
pybind11::arg("configFile"), pybind11::arg("debugMode") = true)
.def("DeclareIO", &adios2::py11::ADIOS::DeclareIO,
"spawn IO object component returning a IO object with a unique "
"name, throws an exception if IO with the same name is declared "
Expand Down

0 comments on commit ab730bb

Please sign in to comment.