MPI_TEST_CANCELLED(3)
π MPI_TEST_CANCELLED π
okay bestie, welcome to MPI_TEST_CANCELLED β this one's a little Open MPI page and it's here to answer exactly one deeply dramatic question: was this request canceled, or not? π
β¨ 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, as in, the whole point (status). π«Ά
π OUTPUT PARAMETERS π
flagβ true if the operation was cancelled (a logical, so it's a yes/no vibe).ierrorβ Fortran only, bestie: the error status, and it's an integer.
π DESCRIPTION π
So here's the tea. This one returns flag = true if the communication tied to that status object was canceled successfully. π And in that case? Lowkey every other field of status β count, tag, the whole friend group β is undefined. Nothing to see there, don't go looking. π
Otherwise it returns flag = false, periodt.
And the actual pro-tip that lives in this manpage: if a receive operation might get canceled, you should call MPI_Test_cancelled first to check whether the cancel actually went through, and only then go poking at the other fields of the return status. Order matters, bestie!! β¨
π¦ NOTES π¦
Cancel can be an expensive operation, so use it only exceptionally. It's giving β¨special occasionβ¨, not everyday fit. π
π ERRORS π
Almost all MPI routines return an error value β C routines give it back as the return result of the function (return), and Fortran routines drop it in the last argument. Okay so:
Before that error value comes back, the current MPI error handler associated with the communication object (think: communicator, window, file) gets called. If there's no communication object associated with the MPI call, then the call counts as attached to MPI_COMM_SELF and it'll call the error handler associated with that instead. And when MPI_COMM_SELF isn't initialized β meaning 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. π
That initial error handler is changeable:
- Call
MPI_Comm_set_errhandleronMPI_COMM_SELFwhen you're in the World model, or - Use the
mpi_initial_errhandlerCLI argument tompiexec, or the info key toMPI_Comm_spawn/MPI_Comm_spawn_multiple.
If no other appropriate error handler has been set, then MPI_ERRORS_RETURN is what gets called for MPI I/O functions, and MPI_ERRORS_ABORT gets called for all other MPI functions.
Open MPI ships three predefined error handlers you can use, and they are:
MPI_ERRORS_ARE_FATALβ causes the program to abort all connected MPI processes. π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 it's 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. And if it's called on a session, it aborts only the local process.MPI_ERRORS_RETURNβ returns an error code to the application.
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
Heads up bestie: MPI does not guarantee that an MPI program can continue past an error. No cap. π¨
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 info. π
π Copyright π
2003-2026, The Open MPI Community
and that's the whole page, bestie!! π
β¨ This lil icon was served up by the Open MPI crew, dated Sep 10, 2026, and yeah β it's stitched right into the good old MPI_TEST_CANCELLED(3) manual page. go forth and test those cancellations responsibly π«ΆπΈ
π¦ where this page comes from
- ubuntu stonking: openmpi-doc 5.0.10-6 Β· other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms