Buffers
Buffers are used for sending and receiving data. MPI.jl provides the following buffer types:
MPI.IN_PLACE — Constant
MPI.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 — Type
MPI.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
data: a Julia object referencing a region of memory to be used for communication. It is required that the object can becconverted to anMPIPtr.count: the number of elements ofdatatypein the buffer. Note that this may not correspond to the number of elements in the array if derived types are used.datatype: theMPI.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 loaded.AMDGPU.ROCArrayif AMDGPU.jl is loaded.oneAPI.oneArrayif oneAPI.jl is loaded.SubArrays of anArray,CUDA.CuArray,AMDGPU.ROCArrayoroneAPI.oneArraywhere the layout is contiguous, sequential or blocked.
See also
MPI.Buffer_send — Function
Buffer_send(data)Construct a Buffer object for a send operation from data, allowing cases where isbits(data).
MPI.UBuffer — Type
MPI.UBufferAn 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 becconverted to anMPIPtr.count: The number of elements ofdatatypein each chunk.nchunks: The maximum number of chunks stored in the buffer. This is used only for validation, and can be set tonothingto disable checks.datatype: TheMPI.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 — Type
MPI.VBufferAn 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 becconverted to anMPIPtr.counts: An array containing the length of each chunk.displs: An array containing the (0-based) displacements of each chunk.datatype: TheMPI.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 — Type
MPI.RBufferAn 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 becconverted 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 becconverted to anMPIPtr.count: the number of elements ofdatatypein the buffer. Note that this may not correspond to the number of elements in the array if derived types are used.datatype: theMPI.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.API.MPIPtr — Type
MPI.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.AMDGPU.ROCArrayif AMDGPU.jl is loaded.oneAPI.oneArrayif oneAPI.jl is loaded.
Additionally, certain sentinel values can be used, e.g. MPI_IN_PLACE or MPI_BOTTOM.