| global range, max, and min | R Documentation |
These functions are global range, max and min applying on distributed data for all ranks.
comm.range(..., na.rm = FALSE, comm = .pbd_env$SPMD.CT$comm)
comm.max(..., na.rm = FALSE, comm = .pbd_env$SPMD.CT$comm)
comm.min(..., na.rm = FALSE, comm = .pbd_env$SPMD.CT$comm)
... |
an 'numeric' objects. |
na.rm |
if |
comm |
a communicator number. |
These functions will apply range(), max() and min()
locally, and apply allgather to get all local results from other ranks,
then apply range(), max() and min() on all local
results.
The global values (range, max, or min) 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.range(a)
comm.print(b)
b <- comm.max(a)
comm.print(b)
b <- comm.min(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.