* FPU test on RedHat7.1
@ 2001-11-22 15:37 Carsten Langgaard
2001-11-22 18:39 ` H . J . Lu
0 siblings, 1 reply; 5+ messages in thread
From: Carsten Langgaard @ 2001-11-22 15:37 UTC (permalink / raw)
To: H . J . Lu, linux-mips
[-- Attachment #1: Type: text/plain, Size: 467 bytes --]
The attached tests fails on my RedHat7.1 system, but works fine on my
old HardHat5.1.
Anyone got any idea.
compile:
g++ -o fpu_test fpu_test.cc
/Carsten
--
_ _ ____ ___ Carsten Langgaard Mailto:carstenl@mips.com
|\ /|||___)(___ MIPS Denmark Direct: +45 4486 5527
| \/ ||| ____) Lautrupvang 4B Switch: +45 4486 5555
TECHNOLOGIES 2750 Ballerup Fax...: +45 4486 5556
Denmark http://www.mips.com
[-- Attachment #2: fpu_test.cc --]
[-- Type: text/plain, Size: 326 bytes --]
#include <math.h>
#include <stdio.h>
int main( int argc,char * argv[ ] )
{
double res;
union {
unsigned long long l;
double d;
} op1, op2;
op1.l = 0x7fefffffffffffff;
op2.l = 0x0000000000000001;
printf("%llx %llx\n", op1.l, op2.l);
res = remainder(op1.d, op2.d);
printf("%llx\n", res);
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: FPU test on RedHat7.1
2001-11-22 15:37 FPU test on RedHat7.1 Carsten Langgaard
@ 2001-11-22 18:39 ` H . J . Lu
2001-11-23 14:54 ` Carsten Langgaard
0 siblings, 1 reply; 5+ messages in thread
From: H . J . Lu @ 2001-11-22 18:39 UTC (permalink / raw)
To: Carsten Langgaard; +Cc: linux-mips
On Thu, Nov 22, 2001 at 04:37:11PM +0100, Carsten Langgaard wrote:
> The attached tests fails on my RedHat7.1 system, but works fine on my
> old HardHat5.1.
> Anyone got any idea.
>
> compile:
> g++ -o fpu_test fpu_test.cc
>
Many FPU related tests in the current glibc from CVS failed on MIPS. I
am planning to look into them. But I need to find time and docs on MIPS
FPU.
H.J.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: FPU test on RedHat7.1
2001-11-22 18:39 ` H . J . Lu
@ 2001-11-23 14:54 ` Carsten Langgaard
2001-11-24 19:25 ` H . J . Lu
0 siblings, 1 reply; 5+ messages in thread
From: Carsten Langgaard @ 2001-11-23 14:54 UTC (permalink / raw)
To: H . J . Lu; +Cc: linux-mips
[-- Attachment #1: Type: text/plain, Size: 913 bytes --]
The file sysdeps/ieee754/dbl-64/e_remainder.c seems to have changed since
glibc-2.2.2.
I have attached the glibc-2.2.2 remainder file, which seems to work
better.
/Carsten
"H . J . Lu" wrote:
> On Thu, Nov 22, 2001 at 04:37:11PM +0100, Carsten Langgaard wrote:
> > The attached tests fails on my RedHat7.1 system, but works fine on my
> > old HardHat5.1.
> > Anyone got any idea.
> >
> > compile:
> > g++ -o fpu_test fpu_test.cc
> >
>
> Many FPU related tests in the current glibc from CVS failed on MIPS. I
> am planning to look into them. But I need to find time and docs on MIPS
> FPU.
>
> H.J.
--
_ _ ____ ___ Carsten Langgaard Mailto:carstenl@mips.com
|\ /|||___)(___ MIPS Denmark Direct: +45 4486 5527
| \/ ||| ____) Lautrupvang 4B Switch: +45 4486 5555
TECHNOLOGIES 2750 Ballerup Fax...: +45 4486 5556
Denmark http://www.mips.com
[-- Attachment #2: e_remainder.c --]
[-- Type: text/plain, Size: 1874 bytes --]
/* @(#)e_remainder.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
* Developed at SunPro, a Sun Microsystems, Inc. business.
* Permission to use, copy, modify, and distribute this
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
*/
#if defined(LIBM_SCCS) && !defined(lint)
static char rcsid[] = "$NetBSD: e_remainder.c,v 1.8 1995/05/10 20:46:05 jtc Exp $";
#endif
/* __ieee754_remainder(x,p)
* Return :
* returns x REM p = x - [x/p]*p as if in infinite
* precise arithmetic, where [x/p] is the (infinite bit)
* integer nearest x/p (in half way case choose the even one).
* Method :
* Based on fmod() return x-[x/p]chopped*p exactlp.
*/
#include "math.h"
#include "math_private.h"
#ifdef __STDC__
static const double zero = 0.0;
#else
static double zero = 0.0;
#endif
#ifdef __STDC__
double __ieee754_remainder(double x, double p)
#else
double __ieee754_remainder(x,p)
double x,p;
#endif
{
int32_t hx,hp;
u_int32_t sx,lx,lp;
double p_half;
EXTRACT_WORDS(hx,lx,x);
EXTRACT_WORDS(hp,lp,p);
sx = hx&0x80000000;
hp &= 0x7fffffff;
hx &= 0x7fffffff;
/* purge off exception values */
if((hp|lp)==0) return (x*p)/(x*p); /* p = 0 */
if((hx>=0x7ff00000)|| /* x not finite */
((hp>=0x7ff00000)&& /* p is NaN */
(((hp-0x7ff00000)|lp)!=0)))
return (x*p)/(x*p);
if (hp<=0x7fdfffff) x = __ieee754_fmod(x,p+p); /* now x < 2p */
if (((hx-hp)|(lx-lp))==0) return zero*x;
x = fabs(x);
p = fabs(p);
if (hp<0x00200000) {
if(x+x>p) {
x-=p;
if(x+x>=p) x -= p;
}
} else {
p_half = 0.5*p;
if(x>p_half) {
x-=p;
if(x>=p_half) x -= p;
}
}
GET_HIGH_WORD(hx,x);
SET_HIGH_WORD(x,hx^sx);
return x;
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: FPU test on RedHat7.1
2001-11-23 14:54 ` Carsten Langgaard
@ 2001-11-24 19:25 ` H . J . Lu
2001-11-26 9:22 ` Carsten Langgaard
0 siblings, 1 reply; 5+ messages in thread
From: H . J . Lu @ 2001-11-24 19:25 UTC (permalink / raw)
To: Carsten Langgaard; +Cc: linux-mips
[-- Attachment #1: Type: text/plain, Size: 473 bytes --]
On Fri, Nov 23, 2001 at 03:54:31PM +0100, Carsten Langgaard wrote:
> The file sysdeps/ieee754/dbl-64/e_remainder.c seems to have changed since
> glibc-2.2.2.
> I have attached the glibc-2.2.2 remainder file, which seems to work
> better.
>
I believe it is a MIPS FPU related issue. glibc tries to do
1.7976931348623157e+308 - 8.5720688574901386e+301 * 2097152
and expects -1.9958403095e+292. However, on mips, I got -inf. Could you
please look into it?
Thanks.
H.J.
[-- Attachment #2: ieee.c --]
[-- Type: text/plain, Size: 308 bytes --]
#include <stdio.h>
int main( int argc,char * argv[ ] )
{
double res, d;
union {
unsigned long long l;
double d;
} op1, op2;
op1.l = 0x7fefffffffffffffLL;
op2.l = 0x7ea0000000000000LL;
d = 2097152;
res = op1.d - d * op2.d;
printf("%llx\n", res);
printf("%20.10e\n", res);
}
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: FPU test on RedHat7.1
2001-11-24 19:25 ` H . J . Lu
@ 2001-11-26 9:22 ` Carsten Langgaard
0 siblings, 0 replies; 5+ messages in thread
From: Carsten Langgaard @ 2001-11-26 9:22 UTC (permalink / raw)
To: H . J . Lu; +Cc: linux-mips
"H . J . Lu" wrote:
> On Fri, Nov 23, 2001 at 03:54:31PM +0100, Carsten Langgaard wrote:
> > The file sysdeps/ieee754/dbl-64/e_remainder.c seems to have changed since
> > glibc-2.2.2.
> > I have attached the glibc-2.2.2 remainder file, which seems to work
> > better.
> >
>
> I believe it is a MIPS FPU related issue. glibc tries to do
>
> 1.7976931348623157e+308 - 8.5720688574901386e+301 * 2097152
>
> and expects -1.9958403095e+292. However, on mips, I got -inf. Could you
> please look into it?
I believe this is ok, 8.5720688574901386e+301 * 2097152 is greater than
1.7976931348623157e+308 (which is the highest floating point number you can
represent).
So 1.7976931348623157e+308 - 8.5720688574901386e+301 * 2097152 do give -Inf on
(I guess) all other architectures than i386, which have a double extended (80
bit / 64 bit mantisse) precision.
I have tried the same calculation on a Sun (Sparc) and it also gives -Inf.
So I guess the problem is in the e_remainder function.
>
> Thanks.
>
> H.J.
>
> ------------------------------------------------------------------------
>
> ieee.cName: ieee.c
> Type: Plain Text (text/plain)
--
_ _ ____ ___ Carsten Langgaard Mailto:carstenl@mips.com
|\ /|||___)(___ MIPS Denmark Direct: +45 4486 5527
| \/ ||| ____) Lautrupvang 4B Switch: +45 4486 5555
TECHNOLOGIES 2750 Ballerup Fax...: +45 4486 5556
Denmark http://www.mips.com
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2001-11-26 10:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-11-22 15:37 FPU test on RedHat7.1 Carsten Langgaard
2001-11-22 18:39 ` H . J . Lu
2001-11-23 14:54 ` Carsten Langgaard
2001-11-24 19:25 ` H . J . Lu
2001-11-26 9:22 ` Carsten Langgaard
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox