English 中文(简体)
REvolution for R
原标题:
  • 时间:2009-11-17 12:36:48
  •  标签:
  • r

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 working? 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.





相关问题
How to plot fitted model over observed time series

This is a really really simple question to which I seem to be entirely unable to get a solution. I would like to do a scatter plot of an observed time series in R, and over this I want to plot the ...

REvolution for R

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 ...

R - capturing elements of R output into text files

I am trying to run an analysis by invoking R through the command line as follows: R --no-save < SampleProgram.R > SampleProgram.opt For example, consider the simple R program below: mydata =...

R statistical package: wrapping GOFrame objects

I m trying to generate GOFrame objects to generate a gene ontology mapping in R for unsupported organisms (see http://www.bioconductor.org/packages/release/bioc/vignettes/GOstats/inst/doc/...

Changing the order of dodged bars in ggplot2 barplot

I have a dataframe df.all and I m plotting it in a bar plot with ggplot2 using the code below. I d like to make it so that the order of the dodged bars is flipped. That is, so that the bars labeled "...

Strange error when using sparse matrices and glmnet

I m getting a weird error when training a glmnet regression. invalid class "dgCMatrix" object: length(Dimnames[[2]]) must match Dim[2] It only happens occasionally, and perhaps only under larger ...

Generating non-duplicate combination pairs in R

Sorry for the non-descriptive title but I don t know whether there s a word for what I m trying to achieve. Let s assume that I have a list of names of different classes like c( 1 , 2 , 3 , 4 ) ...

Per panel smoothing in ggplot2

I m plotting a group of curves, using facet in ggplot2. I d like to have a smoother applied to plots where there are enough points to smooth, but not on plots with very few points. In particular I d ...

热门标签