help-octave
[Top][All Lists]
Advanced

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

Re: Norm problem in Octave 3.4.0 (Mac?)


From: Thomas Treichl
Subject: Re: Norm problem in Octave 3.4.0 (Mac?)
Date: Fri, 01 Apr 2011 10:34:17 +0200
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; de; rv:1.9.2.15) Gecko/20110303 Thunderbird/3.1.9

Am 31.03.11 16:39, schrieb Vic Norton:
Last week I installed Julien Salort's Octave 3.4.0 for Mac OSX 10.6. It
seemed to work perfectly until I tried some heavy duty computation. Now
I see that Julien's Octave 3.4.0 compilation has the slow norm2 problem
that afflicted versions of Octave prior to version 2.9.15 (Oct 2007). I
don't know whether this is an Octave 3.4.0 problem per se or a problem
with Julien's Mac compilation of Octave 3.4.0.

I have compared the speed of the instructions "norm(x)" and
"sqrt(sum(x .* x))" on Thomas Treichl's Octave.app (3.2.3) and Julien
Salort's Octave.app (3.4.0). These versions of octave can be found at
http://sourceforge.net/projects/octave/files/Octave%20MacOSX%20Binary/
2011-03-27 binary of Octave 3.4.0 (2011-03-27)
2009-10-03 binary of Octave 3.2.3 (2010-11-23)

Here is a summary of the results I observed.
1. Octave 3.4.0 is a bit slower than Octave 3.2.3 on sqrt(sum(x .* x)).
2. On Octave 3.2.3, norm(x) is a bit faster than sqrt(sum(x .* x)). This
    is as it should be since NRM2 is a BLAS.
3. On Octave 3.4.0, sqrt(sum(x .* x)) is four times as fast as norm(x).
    This is not as it should be for the reason cited in 2.
4. norm(x) on Octave 3.2.3 is nine times as fast as norm(x) on Octave
    3.4.0.

My test script and my results appear below.

Regards,

Vic

The test script. The two different shebang lines placed at the top
test the two different versions of octave.
    #!/usr/local/bin/octave323

    # norm2test.m

    #!/usr/local/bin/octave323
    #!/usr/local/bin/octave340

    ntests = 20; n = 1e6; x = rand(n, 1);
    test1 = zeros(ntests, 1); test2 = zeros(ntests, 1);

    for i = 1 : ntests
      tic;
      norm(x);
      test1(i) = toc;
    endfor
    for i = 1 : ntests
      tic;
      sqrt(sum(x .* x));
      test2(i) = toc;
    endfor

    printf ("norm2 speed test - octave %s\n", version);
    printf ("%40s\n","ellapsed times");
    printf ("%30s%10s\n", "mean", "stdv");
    printf ("%-20s", "norm(x)");
    printf ("%10.2e", mean(test1));
    printf ("%10.2e", std(test1));
    printf ("\n");
    printf ("%-20s", "sqrt(sum(x .* x))");
    printf ("%10.2e", mean(test2));
    printf ("%10.2e", std(test2));
    printf ("\n");


The output.
---
GNU Octave, version 3.2.3
Copyright (C) 2009 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type `warranty'.

Octave was configured for "i386-apple-darwin8.11.1".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/help-wanted.html

Report bugs to<address@hidden>  (but first, please read
http://www.octave.org/bugs.html to learn how to write a helpful report).

For information about changes from previous versions, type `news'.

norm2 speed test - octave 3.2.3
                         ellapsed times
                         mean      stdv
norm(x)               7.06e-03  2.62e-05
sqrt(sum(x .* x))     1.06e-02  1.98e-03
---

GNU Octave, version 3.4.0
Copyright (C) 2011 John W. Eaton and others.
This is free software; see the source code for copying conditions.
There is ABSOLUTELY NO WARRANTY; not even for MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  For details, type `warranty'.

Octave was configured for "i386-apple-darwin10.6.0".

Additional information about Octave is available at http://www.octave.org.

Please contribute if you find this software useful.
For more information, visit http://www.octave.org/help-wanted.html

Read http://www.octave.org/bugs.html to learn how to submit bug reports.

For information about changes from previous versions, type `news'.

norm2 speed test - octave 3.4.0
                         ellapsed times
                         mean      stdv
norm(x)               6.48e-02  3.78e-04
sqrt(sum(x .* x))     1.46e-02  1.21e-04
---

Hi Vic,

if I can remember correctly then there have been some bug-fixes by David which had been applied and the modification, that I compiled the APP with very high optimization since then, ie. I tried several compiler flags to improve the speed, eg. I used -O3 and the -march=i686 flags etc. (there is no Mac with an Intel processor < i686). You can take a look which options I used if you take an old Octave.app and type the command

  octave_config_info ()

Best regards

  Thomas


reply via email to

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