MPI Broadcast
Broadcast sends one process's data to every other process in the communicator in a single coordinated operation.
The operation
MPI_Bcast distributes a buffer from a designated root process to all other ranks. After the call, every process holds an identical copy. It is the canonical way to disseminate configuration, initial conditions, lookup tables, or model parameters that were read or computed on a single rank.
How it is implemented
A naive broadcast has the root send to each of the P-1 others in turn, costing O(P) time. Real implementations use a binomial tree: in step k, every process that already has the data sends it to a partner that does not, doubling the number of holders each step. This finishes in ceil(log2 P) steps. For very large buffers, a pipelined or scatter-then-allgather scheme splits the message into segments so links stay busy and the cost approaches the bandwidth limit rather than the latency-times-log-P limit.
- Small messages: latency dominates, so minimize step count with a tree.
- Large messages: bandwidth dominates, so pipeline segments through the tree.
- The root is an argument, not necessarily rank 0.
- Every rank must call MPI_Bcast, not only the root.
Common mistakes
A frequent bug is having only the root call the broadcast; all ranks must call it. Another is assuming the buffer on non-root ranks holds valid data before the call returns. A third is broadcasting large read-only tables repeatedly inside a loop when they could be sent once outside it.
from mpi4py import MPI
comm = MPI.COMM_WORLD
if comm.Get_rank() == 0:
params = {'timestep': 1e-6, 'tbr_target': 1.8}
else:
params = None
params = comm.bcast(params, root=0)
# all ranks now share the same params dict
In practice
When a Hyperion simulation reads a magnetic equilibrium or material cross-section table on rank 0, a broadcast pushes it to the whole job. Doing this once at startup, rather than re-reading from the file system on every rank, avoids hammering the parallel file system with thousands of identical reads.