help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Octave vs. Matlab speed difference, any suggestions?


From: John W. Eaton
Subject: Octave vs. Matlab speed difference, any suggestions?
Date: Thu, 6 Aug 2009 16:06:34 -0400

On  6-Aug-2009, szabi-11 wrote:

| I need to multiply and sum up 3 dimensional matrices. I noticed that my
| script run way slower on octave. I traced the problem to the actual
| multiplication of the matrices. For example take the following script:
| 
| --snip --
| Q=rand(256,256,10);
| W=rand(256,256,10);
| 
| tic
| for ind=1:10;
|         Q(:,:,ind).*W(:,:,ind);
| end
| toc
| --snip--
| 
| On a machine having both matlab ( Version 7.5.0.338 (R2007b)) and octave
| (3.0.5 configured for "x86_64-redhat-linux-gnu") the average timings from a
| few runs are
| 
| matlab: 0.0086 seconds
| octave: 0.3350 seconds
| 
| Naturally my question is, why?

Most likely, you are measuring the difference in speed of array
indexing.  In 3.0.x, Octave created temporary variables for slices
like Q(:,:,ind).  In 3.2.x, array slices are handled more efficiently.
For example, Octave 3.0.5 on my system runs your example in about .95
seconds, and Octave 3.2.2 on the same system runs it in about .03
seconds.  So I'd recommend upgrading to 3.2.2 and running your test
again.

| On a separate machine (on which I have administrative rights) I checked what
| difference makes if I install an sse2 optimized ATLAS-package instead of the
| general one. The octave results improved roughly 10%. 

That's surprising, since I don't think any BLAS routines are used when
computing element-by-element array products.

jwe


reply via email to

[Prev in Thread] Current Thread [Next in Thread]