Learn R Programming

pbdMPI (version 0.1-5)

bcast-method: A Rank Broadcast an Object to Every Rank

Description

This method lets a rank broadcast an object to every rank in the same communicator. The default return is the object.

Usage

bcast(x, rank.source = .SPMD.CT$rank.source, comm = .SPMD.CT$comm)

Arguments

x
an object to be broadcast from all ranks.
rank.source
a rank of source where x broadcast from.
comm
a communicator number.

Value

  • Every rank has x returned.

Details

The same copy of x is sent to all ranks.

References

Programming with Big Data in R Website: http://r-pbd.org/

See Also

scatter.

Examples

Run this code
# 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()

### Examples
x <- matrix(1:5, nrow = 1)
y <- bcast(x)
comm.print(y)

### Finish
finalize()

Run the code above in your browser using DataLab