MPI_TESTALL(3)

πŸ’– MPI_TESTALL(3) β€” the Open MPI manual, section 3 πŸ’–

okay bestie, so MPI_Testall is literally the "are we done yet??" check for a whole list of communications. She's the group-chat poll of MPI calls. Let's get into it 🫢

✨ NAME ✨

MPI_Testall β€” tests whether all the previously initiated communications in a list have finished. like, all of them. every single one. no stragglers πŸ’…


🌸 SYNTAX 🌸

πŸ’œ C Syntax

#include <mpi.h>

int MPI_Testall(int count, MPI_Request array_of_requests[],
     int *flag, MPI_Status array_of_statuses[])

πŸ¦‹ Fortran Syntax

USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_TESTALL(COUNT, ARRAY_OF_REQUESTS, FLAG, ARRAY_OF_STATUSES,
             IERROR)
     LOGICAL FLAG
     INTEGER COUNT, ARRAY_OF_REQUESTS(*)
     INTEGER ARRAY_OF_STATUSES(MPI_STATUS_SIZE,*), IERROR

πŸŽ€ Fortran 2008 Syntax

USE mpi_f08
MPI_Testall(count, array_of_requests, flag, array_of_statuses, ierror)
     INTEGER, INTENT(IN) :: count
     TYPE(MPI_Request), INTENT(INOUT) :: array_of_requests(count)
     LOGICAL, INTENT(OUT) :: flag
     TYPE(MPI_Status) :: array_of_statuses(*)
     INTEGER, OPTIONAL, INTENT(OUT) :: ierror

🌈 INPUT PARAMETERS 🌈

  • count β€” how long the list is (integer). the headcount fr.
  • array_of_requests β€” the array of requests (array of handles). the actual guest list 🎟️

πŸ’– OUTPUT PARAMETERS πŸ’–

  • flag β€” true when the previously initiated communications are all complete (logical). this is the yes/no you came for ✨
  • array_of_statuses β€” array of status objects (array of status).
  • ierror β€” Fortran only: error status (integer).

πŸ‘‘ DESCRIPTION πŸ‘‘

so here's the tea: she returns flag = true if all the communications tied to active handles in that array have completed. and yes, that includes the vibe where no handle in the list is active β€” that still counts, periodt. in that true case, every status entry that lines up with an active handle request gets set to the status of the corresponding communication. and if the request was allocated by a nonblocking communication call, it gets deallocated, and the handle is set to MPI_REQUEST_NULL. meanwhile every status entry that maps to a null or inactive handle gets set to empty. clean. iconic.

otherwise? flag = false comes back, no request is modified, and the values of the status entries are straight-up undefined. πŸ™ˆ this is a local operation, ngl.

if your application doesn't need to peek at the array_of_statuses field, you can save resources by using the predefined constant MPI_STATUSES_IGNORE β€” you can use it as a special value for the array_of_statuses argument. efficiency queen πŸ’…

errors that happened during the execution of MPI_Testall get handled in the same manner as errors in MPI_Waitall.

πŸ“Œ NOTE πŸ“Œ

flag is true only if all requests have completed. otherwise flag is false, and neither array_of_requests nor array_of_statuses is modified. like, she touched nothing. respectful πŸ™Œ


πŸ’€ ERRORS πŸ’€

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

before that error value comes back, the current MPI error handler associated with the communication object (like a communicator, window, or 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 will call the associated MPI error handler. and when MPI_COMM_SELF isn't initialized β€” that's 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. 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 with the mpi_initial_errhandler CLI argument to mpiexec, or the 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.

Open MPI ships three predefined error handlers you can use:

  • MPI_ERRORS_ARE_FATAL β€” causes the program to abort all connected MPI processes. yeah. everyone. 😭
  • 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 polite 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. no cap. 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.

okay now here's the detail that matters for real: for each invocation of MPI_Testall, if one or more requests generate an MPI error, only the first MPI request that caused an error will be passed to its corresponding error handler. no other error handlers will be invoked β€” even if multiple requests generated errors. however, all requests that generate an error will have a relevant error code set in the corresponding status.MPI_ERROR field (unless MPI_STATUSES_IGNORE was used). so the receipts are still there ✨

and if the invoked error handler lets MPI_Testall return to the caller, the value MPI_ERR_IN_STATUS will be returned in the C and Fortran bindings.

see also:

  • MPI_Comm_set_errhandler
  • MPI_File_set_errhandler
  • MPI_Test
  • MPI_Testany
  • MPI_Testsome
  • MPI_Wait
  • MPI_Waitall
  • MPI_Waitany
  • MPI_Waitsome
  • MPI_Win_set_errhandler

2003-2026, The Open MPI Community


and that's the whole page, bestie 🧚 the Open MPI crew (copyright 2003-2026, The Open MPI Community) signed off on this one back on Sep 10, 2026 β€” so go forth, test all your requests, and slay πŸ’–βœ¨πŸ‘‘

πŸ“¦ where this page comes from