
gather(x, x.buffer = NULL, x.count = NULL, displs = NULL,
rank.dest = .SPMD.CT$rank.root, comm = .SPMD.CT$comm,
unlist = .SPMD.CT$unlist)
x
' times `comm size' with the same type
of x
.c(0L, cumsum(x.count))
by default.x
gather to.rank.dest == comm.rank(comm)
, then a list of length `comm size'
is returned by default. Otherwise, NULL
is returned.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.gatherv.*()
is
called.
gather()
, allreduce()
, reduce()
.### Save code in a file "demo.r" and run with 2 processors by
### SHELL> mpiexec -np 2 Rscript demo.r
### Initial.
library(pbdMPI, quietly = TRUE)
init()
.comm.size <- comm.size()
.comm.rank <- comm.rank()
### Examples.
N <- 5
x <- (1:N) + N * .comm.rank
y <- gather(matrix(x, nrow = 1))
comm.print(y)
y <- gather(x, double(N * .comm.size))
comm.print(y)
### Finish.
finalize()
Run the code above in your browser using DataLab