@@ -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
2525DESCRIPTION
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
72143NOTES
73144-----
74145
75146The Fortran version does not have provisions for ``argc `` and ``argv `` and
76- takes only ``IERROR ``.
147+ takes only ``REQUIRED ``, `` PROVIDED ``, and `` IERROR ``.
77148
78149It is the caller's responsibility to check the value of ``provided ``, as
79150it 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
88160MPI_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 `
0 commit comments