« Return to documentation listing
NAME
MPI_Finalize - Terminates MPI execution environment.
SYNTAX
C Syntax
#include <mpi.h>
int MPI_Finalize()
Fortran Syntax
INCLUDE 'mpif.h'
MPI_FINALIZE(IERROR)
INTEGER IERROR
C++ Syntax
#include <mpi.h>
void Finalize()
OUTPUT PARAMETER
IERROR Fortran only: Error status (integer).
DESCRIPTION
This routine cleans up all MPI states. Once this routine is called, no
MPI routine (not even MPI_Init) may be called, except for MPI_Get_ver-
sion, MPI_Initialized, and MPI_Finalized. Unless there has been a call
to MPI_Abort, you must ensure that all pending communications involving
a process are complete before the process calls MPI_Finalize. If the
call returns, each process may either continue local computations or
exit without participating in further communication with other pro-
cesses. At the moment when the last process calls MPI_Finalize, all
pending sends must be matched by a receive, and all pending receives
must be matched by a send.
MPI_Finalize is collective over all connected processes. If no pro-
cesses were spawned, accepted, or connected, then this means it is col-
lective over MPI_COMM_WORLD. Otherwise, it is collective over the union
of all processes that have been and continue to be connected.
NOTES
All processes must call this routine before exiting. All processes will
still exist but may not make any further MPI calls. MPI_Finalize guar-
antees that all local actions required by communications the user has
completed will, in fact, occur before it returns. However, MPI_Finalize
guarantees nothing about pending communications that have not been com-
pleted; completion is ensured only by MPI_Wait, MPI_Test, or
MPI_Request_free combined with some other verification of completion.
For example, a successful return from a blocking communication opera-
tion or from MPI_Wait or MPI_Test means that the communication is com-
pleted by the user and the buffer can be reused, but does not guarantee
that the local process has no more work to do. Similarly, a successful
return from MPI_Request_free with a request handle generated by an
MPI_Isend nullifies the handle but does not guarantee that the opera-
arbitrary order. If no key has been attached to MPI_COMM_SELF, then no
callback is invoked. This freeing of MPI_COMM_SELF happens before any
other parts of MPI are affected. Calling MPI_Finalized will thus return
"false" in any of these callback functions. Once you have done this
with MPI_COMM_SELF, the results of MPI_Finalize are not specified.
ERRORS
Almost all MPI routines return an error value; C routines as the value
of the function and Fortran routines in the last argument. C++ func-
tions do not return errors. If the default error handler is set to
MPI::ERRORS_THROW_EXCEPTIONS, then on error the C++ exception mechanism
will be used to throw an MPI:Exception object.
Before the error value is returned, the current MPI error handler is
called. By default, this error handler aborts the MPI job, except for
I/O function errors. The error handler may be changed with
MPI_Comm_set_errhandler; the predefined error handler MPI_ERRORS_RETURN
may be used to cause error values to be returned. Note that MPI does
not guarantee that an MPI program can continue past an error.
1.3.4 Nov 11, 2009 MPI_Finalize(3)
« Return to documentation listing
|