@@ -5,7 +5,7 @@ MPI_Finalize
5
5
6
6
.. include_body
7
7
8
- :ref: `MPI_Finalize ` |mdash | Terminates MPI execution environment .
8
+ :ref: `MPI_Finalize ` |mdash | Terminates MPI world model .
9
9
10
10
.. The following file was automatically generated
11
11
.. include :: ./bindings/mpi_finalize.rst
@@ -18,56 +18,82 @@ OUTPUT PARAMETER
18
18
DESCRIPTION
19
19
-----------
20
20
21
- This routine cleans up all MPI states. Once this routine is called, no
22
- MPI routine (not even MPI_Init) may be called, except for
23
- :ref: `MPI_Get_version `, :ref: `MPI_Initialized `, and :ref: `MPI_Finalized `. Unless there has
24
- been a call to :ref: `MPI_Abort `, you must ensure that all pending
25
- communications involving a process are complete before the process calls
26
- :ref: `MPI_Finalize `. If the call returns, each process may either continue
27
- local computations or exit without participating in further
28
- communication with other processes. At the moment when the last process
29
- calls :ref: `MPI_Finalize `, all pending sends must be matched by a receive, and
30
- all pending receives must be matched by a send.
31
-
32
- :ref: `MPI_Finalize ` is collective over all connected processes. If no processes
33
- were spawned, accepted, or connected, then this means it is collective
34
- over MPI_COMM_WORLD. Otherwise, it is collective over the union of all
35
- processes that have been and continue to be connected.
21
+ This routine finalizes the MPI world model. If the MPI world model
22
+ has been initialized in an MPI process, it *must * be finalized exactly
23
+ once by invoking this routine during the lifetime of that MPI process.
24
+ This is different than the MPI session model, which can be initialized
25
+ and finalized multiple times in an MPI process. See
26
+ :ref: `MPI_Session_init ` and :ref: `MPI_Session_finalize `.
27
+
28
+ Unless there has been a call to :ref: `MPI_Abort `, you must
29
+ ensure that all pending communications in the MPI world model
30
+ involving a process are complete before the process calls
31
+ :ref: `MPI_Finalize `. If the call returns, each process may either
32
+ continue local computations or exit without participating in further
33
+ communication with other processes in the MPI world model. At the
34
+ moment when the last process calls :ref: `MPI_Finalize `, all pending
35
+ sends in the MPI world model must be matched by a receive, and all
36
+ pending receives in the MPI world model must be matched by a send.
37
+
38
+ See `MPI-5.0:11.4.1 <https://www.mpi-forum.org/ >`_ for a list of MPI
39
+ functionality that is available available (e.g., even when the MPI
40
+ world model has not yet initialized or has already been finalized).
41
+
42
+ :ref: `MPI_Finalize ` is collective over all connected processes. If no
43
+ processes were spawned, accepted, or connected, then this means it is
44
+ collective over ``MPI_COMM_WORLD ``. Otherwise, it is collective over
45
+ the union of all processes that have been and continue to be
46
+ connected.
36
47
37
48
NOTES
38
49
-----
39
50
40
- All processes must call this routine before exiting. All processes will
41
- still exist but may not make any further MPI calls. :ref: `MPI_Finalize `
42
- guarantees that all local actions required by communications the user
43
- has completed will, in fact, occur before it returns. However,
44
- :ref: `MPI_Finalize ` guarantees nothing about pending communications that have
45
- not been completed; completion is ensured only by :ref: `MPI_Wait `, :ref: `MPI_Test `, or
46
- :ref: `MPI_Request_free ` combined with some other verification of completion.
47
-
48
- For example, a successful return from a blocking communication operation
49
- or from :ref: `MPI_Wait ` or :ref: `MPI_Test ` means that the communication is completed
50
- by the user and the buffer can be reused, but does not guarantee that
51
- the local process has no more work to do. Similarly, a successful return
52
- from :ref: `MPI_Request_free ` with a request handle generated by an :ref: `MPI_Isend `
53
- nullifies the handle but does not guarantee that the operation has
54
- completed. The :ref: `MPI_Isend ` is complete only when a matching receive has
55
- completed.
56
-
57
- If you would like to cause actions to happen when a process finishes,
58
- attach an attribute to MPI_COMM_SELF with a callback function. Then,
59
- when :ref: `MPI_Finalize ` is called, it will first execute the equivalent of an
60
- :ref: `MPI_Comm_free ` on MPI_COMM_SELF. This will cause the delete callback
61
- function to be executed on all keys associated with MPI_COMM_SELF in an
62
- arbitrary order. If no key has been attached to MPI_COMM_SELF, then no
63
- callback is invoked. This freeing of MPI_COMM_SELF happens before any
64
- other parts of MPI are affected. Calling :ref: `MPI_Finalized ` will thus return
65
- "false" in any of these callback functions. Once you have done this with
66
- MPI_COMM_SELF, the results of :ref: `MPI_Finalize ` are not specified.
51
+ The MPI session model is different than the MPI world model, and has
52
+ different scopes of availability for MPI functionality. See
53
+ :ref: `MPI_Session_init ` and :ref: `MPI_Session_finalize `.
54
+
55
+ All processes that initialized the MPI world model must call this
56
+ routine before exiting. All processes will still exist but may not
57
+ make any further MPI calls in the MPI world model. :ref: `MPI_Finalize `
58
+ guarantees that all local actions required by communications in the
59
+ MPI world model that the user has completed will, in fact, occur
60
+ before it returns. However, :ref: `MPI_Finalize ` guarantees nothing
61
+ about pending communications in the MPI world model that have not been
62
+ completed; completion is ensured only by the :ref: `MPI_Wait ` and
63
+ :ref: `MPI_Test ` variants, or :ref: `MPI_Request_free ` combined with
64
+ some other verification of completion.
65
+
66
+ For example, a successful return from a blocking communication
67
+ operation or from one of the :ref: `MPI_Wait ` or :ref: `MPI_Test `
68
+ varients means that the communication is completed by the user and the
69
+ buffer can be reused, but does not guarantee that the local process
70
+ has no more work to do. Similarly, a successful return from
71
+ :ref: `MPI_Request_free ` with a request handle generated by an
72
+ :ref: `MPI_Isend ` nullifies the handle but does not guarantee that the
73
+ operation has completed. The :ref: `MPI_Isend ` is complete only when a
74
+ matching receive has completed.
75
+
76
+ If you would like to cause actions to happen when a finalizes the MPI
77
+ world model, attach an attribute to ``MPI_COMM_SELF `` with a callback
78
+ function. Then, when :ref: `MPI_Finalize ` is called, it will first
79
+ execute the equivalent of an :ref: `MPI_Comm_free ` on
80
+ ``MPI_COMM_SELF ``. This will cause the delete callback function to be
81
+ executed on all keys associated with ``MPI_COMM_SELF `` in an arbitrary
82
+ order. If no key has been attached to ``MPI_COMM_SELF ``, then no
83
+ callback is invoked. This freeing of ``MPI_COMM_SELF `` happens before
84
+ any other parts of the MPI world model are affected. Calling
85
+ :ref: `MPI_Finalized ` will thus return ``false `` in any of these
86
+ callback functions. Once you have done this with ``MPI_COMM_SELF ``,
87
+ the results of :ref: `MPI_Finalize ` are not specified.
67
88
68
89
ERRORS
69
90
------
70
91
71
92
.. include :: ./ERRORS.rst
72
93
73
- .. seealso :: :ref:`MPI_Init`
94
+ .. seealso ::
95
+ * :ref: `MPI_Finalized `
96
+ * :ref: `MPI_Init `
97
+ * :ref: `MPI_Initialized `
98
+ * :ref: `MPI_Session_init `
99
+ * :ref: `MPI_Session_finalize `
0 commit comments