Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* floating exception
@ 1998-01-13 11:00 Alessandro Mirone
  0 siblings, 0 replies; 13+ messages in thread
From: Alessandro Mirone @ 1998-01-13 11:00 UTC (permalink / raw)


Hi people,
  
  I get "floating exceptions" (and core dump) from some programs
that gave NaN when compiled on a PC-Linux.
 Could someone give me somt tips about how
to deal with it?  a solution of course would be checking the 
values before doing mathematical operations.
 But apart that could I use some compilation switch to get NaN
and avoid crashing the programs?
Any help is appreciated
bye 

Alessandro MIRONE
LULI, 91128  Ecole Polytechnique, Palaiseau
alex@greco2.polytechnique.fr
tel: (33) (1) 64468029
Tel cellulaire : 0681643779 

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: floating exception
       [not found] <Pine.SOL.3.91.980113105530.27582E-100000@greco2>
@ 1998-01-13 13:25 ` Jerry Feldman
  0 siblings, 0 replies; 13+ messages in thread
From: Jerry Feldman @ 1998-01-13 13:25 UTC (permalink / raw)


Alessandro Mirone <alex@greco2.polytechnique.fr> wrote:
>   
>   I get "floating exceptions" (and core dump) from some programs
> that gave NaN when compiled on a PC-Linux.
>  Could someone give me somt tips about how
> to deal with it?  a solution of course would be checking the 
> values before doing mathematical operations.
>  But apart that could I use some compilation switch to get NaN
> and avoid crashing the programs?
> Any help is appreciated
> bye 
You must compile with ieee. The Alpha chips generate an exception on several conditions such as NaN, Infinities, denormals. These must be handled in an exception handler. Use the -mieee when compiling with GCC.

+--------------------------------------------------------------------+
Jerry Feldman            Digital Unix Development Environment
Digital Equipment Corp.  (work)gaf@zk3.dec.com (home)gaf@mediaone.net
110 Spitbrook Rd.        Mailstop: ZKO3-2/W17
Nashua, NH 03062-9987    (603)884-2970, DTN:264-2970
+--------------------------------------------------------------------+
 

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: floating exception
@ 1998-01-13 13:44 David Alan Gilbert
  0 siblings, 0 replies; 13+ messages in thread
From: David Alan Gilbert @ 1998-01-13 13:44 UTC (permalink / raw)


Jerry Feldman wrote:

> You must compile with ieee. The Alpha chips generate an exception on several conditions such as NaN,
> Infinities, denormals. These must be handled in an exception handler. Use the -mieee when compiling with GCC.

What does -mieee do? Does it contain a library of exception handlers or does it
turn the
exceptions off. (I would kind of expect the kernel to handle denormals, although
NaN's and Infinities
I can imagine the user getting).

Dave

-- 
----------------------------------------------------------------------
- Dr. David Alan Gilbert - WARNING! This is a beta release .signature-
- Work:    dg @ cogency.co.uk        -    0161-428-9444              -
- Home:    gro.gilbert @ treblig.org -                               -
----------------------------------------------------------------------

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: floating exception
@ 1998-01-13 15:09 Richard Hadsell
  0 siblings, 0 replies; 13+ messages in thread
From: Richard Hadsell @ 1998-01-13 15:09 UTC (permalink / raw)


Alessandro Mirone wrote:
> 
> Hi people,
> 
>   I get "floating exceptions" (and core dump) from some programs
> that gave NaN when compiled on a PC-Linux.
>  Could someone give me somt tips about how
> to deal with it?  a solution of course would be checking the
> values before doing mathematical operations.
>  But apart that could I use some compilation switch to get NaN
> and avoid crashing the programs?
> Any help is appreciated
> bye

Have you tried compiling with "-mieee"?  It worked for me, for similar
problems.  If your program fails to compile because of an internal
compiler error, you may have to reduce the optimization level.  But it
probably won't -- I'm running on an alpha.

-- 
Dick Hadsell			914-381-8400  Fax: 914-381-9790
Reply-to:			hadsell@blueskystudios.com
Blue Sky | VIFX			http://www.blueskystudios.com
1 South Road, Harrison, NY 10528

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: floating exception
       [not found] <34BB6FB0.1092A7A0@cogency.co.uk>
@ 1998-01-13 15:24 ` Jerry Feldman
  0 siblings, 0 replies; 13+ messages in thread
From: Jerry Feldman @ 1998-01-13 15:24 UTC (permalink / raw)


David Alan Gilbert <dg@cogency.co.uk> wrote:

> What does -mieee do? Does it contain a library of exception handlers or does it
> turn the
> exceptions off. (I would kind of expect the kernel to handle denormals, although
> NaN's and Infinities
> I can imagine the user getting).
Specifically, this tells the compiler to generate floating point instructions with the /s (software completion) option. (eg. multsu $f10, $f11, $f12 # multiply registers $f10 by $f11 (t-floating format) with software completion, underflow enabled). If either input contains an invalid value (denormal, NaN, ...) or the result underfloaws or is invalid, generate a trap. The kernel should contain the appropriate code to perform the fixup. (Note: I am not 100% sure of Linux. I am responsible for the Digital Unix kernel floating point completion). 
+--------------------------------------------------------------------+
Jerry Feldman            Digital Unix Development Environment
Digital Equipment Corp.  (work)gaf@zk3.dec.com (home)gaf@mediaone.net
110 Spitbrook Rd.        Mailstop: ZKO3-2/W17
Nashua, NH 03062-9987    (603)884-2970, DTN:264-2970
+--------------------------------------------------------------------+
 

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: floating exception
@ 1998-01-13 16:03 David Gilbert
  1998-01-13 17:18 ` Jerry Feldman
  0 siblings, 1 reply; 13+ messages in thread
From: David Gilbert @ 1998-01-13 16:03 UTC (permalink / raw)


> What does -mieee do? Does it contain a library of exception handlers or does it
	> turn the
	> exceptions off. (I would kind of expect the kernel to handle denormals, although
	> NaN's and Infinities
	> I can imagine the user getting).
	Specifically, this tells the compiler to generate floating
	point instructions with the /s (software completion) option.
	(eg. multsu $f10, $f11, $f12 # multiply registers $f10 by $f11
	(t-floating format) with software completion, underflow
	enabled). If either input contains an invalid value (denormal,
	NaN, ...) or the result underfloaws or is invalid, generate a
	trap. The kernel should contain the appropriate code to perform
	the fixup. (Note: I am not 100% sure of Linux. I am responsible
	for the Digital Unix kernel floating point completion).

So what happens without -mieee? He is seeing traps without -mieee.

Dave

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: floating exception
  1998-01-13 16:03 David Gilbert
@ 1998-01-13 17:18 ` Jerry Feldman
  0 siblings, 0 replies; 13+ messages in thread
From: Jerry Feldman @ 1998-01-13 17:18 UTC (permalink / raw)


dg@cogency.co.uk (David Gilbert) wrote:
> So what happens without -mieee? He is seeing traps without -mieee.
If you do not compile with -mieee, application will receive a SIGFPE 
exception, and crash if the signal is not handled, in the case of NaNs, 
Infinities, and denormals.
+--------------------------------------------------------------------+
Jerry Feldman            Digital Unix Development Environment
Digital Equipment Corp.  (work)gaf@zk3.dec.com (home)gaf@mediaone.net
110 Spitbrook Rd.        Mailstop: ZKO3-2/W17
Nashua, NH 03062-9987    (603)884-2970, DTN:264-2970
+--------------------------------------------------------------------+
 

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: floating exception
@ 1998-01-13 20:11 Richard Hadsell
  0 siblings, 0 replies; 13+ messages in thread
From: Richard Hadsell @ 1998-01-13 20:11 UTC (permalink / raw)


David Gilbert wrote:
> 
>         > What does -mieee do? Does it contain a library of exception handlers or does it
>         > turn the
>         > exceptions off. (I would kind of expect the kernel to handle denormals, although
>         > NaN's and Infinities
>         > I can imagine the user getting).
>         Specifically, this tells the compiler to generate floating
>         point instructions with the /s (software completion) option.
>         (eg. multsu $f10, $f11, $f12 # multiply registers $f10 by $f11
>         (t-floating format) with software completion, underflow
>         enabled). If either input contains an invalid value (denormal,
>         NaN, ...) or the result underfloaws or is invalid, generate a
>         trap. The kernel should contain the appropriate code to perform
>         the fixup. (Note: I am not 100% sure of Linux. I am responsible
>         for the Digital Unix kernel floating point completion).
> 
> So what happens without -mieee? He is seeing traps without -mieee.

The point is that -mieee allows code to gracefully handle NaNs and
denormalized numbers.  Without it, the floating-point exception handler
cannot produce a reasonable result and let the program continue.  A
reasonable result would be a NaN if one of the operands is a NaN, and it
would probably be a 0 if a denormalized number is multiplied by
something.

You might have noticed that -mieee implies some other options which
increase the granularity of exception context information to the
instruction level.  I don't know what other effects it has on the actual
generated code.

-- 
Dick Hadsell			914-381-8400  Fax: 914-381-9790
Reply-to:			hadsell@blueskystudios.com
Blue Sky | VIFX			http://www.blueskystudios.com
1 South Road, Harrison, NY 10528

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: floating exception
@ 1998-01-13 21:25 Stefan Traby
  0 siblings, 0 replies; 13+ messages in thread
From: Stefan Traby @ 1998-01-13 21:25 UTC (permalink / raw)


> dg@cogency.co.uk (David Gilbert) wrote:
> > So what happens without -mieee? He is seeing traps without -mieee.
> If you do not compile with -mieee, application will receive a SIGFPE 
> exception, and crash if the signal is not handled, in the case of NaNs, 
> Infinities, and denormals.

oups, hmm, ok, you agree with me that the following is heavy outdated ?

--------------
   This is Edition 0.06, last updated 23 December 1994, of `The GNU C
Library Reference Manual', for Version 1.09 Beta of the GNU C Library.
--------------

--------------
   None of the mathematical functions ever generates signals as a
result of domain or range errors.  In particular, this means that you
won't see `SIGFPE' signals generated within these functions.  (*Note
Signal Handling::, for more information about signals.)
--------------

What means this good old text: None of the ANS-C fp-funcs (in libc) use
if(NAN != NAN) raise(SIGFPE); internally,
but the kernel may raise real fpu-exception by sending SIGFPE ?? 

I interpret this as: If you use glibc ANS-C fp-funcs only (not asm-inline), 
installing an SIGFPE handler is a paranoid action.

I think this info-file is only outdated and obsolete.
I don't have an AXP nor I wrote fp-code over the last three years...

gcc handles NAN well under i387+ because FPU-exceptions on an intel
can be masked. I don't know it, but your posting makes me think
that masking is not possible on AXP, so this info-file is simply
outdated because it depends on FPUs where exceptions may be masked.
Is this assumption correct ?
If it's correct  than "-mieee" means libm installs a SIGFPE handler itself and
fakes errno, but without "-mieee", SIGFPE is passed to the app ?
I'm in panic for now. If SIGFPE cannot be avoided at all
(ok, it can, SIG_IGN, -mieee), fp-pthreads programming must be near to hell.)
At moment, I know nothing but I'm heavy confused. :-(
In my "dream word" SIGFPE doesn't exists.
Give me some light, please.

-- 
  ciao - 
    Stefan

Stefan Traby                            phone:  +43-3133-6107-2
Mitterlasznitzstr. 13                     fax:  +43-3133-6107-9
8302 Nestelbach                        mailto://stefan@sime.com
Austria

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: floating exception
       [not found] <199801132125.WAA03288@stefan.sime.com>
@ 1998-01-13 22:42 ` Michal Jaegermann
  1998-01-14 13:29 ` Jerry Feldman
  1 sibling, 0 replies; 13+ messages in thread
From: Michal Jaegermann @ 1998-01-13 22:42 UTC (permalink / raw)


Stefan Traby writes:
> I don't know it, but your posting makes me think
> that masking is not possible on AXP, so this info-file is simply
> outdated because it depends on FPUs where exceptions may be masked.
> Is this assumption correct ?

No, it is not.  Kernel provides ieee_set_fp_control() (see <asm/fph.h>)
which does what it implies **provided** -mieee flag was used
during a compilation.

This facility may have bugs and it is not really documented, unless
a comment in the mentioned header may be taken for a documentation, but
it is there and it works - to an extent.  Sources imply that its
prototype should be 'unsigned long ieee_set_fp_control(unsigned long);'
but do not quote me on that. :-)

  Michal

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: floating exception
       [not found] <199801132242.PAA03608@ellpspace.math.ualberta.ca>
@ 1998-01-14  9:58 ` Alessandro Mirone
  0 siblings, 0 replies; 13+ messages in thread
From: Alessandro Mirone @ 1998-01-14  9:58 UTC (permalink / raw)


> Stefan Traby writes:
> > I don't know it, but your posting makes me think
> > that masking is not possible on AXP, so this info-file is simply
> > outdated because it depends on FPUs where exceptions may be masked.
> > Is this assumption correct ?
> 
> No, it is not.  Kernel provides ieee_set_fp_control() (see <asm/fph.h>)
....
> a comment in the mentioned header may be taken for a documentation, but
> it is there and it works - to an extent.  Sources imply that its
> prototype should be 'unsigned long ieee_set_fp_control(unsigned long);'

Hi,

I did a  grep ieee_set_fp_control on my  whole kernel tree and the 
/usr/include tree on my system :
  I just found this comment

"
  include/asm/fpu.h: * ieee_set_fp_control() etc. can be implemented 
easily and  .....
"
do you mean that it is not yet implemented(at least on my system)?
If not, are patches available?

Best regards
    Alessandro

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: floating exception
       [not found] <199801132125.WAA03288@stefan.sime.com>
  1998-01-13 22:42 ` floating exception Michal Jaegermann
@ 1998-01-14 13:29 ` Jerry Feldman
  1 sibling, 0 replies; 13+ messages in thread
From: Jerry Feldman @ 1998-01-14 13:29 UTC (permalink / raw)


Stefan Traby <stefan@sime.com>  wrote:
> 
> gcc handles NAN well under i387+ because FPU-exceptions on an intel
> can be masked. I don't know it, but your posting makes me think
> that masking is not possible on AXP, so this info-file is simply
> outdated because it depends on FPUs where exceptions may be masked.
> Is this assumption correct ?
> If it's correct  than "-mieee" means libm installs a SIGFPE handler itself and
> fakes errno, but without "-mieee", SIGFPE is passed to the app ?
> I'm in panic for now. If SIGFPE cannot be avoided at all
> (ok, it can, SIG_IGN, -mieee), fp-pthreads programming must be near to hell.)
This assumption is NOT correct. The Alpha has a fast floating point mode which is the default. The -mieee causes the compiler to generate floating point instructions with the /S modifier. It is generally the kernel that handles software completion, not the math library. 
+--------------------------------------------------------------------+
Jerry Feldman            Digital Unix Development Environment
Digital Equipment Corp.  (work)gaf@zk3.dec.com (home)gaf@mediaone.net
110 Spitbrook Rd.        Mailstop: ZKO3-2/W17
Nashua, NH 03062-9987    (603)884-2970, DTN:264-2970
+--------------------------------------------------------------------+
 

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: floating exception
       [not found] <Pine.SOL.3.91.980114105358.14105A-100000@greco2>
@ 1998-01-14 16:00 ` Michal Jaegermann
  0 siblings, 0 replies; 13+ messages in thread
From: Michal Jaegermann @ 1998-01-14 16:00 UTC (permalink / raw)


> 
> > Kernel provides ieee_set_fp_control() (see <asm/fph.h>)
> ....
> 
> I did a  grep ieee_set_fp_control on my  whole kernel tree and the 
> /usr/include tree on my system :

Very good. :-)

>   I just found this comment
> 
> "
>   include/asm/fpu.h: * ieee_set_fp_control() etc. can be implemented 
> easily and  .....
> "

Right!  You found the famous "documentation". :-)  If somebody will
tell me that I missed a detailed description in some other place
I am all ears.

> do you mean that it is not yet implemented(at least on my system)?

Why?  This is, obviously, a user space function and kernel only provides
hooks to implement it.  If you want to see if you really have it you
should try something like that:

$ nm /lib/libc.so.6 | grep ieee
00000000000878e0 T __ieee_get_fp_control
0000000000087920 T __ieee_set_fp_control
00000000000878e0 W ieee_get_fp_control
0000000000087920 W ieee_set_fp_control

So it is there.  Beyond that it is trivial to write a two line C program
which uses the function and try to see if it links.  Faster and more
reliable than bothering the whole world.  And apart of that I wrote
explicitely that the function is available and even provided, guessed,
prototype for it.

  Michal

-- 
To unsubscribe: send e-mail to axp-list-request@redhat.com with
'unsubscribe' as the subject.  Do not send it to axp-list@redhat.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~1998-01-14 16:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <199801132125.WAA03288@stefan.sime.com>
1998-01-13 22:42 ` floating exception Michal Jaegermann
1998-01-14 13:29 ` Jerry Feldman
     [not found] <Pine.SOL.3.91.980114105358.14105A-100000@greco2>
1998-01-14 16:00 ` Michal Jaegermann
     [not found] <199801132242.PAA03608@ellpspace.math.ualberta.ca>
1998-01-14  9:58 ` Alessandro Mirone
1998-01-13 21:25 Stefan Traby
  -- strict thread matches above, loose matches on Subject: below --
1998-01-13 20:11 Richard Hadsell
1998-01-13 16:03 David Gilbert
1998-01-13 17:18 ` Jerry Feldman
     [not found] <34BB6FB0.1092A7A0@cogency.co.uk>
1998-01-13 15:24 ` Jerry Feldman
1998-01-13 15:09 Richard Hadsell
1998-01-13 13:44 David Alan Gilbert
     [not found] <Pine.SOL.3.91.980113105530.27582E-100000@greco2>
1998-01-13 13:25 ` Jerry Feldman
1998-01-13 11:00 Alessandro Mirone

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox