snowfall-calculation(snowfall)
snowfall-calculation()所属R语言包:snowfall
Parallel calculation functions
并行计算功能
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Parallel calculation functions. Execution is distributed automatically over the cluster.<br> Most of this functions are wrappers for snow functions, but all can be used directly in sequential mode.
并行计算功能。在聚类执行的自动分配。<BR>此功能的包装snow功能,但在连续模式下,都可以直接使用。
用法----------Usage----------
sfClusterApply( x, fun, ... )
sfClusterApplyLB( x, fun, ... )
sfClusterApplySR( x, fun, ..., name="default", perUpdate=NULL, restore=sfRestore() )
sfClusterMap( fun, ..., MoreArgs = NULL, RECYCLE = TRUE )
sfLapply( x, fun, ... )
sfSapply( x, fun, ..., simplify = TRUE, USE.NAMES = TRUE )
sfApply( x, margin, fun, ... )
sfRapply( x, fun, ... )
sfCapply( x, fun, ... )
sfMM( a, b )
sfRestore()
参数----------Arguments----------
参数:x
vary depending on function. See function details below.
不同不同的功能。功能细节如下。
参数:fun
function to call
要调用的函数
参数:margin
vector speficying the dimension to use
矢量speficying使用的尺寸
参数:...
additional arguments to pass to standard function
额外的参数传递给标准功能
参数:simplify
logical; see sapply
逻辑;sapply
参数:USE.NAMES
logical; see sapply
逻辑;sapply
参数:a
matrix
矩阵
参数:b
matrix
矩阵
参数:RECYCLE
see snow documentation
看雪文档
参数:MoreArgs
see snow documentation
看雪文档
参数:name
a character string indicating the name of this parallel execution. Naming is only needed if there are more than one call to sfClusterApplySR in a program.
一个字符串,表示此并行执行的名称。如果有一个以上的通话sfClusterApplySR在程序中只需要命名。
参数:perUpdate
a numerical value indicating the progress printing. Values range from 1 to 100 (no printing). Value means: any X percent of progress status is printed. Default (on given value "NULL") is 5).
一个数值显示进度印刷。值的范围从1到100(无印刷)。值是指:任何进展状况的X%的打印。默认值(给定值NULL)为5分)。
参数:restore
logical indicating whether results from previous runs should be restored or not. Default is coming from sfCluster. If running without sfCluster, default is FALSE, if yes, it is set to the value coming from the external program.
逻辑从以前运行的结果是否应恢复或。默认来自sfCluster。如果运行没有sfCluster,默认为FALSE,如果是,它被设置为来自外部程序的价值。
Details
详细信息----------Details----------
sfClusterApply calls each index of a given list on a seperate node, so length of given list must be smaller than nodes. Wrapper for snow function clusterApply.
sfClusterApply调用一个单独的节点上给定列表的每个索引,因此给定列表的长度必须小于节点。包装器snow功能clusterApply。
sfClusterApplyLB is a load balanced version of sfClusterApply. If a node finished it's list segment it immidiately starts with the next segment. Use this function in infrastructures with machines with different speed. Wrapper for snow function clusterApplyLB.
sfClusterApplyLB是一个负载均衡的版本的sfClusterApply。如果一个节点完成它的列表段immidiately开始的下一个段。使用此功能的机器以不同的速度在基础设施方面。包装器snow功能clusterApplyLB。
sfClusterApplySR saves intermediate results and is able to restore them on a restart. Use this function on very long calculations or it is (however) foreseeable that cluster will not be able to finish it's calculations (e.g. because of a shutdown of a node machine). If your program use more than one parallised part, argument name must be given with a unique name for each loop. Intermediate data is saved depending on R-filename, so restore of data must be explicit given for not confusing changes on your R-file (it is recommended to only restore on fully tested programs). If restores, sfClusterApplySR continues calculation after the first non-null value in the saved list. If your parallized function can return null values, you probably want to change this.
sfClusterApplySR保存中间结果,并能够对其进行恢复重新启动。使用此功能非常长的计算(但是)是可预见的,聚类将无法完成它的计算(例如,因为一个节点机的关机)。如果你的程序使用一个以上parallised的一部分,参数name必须给出一个唯一的名称为每个循环。根据R-文件名,中间数据的保存,恢复的数据必须是明确的,给予不混淆R-文件(建议只恢复全面的测试方案)。如果恢复,sfClusterApplySR继续计算后保存的列表中的第一个非空值。如果您的parallized的函数可以返回null值,你可能想改变这一点。
sfLapply, sfSapply and sfApply are parallel versions of lapply, sapply and apply. The first two use an list or vector as argument, the latter an array.
sfLapply,sfSapply和sfApply是并行版本的lapply,sapply和apply。第一次使用作为参数,后者是一个数组列表或向量。
parMM is a parallel matrix multiplication. Wrapper for snow function parMM.
parMM是一个平行的矩阵乘法。包装器snow功能parMM。
sfRapply and sfCapply are not implemented atm.
sfRapply和sfCapply不实施自动取款机。
参见----------See Also----------
See snow documentation for details on commands: snow-parallel
看雪文档的命令的详细信息:snow-parallel
实例----------Examples----------
## Not run: [#不运行:]
restoreResults <- TRUE
sfInit(parallel=FALSE)
## Execute in cluster or sequential.[#在聚类或顺序执行。]
sfLapply(1:10, exp)
## Execute with intermediate result saving and restore on wish.[#执行的中间结果保存和恢复上的愿望。]
sfClusterApplySR(1:100, exp, name="CALC_EXP", restore=restoreResults)
sfClusterApplySR(1:100, sum, name="CALC_SUM", restore=restoreResults)
sfStop()
##[#]
## Small bootstrap example.[#小举的例子。]
##[#]
sfInit(parallel=TRUE, cpus=2)
require(mvna)
data(sir.adm)
sfExport("sir.adm", local=FALSE)
sfLibrary(cmprsk)
wrapper <- function(a) {
index <- sample(1:nrow(sir.adm), replace=TRUE)
temp <- sir.adm[index, ]
fit <- crr(temp$time, temp$status, temp$pneu, failcode=1, cencode=0)
return(fit$coef)
}
result <- sfLapply(1:100, wrapper)
mean( unlist( rbind( result ) ) )
sfStop()
## End(Not run)[#(不执行)]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|