7.4. Broadcast

PreviousUpNext
Up: Collective Communication Next: Example using MPI_BCAST Previous: Barrier Synchronization

MPI_BCAST(buffer, count, datatype, root, comm)
INOUT bufferstarting address of buffer (choice)
IN countnumber of entries in buffer (non-negative integer)
IN datatypedatatype of buffer (handle)
IN rootrank of the root (integer)
IN commcommunicator (handle)
C binding
int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm)
int MPI_Bcast_c(void *buffer, MPI_Count count, MPI_Datatype datatype, int root, MPI_Comm comm)
Fortran 2008 binding
MPI_Bcast(buffer, count, datatype, root, comm, ierror)

TYPE(*), DIMENSION(..) :: buffer
INTEGER, INTENT(IN) :: count, root
TYPE(MPI_Datatype), INTENT(IN) :: datatype
TYPE(MPI_Comm), INTENT(IN) :: comm
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
MPI_Bcast(buffer, count, datatype, root, comm, ierror) !(_c)

TYPE(*), DIMENSION(..) :: buffer
INTEGER(KIND=MPI_COUNT_KIND), INTENT(IN) :: count
TYPE(MPI_Datatype), INTENT(IN) :: datatype
INTEGER, INTENT(IN) :: root
TYPE(MPI_Comm), INTENT(IN) :: comm
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
Fortran binding
MPI_BCAST(BUFFER, COUNT, DATATYPE, ROOT, COMM, IERROR)

<type> BUFFER(*)
INTEGER COUNT, DATATYPE, ROOT, COMM, IERROR

If comm is an intra-communicator, MPI_BCAST broadcasts a message from the MPI process with rank root to all MPI processes of the group, itself included. It is called by all members of the group using the same arguments for comm and root. On return, the content of the root's buffer is copied to all other MPI processes.

General, derived datatypes are allowed for datatype. The type signature of count, datatype on any MPI process must be equal to the type signature of count, datatype at the root. This implies that the amount of data sent must be equal to the amount received, pairwise between each MPI process and the root. MPI_BCAST and all other data-movement collective routines make this restriction. Distinct type maps between sender and receiver are still allowed.

The ``in place'' option is not meaningful here.

If comm is an inter-communicator, then the call involves all MPI processes in the inter-communicator, but with one group (group A) defining the root. All MPI processes in the other group (group B) pass the same value in argument root, which is the rank of the root in group A. The root passes the value MPI_ROOT in root. All other MPI processes in group A pass the value MPI_PROC_NULL in root. Data is broadcast from the root to all MPI processes in group B. The buffer arguments of the MPI processes in group B must be consistent with the buffer argument of the root.


PreviousUpNext
Up: Collective Communication Next: Example using MPI_BCAST Previous: Barrier Synchronization


Return to MPI-4.1 Standard Index
Return to MPI Forum Home Page

(Unofficial) MPI-4.1 of November 2, 2023
HTML Generated on November 19, 2023