MPI_COMM_DELETE_ATTR(3)

πŸ’… MPI_Comm_delete_attr β€” the Open MPI manual, bestie edition πŸŽ€

okay so you're here because you need to delete an attribute value that's associated with a key. that's the whole vibe of MPI_Comm_delete_attr. let's get into it ✨


🌸 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

🫢 INPUT/OUTPUT PARAMETER 🫢

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

πŸ’– INPUT PARAMETER πŸ’–

  • comm_keyval β€” the key value, which is an integer. iykyk.

⭐ OUTPUT PARAMETER ⭐

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

🌈 DESCRIPTION 🌈

So MPI_Comm_delete_attr deletes an attribute from cache by key. the way this works is it invokes the attribute delete function delete_fn that you specified way back when the comm_keyval was created. and like β€” the call will fail if that delete_fn function returns an error code that isn't MPI_SUCCESS. no cap, it just won't go through 😭

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 β€” don't come for me, that's just what the standard says). And whenever a communicator is deleted using MPI_Comm_free, all the callback delete functions for attributes that are currently set are invoked.

This function is literally the same as MPI_Attr_delete but it's needed to match the communicator-specific functions introduced in the MPI-2 standard. also β€” heads up β€” the use of MPI_Attr_delete is deprecated. πŸ’€ so maybe don't.


πŸ‘‘ NOTES πŸ‘‘

okay important caveat time πŸ™ˆ the MPI standard does not define what happens if the delete_fn callback invokes other MPI functions. like, it's just not defined, periodt.

In Open MPI specifically: it is not valid for delete_fn callbacks (or any of their children β€” yes, the whole family tree) to add or delete attributes on the same object on which the delete_fn callback is being invoked. so don't do that. please. 🫢


πŸ’€ ERRORS πŸ’€

Almost all MPI routines return an error value, bestie β€” C routines give it back as the return result of the function, and Fortran routines put it in the last argument.

Before the error value is returned, the current MPI error handler associated with the communication object (like a communicator, window, or file) gets 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. That 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 the 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.

Open MPI includes three predefined error handlers you can use β€” iconic lineup tbh:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. yeah. all of them. 😭
  • 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. chillest of the three ngl.

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. like, it might just be over. πŸ’…

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


and that's the page babes 🧚 this one's from the Open MPI crew, dated Sep 11, 2026, and it's filed under MPI_COMM_DELETE_ATTR(3) β€” go delete those attributes responsibly, mwah πŸ’œβœ¨

πŸ“¦ where this page comes from