help-octave
[Top][All Lists]
Advanced

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

Re: how to improve the speed of octave?


From: frank wang
Subject: Re: how to improve the speed of octave?
Date: Fri, 15 Sep 2006 13:41:35 -0700

Unfortunately, I could not find a pre-built octave 2.9.8 for suse 10.1. I did not install zlib because I only need to make the octave compitable with Matlab. My understanding is that zlib will help octave to load some compressed data. Since this might not be work for matlab, I did not install it.
 
After I install the Atlas, zlib, fftw3, does octave will automatically link to these library or I have to enable them by some flags?
 
Thanks
 
Frank

 
On 9/15/06, Przemek Klosowski <address@hidden> wrote:
We all remember that you compile your own Octave; this has already
caused some complications, e.g. when you didn't have the zlib library
on your system (although it did help to fix a related bug). Octave
really works better if you compile with with the optimal set of
libraries such as FFTW and Atlas and zlib. Unfortunately :) it will
also compile in a reduced environment.

Is there a chance that you'd install one of the versions compiled by
the Octave maintainers, who take care of including the best-of-breed
libraries?  On RPM systems (Fedora/Mandrake/RedHat/etc) it is as
simple as 'yum install octave-forge'; on Debian APT systems it is
'apt-get install octave-forge'.

To address your question directly, Octave, when linked fast libraries
such as FFTW and Atlas, is quite competitive on the raw numerical
calculations. Most of the time the slowness is caused by interpreted
loops, operating on small data chunks, rather than giving a chance to
the numerical libraries to rip through whole large arrays at a time
(traditionally, this is called 'vectorizing').

Here's a good example:  a 89MB array that we total up in a vectorized
way using the sum() builtin, and using explicit loops:

a=hilb(3333);
tic;sum(sum(a));toc
   Elapsed time is 0.321 seconds.
tic; summa=0; [M,N]=size(a); for i=1:M; for j=1:N; summa+=a(i,j); end; end; toc
   Elapsed time is 233.91 seconds.

In this case, the explicit loop is slower by a factor of 700! Such
slowdown is inevitable, but, unfortunately, it is more pronounced in
Octave than in Matlab.

Of course, not all loops are as easy to vectorize as this one;
sometimes it requires Octave code which may be difficult to write and
hard to read/understand, and sometimes it's just plain impossible.


reply via email to

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