mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-26 13:50:33 +05:00
subcomms
This commit is contained in:
parent
bab9d41b1b
commit
8a165ef8f1
@ -3,6 +3,7 @@
|
|||||||
#include <pybind11/pybind11.h>
|
#include <pybind11/pybind11.h>
|
||||||
#include <pybind11/operators.h>
|
#include <pybind11/operators.h>
|
||||||
#include <pybind11/numpy.h>
|
#include <pybind11/numpy.h>
|
||||||
|
#include <pybind11/stl.h>
|
||||||
namespace py = pybind11;
|
namespace py = pybind11;
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -954,13 +954,12 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
|||||||
.def("Sum", [](PyMPI_Comm & c, size_t x) { return MyMPI_AllReduceNG(x, MPI_SUM, c.comm); })
|
.def("Sum", [](PyMPI_Comm & c, size_t x) { return MyMPI_AllReduceNG(x, MPI_SUM, c.comm); })
|
||||||
.def("Min", [](PyMPI_Comm & c, size_t x) { return MyMPI_AllReduceNG(x, MPI_MIN, c.comm); })
|
.def("Min", [](PyMPI_Comm & c, size_t x) { return MyMPI_AllReduceNG(x, MPI_MIN, c.comm); })
|
||||||
.def("Max", [](PyMPI_Comm & c, size_t x) { return MyMPI_AllReduceNG(x, MPI_MAX, c.comm); })
|
.def("Max", [](PyMPI_Comm & c, size_t x) { return MyMPI_AllReduceNG(x, MPI_MAX, c.comm); })
|
||||||
.def("SubComm", [](PyMPI_Comm & c, py::list proc_list) {
|
.def("SubComm", [](PyMPI_Comm & c, std::vector<int> proc_list) {
|
||||||
Array<int> procs(py::len(proc_list));
|
Array<int> procs(proc_list.size());
|
||||||
for (int i = 0; i < procs.Size(); i++)
|
for (int i = 0; i < procs.Size(); i++)
|
||||||
procs[i] = py::extract<int>(proc_list[i])();
|
procs[i] = proc_list[i];
|
||||||
if (!procs.Size())
|
if (!procs.Contains(c.Rank()))
|
||||||
return make_shared<PyMPI_Comm>(MPI_COMM_NULL);
|
throw Exception("rank "+ToString(c.Rank())+" not in subcomm");
|
||||||
|
|
||||||
MPI_Comm subcomm = MyMPI_SubCommunicator(c.comm, procs);
|
MPI_Comm subcomm = MyMPI_SubCommunicator(c.comm, procs);
|
||||||
return make_shared<PyMPI_Comm>(subcomm, true);
|
return make_shared<PyMPI_Comm>(subcomm, true);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user