since the latest Ubuntu release (karmic koala), I noticed that the internal R package advertises on start-up the REvolution package. It seems to be a library collection for high-performance matrix calculations. And it seems to really work, apparently. For example on a matrix transposition with REvolution:
> system.time(t(matrix(rnorm(10000000),ncol=1000)))
user system elapsed
1.280 0.150 1.556
And without REvolution:
> system.time(t(matrix(rnorm(10000000),ncol=1000)))
user system elapsed
1.320 0.170 1.725
Is anyone using it? Is it really w开发者_如何学编程orking? Which specific types of calculation is it improving and how? Any drawback?
Thanks :-)
Yes, on a multicore machine, the Intel MKL libraries implementing the BLAS -- and provided by the package revolution-mkl
and turned-on by package r-revolution-revobase
will work in parallel for linear algebra problems, and you should see a difference to the base case of using just the libblas* packages.
However, your example above is not that significant, I often do something like
mean(replicate(N, system.time( someStuffHere() )["elapsed"]), trim=0.05)
to compute a trimmed mean over a number of replications.
More importantly, note that your example includes the RNG draws in the timings which are
i) expensive, and ii) invariant to the method used so you should generated that outside of system.time()
.
Besides the MKL, revolution-r
also brings in some of the REvolution-authored packages from CRAN that can be used for parallel execution.
(Disclaimer: I helped REvo in putting this together for Ubuntu 9.10)
See this blog post from REvolution for more information. REvolution R 3.0 should be 100% compatible to R-2.9.2 from CRAN. Basically, they use multi-threaded, high performance linear algebra libraries and optimizing compilers. REvolution enhancements include:
- high performance math libraries optimized to take advantage of processor cache, vector instructions and multithreading (Intel Math Kernel Library - MKL) and
- optimizing compilers and runtime libraries.
There are some benchmarks on the REvolution webpage: REvolution R Performance and Simple Benchmarks.
Although they have contributed several interesting extensions to the R community under an OSS license (foreach, iterators, doSNOW, and doMC), the MKL extension is proprietary.
Personally, I've switched to (CRAN) R 2.10.0 to have the latest R features.
Just to reiterate what Dirk mentioned about timing - in your case, constructing the matrix is taking almost all the time. Look what happens (on my system, where I don't have REvolution) when I yank it outside the timing function:
> system.time(t(matrix(rnorm(10000000),ncol=1000)))
user system elapsed
2.256 0.317 2.576
> mt <- matrix(rnorm(10000000),ncol=1000)
> system.time(t(mt))
user system elapsed
0.137 0.070 0.204
In other words, over 90% of the time is spent constructing the matrix, under 10% transposing it.
精彩评论