>Optimized ATLAS BLAS speed gains in R

>After reading this, I decided to give it a go myself and replaced the default Rblas.dll with the the one linked against the ATLAS library and, indeed, speed gains in matrix computations are significant.

I used the C2D version linked against ATLAS 3.9.11, available here.  Here are the results of the same experiment:

require(Matrix)
set.seed(123)
X <- Matrix(rnorm(1e6), 1000)
print(system.time(for(i in 1:25) X%*%X))
print(system.time(for(i in 1:25) solve(X)))
print(system.time(for(i in 1:10) svd(X)))


Default Rblas.dll

> print(system.time(for(i in 1:25) X%*%X))
   user  system elapsed
   24.71    0.25    24.96
> print(system.time(for(i in 1:25) solve(X)))
   user  system elapsed
   17.66    0.03    17.72
> print(system.time(for(i in 1:10) svd(X)))
   user  system elapsed
  50.46    0.68   51.15 

ATLAS optimized Rblas.dll

> print(system.time(for(i in 1:25) X%*%X))
   user  system elapsed
   4.80    0.11    4.92
> print(system.time(for(i in 1:25) solve(X)))
   user  system elapsed
   4.82    0.20    5.03
> print(system.time(for(i in 1:10) svd(X)))
   user  system elapsed
  21.18    0.64   21.83

So, like I said, significant speed gains for such a simple trick as replacing the Rblas.dll.  This is the Pareto principle in practice: minimum effort for maximum result!

About these ads
This entry was posted in Numerical methods, R. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s