Differences between MPI_Scatter and MPI_Bcast
Asked Answered
H

2

18

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?

Heterodox answered 3/1, 2015 at 8:48 Comment(0)
E
29

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.

Escudo answered 3/1, 2015 at 9:47 Comment(2)
While MPI_SCATTER is indeed the opposite of MPI_GATHER, I wouldn't call MPI_BCAST the opposite of MPI_REDUCE.Analgesia
Right, MPI_Reduce() can combine the pieces of data in many different ways, such as MPI_SUM or MPI_MAX and MPI_Bcast() provides the same piece of data to every process, without any operation on the way.Escudo
C
15

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,

Conquer answered 10/5, 2016 at 2:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.