
scatter(x, x.buffer = NULL, x.count = NULL, displs = NULL,
rank.source = .SPMD.CT$rank.source, comm = .SPMD.CT$comm)
x
' with the same type
of the element of x
.c(0L, cumsum(x.count))
by default.x
scatter from.x
is returned according to the rank id.x
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.scatterv.*()
is
called.
bcast()
.### 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 <- split(1:(N * .comm.size), rep(1:.comm.size, N))
y <- scatter(lapply(x, matrix, nrow = 1))
comm.print(y)
y <- scatter(x, double(N))
comm.print(y)
### Finish.
finalize()
Run the code above in your browser using DataLab