Speed up R by using a different BLAS implementation

October 30, 2012

(This article was first published on f3lix » R, and kindly contributed to R-bloggers)

It is no news that R’s default BLAS is much slower that other available BLAS implementations. In A trick to speed up R matrix calculation/ Yu-Sung Su recommends using the ATLAS BLAS which is available on CRAN. When I learned about the possible speed-up  a while ago I tried several BLAS libraries and I found that GotoBLAS2 was giving me the best performance among the open-source BLAS implementations. Today I decided to check once again how much it makes sense to replace R’s default BLAS library.

Here are some results from my Intel i7-620M laptop running Windows 7:

Speed up using MKL or GotoBLAS2 vs. R’s default BLAS

I used rbenchmark for the measurements with the default of 100 repetitions and I saved and reused the same matrix across all runs:

A = matrix(rnorm(1000*1000),ncol=1000)
benchmark(A %*% A)

A %*% A

BLAS seconds  speed-up
MKL 31.65 7.16
GotoBLAS2 42.30 5.36
Default 226.53 1.00


BLAS seconds  speed-up
MKL 317.61 12.52
GotoBLAS2 389.13 10.22
Default 3976.21 1.00


If you are using R operations that rely on BLAS than you should always use a faster BLAS implementation. If you are using Windows, you can use the Rblas.dll from here or you try the Revolution R Community edition which comes with a MKL BLAS.

To leave a comment for the author, please follow the link and comment on their blog: f3lix » R.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)