How does MPI_IN_PLACE work with MPI_Scatter?

What exactly does it do MPI_IN_PLACEwhen given as an argument MPI_Scatterand how to use it? I can not understand man MPI_Scatter:

When the communicator is an internal communicator, you can perform a collection operation in place (the output buffer is used as the input buffer). Use the variable MPI_IN_PLACE as the value of the recvbuf root process. In this case, recvcount and recvtype are ignored, and the root process does not send data to itself. Because the in-place option converts the receive buffer into a send and receive buffer, Fortran bindings that include INTENT should mark them as INOUT, not OUT.

What I want to do is use the same buffer that contains the root data as the receive buffer for every other process (for example, in MPI_Bcast). Would MPI_Scatterusing MPI_IN_PLACEdo it?

+4
source share
1 answer

Sendbuf MPI_scatter is only relevant for the root according to mpich ,

sendbuf - send buffer address (selection significant only in the root directory)

From this discussion,

For scatter / scatter, MPI_IN_PLACE must be passed as recvbuf. For collection and most other collectives, MPI_IN_PLACE must be passed as sendbuf.

, MPI_IN_PLACE recv , .

if (rank == iroot)
     MPI_Scatter(buf, sendcount, MPI_Datatype, MPI_IN_PLACE, sendcount,  
                 MPI_Datatype, iroot, MPI_COMM_WORLD);
else
     MPI_Scatter(dummy, sendcount, MPI_Datatype, buf, sendcount, MPI_Datatype,  
                 iroot, MPI_COMM_WORLD);

buf buf recv . dummy MPI_IN_PLACE.

+3

All Articles