[Top][All Lists]

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

Re: how to improve the speed of octave?

From: Przemek Klosowski
Subject: Re: how to improve the speed of octave?
Date: Fri, 15 Sep 2006 16:16:10 -0400 (EDT)

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:

    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]