MPI_COMM_GET_PARENT(3)

πŸ’– MPI_COMM_GET_PARENT πŸ’–

okay bestie, so this is a page from the Open MPI manual, section 3 (that's the library-functions section, iykyk). The whole thing is literally just MPI_Comm_get_parent β€” it hands you back the parent intercommunicator of whatever process you're running in right now. That's it. That's the whole vibe. πŸ¦‹


✨ SYNTAX ✨

πŸ’… C Syntax

#include <mpi.h>

int MPI_Comm_get_parent(MPI_Comm *parent)

πŸ’… Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_COMM_GET_PARENT(PARENT, IERROR)
     INTEGER PARENT, IERROR

πŸ’… Fortran 2008 Syntax

USE mpi_f08
MPI_Comm_get_parent(parent, ierror)
     TYPE(MPI_Comm), INTENT(OUT) :: parent
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

πŸŽ€ OUTPUT PARAMETERS πŸŽ€

  • parent β€” the parent communicator (handle). bestie this is the whole point of the function πŸ’–
  • ierror β€” Fortran only, it's the error status (integer).

🌸 DESCRIPTION 🌸

so like, if a process got started with MPI_Comm_spawn or MPI_Comm_spawn_multiple, then MPI_Comm_get_parent gives you back the "parent" intercommunicator of the current process. iconic. This parent intercommunicator gets created implicitly, deep inside MPI_Init β€” no cap, it just exists β€” and it's literally the same intercommunicator that the spawn call over in the parent returns. same one. twins. 🫢

if the process wasn't spawned at all? then MPI_Comm_get_parent hands you MPI_COMM_NULL. nothing. void. πŸ’€

and if the parent communicator has been freed or disconnected? yeah, MPI_Comm_get_parent returns MPI_COMM_NULL too. gone. ghosted. πŸ‘»


⭐ NOTES ⭐

MPI_Comm_get_parent returns a handle to one single intercommunicator. calling it a second time? returns a handle to the same intercommunicator. no new one, no duplicates, same girl. ✨

but heads up bestie β€” if you free that handle with MPI_Comm_disconnect or MPI_Comm_free, all the other references to that intercommunicator go invalid. dangling. like, don't use them. 😭

also in case you were wondering: calling MPI_Comm_free on the parent communicator is not useful. so like, don't bother. πŸ™ˆ


πŸ’œ ERRORS πŸ’œ

almost all MPI routines return an error value, periodt. C routines give it back as the return result of the function, and Fortran routines put it in that last argument.

before the error value comes back, the current MPI error handler associated with the communication object (think communicator, window, file) gets called. and if there's no communication object attached to the MPI call? then the call counts as attached to MPI_COMM_SELF and it calls the associated MPI error handler. when MPI_COMM_SELF isn't initialized (which means: before MPI_Init/MPI_Init_thread, after MPI_Finalize, or when you're 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 you're on the World model, or via the mpi_initial_errhandler CLI argument to mpiexec, or the info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. and if no other appropriate error handler has been set: the MPI_ERRORS_RETURN error handler gets called for MPI I/O functions, and the MPI_ERRORS_ABORT error handler gets called for all other MPI functions. slay πŸ’…

πŸ‘‘ Open MPI ships three predefined error handlers πŸ‘‘

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. everyone. gone. πŸ’€
  • MPI_ERRORS_ABORT β€” an error handler you can invoke 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, it 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, it aborts only the local process. (yes, only the local one. main character energy, lowkey.)
  • MPI_ERRORS_RETURN β€” returns an error code to the application. nice and chill. πŸ“

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
fr fr, note that MPI does not guarantee that an MPI program can continue past an error. like, that's it, that's the end of the road. 😭

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 info.

πŸ¦‹ See also πŸ¦‹

  • MPI_Comm_spawn
  • MPI_Comm_spawn_multiple

2003-2026, The Open MPI Community


okay and that's the whole page bestie, we ate and left no crumbs πŸŽ€ β€” this was MPI_COMM_GET_PARENT(3) from the Open MPI manual, dated Sep 10, 2026, copyright 2003-2026, The Open MPI Community. go spawn something. πŸ’–βœ¨πŸ«Ά

πŸ“¦ where this page comes from