Description Usage Arguments Details Warning See Also Examples
(Load balancing) parallellapply and related functions.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | mpi.applyLB(x, fun, ..., apply.seq=NULL, comm=1)
mpi.parApply(x, MARGIN, fun, ..., job.num = mpi.comm.size(comm)-1,
apply.seq=NULL, comm=1)
mpi.parLapply(x, fun, ..., job.num=mpi.comm.size(comm)-1, apply.seq=NULL,
comm=1)
mpi.parSapply(x, fun, ..., job.num=mpi.comm.size(comm)-1, apply.seq=NULL,
simplify=TRUE, USE.NAMES = TRUE, comm=1)
mpi.parRapply(x, fun, ..., job.num=mpi.comm.size(comm)-1, apply.seq=NULL,
comm=1)
mpi.parCapply(x, fun, ..., job.num=mpi.comm.size(comm)-1, apply.seq=NULL,
comm=1)
mpi.parReplicate(n, expr, job.num=mpi.comm.size(comm)-1, apply.seq=NULL,
simplify = TRUE, comm=1)
mpi.parMM (A, B, job.num=mpi.comm.size(comm)-1, comm=1)
|
x |
an array or matrix. |
MARGIN |
vector specifying the dimensions to use. |
fun |
a function. |
simplify |
logical; should the result be simplified to a vector or matrix if possible? |
USE.NAMES |
logical; if |
n |
number of replications. |
A |
a matrix |
B |
a matrix |
expr |
expression to evaluate repeatedly. |
job.num |
Total job numbers. If job numbers is bigger than total slave numbers (default value), a load balancing approach is used. |
apply.seq |
if reproducing the same computation (simulation) is desirable, set it to the integer vector .mpi.applyLB generated in previous computation (simulation). |
... |
optional arguments to |
comm |
a communicator number |
Unless length of x is no more than total slave numbers (slave.num) and in this case
mpi.applyLB is the same as mpi.apply, mpi.applyLB sends a next job to a
slave who just delivered a finished job. The sequence of slaves who deliver results to master are
saved into .mpi.applyLB. It keeps track which part of results done by which slaves.
.mpi.applyLB can be used to reproduce the same simulation result if the same seed is
used and the argument apply.seq is equal to .mpi.applyLB.
With the default value of argument job.num which is slave.num, mpi.parApply,
mpi.parLapply, mpi.parSapply, mpi.parRapply, mpi.parCapply,
mpi.parSapply, and mpi.parMM are clones of snow's parApply, parLappy,
parSapply, parRapply, parCapply, parSapply, and parMM, respectively. When job.num is
bigger than slave.num, a load balancing approach is used.
When using the argument apply.seq with .mpi.applyLB, be sure all settings are the same
as before, i.e., the same data, job.num, slave.num, and seed. Otherwise a deadlock could occur.
Notice that apply.seq is useful only if job.num is bigger than slave.num.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | ## Not run:
#Assume that there are some slaves running
#mpi.applyLB
x=1:7
mpi.applyLB(x,rnorm,mean=2,sd=4)
#get the same simulation
mpi.remote.exec(set.seed(111))
mpi.applyLB(x,rnorm,mean=2,sd=4)
mpi.remote.exec(set.seed(111))
mpi.applyLB(x,rnorm,mean=2,sd=4,apply.seq=.mpi.applyLB)
#mpi.parApply
x=1:24
dim(x)=c(2,3,4)
mpi.parApply(x, MARGIN=c(1,2), fun=mean,job.num = 5)
#mpi.parLapply
mdat <- matrix(c(1,2,3, 7,8,9), nrow = 2, ncol=3, byrow=TRUE,
dimnames = list(c("R.1", "R.2"), c("C.1", "C.2", "C.3")))
mpi.parLapply(mdat, rnorm)
#mpi.parSapply
mpi.parSapply(mdat, rnorm)
#mpi.parMM
A=matrix(1:1000^2,ncol=1000)
mpi.parMM(A,A)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.