Last chance! 50% off unlimited learning
Sale ends in
This method lets a rank send (blocking) an object to the other rank
in the same communicator. The default return is NULL
.
send(x, rank.dest = .pbd_env$SPMD.CT$rank.dest,
tag = .pbd_env$SPMD.CT$tag,
comm = .pbd_env$SPMD.CT$comm)
an object to be sent from a rank.
a rank of destination where x
send to.
a tag number.
a communicator number.
A NULL
is returned by default.
For calling spmd.send.*()
:
signature(x = "ANY")
signature(x = "integer")
signature(x = "numeric")
signature(x = "raw")
A corresponding recv()
should be evoked at the corresponding rank
rank.dest
.
Programming with Big Data in R Website: http://r-pbd.org/
# 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.code <- "
### Initial.
suppressMessages(library(pbdMPI, quietly = TRUE))
init()
.comm.size <- comm.size()
.comm.rank <- comm.rank()
### Examples.
N <- 5
x <- (1:N) + N * .comm.rank
if(.comm.rank == 0){
y <- send(matrix(x, nrow = 1))
} else if(.comm.rank == 1){
y <- recv()
}
comm.print(y, rank.print = 1)
### Finish.
finalize()
"
pbdMPI::execmpi(spmd.code, nranks = 2L)
# }
# NOT RUN {
<!-- %} -->
# }
Run the code above in your browser using DataLab