You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds `MPI.Init_thread` and the `ThreadLevel` enum, along with a threaded test.
Additionally, set the UCX_ERROR_SIGNALS environment variable if not already set to fix#337.
Copy file name to clipboardexpand all lines: src/environment.jl
+62-2
Original file line number
Diff line number
Diff line change
@@ -34,9 +34,11 @@ end
34
34
35
35
Initialize MPI in the current process.
36
36
37
-
All MPI programs must contain exactly one call to `MPI.Init()`. In particular, note that it is not valid to call `MPI.Init` again after calling [`MPI.Finalize`](@ref).
37
+
All MPI programs must contain exactly one call to `MPI.Init` or
38
+
[`MPI.Init_thread`](@ref). In particular, note that it is not valid to call `MPI.Init` or
39
+
`MPI.Init_thread` again after calling [`MPI.Finalize`](@ref).
38
40
39
-
The only MPI functions that may be called before `MPI.Init()` are
41
+
The only MPI functions that may be called before `MPI.Init`/`MPI.Init_thread` are
40
42
[`MPI.Initialized`](@ref) and [`MPI.Finalized`](@ref).
41
43
42
44
# External links
@@ -53,6 +55,64 @@ function Init()
53
55
end
54
56
end
55
57
58
+
@enum ThreadLevel begin
59
+
THREAD_SINGLE = MPI_THREAD_SINGLE
60
+
THREAD_FUNNELED = MPI_THREAD_FUNNELED
61
+
THREAD_SERIALIZED = MPI_THREAD_SERIALIZED
62
+
THREAD_MULTIPLE = MPI_THREAD_MULTIPLE
63
+
end
64
+
65
+
66
+
"""
67
+
Init_thread(required::ThreadLevel)
68
+
69
+
Initialize MPI and the MPI thread environment in the current process. The argument
70
+
specifies the required thread level, which is one of the following:
71
+
72
+
- `MPI.THREAD_SINGLE`: Only one thread will execute.
73
+
- `MPI.THREAD_FUNNELED`: The process may be multi-threaded, but the application must ensure that only the main thread makes MPI calls.
74
+
- `MPI.THREAD_SERIALIZED`: The process may be multi-threaded, and multiple threads may make MPI calls, but only one at a time (i.e. all MPI calls are serialized).
75
+
- `MPI.THREAD_MULTIPLE`: Multiple threads may call MPI, with no restrictions.
76
+
77
+
Tne function will return the provided `ThreadLevel`, and values may be compared via inequalities, i.e.
78
+
```julia
79
+
if Init_thread(required) < required
80
+
error("Insufficient threading")
81
+
end
82
+
```
83
+
84
+
All MPI programs must contain exactly one call to [`MPI.Init`](@ref) or
85
+
`MPI.Init_thread`. In particular, note that it is not valid to call `MPI.Init` or
86
+
`MPI.Init_thread` again after calling [`MPI.Finalize`](@ref).
87
+
88
+
The only MPI functions that may be called before `MPI.Init`/`MPI.Init_thread` are
89
+
[`MPI.Initialized`](@ref) and [`MPI.Finalized`](@ref).
90
+
91
+
# External links
92
+
$(_doc_external("MPI_Init_thread"))
93
+
"""
94
+
functionInit_thread(required::ThreadLevel)
95
+
REFCOUNT[] ==-1||error("MPI.REFCOUNT in incorrect state: MPI may only be initialized once per session.")
96
+
r_provided =Ref{ThreadLevel}()
97
+
# int MPI_Init_thread(int *argc, char ***argv, int required, int *provided)
0 commit comments