Skip to content
Snippets Groups Projects
Commit aac2545c authored by Dmitriy Morozov's avatar Dmitriy Morozov
Browse files

Make PyMPIComm = diy::mpi::communicator

parent 81d28770
No related branches found
No related tags found
No related merge requests found
......@@ -4,27 +4,17 @@ namespace py = pybind11;
#include <mpi.h>
struct PyMPIComm
{
PyMPIComm(MPI_Comm comm_ = MPI_COMM_WORLD):
comm(comm_)
{
MPI_Comm_size(comm, &size);
MPI_Comm_rank(comm, &rank);
}
MPI_Comm comm;
int size;
int rank;
};
#include <diy/mpi/communicator.hpp>
void init_mpi(py::module& m)
{
using PyMPIComm = diy::mpi::communicator;
py::class_<PyMPIComm>(m, "MPIComm")
.def(py::init<>())
.def_readonly("size", &PyMPIComm::size)
.def_readonly("rank", &PyMPIComm::rank)
.def("comm", [](const PyMPIComm& comm) { return (long) &comm.comm; })
.def_property_readonly("size", &PyMPIComm::size)
.def_property_readonly("rank", &PyMPIComm::rank)
.def_property_readonly("comm", &PyMPIComm::handle)
;
m.def("init", []() { int argc = 0; char** argv = 0; MPI_Init(&argc, &argv); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment