Help catching floating point exceptions

sdl sdl at adagio.austin.ibm.com
Wed May 29 12:26:08 AEST 1991


>>>>> gl8f at astsun.astro.Virginia.EDU (Greg Lindahl) writes:


In article <1991May27.213751.24223 at murdoch.acc.Virginia.EDU> gl8f at 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 at adagio.austin.ibm.com        VNET: LINAM at AUSTIN
>From outside IBM:  sdl at glasnost.austin.ibm.com



More information about the Comp.unix.aix mailing list