@@ -164,26 +164,57 @@ function Comm_dup(comm::Comm)
164164end
165165
166166"""
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.
168175
169176# External links
170177$(_doc_external (" MPI_Comm_split" ))
171178"""
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
173183 newcomm = Comm ()
174184 @mpichk ccall ((:MPI_Comm_split , libmpi), Cint,
175185 (MPI_Comm, Cint, Cint, Ptr{MPI_Comm}), comm, color, key, newcomm)
176186 finalizer (free, newcomm)
177187 newcomm
178188end
179189
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+
180197"""
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.
182208
183209# External links
184210$(_doc_external (" MPI_Comm_split_type" ))
185211"""
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
187218 newcomm = Comm ()
188219 @mpichk ccall ((:MPI_Comm_split_type , libmpi), Cint,
189220 (MPI_Comm, Cint, Cint, MPI_Info, Ptr{MPI_Comm}),
0 commit comments