octave-maintainers
[Top][All Lists]
Advanced

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

Re: sparse matrices and error handling


From: Paul Kienzle
Subject: Re: sparse matrices and error handling
Date: Mon, 18 Nov 2002 10:05:48 -0500
User-agent: Mutt/1.2.5.1i

On Sun, Nov 17, 2002 at 07:42:22PM -0600, John W. Eaton wrote:
> On 17-Nov-2002, Paul Kienzle <address@hidden> wrote:
> | BTW, isn't it a misnomer to refer to the setjmp/longjmp setup as only
> | applying to foreign code?  It seems to me that you would want it around
> | any code which can take more than 1/2 second or so to complete, even
> | if it is coded in C++ and is part of liboctave.  If you don't have it,then
> | how can you break out of such code since Ctrl-C can't directly throw an
> | exception?
> 
> In code that we can modify (all of Octave) we can use the new
> OCTAVE_QUIT macro.  It checks to see if an interrupt has occurred, and
> if so, throws an exception.  So everything that is not part of Octave
> and that doesn't allow us to insert checks for the interrupt state and
> maybe throw exceptions is "foreign code" that has to handle interrupts
> some other way.  The simplest way seems to be a longjmp out of a
> signal handler and back to the location where the foreign code was
> called, then throw an exception.

I was assuming that we wouldn't want to interfere with the optimizer by
putting OCTAVE_QUIT in the middle of a tight loop.  To demonstrate this
I looked for an appropriate loop in filter.cc, but I see that that is 
where you put the OCTAVE_QUIT.  

I measure a 4% in the following unrealistic case:

        octave> x=rand(20000,1);
        octave> b = hanning(1024);

        With OCTAVE_QUIT

        octave> tic; filter(b,1,x); toc
        ans = 2.2529

        OCTAVE_QUIT in outer loop only:

        octave> tic; filter(b,1,x); toc
        ans = 2.2023

        Without OCTAVE_QUIT

        octave> tic; filter(b,1,x); toc
        ans = 2.1686


In the following realistic case there is less than 1% performance
penalty:

        octave:9> [b,a]=butter(8,0.3);

        With OCTAVE_QUIT
        octave> tic; filter(b,a,x); toc
        ans = 0.039206

        Without OCTAVE_QUIT
        octave> tic; filter(b,a,x); toc
        ans = 0.038891

Am I correct in assuming nobody will be bothered by this?  I start to
get concerned when it is more than 10-15%, so it doesn't bother me.
         
Paul Kienzle
address@hidden



reply via email to

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