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: Eberhard Burr Subject: Re: Floating Point Exception Date: 1999/09/09 Message-ID: <874sh4rzfs.fsf@gmx.de>#1/1 X-Deja-AN: 522978001 References: <37D5DA1B.7259C242@percy.engr.wisc.edu> <7r5uqr$k66@news2.newsguy.com> <37D7A42E.91156981@ijs.si> X-Server-Date: 9 Sep 1999 13:23:35 GMT Content-Type: text/plain; charset=US-ASCII X-Complaints-To: usenet@rz.uni-karlsruhe.de X-Trace: news.rz.uni-karlsruhe.de 936888911 18418 129.13.216.95 X-Face: 2:,sX1r0xdA[z_iePptW'G?^2L=*gWY0nw*:*PA>=!#c7C?zFR@uZY#ZT_ZuIt?1*aed.rC m!?L%Z>v/\W:$=2kJh+F*]i]`q^p2!WUuRdL4b-?|%K-ig%xV1/KUShOF05kd:/:W7\@#v(R"N*xF6 Tmo&V+q+tjOmN=S~T5p`|n Organization: alpha, beta, crash. Mime-Version: 1.0 (generated by tm-edit 7.108) Newsgroups: comp.os.linux.alpha Tone Kokalj writes: > First, I do think that FPE is not due to GCC, since compiled programs with > DEC FORTAN90 have > nothing to do with GCC, but yet FPE occurs. > > Yesterday I compiled kernel 2.2.12. It runs OK, and there are no more > messages. > > However, I still don't know how to get rid of FPEs. Do You have any recipes > how > to get rid of that??? 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. kind regards, -- Eberhard Burr check http://www.uni-karlsruhe.de/~Eberhard.Burr/publickey.asc for PGP Key -- #include -- electric cookie follows Truly simple systems... require infinite testing. -- Norman Augustine