global base | R Documentation |
These functions are global base functions applying on distributed data for all ranks.
comm.length(x, comm = .pbd_env$SPMD.CT$comm)
comm.sum(..., na.rm = TRUE, comm = .pbd_env$SPMD.CT$comm)
comm.mean(x, na.rm = TRUE, comm = .pbd_env$SPMD.CT$comm)
comm.var(x, na.rm = TRUE, comm = .pbd_env$SPMD.CT$comm)
comm.sd(x, na.rm = TRUE, comm = .pbd_env$SPMD.CT$comm)
x |
a vector. |
... |
as in |
na.rm |
logical, if remove |
comm |
a communicator number. |
These functions will apply globally length()
, sum()
,
mean()
, var()
, and sd()
.
The global values are returned to all ranks.
Wei-Chen Chen wccsnow@gmail.com, George Ostrouchov, Drew Schmidt, Pragneshkumar Patel, and Hao Yu.
Programming with Big Data in R Website: https://pbdr.org/
## Not run:
### 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))
if(comm.size() != 2){
comm.cat(\"2 processors are requried.\n\", quiet = TRUE)
finalize()
}
### Examples.
a <- 1:(comm.rank() + 1)
b <- comm.length(a)
comm.print(b)
b <- comm.sum(a)
comm.print(b)
b <- comm.mean(a)
comm.print(b)
b <- comm.var(a)
comm.print(b)
b <- comm.sd(a)
comm.print(b)
### Finish.
finalize()
"
# execmpi(spmd.code, nranks = 2L)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.