Speed up R by using a different BLAS implementation

[This article was first published on f3lix » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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) benchmark(svd(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 about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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)