The examples in this section use intracommunicators.
** Example**
The reverse of Example Examples using MPI_GATHER, MPI_GATHERV
.
Scatter sets of 100 ` int`s from the root to each process in the group.
See Figure 9
.

MPI_Comm comm; int gsize,*sendbuf; int root, rbuf[100]; ... MPI_Comm_size( comm, &gsize); sendbuf = (int *)malloc(gsize*100*sizeof(int)); ... MPI_Scatter( sendbuf, 100, MPI_INT, rbuf, 100, MPI_INT, root, comm);

**Figure 9: **The root process scatters sets of 100 ` int`s to each process
in the group.

** Example**
The reverse of Example Examples using MPI_GATHER, MPI_GATHERV
.
The root process scatters sets of 100 ` int`s to the other processes,
but the sets of 100 are * stride int*s apart in the sending buffer.
Requires use of MPI_SCATTERV.
Assume
. See Figure 10
.

MPI_Comm comm; int gsize,*sendbuf; int root, rbuf[100], i, *displs, *scounts; ... MPI_Comm_size( comm, &gsize); sendbuf = (int *)malloc(gsize*stride*sizeof(int)); ... displs = (int *)malloc(gsize*sizeof(int)); scounts = (int *)malloc(gsize*sizeof(int)); for (i=0; i<gsize; ++i) { displs[i] = i*stride; scounts[i] = 100; } MPI_Scatterv( sendbuf, scounts, displs, MPI_INT, rbuf, 100, MPI_INT, root, comm);

**Figure 10: **The root process scatters sets of 100 ` int`s, moving by
` stride int`s from send to send in the scatter.

** Example**
The reverse of Example Examples using MPI_GATHER, MPI_GATHERV
.
We have a varying stride between blocks at sending (root) side,
at the receiving side we receive into the ` i`-th column of a 100*×*150
C array.
See Figure 11
.

Return to MPI-2.2 Standard Index

Return to MPI Forum Home Page

(Unofficial) MPI-2.2 of September 4, 2009

HTML Generated on September 10, 2009