1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
|
.. _mpi_wait:
MPI_Wait
========
.. include_body
:ref:`MPI_Wait` |mdash| Waits for an MPI send or receive to complete.
SYNTAX
------
C Syntax
^^^^^^^^
.. code-block:: c
#include <mpi.h>
int MPI_Wait(MPI_Request *request, MPI_Status *status)
Fortran Syntax
^^^^^^^^^^^^^^
.. code-block:: fortran
USE MPI
! or the older form: INCLUDE 'mpif.h'
MPI_WAIT(REQUEST, STATUS, IERROR)
INTEGER REQUEST, STATUS(MPI_STATUS_SIZE), IERROR
Fortran 2008 Syntax
^^^^^^^^^^^^^^^^^^^
.. code-block:: fortran
USE mpi_f08
MPI_Wait(request, status, ierror)
TYPE(MPI_Request), INTENT(INOUT) :: request
TYPE(MPI_Status) :: status
INTEGER, OPTIONAL, INTENT(OUT) :: ierror
INPUT PARAMETER
---------------
* ``request``: Request (handle).
OUTPUT PARAMETERS
-----------------
* ``status``: Status object (status).
* ``ierror``: Fortran only: Error status (integer).
DESCRIPTION
-----------
A call to :ref:`MPI_Wait` returns when the operation identified by request is
complete. If the communication object associated with this request was
created by a nonblocking send or receive call, then the object is
deallocated by the call to :ref:`MPI_Wait` and the request handle is set to
``MPI_REQUEST_NULL``.
The call returns, in status, information on the completed
operation. The content of the status object for a receive operation
can be accessed as described in the "Return Status" subsection of the
"Point-to-Point Communication" chapter in the `MPI Standard
<https://www.mpi-forum.org/docs/>`_. The status object for a send
operation may be queried by a call to :ref:`MPI_Test_cancelled` (see
the "Probe and Cancel" section in the `MPI Standard
<https://www.mpi-forum.org/docs/>`_).
If your application does not need to examine the *status* field, you can
save resources by using the predefined constant ``MPI_STATUS_IGNORE`` as a
special value for the *status* argument.
One is allowed to call :ref:`MPI_Wait` with a null or inactive request
argument. In this case the operation returns immediately with empty
status.
NOTES
-----
Successful return of :ref:`MPI_Wait` after an :ref:`MPI_Ibsend` implies that the user
send buffer can be reused i.e., data has been sent out or copied into a
buffer attached with :ref:`MPI_Buffer_attach`. Note that, at this point, we can
no longer cancel the send (for more information, see the "Probe and
Cancel" section in the `MPI Standard
<https://www.mpi-forum.org/docs/>`_). If a matching receive is never
posted, then the buffer cannot be freed. This runs somewhat counter to
the stated goal of :ref:`MPI_Cancel` (always being able to free program space
that was committed to the communication subsystem).
Example: Simple usage of nonblocking operations and :ref:`MPI_Wait`.
.. code-block:: fortran
CALL MPI_COMM_RANK(comm, rank, ierr)
IF(rank == 0) THEN
CALL MPI_ISEND(a(1), 10, MPI_REAL, 1, tag, comm, request, ierr)
**** do some computation ****
CALL MPI_WAIT(request, status, ierr)
ELSE IF (rank == 1) THEN
CALL MPI_IRECV(a(1), 15, MPI_REAL, 0, tag, comm, request, ierr)
**** do some computation ****
CALL MPI_WAIT(request, status, ierr)
END IF
ERRORS
------
.. include:: ./ERRORS.rst
Note that per the "Return Status" section in the "Point-to-Point
Communication" chapter in the `MPI Standard
<https://www.mpi-forum.org/docs/>`_, MPI errors on requests passed to
:ref:`MPI_WAIT` do not set the ``status.MPI_ERROR`` field in the
returned *status*. The error code is always passed to the back-end
error handler and may be passed back to the caller through the return
value of :ref:`MPI_WAIT` if the back-end error handler returns it. The
pre-defined MPI error handler ``MPI_ERRORS_RETURN`` exhibits this
behavior, for example.
.. seealso::
* :ref:`MPI_Comm_set_errhandler`
* :ref:`MPI_File_set_errhandler`
* :ref:`MPI_Test`
* :ref:`MPI_Testall`
* :ref:`MPI_Testany`
* :ref:`MPI_Testsome`
* :ref:`MPI_Waitall`
* :ref:`MPI_Waitany`
* :ref:`MPI_Waitsome`
* :ref:`MPI_Win_set_errhandler`
|