Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!sdd.hp.com!cs.utexas.edu!romp!auschs!awdprime!awdprime.austin.ibm.com!sdl From: sdl@adagio.austin.ibm.com (sdl) Newsgroups: comp.unix.aix Subject: Re: Help catching floating point exceptions Message-ID: Date: 29 May 91 02:26:08 GMT References: <1991May27.213751.24223@murdoch.acc.Virginia.EDU> Sender: news@awdprime.UUCP Reply-To: sdl@glasnost.austin.ibm.com Organization: IBM PS Programming Lines: 53 In-reply-to: gl8f@astsun.astro.Virginia.EDU's message of 27 May 91 21:37:51 GMT >>>>> gl8f@astsun.astro.Virginia.EDU (Greg Lindahl) writes: In article <1991May27.213751.24223@murdoch.acc.Virginia.EDU> gl8f@astsun.astro.Virginia.EDU (Greg Lindahl) writes: greg> After perusing the info reader (man -k fp produces a nice list of man greg> pages which man can't find...), I am attempting to use fp_enable_all greg> to generate floating point traps. It isn't clear from the manual what greg> an FP trap is on an RS/6000. Nevertheless, I'm still praying that greg> there's a way to get my programs to die gracelessly when they hit a greg> problem. greg> The program below calls fp_enable_all() and then divides by zero. No greg> signal is generated, but an explicit test for divide by zero produces greg> a positive result. AIX 3.1 does not support taking a trap on floating point exceptions. The Risc System/6000 hardware will not generate a floating point trap unless the machine is put into serialized mode (changing the FE bit in the machine status register (MSR) to 1). The instruction to do this is privledged, and in AIX 3.1 there is no kernel service to do this. BTW, in order to to generate a trap you must also enable the specific floating point exceptions that you want to trap, which is what the fp_enable() and fp_enable_all() routines do. However, as I said above, you have to change MSR(FE) as well. We're aware that there is need for floating point exception traping. Be aware, however, that if/when it is available that it only works when the machine is in serialized mode, and this means a performance impact. For "production", or "performance critical", or whatever you call your programs that have to run fast, you can get much better performance by checking the floating point status bits using the routines provided for that purpose (such as fp_divbyzero() in the case of zero division) at "appropriate" times.. Fortran provides an inline instruction for checking the floating point status and control register for this same purpose, but I don't remember what it is called. If you're dealing with such issues, if you don't have this manual you should: IBM RISC System/6000 POWERstation and POWERserver Hardware Technical Reference General Information, SA23-2643. The chapter on the floating point processor has much more information than any of the on-line pubs. Usual disclaimer: I write code, not make policy; this is not an official IBM pronouncement, etc. -- -------------------------------------------------------------------- Stephen Linam PSP Austin T/L: 793-3674 Bell-net: (512) 823-3674 IBM Internet: sdl@adagio.austin.ibm.com VNET: LINAM at AUSTIN From outside IBM: sdl@glasnost.austin.ibm.com