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 if MPI_Abort was called on that communicator. if called on a window or file, acts as if MPI_Abort was 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_errhandler then MPI_Comm_set_errhandler πŸ› οΈ
  • MPI_File_create_errhandler then MPI_File_set_errhandler πŸ—‚οΈ
  • MPI_Session_create_errhandler then MPI_Session_set_errhandler or at MPI_Session_init 🧚
  • MPI_Win_create_errhandler then MPI_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. πŸ“š

2003-2026, The Open MPI Community πŸ’–

xoxo, your Open MPI bestie πŸ’… β€” page date: Sep 11, 2026 ✨

πŸ“¦ where this page comes from