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

Description Usage Arguments Details Value Methods Author(s) References See Also Examples

Description

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

Usage

1
2
bcast(x, rank.source = .pbd_env$SPMD.CT$rank.source,
      comm = .pbd_env$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.

Details

The same copy of x is sent to all ranks.

Value

Every rank has x returned.

Methods

For calling spmd.bcast.*:

signature(x = "ANY")
signature(x = "integer")
signature(x = "numeric")
signature(x = "raw")

Author(s)

Wei-Chen Chen wccsnow@gmail.com, George Ostrouchov, Drew Schmidt, Pragneshkumar Patel, and Hao Yu.

References

Programming with Big Data in R Website: https://pbdr.org/

See Also

scatter().

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
### 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()

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

### Finish.
finalize()
"
pbdMPI::execmpi(spmd.code, nranks = 2L)

pbdMPI documentation built on Nov. 6, 2021, 9:07 a.m.