Buffers
Buffers are used for sending and receiving data. MPI.jl provides the following buffer types:
MPI.IN_PLACE — ConstantMPI.IN_PLACEA 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 therecvbufargument on the root process.Gather!andGatherv!: can be used as thesendbufargument on the root process.Allgather!,Allgatherv!,Alltoall!andAlltoallv!: can be used as thesendbufargument on all processes.Reduce!(root only),Allreduce!,Scan!andExscan!: can be used assendbufargument.
MPI.Buffer — TypeMPI.BufferAn MPI buffer for communication with a single rank. It is used for point-to-point and one-sided operations, as well as some collective operations. Operations will implicitly construct a Buffer when required via the generic constructor, but it can be advantageous to manually construct Buffers when doing so incurs additional overhead, for example when using a non-predefined MPI.Datatype.
Fields
dataa Julia object referencing a region of memory to be used for communication. It is required that the object can be
cconverted to anMPIPtr.countthe number of elements of
datatypein the buffer. Note that this may not correspond to the number of elements in the array if derived types are used.datatypethe
MPI.Datatypestored 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
RefArrayCUDA.CuArrayif CUDA.jl is loadedSubArrays of anArrayorCUDA.CuArraywhere 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.UBufferAn MPI buffer for chunked collective communication, where all chunks are of uniform size.
Fields
dataA Julia object referencing a region of memory to be used for communication. It is required that the object can be
cconverted to anMPIPtr.countThe number of elements of
datatypein each chunk.nchunksThe maximum number of chunks stored in the buffer. This is used only for validation, and can be set to
nothingto disable checks.datatypeThe
MPI.Datatypestored 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.VBufferAn MPI buffer for chunked collective communication, where chunks can be of different sizes and at different offsets.
Fields
dataA Julia object referencing a region of memory to be used for communication. It is required that the object can be
cconverted to anMPIPtr.countsAn array containing the length of each chunk.
displsAn array containing the (0-based) displacements of each chunk.
datatypeThe
MPI.Datatypestored 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 jth chunk, and displs[j] is the 0-based displacement. In other words, the jth chunk occurs in indices displs[j]+1:displs[j]+counts[j].
The default value for displs[j] = sum(counts[1:j-1]).
See also
UBufferwhen chunks are all of the same size.
MPI.RBuffer — TypeMPI.RBufferAn MPI buffer for reduction operations (MPI.Reduce!, MPI.Allreduce!, MPI.Scan!, MPI.Exscan!).
Fields
senddataA Julia object referencing a region of memory to be used for the send buffer. It is required that the object can be
cconverted to anMPIPtr.recvdataA Julia object referencing a region of memory to be used for the receive buffer. It is required that the object can be
cconverted to anMPIPtr.countthe number of elements of
datatypein the buffer. Note that this may not correspond to the number of elements in the array if derived types are used.datatypethe
MPI.Datatypestored 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.
senddatacan beMPI.IN_PLACErecvdatacan benothingon a non-root node withMPI.Reduce!
MPI.MPIPtr — TypeMPI.MPIPtrA 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:
PtrRefArraySubArrayCUDA.CuArrayif CUDA.jl is loaded.
Additionally, certain sentinel values can be used, e.g. MPI_IN_PLACE or MPI_BOTTOM.