7.7.1. Example using MPI_ALLGATHER

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

The example in this section uses intra-communicators.


Example The all-gather version of Example Examples using MPI_GATHER and MPI_GATHERV. Using MPI_ALLGATHER, we will gather 100 ints from every MPI process in the group to every MPI 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 MPI process has the group-wide concatenation of the sets of data.


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


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

(Unofficial) MPI-5.0 of June 9, 2025
HTML Generated on March 2, 2025