Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MPI_Bcast: Efficiency advantages?

In MPI, is MPI_Bcast purely a convenience function or is there an efficiency advantage to using it instead of just looping over all ranks and sending the same message to all of them?

Rationale: MPI_Bcast's behavior of sending the message to everyone, including the root, is inconvenient for me, so I'd rather not use it unless there's a good reason, or it can be made to not send the message to root.

like image 293
dsimcha Avatar asked Aug 05 '11 16:08

dsimcha


2 Answers

Using MPI_Bcast will definitely be more efficient than rolling your own. A lot of work has been done in all MPI implementations to optimise collective operations based on factors such as the message size and the communication architecture.

For example, MPI_Bcast in MPICH2 would use a different algorithm depending on the size of the message. For short messages, a binary tree is used to minimise processing load and latency. For long messages, it is implemented as a binary tree scatter followed by an allgather.

In addition, HPC vendors often provide MPI implementations that make efficient use of the underlying interconnects, especially for collective operations. For example, it is possible to use a hardware supported multicast scheme or to use bespoke algorithms that can take advantage of the existing interconnects.

like image 59
Shawn Chin Avatar answered Sep 25 '22 18:09

Shawn Chin


The collective communications can be much faster than rolling your own. All of the MPI implmementations spend a lot of time working on those routines to be fast.

If you routinely want to do collective-type things but only on a subset of tasks, then you probably want to create your own sub-communicators and use BCAST, etc on those communicators.

like image 24
Jonathan Dursi Avatar answered Sep 25 '22 18:09

Jonathan Dursi