Purpose
Broadcasts a message from root to all tasks in comm.
C synopsis
#include <mpi.h> int MPI_Bcast(void* buffer, int count, MPI_Datatype datatype, int root, MPI_Comm comm);
C++ synopsis
#include mpi.h void MPI::Comm::Bcast(void* buffer, int count, const MPI::Datatype& datatype, int root) const;
FORTRAN synopsis
include 'mpif.h' or use mpi MPI_BCAST(CHOICE BUFFER,INTEGER COUNT,INTEGER DATATYPE,INTEGER ROOT, INTEGER COMM,INTEGER IERROR)
Parameters
Description
This subroutine broadcasts a message from root to all tasks in comm. The contents of root's communication buffer are copied to all tasks on return.
The type signature of count, datatype on any task must be equal to the type signature of count, datatype at the root. This means the amount of data sent must be equal to the amount of data received, pair wise between each task and the root. Distinct type maps between sender and receiver are allowed.
If comm is an intercommunicator, the call involves all tasks in the intercommunicator, but with one group (group A) defining the root task. All tasks in the other group (group B) pass the same value in root, which is the rank of the root in group A. The root passes the value MPI_ROOT in root. All other tasks in group A pass the value MPI_PROC_NULL in root. Data is broadcast from the root to all tasks in group B. The receive buffer arguments of the tasks in group B must be consistent with the send buffer argument of the root.
When you use this subroutine in a threads application, make sure all collective operations on a particular communicator occur in the same order at each task. See IBM Parallel Environment for AIX: MPI Programming Guide for more information on programming with MPI in a threads environment.
Errors
Fatal errors:
For an intracommunicator: root < 0 or root >= groupsize
For an intercommunicator: root < 0 and is neither MPI_ROOT nor MPI_PROC_NULL, or root >= groupsize of the remote group
Develop mode error if:
Related information