Hi, Today I came accros a very interesting thing. I was asked how much time it takes for R to calculate the product of two large matrices. So I generated two 2000x2000 matrices of random normal numbers and measured the time with function system.time m1 <- matrix(rnorm(2000*2000),2000) m2 <- matrix(rnorm(2000*2000),2000) system.time(m3 <- m1%*%m2) and it produced 46.47 0.36 47.68 0.00 0.00 on Debian GNU/Linux Woody, R 1.6.1 computer. The same three lines on the same computer but under Windows 2000 and R 1.5.1 I got 550.23 0.40 552.97 NA NA So to calculate the product of two matrices it takes approximately 10 times more on Windows than on Linux. Is this a bug or a feature? The same operation in Matlab 5.3 on Windows 2000 took approximately 300 seconds and in Octave 2.0.16.92 (i386-pc-linux-gnu) on Linux about 550 seconds. I tried to keep minimum processes running during the computations. I suspect the answer to this is different memory management accros different programs and platforms. Am I right? Thanks for any help Sincerely, Vaidotas Zemlys
Computation time differences between Linux and Windows
2 messages · Vaidotas Zemlys, Brian Ripley
On 2 Dec 2002, Mpiktas wrote:
Today I came accros a very interesting thing. I was asked how much time
Really? You have a real application for repeatedly multiplying random matrices and nothing else?
it takes for R to calculate the product of two large matrices. So I generated two 2000x2000 matrices of random normal numbers and measured the time with function system.time m1 <- matrix(rnorm(2000*2000),2000) m2 <- matrix(rnorm(2000*2000),2000) system.time(m3 <- m1%*%m2) and it produced 46.47 0.36 47.68 0.00 0.00 on Debian GNU/Linux Woody, R 1.6.1 computer. The same three lines on the same computer but under Windows 2000 and R 1.5.1 I got 550.23 0.40 552.97 NA NA So to calculate the product of two matrices it takes approximately 10 times more on Windows than on Linux. Is this a bug or a feature?
Most likely your own misunderstanding. Your Debian installation will be using an optimized BLAS (probably the only pre-compiled distribution that does by default), and I don't suppose that you used an optimized BLAS for Windows (although they are available on CRAN for the common chips). It is bad practice to compare the current version of R on one system with an obselete one on another, as well as to compare ones with different degrees of tuning.
The same operation in Matlab 5.3 on Windows 2000 took approximately 300 seconds and in Octave 2.0.16.92 (i386-pc-linux-gnu) on Linux about 550 seconds. I tried to keep minimum processes running during the computations. I suspect the answer to this is different memory management accros different programs and platforms. Am I right?
Not at this size of matrix. BLAS makes a big difference to simple computations, but little to real problems done in R. Simple `benchmarks' can be seriously misleading. In fact, for this one R was actually slowed down for users without a fast BLAS to allow the speed-up using ATLAS (the default on Debian).
Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272860 (secr) Oxford OX1 3TG, UK Fax: +44 1865 272595