Tuesday, January 26, 2016

Supercharge R, with Multi-Threaded Maths

Supercharge R, with Multi-Threaded Maths


Open up R, either in your RStudio, or your standard RGui, and run the following (matrix multiplication ensues);
system.time({ x <- replicate(5e3, rnorm(5e3)); tcrossprod(x) })

On my system, using either R or RStudio (using the same base R engine), the user time was about 50 seconds. That, due to the single threaded processing nature of R. 



Time to supercharge R maths

Microsoft has come out with a replacement default RGui, MRO (Microsoft R Open), which combined with the MKL (math kernel library), brings about multi-threaded processing.

Go here and download MRO and the MKL
https://mran.revolutionanalytics.com/download/#download 

Your new processing speed will look something more like this now;







If you're using RStudio, be sure you modify the R version in the options to point to your new-fangled R installation.



Happy calculating!