MPI_Scatter 和 MPI_Bcast 之间的差异

Differences between MPI_Scatter and MPI_Bcast

谁能解释一下 MPI_ScatterMPI_Bcast 之间的区别是什么? (除此之外,任何进程都可以使用 MPI_Scatter 进行广播并且只有 root 可以使用 MPI_Bcast

在哪些情况下我应该使用第一个而不是另一个?

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 不言自明。

并且 MPI_Scatter()MPI_Bcast() 都有一个名为 int root 的参数来指定根进程。

MPI_Bcast 在根进程(红框)中获取单个数据元素并将其复制到所有其他进程。 MPI_Scatter 获取一个元素数组,并按照进程等级的顺序分布元素。