MPI_COMM_DELETE_ATTR(3)

πŸ’– MPI_COMM_DELETE_ATTR πŸ’–

okay bestie, so this one is from the Open MPI manual, section 3 (that's the library-calls girlies, not the commands). Let's get into it 🫢

✨ NAME ✨

MPI_Comm_delete_attr β€” literally deletes the attribute value that's associated with a key. bye bye attribute πŸ’…


✨ SYNTAX ✨

🌸 C Syntax 🌸

#include <mpi.h>

int MPI_Comm_delete_attr(MPI_Comm comm, int comm_keyval)

🌸 Fortran Syntax 🌸

USE MPI
! or the older form: INCLUDE 'mpif.h'

MPI_COMM_DELETE_ATTR(COMM, COMM_KEYVAL, IERROR)
    INTEGER COMM, COMM_KEYVAL, IERROR

🌸 Fortran 2008 Syntax 🌸

USE mpi_f08

MPI_Comm_delete_attr(comm, comm_keyval, ierror)
    TYPE(MPI_Comm), INTENT(IN) :: comm
    INTEGER, INTENT(IN) :: comm_keyval
    INTEGER, OPTIONAL, INTENT(OUT) :: ierror

✨ PARAMETERS ✨

🌈 INPUT/OUTPUT PARAMETER 🌈

  • comm β€” the communicator you're deleting the attribute from (it's a handle, bestie).

🌈 INPUT PARAMETER 🌈

  • comm_keyval β€” the key value, and it's an integer.

🌈 OUTPUT PARAMETER 🌈

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

✨ DESCRIPTION ✨

So MPI_Comm_delete_attr deletes an attribute out of the cache, by key. ✨ And here's the part that matters: this function invokes the attribute delete function delete_fn that you specified back when the comm_keyval was created. And if that delete_fn returns an error code that isn't MPI_SUCCESS? The call fails. no cap 😭

Whenever a communicator gets replicated using MPI_Comm_dup, all the callback copy functions for attributes that are currently set get invoked (in arbitrary order, so don't come for the ordering, it's not promised). And whenever a communicator is deleted using MPI_Comm_free, all the callback delete functions for attributes that are currently set get invoked.

This function is the same as MPI_Attr_delete, but it's needed so everything matches the communicator-specific functions that the MPI-2 standard introduced. Also: using MPI_Attr_delete is deprecated, so pls don't πŸ‘‘ The MPI_Attr_delete of it all is giving 2002, periodt.


✨ NOTES ✨

Heads up bestie: the MPI standard does not define what happens if the delete_fn callback invokes other MPI functions. Undefined behaviour, truly iconic in a terrifying way πŸ’€

In Open MPI specifically, it is not valid for delete_fn callbacks (or any of their children) to add or delete attributes on the same object that the delete_fn callback is being invoked on. just don't 🚫


✨ ERRORS ✨

Almost all MPI routines return an error value. C routines give it back as the return result of the function, Fortran routines put it in the last argument. classic πŸ’…

Before that error value gets returned, the current MPI error handler associated with the communication object (like a communicator, window, or file) is called. And if there's no communication object associated with the MPI call, then the call counts as attached to MPI_COMM_SELF and will call the associated MPI error handler. But when MPI_COMM_SELF isn't initialized (like, 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 instead 🌱

You can change that initial error handler by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when you're using the World model, or via the mpi_initial_errhandler CLI argument to mpiexec, or via an info key to MPI_Comm_spawn/MPI_Comm_spawn_multiple. And 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.

πŸ¦‹ The three predefined error handlers πŸ¦‹

Open MPI ships three of them, ready to go:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. dramatic AND effective πŸ’€
  • MPI_ERRORS_ABORT β€” an error handler you can invoke on a communicator, window, file, or session. When it's called on a communicator, it acts as if MPI_Abort was called on that communicator. If it's 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. And if it's called on a session, it aborts only the local process.
  • MPI_ERRORS_RETURN β€” returns an error code to the application. the chill one 🫢

πŸ¦‹ DIY error handlers πŸ¦‹

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

See the MPI man page for a full list of MPI error codes. And see the Error Handling section of the MPI-3.1 standard for more information πŸ“š


2003-2026, The Open MPI Community


and that's the whole page, bestie!! πŸŽ€ this Open MPI page is dated Sep 10, 2026 and it slid into your terminal courtesy of the Open MPI girlies β€” go delete those attributes responsibly, mwah πŸ’–πŸ¦‹βœ¨

πŸ“¦ where this page comes from