2008-07-08

Using optimized linear algebra libraries with R

After reading blog posts by Yu-Sung and Gelman (see also comments) as well as recent additions to R on Debian page at RWiki, I decided to take a try with ATLAS on my laptop. I did not aspect much, since I use a poor IBM ThinkPad R50e with Intel(R) Celeron(R) M processor - 1400MHz. However, this laptop offers what I need when I move around, while I use a "hammer" in the office. I could not find the information about which instruction set (SSE, SSE2, ...) is appropriate for my processor. In order to figure this out and to evaluate the benefits I did:
  • Launched the XUbuntu 7.10 (gutsy)
  • Started R with: R --vanilla -q
  • Used the following R script i.e. setting up the matrix and calculating its crossproduct
mm <- matrix(rnorm(4 * 10^6), ncol = 10^3); system.time(crossprod(mm))
  • Tested packages: atlas3-base, (atlas3-sse, atlas3-sse-dev) and (atlas3-sse2, atlas3-sse2-dev), which is just a matter of installing and removing the packages via aptitude install or remove command
The results (output from system.time function - several calls) are:
  • standard R installation: user ~13.4, system ~0.06, elapsed ~15.0
  • atlas3-base: user ~4.1, system ~0.05, elapsed ~4.2
  • atlas3-sse: user ~3.4, system ~0.03, elapsed ~3.7
  • atlas3-ss2: user ~4.1, system ~0.03, elapsed ~4.1
It is clear that installing ATLAS is beneficial, but there is not much gain with specific instruction sets for my laptop. Nevertheless, I kept atlas3-sse since it was consistently showing the best performance.

No comments: