Reputation: 367
In C++, an example for using MPI_Scatter is:
MPI::COMM_WORLD.Scatter(sendbuf, 100, MPI::INT, recvarr, 100,MPI::INT, root);
This scatters the contents of sendbuff
into 100 separate process to make recvarr
on each process, but ONLY in the MPI World communicator.
Unlike MPI_Scatter in C, the C++ version doesn't have an input for the communicator. How can I modify this example to work for any communicator, and not just MPI_COMM_WORLD?
For example, say my communicator is named comm
. How can I scatter sendbuff
within the comm
communicator group instead of MPI_COMM_WORLD?
Upvotes: 1
Views: 330
Reputation: 38118
comm.Scatter(sendbuf, 100, MPI::INT, recvarr, 100,MPI::INT, root);
The object to the left of the .
is the MPI communicator argument. MPI::COMM_WORLD
happens to be a pre-defined instance of an MPI communicator that corresponds to the C binding's pre-defined MPI_COMM_WORLD
Note that the MPI C++ bindings have been deleted in MPI-3.0, because they were underused, hard to maintain, and had clunky misunderstandings like this.
Upvotes: 5