Re: fsqrt

2013-06-08 Thread Benjamin Herrenschmidt
The interesting thing I'm finding is that our math-emu is actually quite busted :-) For example look at fsqrt. It's defined as type AB which is incorrect, it should be type XB. It ends up looking for it's arguments in the wrong registers, same for fsrqts, fre, and a few others. Also quite a few f

Re: fsqrt

2013-06-08 Thread Dan Malek
Hi Ben. On Jun 7, 2013, at 5:34 PM, Benjamin Herrenschmidt wrote: > The question is whether this is still relevant ? The only answer I could provide is that it's dependent upon the libraries and how the distributions are built. It's also dependent upon processors with hardware FP that don'

Re: fsqrt

2013-06-08 Thread Dan Malek
On Jun 7, 2013, at 4:30 PM, Benjamin Herrenschmidt wrote: > Right, looking more, the code really sucks. Hey! :) > …. Either you use the existing > apparent ability for MATH_EMU to operate in minimal mode, ie, > load/store/fmr only (which seems to do exactly the same thing as the > code in s

Re: fsqrt

2013-06-07 Thread Benjamin Herrenschmidt
On Fri, 2013-06-07 at 18:13 -0700, Dan Malek wrote: > Hi Ben. > > On Jun 7, 2013, at 5:34 PM, Benjamin Herrenschmidt > wrote: > > > The question is whether this is still relevant ? > > The only answer I could provide is that it's dependent upon the > libraries and how the distributions are buil

Re: fsqrt

2013-06-07 Thread Benjamin Herrenschmidt
On Fri, 2013-06-07 at 17:20 -0700, Dan Malek wrote: > The purpose for that "minimal code" was the signal handlers were > hand-coded assembly that always did the FPU load/store regardless of > compiler flags. Over time, it became convenient to emulate a few > others, even with user space math emul

Re: fsqrt

2013-06-07 Thread Benjamin Herrenschmidt
On Sat, 2013-06-08 at 09:25 +1000, Benjamin Herrenschmidt wrote: > On Sat, 2013-06-08 at 09:23 +1000, Benjamin Herrenschmidt wrote: > > Ok, thinking out loud... looks like we might be able to just use existing > > math-emu for that. From what I can tell, all it needs (other than enabling > > the c

Re: fsqrt

2013-06-07 Thread Benjamin Herrenschmidt
On Sat, 2013-06-08 at 09:23 +1000, Benjamin Herrenschmidt wrote: > Ok, thinking out loud... looks like we might be able to just use existing > math-emu for that. From what I can tell, all it needs (other than enabling > the config option), is a call to flush_fp_to_thread(current); > > While talki

Re: fsqrt

2013-06-07 Thread Benjamin Herrenschmidt
On Fri, 2013-06-07 at 14:19 -0500, Kumar Gala wrote: > > I don't personally have the bandwidth to do a clean implementation (that > > handles FP exceptions, NaNs, FPSCR, etc...) but I believe it would be > > valuable if somebody else did (hint hint hint :-) since without this, > > Fedora ppc64 is b

Re: fsqrt

2013-06-07 Thread Kumar Gala
On Jun 7, 2013, at 7:14 AM, Benjamin Herrenschmidt wrote: > On Fri, 2013-06-07 at 11:48 +0100, David Laight wrote: >>> For those interested, this is the Quake3 sqrt from Carmack ... >> there's >>> plenty of literature about it one or two google clicks away :-) >> >> I guess that is a rough enoug

Re: fsqrt

2013-06-07 Thread Benjamin Herrenschmidt
On Fri, 2013-06-07 at 11:48 +0100, David Laight wrote: > > For those interested, this is the Quake3 sqrt from Carmack ... > there's > > plenty of literature about it one or two google clicks away :-) > > I guess that is a rough enough approximation for graphics. > > However it will be miscompiled

Re: fsqrt

2013-06-07 Thread Benjamin Herrenschmidt
On Fri, 2013-06-07 at 17:02 +0800, tiejun.chen wrote: > On 06/07/2013 04:53 PM, Benjamin Herrenschmidt wrote: > > On Fri, 2013-06-07 at 15:46 +0800, tiejun.chen wrote: > >> On 06/07/2013 03:41 PM, Benjamin Herrenschmidt wrote: > >>> Another question... > >>> > >>> Do you guys happen to have a patch

RE: fsqrt

2013-06-07 Thread David Laight
> > + > > +static double crackpot_sqrt(double val) > > +{ > > +int i; > > +float x, y; > > +const float f = 1.5F; > > + > > +x = val * 0.5F; > > +y = val; > > +i = * ( int * ) &y; > > +i = 0x5f3759df - ( i >> 1 ); > > +y = * ( float * ) &i; > > +y = y * ( f

Re: fsqrt

2013-06-07 Thread tiejun.chen
On 06/07/2013 04:53 PM, Benjamin Herrenschmidt wrote: On Fri, 2013-06-07 at 15:46 +0800, tiejun.chen wrote: On 06/07/2013 03:41 PM, Benjamin Herrenschmidt wrote: Another question... Do you guys happen to have a patch to emulate fsqrt in the kernel ? Seems this is already emulated: arch/powe

Re: fsqrt

2013-06-07 Thread Benjamin Herrenschmidt
On Fri, 2013-06-07 at 18:53 +1000, Benjamin Herrenschmidt wrote: > + > +static double crackpot_sqrt(double val) > +{ > +int i; > +float x, y; > +const float f = 1.5F; > + > +x = val * 0.5F; > +y = val; > +i = * ( int * ) &y; > +i = 0x5f3759df - ( i >> 1 ); > +y

Re: fsqrt

2013-06-07 Thread Benjamin Herrenschmidt
On Fri, 2013-06-07 at 07:45 +, Zang Roy-R61911 wrote: > > > -Original Message- > > From: Benjamin Herrenschmidt [mailto:b...@kernel.crashing.org] > > Another question... > > > > Do you guys happen to have a patch to emulate fsqrt in the kernel ? > > > > Fedora 19 seems to be using it

Re: fsqrt

2013-06-07 Thread Benjamin Herrenschmidt
On Fri, 2013-06-07 at 15:46 +0800, tiejun.chen wrote: > On 06/07/2013 03:41 PM, Benjamin Herrenschmidt wrote: > > Another question... > > > > Do you guys happen to have a patch to emulate fsqrt in the kernel ? > > Seems this is already emulated: > > arch/powerpc/math-emu/fsqrt.c > > You can enab

Re: fsqrt

2013-06-07 Thread tiejun.chen
On 06/07/2013 03:41 PM, Benjamin Herrenschmidt wrote: Another question... Do you guys happen to have a patch to emulate fsqrt in the kernel ? Seems this is already emulated: arch/powerpc/math-emu/fsqrt.c You can enable CONFIG_MATH_EMULATION to try. Tiejun ___

RE: fsqrt

2013-06-07 Thread Zang Roy-R61911
> -Original Message- > From: Benjamin Herrenschmidt [mailto:b...@kernel.crashing.org] > Another question... > > Do you guys happen to have a patch to emulate fsqrt in the kernel ? > > Fedora 19 seems to be using it ... among others. You mean this one arch/powerpc/math-emu/fsqrt.c ? Yes.