x
.sendrecv(x, x.buffer = NULL,
rank.dest = as.integer((comm.rank(.SPMD.CT$comm) + 1) %%
comm.size(.SPMD.CT$comm)),
send.tag = .SPMD.CT$tag,
rank.source = as.integer((comm.rank(.SPMD.CT$comm) - 1) %%
comm.size(.SPMD.CT$comm)),
recv.tag = .SPMD.CT$tag,
comm = .SPMD.CT$comm, status = .SPMD.CT$status)
x
sent from the other rank.x
send to.x
sent from.x
is returned by default.sendrecv
should be evoked at the corresponding ranks
rank.dest
and rank.source
.sendrecv.replace
.# Save code in a file "demo.r" and run with 2 processors by
# > mpiexec -np 2 Rscript demo.r
### Initial
library(pbdMPI, quiet = TRUE)
init()
.comm.size <- comm.size()
.comm.rank <- comm.rank()
### Examples
N <- 5
x <- (1:N) + N * .comm.size
y <- sendrecv(matrix(x, nrow = 1))
comm.print(y, rank.print = 1)
### Finish
finalize()
Run the code above in your browser using DataLab