integer division exceptions on SGI

David G. Hough at validgh dgh
Tue Apr 9 15:47:04 PDT 1996


>From comp.arch.arithmetic:

From: duncanasuper.org (Duncan A. Buell)
Newsgroups: comp.arch.arithmetic
Subject: Integer division on SGI Power Challenge
Date: 8 Apr 96 15:15:58 GMT
Organization: Center for Computing Sciences (Bowie, MD)

Perhaps one of the readers of this group can help me.  We have
a 64-bit SGI Power Challenge machine on which I am doing integer
arithmetic.  If I divide by zero on this machine, the quotient 
returned is -1 and no error/trap is generated; the instruction
set manual says that no exceptions are generated by the integer
division instructions.

(Disclaimer:  On the one hand, I do not normally write my programs
so as to intentionally divide by zero, so working programs on good
data shouldn't need to worry about this.  On the other hand, it has
been my experience that bugs in programs or errors in data
streams often lead to divisions by zero, and therefore there is
a reason to be able to trap the error.) 

I have yet to get a straight answer from SGI on how to deal with
this.  There exists for the 32 bit machines (and 32 bit mode on
our machine) a floating point exception library.  If I call up
this library and ask for it to catch division by zero, I can
catch division by zero in 32-bit mode, *even with* full optimization
that (apparently?) removes the 32-bit integer DIV instruction (which,
as said above, wasn't supposed to generate a trap on exception) from
the code.  There is no (or as yet we have not received an) analogous
64-bit fpe library, so I am unable to test whether division by zero
could be caught in the obvious analogous way.

There is, however, a compiler patch we have been offered; I am told
this was requested by (among others?) NYU.  But I haven't been told
by SGI *what* this patch does.  Does it insert extra test instructions,
and if so at what cost (or do I care since the division is so slow
all else will be masked by the division time?)?

Is there anyone who has already dealt with the problem of integer
division on 64-bit SGI Power Challenge machines who could offer
comments and advice?  I would like to know *what* happens, so that
I can adjust my programs (and my confidence in their results)
accordingly.

Duncan Buell
 ----------------------------------------------------------------------
|                                                                      |
|   Duncan A. Buell                    Research Scientist              |
|   301-805-7372                       Center for Computing Sciences   |
|   301-805-7602 (FAX)                 17100 Science Drive             |
|   duncanasuper.org                   Bowie, Maryland 20715           |
|                                                                      |
|              "The one who says it cannot be done                     |
|           must not interrupt the one who is doing it."               |
 ----------------------------------------------------------------------



From: omaraboston.sgi.com (Omar G. Stradella)
Newsgroups: comp.arch.arithmetic
Subject: Re: Integer division on SGI Power Challenge
Date: 9 Apr 96 18:08:35 GMT
Organization: Silicon Graphics, Inc.

Duncan A. Buell wrote:
> 
> [what you read above]
>

Patch 1085 adds a branch if the divisor is non zero, if it is, then a 
break is taken (the same mechanism used by the old 32-bit compiler).
The check is added only if the -TENV:check_div is used to compile. So
you can apply it selectively, if you want. The extra time for those
instructions is hidden by the long ltency of the divide. If you 
install IRIX 6.2, this functionality is already built in the compiler.

Omar.
+-------------------------------------------------------------------+
 Omar G. Stradella, Ph.D.                     Silicon Graphics, Inc. 
 E-mail: omaraboston.sgi.com                 Computational Chemistry 
 Phone:  +1-(508) 567-2258                http://www.sgi.com/ChemBio 
 FAX:    +1-(508) 562-4755     http://reality.sgi.com/employees/omar 
+------  Ph-nglui mglw'nafh Cthulhu R'lyeh wgah'nagl fhtagn  -------+



More information about the Numeric-interest mailing list