Skip to content

Commit 0f4673c

Browse files
committed
docs: numerous updates to MPI_Init[_thread] man pages
Including, but not limited to: * Add references to the MPI world model (since the sessions model now exists), and update outdated text that was no longer entirely correct now that the sessions model exists * Numerous formatting updates * Slightly improve the C code examples * Describe the mathematical relationship between the various MPI_THREAD_* constants * Note that the mathematical relationships render nicely in HTML, but don't render entirely properly in nroff. This commit author is of the opinion that the nroff rendering is currently "good enough", and some Sphinx maintainer will fix it someday. * Add descriptions about the $OMPI_MPI_THREAD_LEVEL env variable and how it is used * Added more seealso links Signed-off-by: Jeff Squyres <[email protected]>
1 parent 9b24edc commit 0f4673c

File tree

4 files changed

+168
-59
lines changed

4 files changed

+168
-59
lines changed

docs/man-openmpi/man3/MPI_Init.3.rst

Lines changed: 35 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ MPI_Init
66

77
.. include_body
88
9-
:ref:`MPI_Init` |mdash| Initializes the MPI execution environment
9+
:ref:`MPI_Init` |mdash| Initializes the MPI world model
1010

1111
.. The following file was automatically generated
1212
.. include:: ./bindings/mpi_init.rst
@@ -23,35 +23,52 @@ OUTPUT PARAMETER
2323
DESCRIPTION
2424
-----------
2525

26-
This routine, or :ref:`MPI_Init_thread`, must be called before most other MPI
27-
routines are called. There are a small number of errors, such as
28-
:ref:`MPI_Initialized` and :ref:`MPI_Finalized`. MPI can be initialized at most once;
29-
subsequent calls to :ref:`MPI_Init` or :ref:`MPI_Init_thread` are erroneous.
26+
When using the MPI world model, this routine, or
27+
:ref:`MPI_Init_thread`, must be called before most other MPI routines
28+
are called. There are a small number of routines that can be invoked
29+
before :ref:`MPI_Init` or :ref:`MPI_Init_thread`, such as
30+
:ref:`MPI_Initialized` and :ref:`MPI_Finalized`.
31+
32+
The MPI world model can be initialized at most once; subsequent calls
33+
to :ref:`MPI_Init` or :ref:`MPI_Init_thread` are erroneous.
34+
35+
Alternatively, instead of the MPI world model, MPI applications can
36+
use the sessions model; see :ref:`MPI_Session_init`.
3037

31-
All MPI programs must contain a call to :ref:`MPI_Init` or :ref:`MPI_Init_thread`.
3238
Open MPI accepts the C *argc* and *argv* arguments to main, but neither
3339
modifies, interprets, nor distributes them:
3440

3541
.. code-block:: c
3642
37-
/* declare variables */
38-
MPI_Init(&argc, &argv);
39-
/* parse arguments */
40-
/* main program */
41-
MPI_Finalize();
43+
#include <mpi.h>
44+
45+
int main(int argv, char *argv[]) {
46+
MPI_Init(&argc, &argv);
47+
/* ...body of main MPI pogram... */
48+
MPI_Finalize();
49+
return 0;
50+
}
4251
52+
By default, :ref:`MPI_Init` is effectively equivalent to invoking
53+
:ref:`MPI_Init_thread` with a *required* value of
54+
``MPI_THREAD_SINGLE``. However, if the ``OMPI_MPI_THREAD_LEVEL``
55+
environment variable is set to a valid value when :ref:`MPI_Init` is
56+
invoked, it is equivalent to invoking :ref:`MPI_Init_thread` with
57+
*required* set to the integer value of the ``OMPI_MPI_THREAD_LEVEL``
58+
environment variable. See :ref:`MPI_Init_thread` for more details.
4359

4460
NOTES
4561
-----
4662

4763
The Fortran version does not have provisions for *argc* and *argv* and
4864
takes only IERROR.
4965

50-
The MPI Standard does not say what a program can do before an :ref:`MPI_Init`
51-
or after an :ref:`MPI_Finalize`. In the Open MPI implementation, it should do
52-
as little as possible. In particular, avoid anything that changes the
53-
external state of the program, such as opening files, reading standard
54-
input, or writing to standard output.
66+
The MPI Standard does not specify what a program using the MPI world
67+
model can do before invoking :ref:`MPI_Init` or :ref:`MPI_Init_thread`
68+
or after invoking :ref:`MPI_Finalize`. In the Open MPI implementation,
69+
it should do as little as possible. In particular, avoid anything that
70+
changes the external state of the program, such as opening files,
71+
reading standard input, or writing to standard output.
5572

5673

5774
ERRORS
@@ -64,3 +81,5 @@ ERRORS
6481
* :ref:`MPI_Initialized`
6582
* :ref:`MPI_Finalize`
6683
* :ref:`MPI_Finalized`
84+
* :ref:`MPI_Session_finalize`
85+
* :ref:`MPI_Session_init`

docs/man-openmpi/man3/MPI_Init_thread.3.rst

Lines changed: 114 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ MPI_Init_thread
66

77
.. include_body
88
9-
:ref:`MPI_Init_thread` |mdash| Initializes the MPI execution environment
9+
:ref:`MPI_Init_thread` |mdash| Initializes the MPI world model
1010

1111
.. The following file was automatically generated
1212
.. include:: ./bindings/mpi_init_thread.rst
@@ -25,64 +25,136 @@ OUTPUT PARAMETERS
2525
DESCRIPTION
2626
-----------
2727

28-
This routine, or :ref:`MPI_Init`, must be called before most other MPI routines
29-
are called. There are a small number of exceptions, such as
30-
:ref:`MPI_Initialized` and :ref:`MPI_Finalized`. MPI can be initialized at most once;
31-
subsequent calls to :ref:`MPI_Init` or :ref:`MPI_Init_thread` are erroneous.
28+
When using the MPI world model, this routine, or
29+
:ref:`MPI_Init_thread`, must be called before most other MPI routines
30+
are called. There are a small number of routines that can be invoked
31+
before :ref:`MPI_Init` or :ref:`MPI_Init_thread`, such as
32+
:ref:`MPI_Initialized` and :ref:`MPI_Finalized`.
3233

33-
:ref:`MPI_Init_thread`, as compared to :ref:`MPI_Init`, has a provision to request a
34-
certain level of thread support in *required*:
34+
The MPI world model can be initialized at most once; subsequent calls
35+
to :ref:`MPI_Init` or :ref:`MPI_Init_thread` are erroneous.
3536

36-
MPI_THREAD_SINGLE
37-
Only one thread will execute.
37+
Alternatively, instead of the MPI world model, MPI applications can
38+
use the sessions model; see :ref:`MPI_Session_init`.
3839

39-
MPI_THREAD_FUNNELED
40-
If the process is multithreaded, only the thread that called
41-
:ref:`MPI_Init_thread` will make MPI calls.
40+
Upon return, the level of thread support available to the program is
41+
set in *provided*. In Open MPI, the value is dependent on how the
42+
library was configured and built. Note that there is no guarantee that
43+
*provided* will be greater than or equal to *required*.
4244

43-
MPI_THREAD_SERIALIZED
44-
If the process is multithreaded, only one thread will make MPI
45-
library calls at one time.
45+
Open MPI accepts the C *argc* and *argv* arguments to main, but
46+
neither modifies, interprets, nor distributes them:
4647

47-
MPI_THREAD_MULTIPLE
48-
If the process is multithreaded, multiple threads may call MPI at
49-
once with no restrictions.
48+
.. code-block:: c
5049
51-
The level of thread support available to the program is set in
52-
*provided*. In Open MPI, the value is dependent on how the library was
53-
configured and built. Note that there is no guarantee that *provided*
54-
will be greater than or equal to *required*.
50+
#include <mpi.h>
5551
56-
Also note that calling :ref:`MPI_Init_thread` with a *required* value of
57-
MPI_THREAD_SINGLE is equivalent to calling :ref:`MPI_Init`.
52+
int main(int argv, char *argv[]) {
53+
int provided;
54+
MPI_Init_thread(&argc, &argv, MPI_THREAD_MULTIPLE, &provided);
55+
/* ...body of main MPI pogram... */
56+
MPI_Finalize();
57+
return 0;
58+
}
5859
59-
All MPI programs must contain a call to :ref:`MPI_Init` or :ref:`MPI_Init_thread`.
60-
Open MPI accepts the C *argc* and *argv* arguments to main, but neither
61-
modifies, interprets, nor distributes them:
6260
63-
.. code-block:: c
61+
:ref:`MPI_Init_thread` has both a direct and an indirect mechanism to
62+
request a specific level of thread support. :ref:`MPI_Init` only has
63+
an indirect mechanism to request a specific level of thread support.
64+
65+
Direct request of thread level
66+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
67+
68+
:ref:`MPI_Init_thread` has the *required* parameter, which can be set
69+
to any one of the following constants (from ``mpi.h``):
70+
71+
* ``MPI_THREAD_SINGLE``: Indicating that only one thread will execute.
72+
73+
* ``MPI_THREAD_FUNNELED``: Indicating that if the process is
74+
multithreaded, only the thread that called :ref:`MPI_Init_thread`
75+
will make MPI calls.
76+
77+
* ``MPI_THREAD_SERIALIZED``: Indicating that if the process is
78+
multithreaded, only one thread will make MPI library calls at one
79+
time.
80+
81+
* ``MPI_THREAD_MULTIPLE``: Indicating that if the process is
82+
multithreaded, multiple threads may call MPI at once with no
83+
restrictions.
84+
85+
The values of these constants adhere to the following relationships:
86+
87+
.. math::
88+
:nowrap:
89+
90+
\begin{eqnarray}
91+
MPI\_THREAD\_SINGLE & < & MPI\_THREAD\_FUNNELED \\
92+
MPI\_THREAD\_FUNNELED & < & MPI\_THREAD\_SERIALIZED \\
93+
MPI\_THREAD\_SERIALIZED & < & MPI\_THREAD\_MULTIPLE \\
94+
\end{eqnarray}
95+
96+
Indirect request of thread level
97+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
98+
99+
Both :ref:`MPI_Init_thread` and :ref:`MPI_Init` support an indirect
100+
method of indicating the required thread level: setting the
101+
``OMPI_MPI_THREAD_LEVEL`` environment variable:
102+
103+
* If the ``OMPI_MPI_THREAD_LEVEL`` environment variable is set at the
104+
time :ref:`MPI_Init` is invoked, it behaves as if
105+
:ref:`MPI_Init_thread` was invoked with that value passed via the
106+
*required* parameter.
107+
108+
* If the ``OMPI_MPI_THREAD_LEVEL`` environment variable is set at the
109+
time :ref:`MPI_Init_thread` is invoked, the environment variable
110+
values overrides the value passed via the *required* parameter.
111+
112+
The ``OMPI_MPI_THREAD_LEVEL`` environment variable can be set to one
113+
of several different values:
114+
115+
.. list-table::
116+
:header-rows: 1
117+
118+
* - Value that Open MPI uses
119+
- Allowable values (case-insensitive)
120+
121+
* - ``MPI_THREAD_SINGLE``
122+
- ``MPI_THREAD_SINGLE``, ``THREAD_SINGLE``, ``SINGLE``, 0
123+
124+
* - ``MPI_THREAD_FUNNELED``
125+
- ``MPI_THREAD_FUNNELED``, ``THREAD_FUNNELED``, ``FUNNELED``, 1
126+
127+
* - ``MPI_THREAD_SERIALIZED``
128+
- ``MPI_THREAD_SERIALIZED``, ``THREAD_SERIALIZED``,
129+
``SERIALIZED``, 2
130+
131+
* - ``MPI_THREAD_MULTIPLE``
132+
- ``MPI_THREAD_MULTIPLE``, ``THREAD_MULTIPLE``, ``MULTIPLE``, 3
64133

65-
/* declare variables */
66-
MPI_Init_thread(&argc, &argv, req, &prov);
67-
/* parse arguments */
68-
/* main program */
69-
MPI_Finalize();
134+
.. note:: Prior to Open MPI v6.0.0, only the integer values 0 through
135+
3 were acceptable values for the ``OMPI_MPI_THREAD_LEVEL``
136+
environment variable.
70137

138+
Starting with Open MPI v6.0.0, the Open MPI community
139+
recomends using one of the string name variants so that it
140+
can be correctly mapped to the corresponding Open MPI ABI
141+
value or the MPI Standard ABI value, as relevant.
71142

72143
NOTES
73144
-----
74145

75146
The Fortran version does not have provisions for ``argc`` and ``argv`` and
76-
takes only ``IERROR``.
147+
takes only ``REQUIRED``, ``PROVIDED``, and ``IERROR``.
77148

78149
It is the caller's responsibility to check the value of ``provided``, as
79150
it may be less than what was requested in ``required``.
80151

81-
The MPI Standard does not say what a program can do before an
82-
:ref:`MPI_Init_thread` or after an :ref:`MPI_Finalize`. In the Open MPI
83-
implementation, it should do as little as possible. In particular, avoid
84-
anything that changes the external state of the program, such as opening
85-
files, reading standard input, or writing to standard output.
152+
The MPI Standard does not specify what a program using the MPI world
153+
model can do before invoking :ref:`MPI_Init` or :ref:`MPI_Init_thread`
154+
or after invoking :ref:`MPI_Finalize`. In the Open MPI implementation,
155+
it should do as little as possible. In particular, avoid anything that
156+
changes the external state of the program, such as opening files,
157+
reading standard input, or writing to standard output.
86158

87159

88160
MPI_THREAD_MULTIPLE Support
@@ -93,7 +165,7 @@ Open MPI was built supports threading. You can check the output of
93165
:ref:`ompi_info(1) <man1-ompi_info>` to see if Open MPI has
94166
``MPI_THREAD_MULTIPLE`` support:
95167

96-
::
168+
.. code-block:: bash
97169
98170
shell$ ompi_info | grep "Thread support"
99171
Thread support: posix (MPI_THREAD_MULTIPLE: yes, OPAL support: yes, OMPI progress: no, Event lib: yes)
@@ -117,3 +189,5 @@ ERRORS
117189
* :ref:`MPI_Initialized`
118190
* :ref:`MPI_Finalize`
119191
* :ref:`MPI_Finalized`
192+
* :ref:`MPI_Session_finalize`
193+
* :ref:`MPI_Session_init`

docs/man-openmpi/man3/MPI_Session_finalize.3.rst

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ DESCRIPTION
2525

2626
:ref:`MPI_Session_finalize` releases all MPI state associated with the supplied
2727
session. Every instantiated session must be finalized using
28-
:ref:`MPI_Session_finalize`. The handle session is set to MPI_SESSION_NULL by
28+
:ref:`MPI_Session_finalize`. The handle session is set to ``MPI_SESSION_NULL`` by
2929
the call.
3030

3131
NOTES
@@ -52,4 +52,5 @@ ERRORS
5252

5353
.. include:: ./ERRORS.rst
5454

55-
.. seealso:: :ref:`MPI_Session_init`
55+
.. seealso::
56+
* :ref:`MPI_Session_init`

docs/man-openmpi/man3/MPI_Session_init.3.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,19 @@ ERRORS
4646

4747
.. include:: ./ERRORS.rst
4848

49-
.. seealso:: :ref:`MPI_Session_get_num_psets` MPI_Session_group_from_pset
49+
.. seealso::
50+
* :ref:`MPI_Group_from_session_pset`
51+
* :ref:`MPI_Session_c2f`
52+
* :ref:`MPI_Session_call_errhandler`
53+
* :ref:`MPI_Session_create_errhandler`
54+
* :ref:`MPI_Session_f2c`
55+
* :ref:`MPI_Session_finalize`
56+
* :ref:`MPI_Session_get_errhandler`
57+
* :ref:`MPI_Session_get_info`
58+
* :ref:`MPI_Session_get_nth_pset`
59+
* :ref:`MPI_Session_get_num_psets`
60+
* :ref:`MPI_Session_get_pset_info`
61+
* :ref:`MPI_Session_init`
62+
* :ref:`MPI_Session_set_errhandler`
63+
* :ref:`MPI_T_pvar_session_create`
64+
* :ref:`MPI_T_pvar_session_free`

0 commit comments

Comments
 (0)