MPI_IBCAST(3)
π MPI_IBCAST(3) π
omg hi bestie!! welcome to the Open MPI manual page for MPI_Bcast and MPI_Ibcast β the broadcast besties. β¨ no cap, this is the one where the process with rank root sends the message to everyone else in the group, and yes, root is main character energy. π
πΈ NAME πΈ
MPI_Bcast, MPI_Ibcast β broadcasts a message from the process with rank root to all other processes of the group.
β¨ SYNTAX β¨
okay so pick your language era, bestie:
π§ C Syntax π§
#include <mpi.h>
int MPI_Bcast(void *buffer, int count, MPI_Datatype datatype,
int root, MPI_Comm comm)
int MPI_Ibcast(void *buffer, int count, MPI_Datatype datatype,
int root, MPI_Comm comm, MPI_Request *request)
π§Έ Fortran Syntax π§Έ
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_BCAST(BUFFER, COUNT, DATATYPE, ROOT, COMM, IERROR)
<type> BUFFER(*)
INTEGER COUNT, DATATYPE, ROOT, COMM, IERROR
MPI_IBCAST(BUFFER, COUNT, DATATYPE, ROOT, COMM, REQUEST, IERROR)
<type> BUFFER(*)
INTEGER COUNT, DATATYPE, ROOT, COMM, REQUEST, IERROR
π¦ Fortran 2008 Syntax π¦
USE mpi_f08
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_Ibcast(buffer, count, datatype, root, comm, request, ierror)
TYPE(*), DIMENSION(..), ASYNCHRONOUS :: buffer
INTEGER, INTENT(IN) :: count, root
TYPE(MPI_Datatype), INTENT(IN) :: datatype
TYPE(MPI_Comm), INTENT(IN) :: comm
TYPE(MPI_Request), INTENT(OUT) :: request
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
π§Έ INPUT/OUTPUT PARAMETERS π§Έ
bufferβ starting address of buffer (choice). πcountβ number of entries in buffer (integer). π’datatypeβ data type of buffer (handle). π·οΈrootβ rank of broadcast root (integer). πcommβ communicator (handle). π‘
π OUTPUT PARAMETERS π
requestβ request (handle, non-blocking only). π¨ierrorβ Fortran only: error status (integer). π§Ύ
π DESCRIPTION π
okay so here's the tea: MPI_Bcast broadcasts a message from the process with rank root to all processes of the group, itself included. it is called by all members of the group using the same arguments for comm, root. on return, the contents of rootβs communication buffer has been copied to all processes. periodt. π
general, derived datatypes are allowed for datatype. the type signature of count, datatype on any 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 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. slay, but make it type-safe. β¨
example: broadcast 100 ints from process 0 to every process in the group.
MPI_Comm comm;
int array[100];
int root=0;
//...
MPI_Bcast( array, 100, MPI_INT, root, comm);
as in many of our sample code fragments, we assume that some of the variables (such as comm in the example above) have been assigned appropriate values. iykyk. π«Ά
π¦ WHEN COMMUNICATOR IS AN INTER-COMMUNICATOR π¦
okay bestie, inter-communicator plot twist: when the communicator is an inter-communicator, the root process in the first group broadcasts data to all the processes in the second group. the first group defines the root process. that process uses MPI_ROOT as the value of its root argument. the remaining processes use MPI_PROC_NULL as the value of their root argument. all processes in the second group use the rank of that root process in the first group as the value of their root argument. the receive buffer arguments of the processes in the second group must be consistent with the send buffer argument of the root process in the first group. the way that this is so specific β obsessed. π
β NOTES β
β οΈ this function does not support the in-place option. not me looking for the in-place option and finding out it's not here π
π ERRORS π
almost all MPI routines return an error value; C routines as the return result of the function and Fortran routines in the last argument. literally the classic MPI vibe check. π§Ύ
before the error value is returned, the current MPI error handler associated with the communication object (e.g., communicator, window, file) is called. if no communication object is associated with the MPI call, then the call is considered attached to MPI_COMM_SELF and will call the associated MPI error handler. when MPI_COMM_SELF is not initialized (i.e., before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when using the Sessions Model exclusively) the error raises the initial error handler. the initial error handler can be changed by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using the World model, or the mpi_initial_errhandler CLI argument to mpiexec or info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. if no other appropriate error handler has been set, then the MPI_ERRORS_RETURN error handler is called for MPI I/O functions and the MPI_ERRORS_ABORT error handler is called for all other MPI functions. fr fr, that's the whole chain. π₯
Open MPI includes three predefined error handlers that can be used:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. πMPI_ERRORS_ABORTβ an error handler that can be invoked on a communicator, window, file, or session. when called on a communicator, it acts as ifMPI_Abortwas called on that communicator. if called on a window or file, acts as ifMPI_Abortwas called on a communicator containing the group of processes in the corresponding window or file. if called on a session, aborts only the local process. πMPI_ERRORS_RETURNβ returns an error code to the application. π¬
MPI applications can also implement their own error handlers by calling:
MPI_Comm_create_errhandlerthenMPI_Comm_set_errhandlerπ οΈMPI_File_create_errhandlerthenMPI_File_set_errhandlerποΈMPI_Session_create_errhandlerthenMPI_Session_set_errhandleror atMPI_Session_initπ§MPI_Win_create_errhandlerthenMPI_Win_set_errhandlerπͺ
β οΈ note that MPI does not guarantee that an MPI program can continue past an error. highkey important, bestie.
see the MPI man page for a full list of MPI error codes. see the Error Handling section of the MPI-3.1 standard for more information. π
π COPYRIGHT π
2003-2026, The Open MPI Community π
xoxo, your Open MPI bestie π β page date: Sep 11, 2026 β¨
π¦ where this page comes from
- arch rolling: openmpi 5.0.11-1 Β· BSD-3-Clause AND LicenseRef-MPICH
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms