不能使用 R 中的所有内核

Can't use all cores in R

我试图创建一个并行循环,但我发现 R 无法利用我所有的 8 个内核,它仅使用 1 个与此代码:

library(parallel)
library(foreach)
library(doParallel)
no_cores <- detectCores() - 1
cl <- makeCluster(no_cores)
registerDoParallel(cl, cores = no_cores)

sum.of.squares <- foreach(i = 1:10e4, .combine = "+", .init = 0) %dopar% {
  sqrt(i)
}

stopCluster(cl)

它只使用了 CPU 的 13-15%。为什么?

使用 Windows 8.1 和 R 3.2.1。

使用 R Revolution Open (RRO) 3.2

http://mran.revolutionanalytics.com/documents/rro/installation/

它集成了 Intel MKL 并行数学库。

看到一个fuller comparison here