Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Differences between MPI_Scatter and MPI_Bcast

Tags:

c++

mpi

Can anyone please explain what are the differences between MPI_Scatter and MPI_Bcast? (Beside the fact that any process can broadcast using MPI_Scatter and only root can use MPI_Bcast)

In which cases I should use the first one over the other?

like image 896
Gil Peretz Avatar asked Jan 03 '15 08:01

Gil Peretz


2 Answers

MPI_Bcast() sends the same piece of data to everyone, while MPI_Scatter() sends each process a part of the input array. MPI_Bcast() is the opposite of MPI_Reduce() and MPI_Scatter() is the opposite of MPI_Gather(). A little scheme like this one is self-explanatory.

And both MPI_Scatter() and MPI_Bcast() have an argument named int root to specify the root process.

like image 171
francis Avatar answered Sep 19 '22 17:09

francis


MPI_Bcast takes a single data element at the root process (the red box) and copies it to all other processes. MPI_Scatter takes an array of elements and distributes the elements in the order of process rank.

the illustration,

like image 20
almgwary Avatar answered Sep 19 '22 17:09

almgwary