[comp.sys.sgi] floating-point exceptions

mccalpin@masig3.ocean.fsu.edu (John D. McCalpin) (11/25/89)

How does one modify the response of the floating-point exception
handler on the IRIS 4D machines?  What I want to do is to turn off
error handling for operations which have NaN as an operand, so that
the code will simply continue.

I know that in this case, the effects of the NaN's will be limited,
since the problem occurs in the scaling of some results for output....

Thanks....
--
John D. McCalpin - mccalpin@masig1.ocean.fsu.edu
		   mccalpin@scri1.scri.fsu.edu
		   mccalpin@delocn.udel.edu

deb@kea.wpd.sgi.com (Deb Ryan) (11/29/89)

Here is a short overview of the trap handler package we plan to provide 
in the next release:

caveat:  I should not be making promises -but all the work has been done.

(Edited from the man page)


Background:

  The MIPS floating-point accelerator may raise floating-point exceptions 
  due to five conditions: overflow, underflow, divide by zero, inexact result 
  or invalid operand (e.g. infinity).  Usually these conditions are masked, 
  and do not cause a floating-point exception. Instead,
  a default value is substituted for the result of the operation,
  and the program continues silently.  This event may be intercepted
  by causing an exception to be raised.  Once an exception is raised,
  the specific conditions which caused the exception may be 
  determined, and more appropriate action taken.

Our solution:

  The floating point library provides two methods to unmask and handle
  these conditions: a subroutine interface, and an environment variable.
  The environment variable requires no change to user code.

  Both methods provide a mechanism for unmasking each condition
  except inexact result, for handling and classifying exceptions arising 
  from them, and for substituting either a default value or a chosen one.
  They also provide mechanisms to count, trace, exit or abort on enabled
  exceptions.  

  If more control is required, the subroutine interface provides the ability 
  to call a user written routine.
  
  The environment variable is supported for Fortran, C and Pascal.
  The subroutine interface is supported for C and Fortran.

Limitations:
  
  Some math library routines, like sqrt, are written in software and do
  not yet conform to IEEE standards.  As a result, the square root of a 
  negative number, for example, will produce Nan and not get caught by the trap
  handler until used in user code.

--

					-Deb
					 deb@sgi.com
 					 Deborah Caruso @ Silicon Graphics