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 ifMPI_Abortwas called on that communicator. If called on a window or file, it acts as ifMPI_Abortwas 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_errhandlerthenMPI_Comm_set_errhandlerMPI_File_create_errhandlerthenMPI_File_set_errhandlerMPI_Session_create_errhandlerthenMPI_Session_set_errhandleror atMPI_Session_initMPI_Win_create_errhandlerthenMPI_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.
Β©οΈ COPYRIGHT
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
- arch rolling: openmpi 5.0.11-1 Β· BSD-3-Clause AND LicenseRef-MPICH
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms