Buffers
Buffers are used for sending and receiving data. MPI.jl provides the following buffer types:
MPI.IN_PLACE
— ConstantMPI.IN_PLACE
A sentinel value that can be passed as a buffer argument for certain collective operations to use the same buffer for send and receive operations.
Scatter!
andScatterv!
: can be used as therecvbuf
argument on the root process.Gather!
andGatherv!
: can be used as thesendbuf
argument on the root process.Allgather!
,Allgatherv!
,Alltoall!
andAlltoallv!
: can be used as thesendbuf
argument on all processes.Reduce!
(root only),Allreduce!
,Scan!
andExscan!
: can be used assendbuf
argument.
MPI.Buffer
— TypeMPI.Buffer
An MPI buffer for communication with a single rank. It is used for point-to-point communication and some collective operations.
Fields
data
a Julia object referencing a region of memory to be used for communication. It is required that the object can be
cconvert
ed to anMPIPtr
.count
the number of elements of
datatype
in the buffer. Note that this may not correspond to the number of elements in the array if derived types are used.datatype
the
MPI.Datatype
stored in the buffer.
Usage
Buffer(data, count::Integer, datatype::Datatype)
Generic constructor.
Buffer(data)
Construct a Buffer
backed by data
, automatically determining the appropriate count
and datatype
. Methods are provided for
Ref
Array
CUDA.CuArray
if CUDA.jl is loadedSubArray
s of anArray
orCUDA.CuArray
where the layout is contiguous, sequential or blocked.
See also
MPI.Buffer_send
— FunctionBuffer_send(data)
Construct a Buffer
object for a send operation from data
, allowing cases where isbits(data)
.
MPI.UBuffer
— TypeMPI.UBuffer
An MPI buffer for chunked collective communication, where all chunks are of uniform size.
Fields
data
A Julia object referencing a region of memory to be used for communication. It is required that the object can be
cconvert
ed to anMPIPtr
.count
The number of elements of
datatype
in each chunk.nchunks
The maximum number of chunks stored in the buffer. This is used only for validation, and can be set to
nothing
to disable checks.datatype
The
MPI.Datatype
stored in the buffer.
Usage
UBuffer(data, count::Integer, nchunks::Union{Nothing, Integer}, datatype::Datatype)
Generic constructor.
UBuffer(data, count::Integer)
Construct a UBuffer
backed by data
, where count
is the number of elements in each chunk.
See also
VBuffer
: similar, but supports chunks of non-uniform sizes.
MPI.VBuffer
— TypeMPI.VBuffer
An MPI buffer for chunked collective communication, where chunks can be of different sizes and at different offsets.
Fields
data
A Julia object referencing a region of memory to be used for communication. It is required that the object can be
cconvert
ed to anMPIPtr
.counts
An array containing the length of each chunk.
displs
An array containing the (0-based) displacements of each chunk.
datatype
The
MPI.Datatype
stored in the buffer.
Usage
VBuffer(data, counts[, displs[, datatype]])
Construct a VBuffer
backed by data
, where counts[j]
is the number of elements in the j
th chunk, and displs[j]
is the 0-based displacement. In other words, the j
th chunk occurs in indices displs[j]+1:displs[j]+counts[j]
.
The default value for displs[j] = sum(counts[1:j-1])
.
See also
UBuffer
when chunks are all of the same size.
MPI.RBuffer
— TypeMPI.RBuffer
An MPI buffer for reduction operations (MPI.Reduce!
, MPI.Allreduce!
, MPI.Scan!
, MPI.Exscan!
).
Fields
senddata
A Julia object referencing a region of memory to be used for the send buffer. It is required that the object can be
cconvert
ed to anMPIPtr
.recvdata
A Julia object referencing a region of memory to be used for the receive buffer. It is required that the object can be
cconvert
ed to anMPIPtr
.count
the number of elements of
datatype
in the buffer. Note that this may not correspond to the number of elements in the array if derived types are used.datatype
the
MPI.Datatype
stored in the buffer.
Usage
RBuffer(senddata, recvdata[, count, datatype])
Generic constructor.
RBuffer(senddata, recvdata)
Construct a Buffer
backed by senddata
and recvdata
, automatically determining the appropriate count
and datatype
.
senddata
can beMPI.IN_PLACE
recvdata
can benothing
on a non-root node withMPI.Reduce!
MPI.MPIPtr
— TypeMPI.MPIPtr
A pointer to an MPI buffer. This type is used only as part of the implicit conversion in ccall
: a Julia object can be passed to MPI by defining methods for Base.cconvert(::Type{MPIPtr}, ...)
/Base.unsafe_convert(::Type{MPIPtr}, ...)
.
Currently supported are:
Ptr
Ref
Array
SubArray
CUDA.CuArray
if CUDA.jl is loaded.
Additionally, certain sentinel values can be used, e.g. MPI_IN_PLACE
or MPI_BOTTOM
.