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?
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.
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.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With