Subject: Re: fsqrt

From: Benjamin Herrenschmidt <[email-masked]>
Date: Fri, 07 Jun 2013 22:07:02 +1000

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 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.
> >
> > Is math emu expected to work at all on top of a real FPU ? I though it
> > didn't ... maybe I'm wrong.
> 
> As I understand often the real FPU can't support all float instructions, so we 
> have to enable this to emulate those unsupported float instructions in that 
> scenario.

Ok, two things come to mind here:

  - do_mathemu doesn't do giveup_fpu() so the FPU state might still be
in the "live" FP registers and not in the thread_struct, so it can't
work... unless I missed something.

  - mathemu uses solely integers. For something like fsqrt it's going to
suck a lot more than implementing using floating points in the kernel.

Cheers,
Ben.