@@ -164,26 +164,57 @@ function Comm_dup(comm::Comm)
164
164
end
165
165
166
166
"""
167
- Comm_split(comm::Comm, color::Integer, key::Integer)
167
+ Comm_split(comm::Comm, color::Union{Integer,Nothing}, key::Integer)
168
+
169
+ Partition the communicator `comm`, one for each value of `color`, returning a
170
+ new communicator. Within each group, the processes are ranked in the order of
171
+ `key`, with ties broken by the order of `comm`.
172
+
173
+ `color` should be a non-negative integer, or `nothing`, in which case a null
174
+ communicator is returned for that rank.
168
175
169
176
# External links
170
177
$(_doc_external (" MPI_Comm_split" ))
171
178
"""
172
- function Comm_split (comm:: Comm , color:: Integer , key:: Integer )
179
+ function Comm_split (comm:: Comm , color:: Union{Integer, Nothing} , key:: Integer )
180
+ if isnothing (color)
181
+ color = Consts. MPI_UNDEFINED[]
182
+ end
173
183
newcomm = Comm ()
174
184
@mpichk ccall ((:MPI_Comm_split , libmpi), Cint,
175
185
(MPI_Comm, Cint, Cint, Ptr{MPI_Comm}), comm, color, key, newcomm)
176
186
finalizer (free, newcomm)
177
187
newcomm
178
188
end
179
189
190
+ mutable struct SplitType
191
+ val:: Cint
192
+ end
193
+ const COMM_TYPE_SHARED = SplitType (- 1 )
194
+ add_load_time_hook! (() -> COMM_TYPE_SHARED. val = Consts. MPI_COMM_TYPE_SHARED[])
195
+
196
+
180
197
"""
181
- Comm_split_type(comm::Comm, split_type::Integer, key::Integer; kwargs...)
198
+ Comm_split_type(comm::Comm, split_type, key::Integer; kwargs...)
199
+
200
+ Partitions the communicator `comm` based on `split_type`, returning a new
201
+ communicator. Within each group, the processes are ranked in the order of
202
+ `key`, with ties broken by the order of `comm`.
203
+
204
+ Currently only one `split_type` is provided:
205
+
206
+ - `MPI.COMM_TYPE_SHARED`: splits the communicator into subcommunicators, each of
207
+ which can create a shared memory region.
182
208
183
209
# External links
184
210
$(_doc_external (" MPI_Comm_split_type" ))
185
211
"""
186
- function Comm_split_type (comm:: Comm ,split_type:: Integer ,key:: Integer ; kwargs... )
212
+ function Comm_split_type (comm:: Comm , split_type, key:: Integer ; kwargs... )
213
+ if isnothing (split_type)
214
+ split_type = Consts. MPI_UNDEFINED[]
215
+ elseif split_type isa SplitType
216
+ split_type = split_type. val
217
+ end
187
218
newcomm = Comm ()
188
219
@mpichk ccall ((:MPI_Comm_split_type , libmpi), Cint,
189
220
(MPI_Comm, Cint, Cint, MPI_Info, Ptr{MPI_Comm}),
0 commit comments