sfFArgsApplyDep: sfFArgsApplyDep

Description Usage Arguments Author(s) See Also Examples

Description

Load balanced application of F_APPLY with using result from a previous run to construct arguments.

Usage

1
2
3
4
sfFArgsApplyDep(N_APPLYCASES, F_ARGS, F_APPLY, SFFARGSAPPLY_initVal, 
    SFFARGSAPPLY_dependsStep = length(SFFARGSAPPLY_initVal), 
    ..., SFFARGSAPPLY_ADDARGS = list(), debugSequential = FALSE, 
    freeMasterNode = FALSE)

Arguments

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

Author(s)

Thomas Wutzler

See Also

twSnowfall twDynamicClusterApplyDep

Examples

 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.

twSnowfall documentation built on May 2, 2019, 4:47 p.m.