Last chance! 50% off unlimited learning
Sale ends in
This method lets a rank send an object to the other rank and
receive an object from another rank in the same communicator.
The default return is x
.
sendrecv.replace(x,
rank.dest = (comm.rank(.pbd_env$SPMD.CT$comm) + 1) %%
comm.size(.pbd_env$SPMD.CT$comm),
send.tag = .pbd_env$SPMD.CT$tag,
rank.source = (comm.rank(.pbd_env$SPMD.CT$comm) - 1) %%
comm.size(.pbd_env$SPMD.CT$comm),
recv.tag = .pbd_env$SPMD.CT$tag,
comm = .pbd_env$SPMD.CT$comm, status = .pbd_env$SPMD.CT$status)
A x
is returned by default.
an object to be sent from a rank.
a rank of destination where x
send to.
a send tag number.
a source rank where x
sent from.
a receive tag number.
a communicator number.
a status number.
For calling spmd.sendrecv.replace.*()
:
signature(x = "ANY")
signature(x = "integer")
signature(x = "numeric")
signature(x = "raw")
Wei-Chen Chen wccsnow@gmail.com, George Ostrouchov, Drew Schmidt, Pragneshkumar Patel, and Hao Yu.
A corresponding sendrecv.replace()
should be evoked at the
corresponding ranks rank.dest
and rank.source
.
rank.dest
and rank.source
can be as.integer(NULL)
to
create a silent sendrecv operation which is more efficient than setting
rank.dest
and rank.source
to be equal.
Warning: sendrecv.replace()
is not safe for R since R is
not a thread safe package that a dynamic returning object requires certain
blocking or barrier at some where. The replaced object or memory address
`MUST' return correctly. This is almost equivalent to sendrecv()
.
Programming with Big Data in R Website: https://pbdr.org/
sendrecv()
.
if (FALSE) {
### Save code in a file "demo.r" and run with 2 processors by
### SHELL> mpiexec -np 2 Rscript demo.r
spmd.code <- "
### Initialize
suppressMessages(library(pbdMPI, quietly = TRUE))
.comm.size <- comm.size()
.comm.rank <- comm.rank()
### Examples.
N <- 5
x <- (1:N) + N * .comm.size
x <- sendrecv.replace(matrix(x, nrow = 1))
comm.print(x, rank.print = 1)
### Finish.
finalize()
"
# execmpi(spmd.code, nranks = 2L)
}
Run the code above in your browser using DataLab