Linux PARISC architecture development
 help / color / mirror / Atom feed
* [parisc-linux] PA 2.0 float conversion to unsigned long long
@ 2005-07-14  2:53 John David Anglin
  2005-07-14  3:32 ` Kyle McMartin
  0 siblings, 1 reply; 13+ messages in thread
From: John David Anglin @ 2005-07-14  2:53 UTC (permalink / raw)
  To: parisc-linux

The enclosed testcase derived from GCC PR 22474 aborts under linux but
not under hpux.  The problem is the following insn:

0x00002930 <f2ull+24>:  fcnv,t,sgl,udw fr22,fr22

Dave
-- 
J. David Anglin                                  dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada              (613) 990-0752 (FAX: 952-6602)

/* gcc -w -o pr22474 -O0 -march=2.0 -fno-show-column pr22474.c */
unsigned long long
f2ull(float f)
{
  return (unsigned long long int) f;
}

int
main ()
{
  if (f2ull((float) ((~0ULL) >> 1)) != (~0ULL) >> 1 &&  /* 0x7fffffff */
      f2ull((float) ((~0ULL) >> 1)) != ((~0ULL) >> 1) + 1)
    abort();
  return 0;
}
_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: [parisc-linux] PA 2.0 float conversion to unsigned long long
@ 2005-07-19 17:41 soete.joel
  2005-07-19 18:29 ` John David Anglin
  0 siblings, 1 reply; 13+ messages in thread
From: soete.joel @ 2005-07-19 17:41 UTC (permalink / raw)
  To: dave; +Cc: kyle, parisc-linux

---------- Initial header -----------

>>From      : parisc-linux-bounces@lists.parisc-linux.org
To          : grundler@parisc-linux.org
CC          : kyle@mcmartin.ca,parisc-linux@lists.parisc-linux.org
Date      : Mon, 18 Jul 2005 18:34:17 -0400 (EDT)
Subject : Re: [parisc-linux] PA 2.0 float conversion to unsigned long lon=
g

> > On Wed, Jul 13, 2005 at 11:56:28PM -0400, John David Anglin wrote:
> > ...
> > > That's what I was thinking when I wrote the message.  Under linux,
> > > both the left and right halves of fr22 end up with 0x80000000.  Und=
er
> > > hpux, the left result is 0x80000000 and the right 0.  The only othe=
r
> > > explanation is that the c3k fpu has a bug that's not present in an =
=3D
> > A500
> > > (doubtful).
> > 
Dave would you mean that c3k was runing parisc-linux and a500 hpux?

> > If they are running at the same clock speed, they are likely to have
> > identical CPUs. Some of the 440Mhz boxes did roll CPU HW version
> > after initial release - including some SMP bugs that C3K wouldn't
> > be exposed to. I'm skeptical it's a bug in the FPU unless you
> > can demonstrate the same code works on another (newer) CPU model.
> 
> Actually, it's the reverse.  I believe that the A500 is a 550 MHz
> 8600 and the C3K is a 875 MHz 8700.
I doubt it help but with parisc-linux, I also encounter the same pb with =
a
pa8000 180mhz (d380), as well as on a pa8600 440Mhz (b2k) or same pa8600
550Mhz (n4k smp)

(sorry no pa2.0 running hpux on which I could install gcc :_( ) 

> It's really unclear which of
> the new PA 2.0 floating-point instructions are actually supported
> in hardware.  I'd have to do some timing tests to figure that out
> as there's not much documentation.  It is clear that linux has code
> in the kernel to handle the convert in question.
> 
mmm fwiw, when I did the test replacing float with double as:
unsigned long long
d2ull(double f)
{
  return (unsigned long long int) f;
}

int
main ()
{
  unsigned long long x1, x2;

  x1 =3D ((~0ULL) >> 1);
  x2 =3D ((~0ULL) >> 1);

  printf("x1 =3D 0x%llx\n", x1);
  printf("d2ull((double) x1) =3D 0x%llx\n", d2ull((double) x1));

  printf("(~0ULL) >> 1 =3D 0x%llx\n", (~0ULL) >> 1);
  printf("((~0ULL) >> 1) + 1 =3D 0x%llx\n", ((~0ULL) >> 1) + 1);

  if (d2ull((double) x1) !=3D (~0ULL) >> 1 &&  /* 0x7fffffff */
      d2ull((double) x2) !=3D ((~0ULL) >> 1) + 1)
    abort();
  return 0;
}
/*
x1 =3D 0x7fffffffffffffff
d2ull((double) x1) =3D 0x8000000000000000
(~0ULL) >> 1 =3D 0x7fffffffffffffff
((~0ULL) >> 1) + 1 =3D 0x8000000000000000
 */

(I just used x var to encounter the 'ull -> float' in main() too)

Is there some pb in sgl -> udw convertion?

Joel=0A=0A-------------------------------------------------------=0ANOTE!=
 My email address is changing to ... @scarlet.be=0APlease make the necess=
ary changes in your address book. =0A=0A

_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: [parisc-linux] PA 2.0 float conversion to unsigned long long
@ 2005-07-20 15:30 soete.joel
  2005-07-22 22:04 ` Joel Soete
  0 siblings, 1 reply; 13+ messages in thread
From: soete.joel @ 2005-07-20 15:30 UTC (permalink / raw)
  To: dave; +Cc: kyle, parisc-linux

> > Dave would you mean that c3k was runing parisc-linux and a500 hpux?
> 
> Correct.
> 
Ok clear.

> > Is there some pb in sgl -> udw convertion?
> 
> Could be.  There is a significant different between PA 1.x and 2.0
> in this respect.  PA 2.0 has "hardware" instructions to do these
> conversions.  GCC currently uses these instructions when generating
> PA 2.0 code.

After severall hours of test, I changed my mind.

I have my ws runing hpux 11.00 and gcc to compile pr code ;-)

I have a n4k 2-way pa8600 550Mhz testing parisc-linux 2.6.12-pa2-n4ksmp
(ggc-4.0 + fpr limits) 

I can also use a developement n4k 4-way pa8600 440Mhz (not od this clock)=

runing hpux 11.00 (with latest patch bundle).

First thing on p-l I noticed:
I get rid of unsigned by:
long long
f2ull(float f)
{
 return (long long) f;
}

And it print well 'f2ull((float) ((~0ULL) >> 1)) =3D 0x7fffffffffffffff'

I let you also check the resulting .s file when I play with following:
unsigned long long
f2ull(float f)
{
  long long tmp =3D (long long) f;
  return (unsigned long long) temp;
}

Semanticaly it would be the same as the original but the result is also:
'f2ull((float) ((~0ULL) >> 1)) =3D 0x7fffffffffffffff' ?

Now the brain shacking ;-)

the behaviour comparison between hpux and p-l (on the original code):
I used some gui gdb helper (wdb on hpux and insight and ddd on p-l)

    * at the end of f2ull() ret0 and ret1 (aka r28 & r29) are well differ=
ent:
        hpux: r28 =3D=3D 0x80000000; r29 =3D=3D 0x00000000,
        p-l : r28 =3D r29 =3D=3D 0x80000000
    ???? (the code of .s file is quite the same ;-)

    * very strange is the very difference of fpsr:
      (e.g. after fldw r3(,ret0),fr22
            hpux : fpsr =3D=3D 0x40

            after next fcnv insn
            hpux : fpsr =3D=3D 0x80000000; 

            p-l  : fpsr stay constantly =3D=3D 0x0

So as far as this time the 2 hw are nearly the same, as well as the execu=
table
txt, the 2 previous test make me better thought that fpu are 'configurabl=
e'
(may be not all model) and are not setup the same way by the different OS=
. 
That said, I never read anything about this but i don't see other reasona=
ble
explanation?


Joel

PS:
obviously gdb relase are very different on the 2 systems, but I hope that=
 such
'printf "%x\n", $fpsr' (or what else as reg) could show me actual cpu reg=

value, though.

=0A=0A-------------------------------------------------------=0ANOTE! My =
email address is changing to ... @scarlet.be=0APlease make the necessary =
changes in your address book. =0A=0A

_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

^ permalink raw reply	[flat|nested] 13+ messages in thread
* Re: [parisc-linux] PA 2.0 float conversion to unsigned long long
@ 2005-07-25  9:57 Joel Soete
  0 siblings, 0 replies; 13+ messages in thread
From: Joel Soete @ 2005-07-25  9:57 UTC (permalink / raw)
  To: grundler; +Cc: kyle, dave, parisc-linux, tsg45800

> On Sat, Jul 23, 2005 at 09:39:34AM +0000, Joel Soete wrote:
> > >I'm not sure it's a very good idea posting bits of the HP-UX
> > >kernel on a publicly archived mailing list. I imagine the disassembl=
y's
> > >legal status is questionable... 
> >
> > Yes I hesitate but finaly though that reverse engineering is legal (s=
ee the 
> > famous samba project ;-) )?
> 
> samba didn't disassemble a copy of the binary.
> They reverse engineered the "on wire" protocol as captured by tcpdump.
> 
(mmm is boomerang <http://boomerang.sourceforge.net/> a more relevant exa=
mple
:-? )
That said, my worry was not much the way reverse engineering was realised=
 then
reverse-engineering by itself: is it or not legal?
 
> Dumping raw dissassembly isn't interesting.
More over ;-)(absolutely agree with you)

Anyway may I come back shortly to the original object of this thread:
"PA 2.0 float conversion to unsigned long long"

I reach to reproduce the pb clearly decribe by jda and with the help of g=
db I
observed not only a difference of results between p-l and hpux-11.00 but =
also
a noticable difference of behaviour in fpsr.

The differences make me ask if "fpu is configurable?"

On irc Carlos put me another question on the fpu mode which make me disco=
ver
in parisc2.0.pdf ("PA-RISC 2.0 Architecture Floating-Point Instruction Se=
t
9-9") a documented way to (at least) indentify pfu.

Btw I discover:
    o this chunk wasn't implemented in p-l but well hpux-11.00 (32 and 64=
bit).

    o hpux (11-.00) has also a label which make thought
      that fpu have actualy to be initialized

    o this thread
<http://lists.parisc-linux.org/pipermail/parisc-linux/2003-January/018852=
.html>
      (my grasp of this code is not yet complete sorry: 
            when/where fpregs[] was setup? ...)

Are we missing something?

> If it is legal in your country to analyze the behaviors, I'm
> really only interested in the analysis.
> 
(In a help desk, I read this joke: ... for miracle we ask you a delay of =
24h :-)

Thanks again,
    Joel=0A=0A-------------------------------------------------------=0AN=
OTE! My email address is changing to ... @scarlet.be=0APlease make the ne=
cessary changes in your address book. =0A=0A

_______________________________________________
parisc-linux mailing list
parisc-linux@lists.parisc-linux.org
http://lists.parisc-linux.org/mailman/listinfo/parisc-linux

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

end of thread, other threads:[~2005-07-25  9:57 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-07-14  2:53 [parisc-linux] PA 2.0 float conversion to unsigned long long John David Anglin
2005-07-14  3:32 ` Kyle McMartin
2005-07-14  3:56   ` John David Anglin
2005-07-14  6:29     ` Joel Soete
2005-07-18 19:45     ` Grant Grundler
2005-07-18 22:34       ` John David Anglin
  -- strict thread matches above, loose matches on Subject: below --
2005-07-19 17:41 soete.joel
2005-07-19 18:29 ` John David Anglin
2005-07-20 15:30 soete.joel
2005-07-22 22:04 ` Joel Soete
2005-07-22 23:16   ` Kyle McMartin
2005-07-23  9:39     ` Joel Soete
2005-07-25  9:57 Joel Soete

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