Description Usage Arguments Author(s) See Also Examples
Load balanced application of F_APPLY with using result from a previous run to construct arguments.
1 2 3 4 |
N_APPLYCASES |
number of cases to calculate |
F_ARGS |
function returning arguments for case i, see details |
F_APPLY |
function to calculate |
SFFARGSAPPLY_initVal |
intial values |
SFFARGSAPPLY_dependsStep |
dependencies in 1..n, |
... |
further arguments passed to F_APPLY |
SFFARGSAPPLY_ADDARGS |
results presented to argfun for the first 1..dependsStep results |
debugSequential |
the number of processors (might be smaller than cluster to assure that previous case i-useNCpus has been evaluated.) |
freeMasterNode |
if set to TRUE, no job is submitted to first node, so that this node can dispatch jobs without waiting |
Thomas Wutzler
twSnowfall
twDynamicClusterApplyDep
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | #sfInit(parallel=TRUE,cpus=2)
# using as many cpus as rows in Z
(Z<-matrix(letters[1:12],nrow=3))
F_APPLY <- function(x,z) paste(x,z,sep="");
F_ARGS <- function(i,prevRes){list(x=prevRes,z=Z[i])}
.res0 <- rep("_",nrow(Z)) # dependStep will be length of .res0
resSeq <- sfFArgsApplyDep( length(Z), F_ARGS, F_APPLY, .res0)
(res <- matrix(sfSimplifyLBResult(resSeq),nrow=nrow(Z)))
# Gives the same results as having one parallel call per column.
# However, in this implementation, the finished nodes do not need to
# wait for possibly slower finishing of other rows, and can tackle
# already further columns.
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.