* Alpha/Linux FP denormal processing
2000-09-17 23:15 ` Richard Henderson
@ 2000-09-19 0:59 ` Uncle George
2000-09-19 1:54 ` Brad Lucier
2000-09-19 12:10 ` Jeff Sturm
0 siblings, 2 replies; 36+ messages in thread
From: Uncle George @ 2000-09-19 0:59 UTC (permalink / raw)
To: axp-list, Richard Henderson
Is there anyone who has knowledge of how FPU underflows of denormal numbers
are to be processed in Alpha/linux. The concept of a ieee rolling underflow
seems to stop at the smallest FPU normalized number. Tests expect that the
smallest should go to e-324. on True64 the test will go till e-324 if u use
the ieee switch. On alpha/linux I cannot get it to go beyond e-308, no
matter what FloatingPointControlRegister bits i set.
/gat
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 0:59 ` Alpha/Linux FP denormal processing Uncle George
@ 2000-09-19 1:54 ` Brad Lucier
2000-09-19 9:29 ` Uncle George
2000-09-19 12:10 ` Jeff Sturm
1 sibling, 1 reply; 36+ messages in thread
From: Brad Lucier @ 2000-09-19 1:54 UTC (permalink / raw)
To: axp-list; +Cc: Brad Lucier
You don't say what compiler or CPU you're using. Try -mieee with gcc.
Brad Lucier
> Is there anyone who has knowledge of how FPU underflows of denormal numbers
> are to be processed in Alpha/linux. The concept of a ieee rolling underflow
> seems to stop at the smallest FPU normalized number. Tests expect that the
> smallest should go to e-324. on True64 the test will go till e-324 if u use
> the ieee switch. On alpha/linux I cannot get it to go beyond e-308, no
> matter what FloatingPointControlRegister bits i set.
> /gat
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 1:54 ` Brad Lucier
@ 2000-09-19 9:29 ` Uncle George
2000-09-19 13:03 ` Greg Lindahl
2000-09-19 14:16 ` Brad Lucier
0 siblings, 2 replies; 36+ messages in thread
From: Uncle George @ 2000-09-19 9:29 UTC (permalink / raw)
To: axp-list, Brad Lucier
CPU dont matter, as well as gcc. all denorm FP numbers are trapped to the kernel,
as the FPU ( even up to a 21264 ) cant process them :-/
/gat
Brad Lucier wrote:
> You don't say what compiler or CPU you're using. Try -mieee with gcc.
>
> Brad Lucier
>
> > Is there anyone who has knowledge of how FPU underflows of denormal numbers
> > are to be processed in Alpha/linux. The concept of a ieee rolling underflow
> > seems to stop at the smallest FPU normalized number. Tests expect that the
> > smallest should go to e-324. on True64 the test will go till e-324 if u use
> > the ieee switch. On alpha/linux I cannot get it to go beyond e-308, no
> > matter what FloatingPointControlRegister bits i set.
> > /gat
>
> _______________________________________________
> Axp-list mailing list
> Axp-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/axp-list
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 0:59 ` Alpha/Linux FP denormal processing Uncle George
2000-09-19 1:54 ` Brad Lucier
@ 2000-09-19 12:10 ` Jeff Sturm
1 sibling, 0 replies; 36+ messages in thread
From: Jeff Sturm @ 2000-09-19 12:10 UTC (permalink / raw)
To: axp-list
Uncle George wrote:
> Is there anyone who has knowledge of how FPU underflows of denormal numbers
> are to be processed in Alpha/linux. The concept of a ieee rolling underflow
> seems to stop at the smallest FPU normalized number. Tests expect that the
> smallest should go to e-324. on True64 the test will go till e-324 if u use
> the ieee switch. On alpha/linux I cannot get it to go beyond e-308, no
> matter what FloatingPointControlRegister bits i set.
1) You are compiling with -mieee, right?
2) Can you post a test case?
3) If this is really a kernel bug, I'd suggest posting to linux-kernel
as well... dunno if all those folk read axp-list.
Jeff
^ permalink raw reply [flat|nested] 36+ messages in thread
* RE: Alpha/Linux FP denormal processing
2000-09-19 9:29 ` Uncle George
@ 2000-09-19 13:03 ` Greg Lindahl
2000-09-19 16:48 ` Richard Henderson
2000-09-19 14:16 ` Brad Lucier
1 sibling, 1 reply; 36+ messages in thread
From: Greg Lindahl @ 2000-09-19 13:03 UTC (permalink / raw)
To: axp-list
> CPU dont matter, as well as gcc. all denorm FP numbers are
> trapped to the kernel,
> as the FPU ( even up to a 21264 ) cant process them :-/
gcc or ccc matters a whole lot. In order to do denorms, you don't just set a
bit in a register, you have to ask the compiler (-mieee for gcc, -fp3 for
ccc) to insert extra trap instructions.
The standard kernel has the appropriate handler routines.
I've used this and it works. gcc's ability to *print* denorms is kind of
interesting, though.
-- g
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 9:29 ` Uncle George
2000-09-19 13:03 ` Greg Lindahl
@ 2000-09-19 14:16 ` Brad Lucier
2000-09-19 14:31 ` Uncle George
1 sibling, 1 reply; 36+ messages in thread
From: Brad Lucier @ 2000-09-19 14:16 UTC (permalink / raw)
To: Uncle George; +Cc: axp-list, Brad Lucier
Here's the program:
int main()
{
double x = 1.0;
for (x = 1.0; x != 0.0; x *=0.5)
printf("%e\n", x);
}
Here's the end of the output:
6.324040e-322
3.162020e-322
1.581010e-322
7.905050e-323
3.952525e-323
1.976263e-323
9.881313e-324
4.940656e-324
Here's the compiler I use:
popov-141% gcc -v
Reading specs from /export/u10/gcc-2.95.1/lib/gcc-lib/alphaev6-unknown-linux-gnu/2.95.1/specs
gcc version 2.95.1 19990816 (release)
and here's the assembler (there are no trapb instructions because
this is 21264 and they aren't needed):
popov-143% cat testdenorm.s
.file 1 "testdenorm.c"
.set noat
.set noreorder
.arch ev6
.section .rodata
$LC1:
.ascii "%e\12\0"
.align 3
$LC0:
.t_floating 1.00000000000000000000e0
.align 3
$LC2:
.t_floating 5.00000000000000000000e-1
.text
.align 5
.globl main
.ent main
main:
.eflag 48
.frame $15,32,$26,0
.mask 0x4008000,-32
ldgp $29,0($27)
$main..ng:
lda $30,-32($30)
stq $26,0($30)
stq $15,8($30)
mov $30,$15
.prologue 1
lda $1,$LC0
ldt $f10,0($1)
stt $f10,16($15)
lda $1,$LC0
ldt $f10,0($1)
stt $f10,16($15)
$L3:
ldt $f10,16($15)
cmpteqsu $f10,$f31,$f11 <= su implies ieee fp version of instruction
fbeq $f11,$L6
br $31,$L4
$L6:
lda $16,$LC1
ldt $f17,16($15)
jsr $26,printf
ldgp $29,0($26)
$L5:
ldt $f10,16($15)
lda $1,$LC2
ldt $f11,0($1)
multsu $f10,$f11,$f12 <= su implies ieee fp version of instruction
fmov $f12,$f10
stt $f10,16($15)
br $31,$L3
$L4:
$L2:
mov $15,$30
ldq $26,0($30)
ldq $15,8($30)
lda $30,32($30)
ret $31,($26),1
.end main
.ident "GCC: (GNU) 2.95.1 19990816 (release)"
Brad Lucier
>
> CPU dont matter, as well as gcc. all denorm FP numbers are trapped to the kernel,
> as the FPU ( even up to a 21264 ) cant process them :-/
> /gat
>
> Brad Lucier wrote:
>
> > You don't say what compiler or CPU you're using. Try -mieee with gcc.
> >
> > Brad Lucier
> >
> > > Is there anyone who has knowledge of how FPU underflows of denormal numbers
> > > are to be processed in Alpha/linux. The concept of a ieee rolling underflow
> > > seems to stop at the smallest FPU normalized number. Tests expect that the
> > > smallest should go to e-324. on True64 the test will go till e-324 if u use
> > > the ieee switch. On alpha/linux I cannot get it to go beyond e-308, no
> > > matter what FloatingPointControlRegister bits i set.
> > > /gat
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 14:16 ` Brad Lucier
@ 2000-09-19 14:31 ` Uncle George
2000-09-19 16:25 ` Michal Jaegermann
2000-09-19 16:52 ` Richard Henderson
0 siblings, 2 replies; 36+ messages in thread
From: Uncle George @ 2000-09-19 14:31 UTC (permalink / raw)
To: axp-list; +Cc: Brad Lucier
Instead of *= 0.5, try /= 2.0
I think it is now being narrowed down - thanks.
/gat
Brad Lucier wrote:
> Here's the program:
>
> int main()
> {
> double x = 1.0;
> for (x = 1.0; x != 0.0; x *=0.5)
> printf("%e\n", x);
> }
>
> Here's the end of the output:
>
> 6.324040e-322
> 3.162020e-322
> 1.581010e-322
> 7.905050e-323
> 3.952525e-323
> 1.976263e-323
> 9.881313e-324
> 4.940656e-324
>
> Here's the compiler I use:
>
> popov-141% gcc -v
> Reading specs from /export/u10/gcc-2.95.1/lib/gcc-lib/alphaev6-unknown-linux-gnu/2.95.1/specs
> gcc version 2.95.1 19990816 (release)
>
> and here's the assembler (there are no trapb instructions because
> this is 21264 and they aren't needed):
>
> popov-143% cat testdenorm.s
> .file 1 "testdenorm.c"
> .set noat
> .set noreorder
> .arch ev6
> .section .rodata
> $LC1:
> .ascii "%e\12\0"
> .align 3
> $LC0:
> .t_floating 1.00000000000000000000e0
> .align 3
> $LC2:
> .t_floating 5.00000000000000000000e-1
> .text
> .align 5
> .globl main
> .ent main
> main:
> .eflag 48
> .frame $15,32,$26,0
> .mask 0x4008000,-32
> ldgp $29,0($27)
> $main..ng:
> lda $30,-32($30)
> stq $26,0($30)
> stq $15,8($30)
> mov $30,$15
> .prologue 1
> lda $1,$LC0
> ldt $f10,0($1)
> stt $f10,16($15)
> lda $1,$LC0
> ldt $f10,0($1)
> stt $f10,16($15)
> $L3:
> ldt $f10,16($15)
> cmpteqsu $f10,$f31,$f11 <= su implies ieee fp version of instruction
> fbeq $f11,$L6
> br $31,$L4
> $L6:
> lda $16,$LC1
> ldt $f17,16($15)
> jsr $26,printf
> ldgp $29,0($26)
> $L5:
> ldt $f10,16($15)
> lda $1,$LC2
> ldt $f11,0($1)
> multsu $f10,$f11,$f12 <= su implies ieee fp version of instruction
> fmov $f12,$f10
> stt $f10,16($15)
> br $31,$L3
> $L4:
> $L2:
> mov $15,$30
> ldq $26,0($30)
> ldq $15,8($30)
> lda $30,32($30)
> ret $31,($26),1
> .end main
> .ident "GCC: (GNU) 2.95.1 19990816 (release)"
>
> Brad Lucier
>
> >
> > CPU dont matter, as well as gcc. all denorm FP numbers are trapped to the kernel,
> > as the FPU ( even up to a 21264 ) cant process them :-/
> > /gat
> >
> > Brad Lucier wrote:
> >
> > > You don't say what compiler or CPU you're using. Try -mieee with gcc.
> > >
> > > Brad Lucier
> > >
> > > > Is there anyone who has knowledge of how FPU underflows of denormal numbers
> > > > are to be processed in Alpha/linux. The concept of a ieee rolling underflow
> > > > seems to stop at the smallest FPU normalized number. Tests expect that the
> > > > smallest should go to e-324. on True64 the test will go till e-324 if u use
> > > > the ieee switch. On alpha/linux I cannot get it to go beyond e-308, no
> > > > matter what FloatingPointControlRegister bits i set.
> > > > /gat
>
> _______________________________________________
> Axp-list mailing list
> Axp-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/axp-list
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 14:31 ` Uncle George
@ 2000-09-19 16:25 ` Michal Jaegermann
2000-09-19 17:27 ` Jeff Sturm
2000-09-19 16:52 ` Richard Henderson
1 sibling, 1 reply; 36+ messages in thread
From: Michal Jaegermann @ 2000-09-19 16:25 UTC (permalink / raw)
To: axp-list
Uncle George wrote:
>
> Instead of *= 0.5, try /= 2.0
Hm, I just did. Both "2.0" and just "2" for a good measure. This
is a tail of an output:
2.529616e-321
1.264808e-321
6.324040e-322
3.162020e-322
1.581010e-322
7.905050e-323
3.952525e-323
1.976263e-323
9.881313e-324
4.940656e-324
And this is a compiler I used: gcc version 2.95.2 19991024 (release).
A test program compiled with -mieee flag. Without -mieee this will
stop at 2.225074e-308.
> I think it is now being narrowed down - thanks.
Other versions of a compiler are tripping you?
Michal
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 13:03 ` Greg Lindahl
@ 2000-09-19 16:48 ` Richard Henderson
0 siblings, 0 replies; 36+ messages in thread
From: Richard Henderson @ 2000-09-19 16:48 UTC (permalink / raw)
To: axp-list
On Tue, Sep 19, 2000 at 09:03:10AM -0400, Greg Lindahl wrote:
> gcc's ability to *print* denorms is kind of interesting, though.
glibc uses multi-word integer arithmetic to print fp values.
r~
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 14:31 ` Uncle George
2000-09-19 16:25 ` Michal Jaegermann
@ 2000-09-19 16:52 ` Richard Henderson
2000-09-20 2:23 ` Richard Henderson
1 sibling, 1 reply; 36+ messages in thread
From: Richard Henderson @ 2000-09-19 16:52 UTC (permalink / raw)
To: axp-list; +Cc: Brad Lucier
On Tue, Sep 19, 2000 at 09:31:59AM -0500, Uncle George wrote:
> Instead of *= 0.5, try /= 2.0
Yes indeed you've found a bug in the kernel's FP emulation.
I'll see about fixing it.
r~
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 16:25 ` Michal Jaegermann
@ 2000-09-19 17:27 ` Jeff Sturm
2000-09-19 17:43 ` Michal Jaegermann
0 siblings, 1 reply; 36+ messages in thread
From: Jeff Sturm @ 2000-09-19 17:27 UTC (permalink / raw)
To: axp-list
Michal Jaegermann wrote:
> And this is a compiler I used: gcc version 2.95.2 19991024 (release).
> A test program compiled with -mieee flag. Without -mieee this will
> stop at 2.225074e-308.
As does mine, with or without -mieee. What kernel version are you running? I
have 2.2.14.
--
Jeff Sturm
jeff.sturm@commerceone.com
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 17:27 ` Jeff Sturm
@ 2000-09-19 17:43 ` Michal Jaegermann
2000-09-19 19:10 ` Uncle George
0 siblings, 1 reply; 36+ messages in thread
From: Michal Jaegermann @ 2000-09-19 17:43 UTC (permalink / raw)
To: axp-list
Jeff Sturm wrote:
>
> Michal Jaegermann wrote:
> > And this is a compiler I used: gcc version 2.95.2 19991024 (release).
> > A test program compiled with -mieee flag. Without -mieee this will
> > stop at 2.225074e-308.
>
> As does mine, with or without -mieee. What kernel version are you
> running? I have 2.2.14.
On this particular machine I ran tests this was with 2.2.17pre10x
("x" as I have there also some e"x"tra patches but I do not think
that these would affect floating point). Other, possibly relevant,
pieces from 'cat /proc/cpuinfo':
cpu : Alpha
cpu model : EV4
...
system type : EB64+
system variation : EB64+
system revision : 0
Richard says this is a kernel bug. Hm, I wonder when I got that fixed.
The problem is that I do not recall doing that deliberately, but maybe
I forgot/missed something.
Michal
p.s. "17pre10" above is not of any special significance. The machine I
used has some other duties and it is not rebooted very often.
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 17:43 ` Michal Jaegermann
@ 2000-09-19 19:10 ` Uncle George
2000-09-19 19:30 ` Michal Jaegermann
0 siblings, 1 reply; 36+ messages in thread
From: Uncle George @ 2000-09-19 19:10 UTC (permalink / raw)
To: axp-list
Maybe u can point to where I can get a copy of pre10x .
/gat
Michal Jaegermann wrote:
> Jeff Sturm wrote:
> >
> > Michal Jaegermann wrote:
> > > And this is a compiler I used: gcc version 2.95.2 19991024 (release).
> > > A test program compiled with -mieee flag. Without -mieee this will
> > > stop at 2.225074e-308.
> >
> > As does mine, with or without -mieee. What kernel version are you
> > running? I have 2.2.14.
>
> On this particular machine I ran tests this was with 2.2.17pre10x
> ("x" as I have there also some e"x"tra patches but I do not think
> that these would affect floating point). Other, possibly relevant,
> pieces from 'cat /proc/cpuinfo':
>
> cpu : Alpha
> cpu model : EV4
> ...
> system type : EB64+
> system variation : EB64+
> system revision : 0
>
> Richard says this is a kernel bug. Hm, I wonder when I got that fixed.
> The problem is that I do not recall doing that deliberately, but maybe
> I forgot/missed something.
>
> Michal
>
> p.s. "17pre10" above is not of any special significance. The machine I
> used has some other duties and it is not rebooted very often.
>
> _______________________________________________
> Axp-list mailing list
> Axp-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/axp-list
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 19:10 ` Uncle George
@ 2000-09-19 19:30 ` Michal Jaegermann
2000-09-19 19:46 ` Brad Lucier
0 siblings, 1 reply; 36+ messages in thread
From: Michal Jaegermann @ 2000-09-19 19:30 UTC (permalink / raw)
To: axp-list
Uncle George wrote:
>
> Maybe u can point to where I can get a copy of pre10x .
As I mentioned this is something patched up by me so it is not thing
commonly found. I would suggest checking first an "official" 2.2.17
release before we start digging through other patches. That one will be
on ftp.us.kernel.org.
Also, if you want to spare yourself a recompilation, the latest Red Hat
kernel from updates to 6.2 (this wil be 2.2.16-<something>) may be ok.
It has, actually, a number of common points with what I tried.
Michal
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 19:30 ` Michal Jaegermann
@ 2000-09-19 19:46 ` Brad Lucier
2000-09-19 20:03 ` Uncle George
2000-09-19 20:33 ` Michal Jaegermann
0 siblings, 2 replies; 36+ messages in thread
From: Brad Lucier @ 2000-09-19 19:46 UTC (permalink / raw)
To: axp-list
> Uncle George wrote:
> >
> > Maybe u can point to where I can get a copy of pre10x .
>
> As I mentioned this is something patched up by me so it is not thing
> commonly found. I would suggest checking first an "official" 2.2.17
> release before we start digging through other patches. That one will be
> on ftp.us.kernel.org.
2.2.17 with more-or-less standard configure on a DS20 clone will
stop at 2e-308 when the iteration is x /= 2.0. This is with
gcc-2.95.1 on alphaev6-unknown-linux-gnu.
Brad Lucier
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 19:46 ` Brad Lucier
@ 2000-09-19 20:03 ` Uncle George
2000-09-19 20:16 ` Brad Lucier
2000-09-19 20:33 ` Michal Jaegermann
1 sibling, 1 reply; 36+ messages in thread
From: Uncle George @ 2000-09-19 20:03 UTC (permalink / raw)
To: axp-list
Kan i presume u used -mieee ??? Even though the user pgm is not at fault,
the kern needs to know if there is a fpdiv/su as part of the scenario
/gat
Brad Lucier wrote:
> > Uncle George wrote:
> > >
> > > Maybe u can point to where I can get a copy of pre10x .
> >
> > As I mentioned this is something patched up by me so it is not thing
> > commonly found. I would suggest checking first an "official" 2.2.17
> > release before we start digging through other patches. That one will be
> > on ftp.us.kernel.org.
>
> 2.2.17 with more-or-less standard configure on a DS20 clone will
> stop at 2e-308 when the iteration is x /= 2.0. This is with
> gcc-2.95.1 on alphaev6-unknown-linux-gnu.
>
> Brad Lucier
>
> _______________________________________________
> Axp-list mailing list
> Axp-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/axp-list
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 20:03 ` Uncle George
@ 2000-09-19 20:16 ` Brad Lucier
2000-09-19 21:09 ` Michal Jaegermann
0 siblings, 1 reply; 36+ messages in thread
From: Brad Lucier @ 2000-09-19 20:16 UTC (permalink / raw)
To: axp-list
Yes, this is with -mieee. It went to e-324 with x *= 0.5, but
only to e-308 with x /= 2.0.
Brad
>
> Kan i presume u used -mieee ??? Even though the user pgm is not at fault,
> the kern needs to know if there is a fpdiv/su as part of the scenario
> /gat
>
> Brad Lucier wrote:
>
> > > Uncle George wrote:
> > > >
> > > > Maybe u can point to where I can get a copy of pre10x .
> > >
> > > As I mentioned this is something patched up by me so it is not thing
> > > commonly found. I would suggest checking first an "official" 2.2.17
> > > release before we start digging through other patches. That one will be
> > > on ftp.us.kernel.org.
> >
> > 2.2.17 with more-or-less standard configure on a DS20 clone will
> > stop at 2e-308 when the iteration is x /= 2.0. This is with
> > gcc-2.95.1 on alphaev6-unknown-linux-gnu.
> >
> > Brad Lucier
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 19:46 ` Brad Lucier
2000-09-19 20:03 ` Uncle George
@ 2000-09-19 20:33 ` Michal Jaegermann
1 sibling, 0 replies; 36+ messages in thread
From: Michal Jaegermann @ 2000-09-19 20:33 UTC (permalink / raw)
To: axp-list
Brad Lucier wrote:
>
> > Uncle George wrote:
> > >
> > > Maybe u can point to where I can get a copy of pre10x .
> >
> > As I mentioned this is something patched up by me so it is not thing
> > commonly found. I would suggest checking first an "official" 2.2.17
> > release before we start digging through other patches. That one will be
> > on ftp.us.kernel.org.
>
> 2.2.17 with more-or-less standard configure on a DS20 clone will
> stop at 2e-308 when the iteration is x /= 2.0. This is with
> gcc-2.95.1 on alphaev6-unknown-linux-gnu.
Bummer! I will try more systematic checks but later.
Michal
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 20:16 ` Brad Lucier
@ 2000-09-19 21:09 ` Michal Jaegermann
2000-09-19 21:48 ` Brad Lucier
2000-09-19 22:09 ` Brad Lucier
0 siblings, 2 replies; 36+ messages in thread
From: Michal Jaegermann @ 2000-09-19 21:09 UTC (permalink / raw)
To: axp-list
Brad Lucier wrote:
>
> Yes, this is with -mieee. It went to e-324 with x *= 0.5, but
> only to e-308 with x /= 2.0.
>
> Brad
>
> >
> > Kan i presume u used -mieee ???
Ok, here is a test source I am using now:
#include <stdio.h>
int main()
{
double x = 1.0;
for (x = 1.0; x != 0.0; x /= 2)
printf("%e\n", x);
return 0;
}
Compiled with gcc version 2.95.2 19991024 (release) and the following
flags '-Wall -mieee -O2' it is producing the following tail in its
output:
2.529616e-321
1.264808e-321
6.324040e-322
3.162020e-322
1.581010e-322
7.905050e-323
3.952525e-323
1.976263e-323
9.881313e-324
4.940656e-324
This time a machine is
cpu : Alpha
cpu model : EV56
system type : Ruffian
and its kernel is 2.2.17 with the following patches, in this moment,
applied and in this order (could be important if you want avoid
too many troubles):
raid-2.2.17-A0.bz2
ide.2.2.17.all.20000904.patch.bz2
00_IO-wait-2.gz
00_SMP-scheduler-2.2.14-G.gz
00_account-failed-buffer-tries-1.gz
00_alpha-epoch-1.gz
00_alpha-read-unlock-SMP-race-1.gz
00_nanosleep-4.gz
00_set_rtc_mss-SMP-race-1.gz
00_silent-stack-overflow-4.gz
10_bigmem-2.2.18pre2-18.bz2
Comments:
- RAID patch is from http://people.redhat.com/mingo/
and it requires some corrections to resolve one reject
- IDE patch is available on kernel repositories under people/hedrick
- Other patches are from Andrea Arcangeli collection; the same location
as above but under people/andrea
- Aside of this one reject you will get various line offsets (not
very surprising)
I do not see at the first glance which of these may affect a floating
point behaviour in a kernel but quite possible I miss something here.
Oh, without -mieee an output stops around e-308, as expected.
Now I have to run! :-)
One more thing. On failed test did you use '-O2', or higher,
optimizations? Maybe some non-expanded inline stuff from headers
is significant here? Just a thought.
Michal
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
@ 2000-09-19 21:26 Arkadiy Chapkis - Arc
2000-09-19 23:06 ` Uncle George
0 siblings, 1 reply; 36+ messages in thread
From: Arkadiy Chapkis - Arc @ 2000-09-19 21:26 UTC (permalink / raw)
To: axp-list
I tried this code and I got up (or down?) to
2.225074e-308 without -Wall -mieee -O2
and
4.940656e-324 with those flags.
The machine is AS200 4/233, kernel 2.3.45, gcc version 2.95.2 19991024
(release)
Arc C.
achapkis@dls.net
achapkis@shark.dls.net
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 21:09 ` Michal Jaegermann
@ 2000-09-19 21:48 ` Brad Lucier
2000-09-19 22:41 ` Uncle George
2000-09-20 7:00 ` Christian Iseli
2000-09-19 22:09 ` Brad Lucier
1 sibling, 2 replies; 36+ messages in thread
From: Brad Lucier @ 2000-09-19 21:48 UTC (permalink / raw)
To: axp-list
>
> Brad Lucier wrote:
> >
> > Yes, this is with -mieee. It went to e-324 with x *= 0.5, but
> > only to e-308 with x /= 2.0.
> >
> > Brad
> >
> > >
> > > Kan i presume u used -mieee ???
Yes, -O2 makes a difference:
popov-289% cat > denormtest.c
#include <stdio.h>
int main()
{
double x = 1.0;
for (x = 1.0; x != 0.0; x /= 2)
printf("%e\n", x);
return 0;
}
popov-290% gcc -Wall -mieee -O2 -o denormtest denormtest.c
popov-291% ./denormtest | tail
2.529616e-321
1.264808e-321
6.324040e-322
3.162020e-322
1.581010e-322
7.905050e-323
3.952525e-323
1.976263e-323
9.881313e-324
4.940656e-324
popov-292% gcc -Wall -mieee -o denormtest denormtest.c
popov-293% ./denormtest | tail
1.139238e-305
5.696189e-306
2.848095e-306
1.424047e-306
7.120236e-307
3.560118e-307
1.780059e-307
8.900295e-308
4.450148e-308
2.225074e-308
popov-294% gcc -v
Reading specs from /export/u10/gcc-2.95.1/lib/gcc-lib/alphaev6-unknown-linux-gnu/2.95.1/specs
gcc version 2.95.1 19990816 (release)
popov-295% uname -a
Linux popov.math.purdue.edu 2.2.17 #2 SMP Sat Sep 9 15:42:16 EST 2000 alpha unknown
With -O2, gcc converts the divide by 2.0 to multiplication by 0.5;
this gets rid of the problem :-).
Brad
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 21:09 ` Michal Jaegermann
2000-09-19 21:48 ` Brad Lucier
@ 2000-09-19 22:09 ` Brad Lucier
2000-09-19 22:42 ` Michal Jaegermann
1 sibling, 1 reply; 36+ messages in thread
From: Brad Lucier @ 2000-09-19 22:09 UTC (permalink / raw)
To: axp-list
>
> Brad Lucier wrote:
> >
> > Yes, this is with -mieee. It went to e-324 with x *= 0.5, but
> > only to e-308 with x /= 2.0.
> >
> > Brad
> >
> > >
> > > Kan i presume u used -mieee ???
>
>
> Ok, here is a test source I am using now:
>
> #include <stdio.h>
>
> int main()
> {
> double x = 1.0;
> for (x = 1.0; x != 0.0; x /= 2)
> printf("%e\n", x);
> return 0;
> }
>
> Compiled with gcc version 2.95.2 19991024 (release) and the following
> flags '-Wall -mieee -O2' it is producing the following tail in its
> output:
>
> 2.529616e-321
> 1.264808e-321
> 6.324040e-322
> 3.162020e-322
> 1.581010e-322
> 7.905050e-323
> 3.952525e-323
> 1.976263e-323
> 9.881313e-324
> 4.940656e-324
>
> This time a machine is
> cpu : Alpha
> cpu model : EV56
> system type : Ruffian
>
> and its kernel is 2.2.17 with the following patches, in this moment,
> applied and in this order (could be important if you want avoid
> too many troubles):
>
-O2 converts the divide by 2 to a multiplication by 0.5, and so
avoids the error.
Brad Lucier
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 21:48 ` Brad Lucier
@ 2000-09-19 22:41 ` Uncle George
2000-09-20 7:00 ` Christian Iseli
1 sibling, 0 replies; 36+ messages in thread
From: Uncle George @ 2000-09-19 22:41 UTC (permalink / raw)
To: axp-list
I suppose it wouldn't be so inverse friendly, if it didn't know what the constant would be ?
/gat
Brad Lucier wrote:
> >
> > Brad Lucier wrote:
> > >
> > > Yes, this is with -mieee. It went to e-324 with x *= 0.5, but
> > > only to e-308 with x /= 2.0.
> > >
> > > Brad
> > >
> > > >
> > > > Kan i presume u used -mieee ???
>
> Yes, -O2 makes a difference:
>
> popov-289% cat > denormtest.c
> #include <stdio.h>
>
> int main()
> {
> double x = 1.0;
> for (x = 1.0; x != 0.0; x /= 2)
> printf("%e\n", x);
> return 0;
> }
> popov-290% gcc -Wall -mieee -O2 -o denormtest denormtest.c
> popov-291% ./denormtest | tail
> 2.529616e-321
> 1.264808e-321
> 6.324040e-322
> 3.162020e-322
> 1.581010e-322
> 7.905050e-323
> 3.952525e-323
> 1.976263e-323
> 9.881313e-324
> 4.940656e-324
> popov-292% gcc -Wall -mieee -o denormtest denormtest.c
> popov-293% ./denormtest | tail
> 1.139238e-305
> 5.696189e-306
> 2.848095e-306
> 1.424047e-306
> 7.120236e-307
> 3.560118e-307
> 1.780059e-307
> 8.900295e-308
> 4.450148e-308
> 2.225074e-308
> popov-294% gcc -v
> Reading specs from /export/u10/gcc-2.95.1/lib/gcc-lib/alphaev6-unknown-linux-gnu/2.95.1/specs
> gcc version 2.95.1 19990816 (release)
> popov-295% uname -a
> Linux popov.math.purdue.edu 2.2.17 #2 SMP Sat Sep 9 15:42:16 EST 2000 alpha unknown
>
> With -O2, gcc converts the divide by 2.0 to multiplication by 0.5;
> this gets rid of the problem :-).
>
> Brad
>
> _______________________________________________
> Axp-list mailing list
> Axp-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/axp-list
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 22:09 ` Brad Lucier
@ 2000-09-19 22:42 ` Michal Jaegermann
2000-09-19 23:02 ` Brad Lucier
0 siblings, 1 reply; 36+ messages in thread
From: Michal Jaegermann @ 2000-09-19 22:42 UTC (permalink / raw)
To: axp-list
>
> -O2 converts the divide by 2 to a multiplication by 0.5, and so
> avoids the error.
Yes, indeed. Even '-O' is good enough and '-O0' will expose the problem.
OTOH compiling anything with gcc and without optimization is a pure
masochism and only a check that a code generator indeed does exist;
so I did not even considered that somebody may want to use that
to compile something for running.
Michal
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 22:42 ` Michal Jaegermann
@ 2000-09-19 23:02 ` Brad Lucier
2000-09-19 23:55 ` Michal Jaegermann
` (2 more replies)
0 siblings, 3 replies; 36+ messages in thread
From: Brad Lucier @ 2000-09-19 23:02 UTC (permalink / raw)
To: axp-list
>
> >
> > -O2 converts the divide by 2 to a multiplication by 0.5, and so
> > avoids the error.
>
> Yes, indeed. Even '-O' is good enough and '-O0' will expose the problem.
>
> OTOH compiling anything with gcc and without optimization is a pure
> masochism and only a check that a code generator indeed does exist;
> so I did not even considered that somebody may want to use that
> to compile something for running.
>
> Michal
Huh? This fails with -O2, too:
popov-325% cat denormtest.c
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
double x = 1.0;
double y;
y = atof(argv[1]);
for (x = 1.0; x != 0.0; x /= y)
printf("%e\n", x);
return 0;
}
popov-326% gcc -O2 -Wall -o denormtest denormtest.c
popov-327% ./denormtest 2.0 | tail
1.139238e-305
5.696189e-306
2.848095e-306
1.424047e-306
7.120236e-307
3.560118e-307
1.780059e-307
8.900295e-308
4.450148e-308
2.225074e-308
Brad Lucier
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 21:26 Alpha/Linux FP denormal processing Arkadiy Chapkis - Arc
@ 2000-09-19 23:06 ` Uncle George
0 siblings, 0 replies; 36+ messages in thread
From: Uncle George @ 2000-09-19 23:06 UTC (permalink / raw)
To: axp-list
Kan u try using -O0 ?
/gat
Arkadiy Chapkis - Arc wrote:
> I tried this code and I got up (or down?) to
> 2.225074e-308 without -Wall -mieee -O2
>
> and
> 4.940656e-324 with those flags.
>
> The machine is AS200 4/233, kernel 2.3.45, gcc version 2.95.2 19991024
> (release)
>
> Arc C.
> achapkis@dls.net
> achapkis@shark.dls.net
>
> _______________________________________________
> Axp-list mailing list
> Axp-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/axp-list
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 23:02 ` Brad Lucier
@ 2000-09-19 23:55 ` Michal Jaegermann
2000-09-20 1:39 ` W Bauske
2000-09-20 0:12 ` Brad Lucier
2000-09-20 7:53 ` Uncle George
2 siblings, 1 reply; 36+ messages in thread
From: Michal Jaegermann @ 2000-09-19 23:55 UTC (permalink / raw)
To: axp-list
Brad Lucier wrote:
>
> >
> > OTOH compiling anything with gcc and without optimization is a pure
> > masochism
>
> Huh? This fails with -O2, too:
>
....
> for (x = 1.0; x != 0.0; x /= y)
....
Yes, sure. We know that this is a kernel bug and here optimization
will not help. But we were talking about different case and why
my test runs were ok.
BTW - for those trying a new variant. Make sure that you are not
using an argument which is too small. :-)
Michal
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 23:02 ` Brad Lucier
2000-09-19 23:55 ` Michal Jaegermann
@ 2000-09-20 0:12 ` Brad Lucier
2000-09-20 7:53 ` Uncle George
2 siblings, 0 replies; 36+ messages in thread
From: Brad Lucier @ 2000-09-20 0:12 UTC (permalink / raw)
To: axp-list
> Huh? This fails with -O2, too:
> ...
> popov-326% gcc -O2 -Wall -o denormtest denormtest.c
Sorry, there is really an invisible -mieee there. It fails
with -mieee.
Brad
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 23:55 ` Michal Jaegermann
@ 2000-09-20 1:39 ` W Bauske
2000-09-20 8:24 ` Helge Kreutzmann
0 siblings, 1 reply; 36+ messages in thread
From: W Bauske @ 2000-09-20 1:39 UTC (permalink / raw)
To: axp-list
Michal Jaegermann wrote:
>
> Brad Lucier wrote:
> >
> > >
> > > OTOH compiling anything with gcc and without optimization is a pure
> > > masochism
> >
> > Huh? This fails with -O2, too:
> >
> ....
> > for (x = 1.0; x != 0.0; x /= y)
> ....
>
> Yes, sure. We know that this is a kernel bug and here optimization
> will not help. But we were talking about different case and why
> my test runs were ok.
>
> BTW - for those trying a new variant. Make sure that you are not
> using an argument which is too small. :-)
>
A smart compiler would still remove the divide for this
case. Divides are notoriously slow compared to multiplies.
The variable is not loop dependent so use a reciprocal
and multiply. Does ccc leave the divide there? I wouldn't
think so.
Wes
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 16:52 ` Richard Henderson
@ 2000-09-20 2:23 ` Richard Henderson
2000-09-20 3:58 ` David S. Miller
0 siblings, 1 reply; 36+ messages in thread
From: Richard Henderson @ 2000-09-20 2:23 UTC (permalink / raw)
To: axp-list; +Cc: torvalds, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 519 bytes --]
On Tue, Sep 19, 2000 at 09:52:15AM -0700, Richard Henderson wrote:
> > Instead of *= 0.5, try /= 2.0
>
> Yes indeed you've found a bug in the kernel's FP emulation.
> I'll see about fixing it.
Rather than fix the old udiv128 function, which was trying to do
128/128 bit division, I've pulled in a subroutine from libgcc
that does 128/64 bit division, which is all we need here.
So it should be a bit faster than the old routine, for what ever
that's worth to someone who is already trapping into the kernel...
r~
[-- Attachment #2: d-2409-math --]
[-- Type: text/plain, Size: 6737 bytes --]
diff -ruNp linux/arch/alpha/math-emu/Makefile 2.4.0-9-4/arch/alpha/math-emu/Makefile
--- linux/arch/alpha/math-emu/Makefile Thu Dec 2 15:28:54 1999
+++ 2.4.0-9-4/arch/alpha/math-emu/Makefile Tue Sep 19 18:45:17 2000
@@ -8,7 +8,7 @@
# Note 2! The CFLAGS definition is now in the main makefile...
O_TARGET := math-emu.o
-O_OBJS := math.o
+O_OBJS := math.o qrnnd.o
CFLAGS += -I. -I$(TOPDIR)/include/math-emu -w
ifeq ($(CONFIG_MATHEMU),m)
diff -ruNp linux/arch/alpha/math-emu/math.c 2.4.0-9-4/arch/alpha/math-emu/math.c
--- linux/arch/alpha/math-emu/math.c Tue Mar 21 10:47:06 2000
+++ 2.4.0-9-4/arch/alpha/math-emu/math.c Tue Sep 19 18:26:38 2000
@@ -84,66 +84,6 @@ void cleanup_module(void)
#endif /* MODULE */
-/* For 128-bit division. */
-
-void
-udiv128(unsigned long divisor_f0, unsigned long divisor_f1,
- unsigned long dividend_f0, unsigned long dividend_f1,
- unsigned long *quot, unsigned long *remd)
-{
- _FP_FRAC_DECL_2(quo);
- _FP_FRAC_DECL_2(rem);
- _FP_FRAC_DECL_2(tmp);
- unsigned long i, num_bits, bit;
-
- _FP_FRAC_SET_2(rem, _FP_ZEROFRAC_2);
- _FP_FRAC_SET_2(quo, _FP_ZEROFRAC_2);
-
- if (_FP_FRAC_ZEROP_2(divisor))
- goto out;
-
- if (_FP_FRAC_GT_2(divisor, dividend)) {
- _FP_FRAC_COPY_2(rem, dividend);
- goto out;
- }
-
- if (_FP_FRAC_EQ_2(divisor, dividend)) {
- __FP_FRAC_SET_2(quo, 0, 1);
- goto out;
- }
-
- num_bits = 128;
- while (1) {
- bit = _FP_FRAC_NEGP_2(dividend);
- _FP_FRAC_COPY_2(tmp, rem);
- _FP_FRAC_SLL_2(tmp, 1);
- _FP_FRAC_LOW_2(tmp) |= bit;
- if (! _FP_FRAC_GE_2(tmp, divisor))
- break;
- _FP_FRAC_COPY_2(rem, tmp);
- _FP_FRAC_SLL_2(dividend, 1);
- num_bits--;
- }
-
- for (i = 0; i < num_bits; i++) {
- bit = _FP_FRAC_NEGP_2(dividend);
- _FP_FRAC_SLL_2(rem, 1);
- _FP_FRAC_LOW_2(rem) |= bit;
- _FP_FRAC_SUB_2(tmp, rem, divisor);
- bit = _FP_FRAC_NEGP_2(tmp);
- _FP_FRAC_SLL_2(dividend, 1);
- _FP_FRAC_SLL_2(quo, 1);
- if (!bit) {
- _FP_FRAC_LOW_2(quo) |= 1;
- _FP_FRAC_COPY_2(rem, tmp);
- }
- }
-
-out:
- *quot = quo_f1;
- *remd = rem_f1;
- return;
-}
/*
* Emulate the floating point instruction at address PC. Returns 0 if
diff -ruNp linux/arch/alpha/math-emu/qrnnd.S 2.4.0-9-4/arch/alpha/math-emu/qrnnd.S
--- linux/arch/alpha/math-emu/qrnnd.S Wed Dec 31 16:00:00 1969
+++ 2.4.0-9-4/arch/alpha/math-emu/qrnnd.S Tue Sep 19 18:41:26 2000
@@ -0,0 +1,163 @@
+ # Alpha 21064 __udiv_qrnnd
+ # Copyright (C) 1992, 1994, 1995, 2000 Free Software Foundation, Inc.
+
+ # This file is part of GCC.
+
+ # The GNU MP Library is free software; you can redistribute it and/or modify
+ # it under the terms of the GNU General Public License as published by
+ # the Free Software Foundation; either version 2 of the License, or (at your
+ # option) any later version.
+
+ # In addition to the permissions in the GNU General Public License, the
+ # Free Software Foundation gives you unlimited permission to link the
+ # compiled version of this file with other programs, and to distribute
+ # those programs without any restriction coming from the use of this
+ # file. (The General Public License restrictions do apply in other
+ # respects; for example, they cover modification of the file, and
+ # distribution when not linked into another program.)
+
+ # This file is distributed in the hope that it will be useful, but
+ # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
+ # License for more details.
+
+ # You should have received a copy of the GNU General Public License
+ # along with GCC; see the file COPYING. If not, write to the
+ # Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ # MA 02111-1307, USA.
+
+ .set noreorder
+ .set noat
+
+ .text
+
+ .globl __udiv_qrnnd
+ .ent __udiv_qrnnd
+__udiv_qrnnd:
+ .frame $30,0,$26,0
+ .prologue 0
+
+#define cnt $2
+#define tmp $3
+#define rem_ptr $16
+#define n1 $17
+#define n0 $18
+#define d $19
+#define qb $20
+#define AT $at
+
+ ldiq cnt,16
+ blt d,$largedivisor
+
+$loop1: cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule d,n1,qb
+ subq n1,d,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule d,n1,qb
+ subq n1,d,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule d,n1,qb
+ subq n1,d,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule d,n1,qb
+ subq n1,d,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ subq cnt,1,cnt
+ bgt cnt,$loop1
+ stq n1,0(rem_ptr)
+ bis $31,n0,$0
+ ret $31,($26),1
+
+$largedivisor:
+ and n0,1,$4
+
+ srl n0,1,n0
+ sll n1,63,tmp
+ or tmp,n0,n0
+ srl n1,1,n1
+
+ and d,1,$6
+ srl d,1,$5
+ addq $5,$6,$5
+
+$loop2: cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule $5,n1,qb
+ subq n1,$5,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule $5,n1,qb
+ subq n1,$5,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule $5,n1,qb
+ subq n1,$5,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ cmplt n0,0,tmp
+ addq n1,n1,n1
+ bis n1,tmp,n1
+ addq n0,n0,n0
+ cmpule $5,n1,qb
+ subq n1,$5,tmp
+ cmovne qb,tmp,n1
+ bis n0,qb,n0
+ subq cnt,1,cnt
+ bgt cnt,$loop2
+
+ addq n1,n1,n1
+ addq $4,n1,n1
+ bne $6,$Odd
+ stq n1,0(rem_ptr)
+ bis $31,n0,$0
+ ret $31,($26),1
+
+$Odd:
+ /* q' in n0. r' in n1 */
+ addq n1,n0,n1
+
+ cmpult n1,n0,tmp # tmp := carry from addq
+ subq n1,d,AT
+ addq n0,tmp,n0
+ cmovne tmp,AT,n1
+
+ cmpult n1,d,tmp
+ addq n0,1,AT
+ cmoveq tmp,AT,n0
+ subq n1,d,AT
+ cmoveq tmp,AT,n1
+
+ stq n1,0(rem_ptr)
+ bis $31,n0,$0
+ ret $31,($26),1
+
+ .end __udiv_qrnnd
diff -ruNp linux/arch/alpha/math-emu/sfp-util.h 2.4.0-9-4/arch/alpha/math-emu/sfp-util.h
--- linux/arch/alpha/math-emu/sfp-util.h Thu Dec 2 15:28:54 1999
+++ 2.4.0-9-4/arch/alpha/math-emu/sfp-util.h Tue Sep 19 18:41:05 2000
@@ -17,18 +17,13 @@
: "r" ((UDItype)(u)), \
"r" ((UDItype)(v)))
-extern void udiv128(unsigned long, unsigned long,
- unsigned long, unsigned long,
- unsigned long *,
- unsigned long *);
-
-#define udiv_qrnnd(q, r, n1, n0, d) \
- do { \
- unsigned long xr, xi; \
- udiv128((n0), (n1), 0, (d), &xr, &xi); \
- (q) = xr; \
- (r) = xi; \
+#define udiv_qrnnd(q, r, n1, n0, d) \
+ do { unsigned long __r; \
+ (q) = __udiv_qrnnd (&__r, (n1), (n0), (d)); \
+ (r) = __r; \
} while (0)
+extern unsigned long __udiv_qrnnd (unsigned long *, unsigned long,
+ unsigned long , unsigned long);
#define UDIV_NEEDS_NORMALIZATION 1
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-20 2:23 ` Richard Henderson
@ 2000-09-20 3:58 ` David S. Miller
2000-09-21 21:17 ` Richard Henderson
0 siblings, 1 reply; 36+ messages in thread
From: David S. Miller @ 2000-09-20 3:58 UTC (permalink / raw)
To: rth; +Cc: axp-list, torvalds, linux-kernel
Date: Tue, 19 Sep 2000 19:23:42 -0700
From: Richard Henderson <rth@twiddle.net>
Rather than fix the old udiv128 function, which was trying to do
128/128 bit division, I've pulled in a subroutine from libgcc that
does 128/64 bit division, which is all we need here.
So it should be a bit faster than the old routine, for what ever
that's worth to someone who is already trapping into the kernel...
Is this a serious patch submission or just a call for testing? If the
former, I need to cook up the sparc bits once it gets in :-)
Later,
David S. Miller
davem@redhat.com
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 21:48 ` Brad Lucier
2000-09-19 22:41 ` Uncle George
@ 2000-09-20 7:00 ` Christian Iseli
1 sibling, 0 replies; 36+ messages in thread
From: Christian Iseli @ 2000-09-20 7:00 UTC (permalink / raw)
To: axp-list
lucier@math.purdue.edu said:
> With -O2, gcc converts the divide by 2.0 to multiplication by 0.5;
> this gets rid of the problem :-).
Same here, using kernel 2.4.0-test3...
Machine:
cpu : Alpha
cpu model : EV56
cpu variation : 7
cpu revision : 0
system type : EB164
system variation : LX164
system revision : 0
Christian
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-19 23:02 ` Brad Lucier
2000-09-19 23:55 ` Michal Jaegermann
2000-09-20 0:12 ` Brad Lucier
@ 2000-09-20 7:53 ` Uncle George
2 siblings, 0 replies; 36+ messages in thread
From: Uncle George @ 2000-09-20 7:53 UTC (permalink / raw)
To: axp-list
I was thinking more of this:
int main()
{
double div = 1.0, dis = 2.0;
start( div, dis );
}
start( double div, double dis )
{
double x;
for (x = div; x != 0.0; x /= dis)
printf("%e\n", x);
}
even with -O2, it fails here.
Brad Lucier wrote:
> >
> > >
> > > -O2 converts the divide by 2 to a multiplication by 0.5, and so
> > > avoids the error.
> >
> > Yes, indeed. Even '-O' is good enough and '-O0' will expose the problem.
> >
> > OTOH compiling anything with gcc and without optimization is a pure
> > masochism and only a check that a code generator indeed does exist;
> > so I did not even considered that somebody may want to use that
> > to compile something for running.
> >
> > Michal
>
> Huh? This fails with -O2, too:
>
> popov-325% cat denormtest.c
> #include <stdio.h>
> #include <stdlib.h>
>
> int main(int argc, char **argv)
> {
> double x = 1.0;
> double y;
> y = atof(argv[1]);
> for (x = 1.0; x != 0.0; x /= y)
> printf("%e\n", x);
> return 0;
> }
> popov-326% gcc -O2 -Wall -o denormtest denormtest.c
> popov-327% ./denormtest 2.0 | tail
> 1.139238e-305
> 5.696189e-306
> 2.848095e-306
> 1.424047e-306
> 7.120236e-307
> 3.560118e-307
> 1.780059e-307
> 8.900295e-308
> 4.450148e-308
> 2.225074e-308
>
> Brad Lucier
>
> _______________________________________________
> Axp-list mailing list
> Axp-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/axp-list
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-20 1:39 ` W Bauske
@ 2000-09-20 8:24 ` Helge Kreutzmann
0 siblings, 0 replies; 36+ messages in thread
From: Helge Kreutzmann @ 2000-09-20 8:24 UTC (permalink / raw)
To: axp-list; +Cc: Lukas Dobrek, Carsten Luckmann, Thomas Boettner, Martin Mueller
Hello !
On Tue, Sep 19, 2000 at 08:39:23PM -0500, W Bauske wrote:
<snip>
> > >
> > ....
> > > for (x = 1.0; x != 0.0; x /= y)
> > ....
> >
> A smart compiler would still remove the divide for this
> case. Divides are notoriously slow compared to multiplies.
> The variable is not loop dependent so use a reciprocal
> and multiply. Does ccc leave the divide there? I wouldn't
> think so.
Comparing a XP1000 running Linux Alpha
Linux hakan 2.2.17 #1 Tue Sep 5 16:02:08 CEST 2000 alpha unknown
with
aa: gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
ab: Compaq C V6.2-503 on Linux 2.2.17 alpha
with an similar machines (sorry, don't have the excat specs because
I seldomly use the du machines and don't know where to look) running
OSF1 suker V4.0 1091 alpha
with
ba: gcc version 2.7-96q3
bb: DEC C V5.8-009 on Digital UNIX V4.0 (Rev. 1091)
I get for the three programs (1: *= 0.5; 2: /= 2.0 and 3: x/=y) the
following minimal exponent:
aa ab ba bb
1 e-308 e-308 e-308 e-308
1 -O2 e-308 e-308 e-308 e-308
1 -O2 -mieee e-324 e-324 ? e-324
1 -mieee e-324 e-324 ? e-324
2 e-308 e-308 e-308 e-308
2 -O2 e-308 e-308 e-308 e-308
2 -O2 -mieee e-324 e-324 ? e-324
2 -mieee e-308 e-324 ? e-324
3 e-308 e-308 e-308 e-308
3 -O2 e-308 e-308 e-308 e-308
3 -O2 -mieee e-308 e-308 ? e-324
3 -mieee e-308 e-308 ? e-324
With the compaq compiler on DU -ieee was used. And our gcc on DU unfortunately
does not understand -mieee.
Since no ccc test runs were posted I hope this might help. Especially
programm three in comparison DU<->Linux indicates the kernel problem.
Regards
Helge
--
Helge Kreutzmann, Dipl.-Phys. kreutzm@itp.uni-hannover.de
For gpg-key: finger kreutzm@rigel.itp.uni-hannover.de
64bit GNU powered http://www.itp.uni-hannover.de/~kreutzm
Help keep free software "libre": http://www.freepatents.org/
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-20 3:58 ` David S. Miller
@ 2000-09-21 21:17 ` Richard Henderson
2000-09-21 21:50 ` David S. Miller
0 siblings, 1 reply; 36+ messages in thread
From: Richard Henderson @ 2000-09-21 21:17 UTC (permalink / raw)
To: David S. Miller; +Cc: axp-list, torvalds, linux-kernel
On Tue, Sep 19, 2000 at 08:58:06PM -0700, David S. Miller wrote:
> Is this a serious patch submission or just a call for testing? If the
> former, I need to cook up the sparc bits once it gets in :-)
Huh? A serious patch submission, since it fixes a bug.
Why would you need to cook up any sparc bits? Jakub
already has a proper implementaion of qrnnd for sparc...
r~
^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: Alpha/Linux FP denormal processing
2000-09-21 21:17 ` Richard Henderson
@ 2000-09-21 21:50 ` David S. Miller
0 siblings, 0 replies; 36+ messages in thread
From: David S. Miller @ 2000-09-21 21:50 UTC (permalink / raw)
To: rth; +Cc: axp-list, torvalds, linux-kernel
Date: Thu, 21 Sep 2000 14:17:12 -0700
From: Richard Henderson <rth@twiddle.net>
Why would you need to cook up any sparc bits? Jakub
already has a proper implementaion of qrnnd for sparc...
Nevermind, brain fart.
Later,
David S. Miller
davem@redhat.com
^ permalink raw reply [flat|nested] 36+ messages in thread
end of thread, other threads:[~2000-09-21 22:03 UTC | newest]
Thread overview: 36+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2000-09-19 21:26 Alpha/Linux FP denormal processing Arkadiy Chapkis - Arc
2000-09-19 23:06 ` Uncle George
-- strict thread matches above, loose matches on Subject: below --
2000-09-16 23:58 OT: gcc on DU5 Larry Snyder
2000-09-18 3:29 ` Peter Rival
2000-09-17 23:15 ` Richard Henderson
2000-09-19 0:59 ` Alpha/Linux FP denormal processing Uncle George
2000-09-19 1:54 ` Brad Lucier
2000-09-19 9:29 ` Uncle George
2000-09-19 13:03 ` Greg Lindahl
2000-09-19 16:48 ` Richard Henderson
2000-09-19 14:16 ` Brad Lucier
2000-09-19 14:31 ` Uncle George
2000-09-19 16:25 ` Michal Jaegermann
2000-09-19 17:27 ` Jeff Sturm
2000-09-19 17:43 ` Michal Jaegermann
2000-09-19 19:10 ` Uncle George
2000-09-19 19:30 ` Michal Jaegermann
2000-09-19 19:46 ` Brad Lucier
2000-09-19 20:03 ` Uncle George
2000-09-19 20:16 ` Brad Lucier
2000-09-19 21:09 ` Michal Jaegermann
2000-09-19 21:48 ` Brad Lucier
2000-09-19 22:41 ` Uncle George
2000-09-20 7:00 ` Christian Iseli
2000-09-19 22:09 ` Brad Lucier
2000-09-19 22:42 ` Michal Jaegermann
2000-09-19 23:02 ` Brad Lucier
2000-09-19 23:55 ` Michal Jaegermann
2000-09-20 1:39 ` W Bauske
2000-09-20 8:24 ` Helge Kreutzmann
2000-09-20 0:12 ` Brad Lucier
2000-09-20 7:53 ` Uncle George
2000-09-19 20:33 ` Michal Jaegermann
2000-09-19 16:52 ` Richard Henderson
2000-09-20 2:23 ` Richard Henderson
2000-09-20 3:58 ` David S. Miller
2000-09-21 21:17 ` Richard Henderson
2000-09-21 21:50 ` David S. Miller
2000-09-19 12:10 ` Jeff Sturm
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox