Usenet comp.os.linux.alpha (1997-2013)
 help / color / mirror / Atom feed
From: Tone Kokalj <Tone.Kokalj@ijs.si>
Subject: Re: Floating Point Exception
Date: 1999/09/10	[thread overview]
Message-ID: <37D8A7F4.1C96A97A@ijs.si> (raw)
In-Reply-To: 874sh4rzfs.fsf@gmx.de

Eberhard Burr wrote:

> hmm, seems when two weeks ago after I had just installed this nice
> SX164, my news system was misconfiged and thus my call for help in the
> very same subject didn't get thru... I've since learned the following
> and I'd appreciate to get even more (or better) information on it.
>
> Here we go:
>  1) the Alpha is not fully IEEE compliant by itself and differs from
>     other processors in that the FPU exception cannot be switched off.
>     When a division by zero appears then other processors represent
>     the result with a special bit pattern which has the meaning "this
>     result is invalid" while the alpha fires an exception (same for
>     underflows, overflows and undefined operations, of course)
>  2) the alpha is faster in floating point. Part of this is because it
>     doesn't have to treat those special bit patterns (NaN, INF and
>     friends, which are defined somewhere in math.h on i86 Linux).
>  3) someone suggested using the -mieee switch to gcc to get the same
>     behaviour as with the defaults on i86. I have not tried it though.
>  4) Exception handling is easy:
>
>    a) make a global variable to hold error codes
>      volatile int my_err;
>
>    b) write the error handler, which might be as lean as
>      static void my_fpu_handler(int err)
>      {
>        my_err = err;  /* my_err defined globally and volatile */
>      }
>
>    c) install the handler:
>
>      void (*oldhandler)();  /* keep a reference to the initial value
>                                so it can be restored later */
>
>      oldhandler = signal(SIGFPE, my_fpu_handler);
>      if (SIG_ERR == oldhandler) {
>         /* you might want to write your own BARF(), of course */
>         BARF("cannot install floating point exception handler");
>     }
>
>    d) instead of using the functions isnan(), finite() and friends to
>     check results for validity, check the content of my_err and reset
>     it to zero after having taken sensible measures.
>
>  5) Code which neither uses exception handling nor the ieee-conformant
>     finite() isnan() ... functions to test results is broken by
>     design.
>
>  6) the gcc-documentation is rather good, it's just a bit hard to read
>     because it's in info format. Same for the glibc-documentation;
>     -mieee and friends are described in the egcs node about
>     architecture-dependent options, the signal() function is in the
>     glibc docs. Both are definitely worth reading if you want to make
>     use of the alpha's superior floating point performance.


Thank You Eberhard. I will see what I can do. Certainly, above are nice
hints. When I will study them and perform some tests I will be probably
back; I may have a couple of questions then.

Best regards,
Tone

--
+------------------------------------------------------------------------+
| Tone Kokalj                                  Email: Tone.Kokalj@ijs.si |
| Department of Physical and Organic Chemistry Phone: x 386 61 177 3520  |
| Jozef Stefan Institute                         Fax: x 386 61 177 3811  |
| Jamova 39, SI-1000 Ljubljana                                           |
| SLOVENIA                                                               |
+------------------------------------------------------------------------+






  reply	other threads:[~1999-09-10  4:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-09-07  4:00 Floating Point Exception Tone Kokalj
1999-09-07  4:00 ` Greg Lindahl
1999-09-07  4:00 ` J. Josh Feng
1999-09-08  4:00   ` Greg Lindahl
1999-09-09  4:00     ` Tone Kokalj
1999-09-09  4:00       ` Eberhard Burr
1999-09-10  4:00         ` Tone Kokalj [this message]
1999-09-08  4:00   ` Tone Kokalj
1999-09-08  4:00     ` J. Josh Feng
1999-09-08  4:00       ` Greg Lindahl
  -- strict thread matches above, loose matches on Subject: below --
2001-05-29 10:11 Floating point exception BERTRAND Joël
2001-05-29 12:50 ` BERTRAND Joël
2001-06-25 21:45   ` Ken Whaley
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox