pbdMPI (version 0.3-9)

allgather-method: All Ranks Gather Objects from Every Rank

Description

This method lets all ranks gather objects from every rank in the same communicator. The default return is a list of length equal to comm.size(comm).

Usage

allgather(x, x.buffer = NULL, x.count = NULL, displs = NULL,
          comm = .pbd_env$SPMD.CT$comm,
          unlist = .pbd_env$SPMD.CT$unlist)

Arguments

x

an object to be gathered from all ranks.

x.buffer

a buffer to hold the return object which probably has `size of x' times `comm.size(comm)' with the same type of x.

x.count

a vector of length `comm size' containing all object lengths.

displs

c(0L, cumsum(x.count)) by default.

comm

a communicator number.

unlist

if unlist the return.

Value

A list of length comm.size(comm) is returned by default.

Methods

For calling spmd.allgather.*():

signature(x = "ANY", x.buffer = "missing", x.count = "missing")

signature(x = "integer", x.buffer = "integer", x.count = "missing")

signature(x = "numeric", x.buffer = "numeric", x.count = "missing")

signature(x = "raw", x.buffer = "raw", x.count = "missing")

For calling spmd.allgatherv.*:

signature(x = "ANY", x.buffer = "missing", x.count = "integer")

signature(x = "ANY", x.buffer = "ANY", x.count = "integer")

signature(x = "integer", x.buffer = "integer", x.count = "integer")

signature(x = "numeric", x.buffer = "numeric", x.count = "integer")

signature(x = "raw", x.buffer = "raw", x.count = "integer")

Details

All x on all ranks are likely presumed to have the same size and type.

x.buffer, x.count, and displs can be NULL or unspecified. If specified, the type should be one of integer, double, or raw specified correctly according to the type of x.

If x.count is specified, then the spmd.allgatherv.*() is called.

References

Programming with Big Data in R Website: http://r-pbd.org/

See Also

gather(), allreduce(), reduce().

Examples

Run this code
# NOT RUN {
<!-- %\dontrun{ -->
# }
# NOT RUN {
### Save code in a file "demo.r" and run with 2 processors by
### SHELL> mpiexec -np 2 Rscript demo.r

spmd.file <- tempfile()
cat("
### Initial.
suppressMessages(library(pbdMPI, quietly = TRUE))
init()
.comm.size <- comm.size()
.comm.rank <- comm.rank()

### Examples.
N <- 5
x <- (1:N) + N * .comm.rank
y <- allgather(matrix(x, nrow = 1))
comm.print(y)

y <- allgather(x, double(N * .comm.size))
comm.print(y)

### Finish.
finalize()
", file = spmd.file)
pbdMPI::execmpi(spmd.file = spmd.file, nranks = 2L)
# }
# NOT RUN {
<!-- %} -->
# }

Run the code above in your browser using DataCamp Workspace