public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* Architecture floating-point underflow information wanted
@ 2012-09-25 12:52 Joseph S. Myers
  2012-09-25 13:12 ` Andreas Schwab
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Joseph S. Myers @ 2012-09-25 12:52 UTC (permalink / raw)
  To: libc-alpha, libc-ports
  Cc: Andreas Krebbel, Richard Henderson, Mark Salter,
	Carlos O'Donell, Mike Frysinger, Andreas Schwab

As part of fixing bug 14047, I'd like information about how each glibc 
architecture (libc and ports) detects floating-point underflow.  (IEEE 
754-2008 gives two options: "before rounding" (exponent would be below 
normal range if both exponent range and mantissa precision were unbounded) 
and "after rounding" (exponent of the rounded value would be below normal 
range if the exponent range were unbounded and values with all exponents 
had the same mantissa precision as for normal values).)

You can identify the choice made by an architecture by running the 
following program.  The GCC and glibc versions used to build and run the 
program don't matter, but it's best to run this on hardware not an 
emulator since it's quite possible some emulators could get this sort of 
detail wrong.  It may also be possible to find this information in 
architecture manuals.

#include <fenv.h>
#include <stdio.h>

volatile float a = 0x1.fffp-126;
volatile float b = 0x1.0008p-1;
volatile float c;

int
main (void)
{
  feclearexcept (FE_ALL_EXCEPT);
  c = a * b;
  if (fetestexcept (FE_UNDERFLOW))
    puts ("before rounding");
  else
    puts ("after rounding");
  return 0;
}

I'm looking for information for the following architectures:

s390-32, s390-64
alpha
am33
hppa
ia64
m68k (classic)

I have the following information for architectures I have access to:

x86, x86_64: after rounding
powerpc32, powerpc64: before rounding
sh: after rounding
sparc32, sparc64: before rounding
arm: before rounding
m68k (coldfire): before rounding
mips32, mips64: after rounding

(Tile does not support the underflow exception so the question is 
inapplicable there; I propose to use "before rounding" as a default for 
such architectures for strto*.)

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: Architecture floating-point underflow information wanted
  2012-09-25 12:52 Architecture floating-point underflow information wanted Joseph S. Myers
@ 2012-09-25 13:12 ` Andreas Schwab
  2012-09-25 14:18 ` Mark Salter
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Andreas Schwab @ 2012-09-25 13:12 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: libc-alpha, libc-ports, Andreas Krebbel, Richard Henderson,
	Mark Salter, Carlos O'Donell, Mike Frysinger

"Joseph S. Myers" <joseph@codesourcery.com> writes:

> m68k (classic)

According to the manual: before rounding.

M68000PRM, section 3.6.1 (p. 3-28): "At the completion of an arithmetic
operation, the intermediate result is checked to see if it is too small
to be represented as a normalized number in the selected precision. If
so, the underflow (UNFL) bit is set in the FPSR EXC byte."

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: Architecture floating-point underflow information wanted
  2012-09-25 12:52 Architecture floating-point underflow information wanted Joseph S. Myers
  2012-09-25 13:12 ` Andreas Schwab
@ 2012-09-25 14:18 ` Mark Salter
  2012-09-25 15:18 ` Carlos O'Donell
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: Mark Salter @ 2012-09-25 14:18 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: libc-alpha, libc-ports, Andreas Krebbel, Richard Henderson,
	Carlos O'Donell, Mike Frysinger, Andreas Schwab


> am33

after rounding according to test. I couldn't find anything definitive
in the manual.


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

* Re: Architecture floating-point underflow information wanted
  2012-09-25 12:52 Architecture floating-point underflow information wanted Joseph S. Myers
  2012-09-25 13:12 ` Andreas Schwab
  2012-09-25 14:18 ` Mark Salter
@ 2012-09-25 15:18 ` Carlos O'Donell
  2012-09-25 15:22   ` Carlos O'Donell
  2012-09-25 17:11 ` David Miller
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 10+ messages in thread
From: Carlos O'Donell @ 2012-09-25 15:18 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: libc-alpha, libc-ports, Andreas Krebbel, Richard Henderson,
	Mark Salter, Mike Frysinger, Andreas Schwab

On Tue, Sep 25, 2012 at 8:52 AM, Joseph S. Myers
<joseph@codesourcery.com> wrote:
> As part of fixing bug 14047, I'd like information about how each glibc
> architecture (libc and ports) detects floating-point underflow.  (IEEE
> 754-2008 gives two options: "before rounding" (exponent would be below
> normal range if both exponent range and mantissa precision were unbounded)
> and "after rounding" (exponent of the rounded value would be below normal
> range if the exponent range were unbounded and values with all exponents
> had the same mantissa precision as for normal values).)

Thanks for the test case.

> I'm looking for information for the following architectures:
>
> s390-32, s390-64
> alpha
> am33
> hppa
> ia64
> m68k (classic)

hppa (64-bit PA-RISC 2.0) is after rounding according to the test.

The manual says:
~~~
Tininess is detected on a nonzero result which lies strictly between
+/-2^(Emin), when the result is rounded as if the exponent range were
unbounded.
~~~

Thus verified by what the manual says.

Cheers,
Carlos.

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

* Re: Architecture floating-point underflow information wanted
  2012-09-25 15:18 ` Carlos O'Donell
@ 2012-09-25 15:22   ` Carlos O'Donell
  0 siblings, 0 replies; 10+ messages in thread
From: Carlos O'Donell @ 2012-09-25 15:22 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: libc-alpha, libc-ports, Andreas Krebbel, Richard Henderson,
	Mark Salter, Mike Frysinger, Andreas Schwab

On Tue, Sep 25, 2012 at 11:17 AM, Carlos O'Donell
<carlos@systemhalted.org> wrote:
> On Tue, Sep 25, 2012 at 8:52 AM, Joseph S. Myers
> <joseph@codesourcery.com> wrote:
>> As part of fixing bug 14047, I'd like information about how each glibc
>> architecture (libc and ports) detects floating-point underflow.  (IEEE
>> 754-2008 gives two options: "before rounding" (exponent would be below
>> normal range if both exponent range and mantissa precision were unbounded)
>> and "after rounding" (exponent of the rounded value would be below normal
>> range if the exponent range were unbounded and values with all exponents
>> had the same mantissa precision as for normal values).)
>
> Thanks for the test case.
>
>> I'm looking for information for the following architectures:
>>
>> s390-32, s390-64
>> alpha
>> am33
>> hppa
>> ia64
>> m68k (classic)
>
> hppa (64-bit PA-RISC 2.0) is after rounding according to the test.
>
> The manual says:
> ~~~
> Tininess is detected on a nonzero result which lies strictly between
> +/-2^(Emin), when the result is rounded as if the exponent range were
> unbounded.
> ~~~
>
> Thus verified by what the manual says.

Verified that PA-RISC 1.1 hardware is also after rounding according to
the manual.

I have not booted real 1.1 hardware to verify.

Cheers,
Carlos.

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

* Re: Architecture floating-point underflow information wanted
  2012-09-25 12:52 Architecture floating-point underflow information wanted Joseph S. Myers
                   ` (2 preceding siblings ...)
  2012-09-25 15:18 ` Carlos O'Donell
@ 2012-09-25 17:11 ` David Miller
  2012-09-25 17:39 ` Andreas Krebbel
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 10+ messages in thread
From: David Miller @ 2012-09-25 17:11 UTC (permalink / raw)
  To: joseph
  Cc: libc-alpha, libc-ports, krebbel, rth, msalter, carlos, vapier, schwab

From: "Joseph S. Myers" <joseph@codesourcery.com>
Date: Tue, 25 Sep 2012 12:52:16 +0000

> #include <fenv.h>
> #include <stdio.h>
> 
> volatile float a = 0x1.fffp-126;
> volatile float b = 0x1.0008p-1;
> volatile float c;
> 
> int
> main (void)
> {
>   feclearexcept (FE_ALL_EXCEPT);
>   c = a * b;
>   if (fetestexcept (FE_UNDERFLOW))
>     puts ("before rounding");
>   else
>     puts ("after rounding");
>   return 0;
> }

Just confirming that this gives 'before rounding' on all sparcs I have
access to.

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

* Re: Architecture floating-point underflow information wanted
  2012-09-25 12:52 Architecture floating-point underflow information wanted Joseph S. Myers
                   ` (3 preceding siblings ...)
  2012-09-25 17:11 ` David Miller
@ 2012-09-25 17:39 ` Andreas Krebbel
  2012-09-25 18:11 ` Andreas Schwab
  2012-09-26 16:36 ` Mike Frysinger
  6 siblings, 0 replies; 10+ messages in thread
From: Andreas Krebbel @ 2012-09-25 17:39 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: libc-alpha, libc-ports, Richard Henderson, Mark Salter,
	Carlos O'Donell, Mike Frysinger, Andreas Schwab

On 25/09/12 14:52, Joseph S. Myers wrote:
> I'm looking for information for the following architectures:
> 
> s390-32, s390-64
> alpha
> am33
> hppa
> ia64
> m68k (classic)

Your testcase returns "before rounding" on System z. Should be the same for s390.

-Andreas-


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

* Re: Architecture floating-point underflow information wanted
  2012-09-25 12:52 Architecture floating-point underflow information wanted Joseph S. Myers
                   ` (4 preceding siblings ...)
  2012-09-25 17:39 ` Andreas Krebbel
@ 2012-09-25 18:11 ` Andreas Schwab
  2012-09-25 19:30   ` Joseph S. Myers
  2012-09-26 16:36 ` Mike Frysinger
  6 siblings, 1 reply; 10+ messages in thread
From: Andreas Schwab @ 2012-09-25 18:11 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: libc-alpha, libc-ports, Andreas Krebbel, Richard Henderson,
	Mark Salter, Carlos O'Donell, Mike Frysinger

"Joseph S. Myers" <joseph@codesourcery.com> writes:

> #include <fenv.h>
> #include <stdio.h>
>
> volatile float a = 0x1.fffp-126;
> volatile float b = 0x1.0008p-1;
> volatile float c;
>
> int
> main (void)
> {
>   feclearexcept (FE_ALL_EXCEPT);
>   c = a * b;
>   if (fetestexcept (FE_UNDERFLOW))

Does this really give the correct result for FLT_EVAL_METHOD != 0?  I
think for those archs you have to set the rounding mode to float to be
accurate.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

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

* Re: Architecture floating-point underflow information wanted
  2012-09-25 18:11 ` Andreas Schwab
@ 2012-09-25 19:30   ` Joseph S. Myers
  0 siblings, 0 replies; 10+ messages in thread
From: Joseph S. Myers @ 2012-09-25 19:30 UTC (permalink / raw)
  To: Andreas Schwab
  Cc: libc-alpha, libc-ports, Andreas Krebbel, Richard Henderson,
	Mark Salter, Carlos O'Donell, Mike Frysinger

On Tue, 25 Sep 2012, Andreas Schwab wrote:

> "Joseph S. Myers" <joseph@codesourcery.com> writes:
> 
> > #include <fenv.h>
> > #include <stdio.h>
> >
> > volatile float a = 0x1.fffp-126;
> > volatile float b = 0x1.0008p-1;
> > volatile float c;
> >
> > int
> > main (void)
> > {
> >   feclearexcept (FE_ALL_EXCEPT);
> >   c = a * b;
> >   if (fetestexcept (FE_UNDERFLOW))
> 
> Does this really give the correct result for FLT_EVAL_METHOD != 0?  I
> think for those archs you have to set the rounding mode to float to be
> accurate.

On such architectures, the multiplication is exact (in a wider evaluation 
type) and the potential underflow occurs on conversion to float to be 
stored in "volatile float c".  It doesn't matter whether the operation 
with potential underflow is multiplication or conversion to float; both 
are operations with binary floating-point results, so are required to 
detect tinyness the same way.

-- 
Joseph S. Myers
joseph@codesourcery.com

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

* Re: Architecture floating-point underflow information wanted
  2012-09-25 12:52 Architecture floating-point underflow information wanted Joseph S. Myers
                   ` (5 preceding siblings ...)
  2012-09-25 18:11 ` Andreas Schwab
@ 2012-09-26 16:36 ` Mike Frysinger
  6 siblings, 0 replies; 10+ messages in thread
From: Mike Frysinger @ 2012-09-26 16:36 UTC (permalink / raw)
  To: Joseph S. Myers
  Cc: libc-alpha, libc-ports, Andreas Krebbel, Richard Henderson,
	Mark Salter, Carlos O'Donell, Andreas Schwab

[-- Attachment #1: Type: Text/Plain, Size: 104 bytes --]

On Tuesday 25 September 2012 08:52:16 Joseph S. Myers wrote:
> ia64

test reports:
after rounding
-mike

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

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

end of thread, other threads:[~2012-09-26 16:36 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-09-25 12:52 Architecture floating-point underflow information wanted Joseph S. Myers
2012-09-25 13:12 ` Andreas Schwab
2012-09-25 14:18 ` Mark Salter
2012-09-25 15:18 ` Carlos O'Donell
2012-09-25 15:22   ` Carlos O'Donell
2012-09-25 17:11 ` David Miller
2012-09-25 17:39 ` Andreas Krebbel
2012-09-25 18:11 ` Andreas Schwab
2012-09-25 19:30   ` Joseph S. Myers
2012-09-26 16:36 ` Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).