From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111c93,bbabe699fb9ce159 X-Google-Attributes: gid111c93,public From: Tone Kokalj Subject: Re: Floating Point Exception Date: 1999/09/10 Message-ID: <37D8A7F4.1C96A97A@ijs.si>#1/1 X-Deja-AN: 523278779 Content-Transfer-Encoding: 7bit References: <37D5DA1B.7259C242@percy.engr.wisc.edu> <7r5uqr$k66@news2.newsguy.com> <37D7A42E.91156981@ijs.si> <874sh4rzfs.fsf@gmx.de> Content-Type: text/plain; charset=us-ascii X-Complaints-To: newsmaster@ijs.si X-Trace: goodnews.ijs.si 936945653 14220 193.2.5.109 (10 Sep 1999 06:40:53 GMT) Organization: J. Stefan Institute Mime-Version: 1.0 Reply-To: Tone.Kokalj@ijs.si NNTP-Posting-Date: 10 Sep 1999 06:40:53 GMT Newsgroups: comp.os.linux.alpha 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 | +------------------------------------------------------------------------+