Tutorial by Examples

The following code broadcasts the contents in buffer among all the processes belonging to the MPI_COMM_WORLD communicator (i.e. all the processes running in parallel) using the MPI_Bcast operation. int rank; int res; res = MPI_Comm_rank (MPI_COMM_WORLD, &rank); if (res != MPI_SUCCESS) { ...
The MPI_Barrier operation performs a synchronization among the processes belonging to the given communicator. That is, all the processes from a given communicator will wait within the MPI_Barrier until all of them are inside, and at that point, they will leave the operation. int res; res = MPI_B...
The root process scatters the contents in sendbuf to all processes (including itself) using the MPI_Scatter operation. int rank; int size; int sendcount = 1; int recvcount = sendcount; int sendbuf[3]; int recvbuf; int root = 0; MPI_Comm_size (MPI_COMM_WORLD, &size); if (size != 3) ...

Page 1 of 1