MPI_COMM_SET_NAME(3)

πŸ’– MPI_COMM_SET_NAME(3) β€” Open MPI manual, bestie edition πŸ’–

okay so welcome to the Open MPI girlies' guide to naming your communicators. yes this is a real thing you can do. no cap.


✨ NAME ✨

MPI_Comm_set_name β€” associates a name with a communicator. it's giving "let me label my stuff so future me doesn't cry" energy 🏷️


🌸 SYNTAX 🌸

C Syntax

#include <mpi.h>

int MPI_Comm_set_name(MPI_Comm comm, const char *comm_name)

Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_COMM_SET_NAME(COMM, COMM_NAME, IERROR)
     INTEGER COMM, IERROR
     CHARACTER*(*) COMM_NAME

Fortran 2008 Syntax

USE mpi_f08
MPI_Comm_set_name(comm, comm_name, ierror)
     TYPE(MPI_Comm), INTENT(IN) :: comm
     CHARACTER(LEN=*), INTENT(IN) :: comm_name
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

🫢 INPUT/OUTPUT PARAMETER 🫢

  • comm β€” the communicator whose identifier is getting set (a handle). πŸ’…

πŸŽ€ INPUT PARAMETER πŸŽ€

  • comm_name β€” the character string that becomes the identifier for the communicator (a string). this is the glowed-up name bestie ✨

πŸ¦‹ OUTPUT PARAMETER πŸ¦‹

  • ierror β€” Fortran only: the error status (integer).

πŸ‘‘ DESCRIPTION πŸ‘‘

MPI_Comm_set_name lets you, a user, associate a name string with a communicator. the character string you pass to MPI_Comm_set_name gets saved inside the MPI library β€” so literally you can free it right after the call, or just allocate it on the stack, no worries, she's copied, she's safe πŸ’–

leading spaces in the name are significant, but trailing ones are not. so " hi" and "hi " are not the same vibe. sorry, that's just how it is πŸ™ˆ

MPI_Comm_set_name is a local (noncollective) operation. meaning it only affects the name of the communicator as seen in the process that actually made the MPI_Comm_set_name call. there is no requirement that the same name β€” or any name at all β€” be assigned to a communicator in every process where it exists. so like, everyone can pick their own name if they want. chaos permitted 😌

now the length limit, and this one matters: the length of the name that can be stored is limited to the value of MPI_MAX_OBJECT_NAME in Fortran, and MPI_MAX_OBJECT_NAME-1 in C (to allow for the null terminator). attempts to set names longer than this will result in truncation of the name. and MPI_MAX_OBJECT_NAME must have a value of at least 64. periodt. πŸ’…


πŸ’€ NOTES πŸ’€

since MPI_Comm_set_name is provided to help debug code, it is sensible to give the same name to a communicator in all of the processes where it exists β€” otherwise you're gonna confuse yourself and honestly? you don't deserve that. be kind to future you 🫢

regarding name length, here's the lowkey scary part: under circumstances of store exhaustion, an attempt to set a name of any length could fail. therefore, the value of MPI_MAX_OBJECT_NAME should be viewed only as a strict upper bound on the name length β€” not a guarantee that setting names of less than this length will always succeed. so like, it's a ceiling, not a promise, bestie 😭


πŸ”₯ 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. classic πŸ™ƒ

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. she's detailed, she's thorough πŸ’…

Open MPI includes three predefined error handlers that can be used:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. dramatic but valid πŸ’€
  • 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, 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.
  • MPI_ERRORS_RETURN β€” returns an error code to the application. the chill one.

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. fr fr. plan accordingly 😭

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.

see also:

  • MPI_Comm_get_name

2003-2026, The Open MPI Community


and that's the whole page, bestie!! πŸŽ€ you now know everything there is to know about naming communicators, and honestly? iconic behavior. this was the MPI_COMM_SET_NAME(3) page from the Open MPI manual, dated Sep 10, 2026 β€” love her, respect her, go name something πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from