Octave versus matlab performances on linux platform 64 bits

Peter Cloetens cloetens at esrf.fr
Thu Oct 30 11:43:53 CDT 2008



Sergei Steshenko wrote:
> 
> 
> --- On Wed, 10/29/08, Jaroslav Hajek <highegg at gmail.com> wrote:
> 
>> From: Jaroslav Hajek <highegg at gmail.com>
>> Subject: Re: Octave versus matlab performances on linux platform 64 bits
>> To: "Luca Tagliacozzo" <luca.tagliacozzo at gmail.com>
>> Cc: help-octave at cae.wisc.edu
>> Date: Wednesday, October 29, 2008, 11:47 PM
>> On Thu, Oct 30, 2008 at 7:01 AM, Luca Tagliacozzo
>> <luca.tagliacozzo at gmail.com> wrote:
>>> Hello, I was wondering what  I am doing wrong:
>>>
>>> I was planning to pass some matlab programs to octave
>> but as I will have to
>>> do real simulation I was planning to write them in
>> C++.
>>> Before starting the project I decided to make a simple
>> test.
>>> I took the DaCoda example of the matpow.m file, did
>> the esteatical changes
>>> such that it can be run on matlab,
>>>
>>> and I run it on matlab via the following script:
>> test.m
>>>
>>> a=matpow(rand(1000),10);
>>>
>>>
>>> That is it mutliplies log_2(10) times  a 1000x1000
>> matrix
>>> By running
>>> time matlab -nodisplay <test.m
>>>
>>>
>>> I get     0m4.076s as a user time
>>>
>>> we see that it take 4.076s to execute on my already
>> fully loaded machine.
>>> Now always with the matpow.m file i did the following
>> test:
>>> time octave test.m: user    0m21.189s
>>> where we see that Octave took 21.189 seconds  (like 7
>> times matlab)
>>> Till here nothing strange since I was exectuing the
>> matpow.m file.
>>> Now I compile the matpow.cc and I crosscheck that
>> octave sees it:
>>>
>>> octave:1> help matpow
>>> Return b = a^n for square matrix a, and non-negative,
>> integral
>>> n./home/luca/Desktop/testing_perf/matpow.oct
>>> ......
>>>
>>> where we see that indeed it does see it in
>>> /home/luca/Desktop/testing_perf/matpow.oct
>>>
>>> So now I run again the test: and we see that the the
>> time is now 20.161s
>>> very slight variation with respect to the non compiled
>> case.
>>>
>>> I thought it could be a matter of overload taken by
>> octave to startup so I
>>> decided to increase the matrix size to 3000x3000 where
>> we would expect that
>>> this should run for around 10 minutes so that the
>> starting overhead should
>>> be negligible
>>>
>>>
>>>
>>>
>>> By running the .m file with matlab I get: 1m3.564s
>>>
>>> By running the .oct file with octave I get: a user
>> time 8m59.474s
>>> By running the .m file with octave I get: 8m58.702s
>>>
>>>
>>>
>>> So I do not get any increase of performance by
>> compiling the matlab
>>> matpow.cc .
>>>
>>>
>>> What am I missing?
>>
>> What Octave version do you use? How is it configured?
>> The speed of large matrix multiplication is basically all
>> about what
>> BLAS library you use. If Octave doesn't find a suitable
>> BLAS library,
>> it will compile a simplistic one for you, but depending on
>> what
>> Fortran compiler you use, the compiled thing's speed
>> may range from "a
>> little slow" to "really slow". Also, chances
>> are that your Matlab's
>> BLAS is exploiting multiple cores, if you have a multi-core
>> machine.
>>
>> -- 
>> RNDr. Jaroslav Hajek
>> computing expert
>> Aeronautical Research and Test Institute (VZLU)
>> Prague, Czech Republic
>> url: www.highegg.matfyz.cz
>> _______________________________________________
>> Help-octave mailing list
>> Help-octave at cae.wisc.edu
>> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
> 
> I've tested that http://wiki.octave.org/wiki.pl?CodaTutorial matpow.cc
> example on my self-built (including self-built ATLAS) 'octave' - the
> machine runs 32 bit OS.
> 
> Here is the benchmark:
> 
> "
> octave:8> tic;a=matpow(rand(1000),10);toc;
> Elapsed time is 3.52261 seconds.
> "
> 
> - not bad.
> 
> The CPU is AMD X2 (AM2) 5000+.
> 
> Regards,
>   Sergei.
> 
> 
>       
> _______________________________________________
> Help-octave mailing list
> Help-octave at cae.wisc.edu
> https://www-old.cae.wisc.edu/mailman/listinfo/help-octave
This seems indeed very dependent on the BLAS library:
On 3.0.1 with standard blas and lapack we get (with the m-code):
tic;a=matpow(rand(1000),10);toc
Elapsed time is 20.3305 seconds.

and for the large problem
tic;a=matpow(rand(3000),10);toc
Elapsed time is 547.43 seconds.

On 2.1.73 where we had mkl from intel (with the m-code and using 1 cpu):
tic;a=matpow(rand(1000),10);toc
ans = 3.7134

and for the large problem
tic;a=matpow(rand(3000),10);toc
ans = 89.689

This makes a factor of 6 for the same code.
Peter




More information about the Help-octave mailing list