MPI_TEST_CANCELLED(3)

πŸ’… MPI_TEST_CANCELLED β€” bestie, was it cancelled or not?

okay so this is the Open MPI page for MPI_Test_cancelled, and honestly? it's a whole vibe check for your MPI_Status object. the actual function name is MPI_Test_cancelled and it lives in section 3 of the manual, so like… you already know it's a library call, not a command you type in your shell, bestie 🫢


✨ SYNTAX ✨

🌸 C Syntax

#include <mpi.h>

int MPI_Test_cancelled(const MPI_Status *status, int *flag)

πŸ¦‹ Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_TEST_CANCELLED(STATUS, FLAG, IERROR)
     LOGICAL FLAG
     INTEGER STATUS(MPI_STATUS_SIZE), IERROR

πŸŽ€ Fortran 2008 Syntax

USE mpi_f08
MPI_Test_cancelled(status, flag, ierror)
     TYPE(MPI_Status), INTENT(IN) :: status
     LOGICAL, INTENT(OUT) :: flag
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

πŸ“₯ INPUT PARAMETER

  • status β€” the status object, aka the little receipt you got back from your communication call. it's the thing you're interrogating. (type: status)

πŸ“€ OUTPUT PARAMETERS

  • flag β€” set to true if the operation was actually cancelled. yes bestie, we love a definitive answer. (logical)
  • ierror β€” Fortran only, babes: the error status, as an integer.

πŸ’– DESCRIPTION πŸ’–

so here's the tea β˜• β€” this one returns flag = true if the communication associated with the status object was canceled successfully. and listen, this is important: in that case, all the other fields of status (think count, tag, all of them) are undefined. not zero, not empty, just… undefined. do not touch. do not read. do not pass go 😭

otherwise it returns flag = false, and life is normal.

and if there's any chance your receive operation might get cancelled? the move is to call MPI_Test_cancelled first to check whether the operation was canceled, before you go poking at the other fields of the return status. order of operations, bestie. it's giving "check the vibes before you commit" πŸ’…


πŸ“ NOTES

Cancel can be an expensive operation, so it should only be used exceptionally. like, special-occasion energy only. not an everyday thing. no cap πŸ™ˆ


πŸ’€ ERRORS

okay, deep breath, because this part is long but it's all facts and you need all of it:

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

Before that error value comes back, the current MPI error handler associated with the communication object (e.g., communicator, window, file) gets called. If there's no communication object associated with the MPI call, then the call is considered attached to MPI_COMM_SELF and will call the associated MPI error handler. And when MPI_COMM_SELF isn't 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. You can change that initial error handler by calling MPI_Comm_set_errhandler on MPI_COMM_SELF when using 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. If no other appropriate error handler has been set, then MPI_ERRORS_RETURN is called for MPI I/O functions, and MPI_ERRORS_ABORT is called for all other MPI functions. πŸŒ€

Open MPI ships three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. dramatic. final. πŸ’€
  • 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. like, no promises, bestie. 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.


2003-2026, The Open MPI Community β€” protect the community at all costs πŸ‘‘


and that's the whole page, bestie! this one's from the Open MPI crew, dated Sep 11, 2026, and it's page MPI_TEST_CANCELLED(3) of the manual. go forth and check your flags before you check your fields πŸ’–βœ¨

πŸ“¦ where this page comes from