[英]the difference between doMC and doParallel in R
What's the difference between doParallel
and doMC
in R concerning foreach
function? 关于foreach
函数, doParallel
和doMC
之间有什么区别? doParallel
supports windows, unix-like, while doMC
supports unix-like only. doParallel
支持windows,unix-like,而doMC
仅支持unix-like。 In other words, why doParallel
cannot replace doMC
directly? 换句话说,为什么doParallel
不能直接替换doMC
? Thank you. 谢谢。
Update: doParallel
is built on parallel
, which is essentially a merger of multicore
and snow
and automatically uses the appropriate tool for your system. 更新: doParallel
基于parallel
构建,它基本上是multicore
和snow
的合并,并自动为您的系统使用适当的工具。 As a result, we can use doParallel
to support multi systems. 因此,我们可以使用doParallel
来支持多系统。 In other words, we can use doParallel
to replace doMC
. 换句话说,我们可以使用doParallel
来替换doMC
。
ref: http://michaeljkoontz.weebly.com/uploads/1/9/9/4/19940979/parallel.pdf 参考: http : //michaeljkoontz.weebly.com/uploads/1/9/9/4/19940979/parallel.pdf
BTW, what is the difference between registerDoParallel(ncores=3)
and BTW, registerDoParallel(ncores=3)
和。之间的区别是什么
cl <- makeCluster(3)
registerDoParallel(cl)
It seems registerDoParallel(ncores=3)
can stop cluster automatically, while the second do not stop automatically and needs stopCluster(cl)
. 似乎registerDoParallel(ncores=3)
可以自动停止集群,而第二个不会自动停止并需要stopCluster(cl)
。
ref: http://cran.r-project.org/web/packages/doParallel/vignettes/gettingstartedParallel.pdf 参考: http : //cran.r-project.org/web/packages/doParallel/vignettes/gettingstartedParallel.pdf
The doParallel
package is a merger of doSNOW
and doMC
, much as parallel
is a merger of snow
and multicore
. doParallel
包是doSNOW
和doMC
的合并,就像parallel
是snow
和multicore
的合并一样。 But although doParallel
has all the features of doMC
, I was told by Rich Calaway of Revolution Analytics that they wanted to keep doMC
around because it was more efficient in certain circumstances, even though doMC
now uses parallel
just like doParallel
. 但是虽然doParallel
具有doParallel
所有功能,但doParallel
对doMC
我告诉我,他们想要保持doMC
,因为它在某些情况下更有效,即使doMC
现在使用parallel
就像doParallel
。 I haven't personally run any benchmarks to determine if and when there is a significant difference. 我没有亲自运行任何基准来确定是否以及何时存在显着差异。
I tend to use doMC
on a Linux or Mac OS X computer, doParallel
on a Windows computer, and doMPI
on a Linux cluster, but doParallel
does work on all of those platforms. 我倾向于使用doMC
在Linux或Mac OS X计算机, doParallel
在Windows电脑上,并doMPI
Linux集群上,但doParallel
确实在所有这些平台的工作。
As for the different registration methods, if you execute: 至于不同的注册方法,如果你执行:
registerDoParallel(cores=3)
on a Windows machine, it will create a cluster object implicitly for later use with clusterApplyLB
, whereas on Linux and Mac OS X, no cluster object is created or used. 在Windows机器上,它将隐式创建一个集群对象,以便以后与clusterApplyLB
使用,而在Linux和Mac OS X上,不会创建或使用集群对象。 The number of cores is simply remembered and used as the value of the mc.cores
argument later when calling mclapply
. 简单地记住核心数量,并在稍后调用mclapply
时将其mc.cores
参数的值。
If you execute: 如果你执行:
cl <- makeCluster(3)
registerDoParallel(cl)
then the registered cluster object will be used with clusterApplyLB
regardless of the platform. 然后,无论平台如何,已注册的集群对象都将与clusterApplyLB
一起使用。 You are correct that in this case, it is your responsibility to shutdown the cluster object since you created it, whereas the implicit cluster object is automatically shutdown. 您是正确的,在这种情况下,您有责任在创建集群对象后关闭集群对象,而隐式集群对象会自动关闭。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.