103. Example using MPI_ALLGATHER

PreviousUpNext
Up: Gather-to-all Next: All-to-All Scatter/Gather Previous: Gather-to-all

The example in this section uses intracommunicators.


Example The all-gather version of Example Examples using MPI_GATHER, MPI_GATHERV . Using MPI_ALLGATHER, we will gather 100 ints from every process in the group to every process.


    MPI_Comm comm; 
    int gsize,sendarray[100]; 
    int *rbuf; 
    ... 
    MPI_Comm_size(comm, &gsize); 
    rbuf = (int *)malloc(gsize*100*sizeof(int)); 
    MPI_Allgather(sendarray, 100, MPI_INT, rbuf, 100, MPI_INT, comm); 
After the call, every process has the group-wide concatenation of the sets of data.


PreviousUpNext
Up: Gather-to-all Next: All-to-All Scatter/Gather Previous: Gather-to-all


Return to MPI-3.1 Standard Index
Return to MPI Forum Home Page

(Unofficial) MPI-3.1 of June 4, 2015
HTML Generated on June 4, 2015