* Doing floating point calculations in kernel space
@ 2003-10-17 7:15 Toni Van Remortel
2003-10-17 7:33 ` Wolfgang Grandegger
0 siblings, 1 reply; 8+ messages in thread
From: Toni Van Remortel @ 2003-10-17 7:15 UTC (permalink / raw)
To: Linuxppc-Embedded
Hi all,
When I thought it was a /proc problem, it was a float problem.
The CPU (405GP) has no FPU, but I need to calculate sin and cos in a
kernel module.
Why? Well, we use a formula to draw figures (all deformed circles).
Those figures can be defined with only 6 parameters, which are passed
from the control-panel (in userspace) to the RTAI-powered kernel module.
That module calculates the X and Y positions, creates PWM signals from
it and outputs them to GPIO1 and 2.
I don't see another approach to get this working, because the
control-panel isn't real time, while the kernel module is. So the module
needs to calculate the X and Y positions from the 6 parameters.
To make it short: can I use floating points in kernel space? The info
I've found just tells me 'no', but I'm wondering if there are any
workarounds for this.
I did find some 'faster math functions' which don't require any sin or
cos anymore, but they do require floating points.
A possible solution to me, is using 'unsinged long int' multiplied by
some factor of 10.
Anybody a better solution?
PS: might be a bit off topic here, sorry about that.
--
Toni Van Remortel
Wetenschappelijk Medewerker - D-science lab
Real time Linux for embedded systems: http://linemb.d-sciencelab.com
Tel: +32 3 205 61 72 - Fax: +32 3 205 61 95
E-mail: t.vanremortel@ha.be
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Doing floating point calculations in kernel space
2003-10-17 7:15 Doing floating point calculations in kernel space Toni Van Remortel
@ 2003-10-17 7:33 ` Wolfgang Grandegger
2003-10-17 7:52 ` Toni Van Remortel
0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Grandegger @ 2003-10-17 7:33 UTC (permalink / raw)
To: t.vanremortel, Linuxppc-Embedded
Hi,
this has been discussed recently. For RTAI on MPC 8xx we
provide the following example:
ftp://ftp.denx.de/pub/RTAI/contrib/fp_ppc_8xx.tar.bz2
It links statically with the libm and the soft-float
library derived from libgcc.
Hope it's useful.
>-- Original Message --
>Subject: Doing floating point calculations in kernel space
>From: Toni Van Remortel <t.vanremortel@ha.be>
>Reply-To: t.vanremortel@ha.be
>To: Linuxppc-Embedded <linuxppc-embedded@lists.linuxppc.org>
>Date: Fri, 17 Oct 2003 09:15:39 +0200
>
>
>
>Hi all,
>
>When I thought it was a /proc problem, it was a float problem.
>The CPU (405GP) has no FPU, but I need to calculate sin and cos in a
>kernel module.
>Why? Well, we use a formula to draw figures (all deformed circles).
>Those figures can be defined with only 6 parameters, which are passed
>from the control-panel (in userspace) to the RTAI-powered kernel module.
>That module calculates the X and Y positions, creates PWM signals from
>it and outputs them to GPIO1 and 2.
>
>I don't see another approach to get this working, because the
>control-panel isn't real time, while the kernel module is. So the module
>needs to calculate the X and Y positions from the 6 parameters.
>
>To make it short: can I use floating points in kernel space? The info
>I've found just tells me 'no', but I'm wondering if there are any
>workarounds for this.
>I did find some 'faster math functions' which don't require any sin or
>cos anymore, but they do require floating points.
>
>A possible solution to me, is using 'unsinged long int' multiplied by
>some factor of 10.
>
>Anybody a better solution?
>
>PS: might be a bit off topic here, sorry about that.
>--
> Toni Van Remortel
> Wetenschappelijk Medewerker - D-science lab
> Real time Linux for embedded systems: http://linemb.d-sciencelab.com
> Tel: +32 3 205 61 72 - Fax: +32 3 205 61 95
> E-mail: t.vanremortel@ha.be
>
>
>
\x18
Wolfgang
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Doing floating point calculations in kernel space
2003-10-17 7:33 ` Wolfgang Grandegger
@ 2003-10-17 7:52 ` Toni Van Remortel
2003-10-17 8:59 ` Toni Van Remortel
0 siblings, 1 reply; 8+ messages in thread
From: Toni Van Remortel @ 2003-10-17 7:52 UTC (permalink / raw)
To: Wolfgang Grandegger; +Cc: Linuxppc-Embedded
Op vr 17-10-2003, om 09:33 schreef Wolfgang Grandegger:
> Hi,
>
> this has been discussed recently. For RTAI on MPC 8xx we
> provide the following example:
>
> ftp://ftp.denx.de/pub/RTAI/contrib/fp_ppc_8xx.tar.bz2
>
> It links statically with the libm and the soft-float
> library derived from libgcc.
>
> Hope it's useful.
Seems useful. Let's check it out deeper and implement it into my module.
I'll keep you informed.
Tnx!
--
Toni Van Remortel
Wetenschappelijk Medewerker - D-science lab
Real time Linux for embedded systems: http://linemb.d-sciencelab.com
Tel: +32 3 205 61 72 - Fax: +32 3 205 61 95
E-mail: t.vanremortel@ha.be
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Doing floating point calculations in kernel space
2003-10-17 7:52 ` Toni Van Remortel
@ 2003-10-17 8:59 ` Toni Van Remortel
2003-10-17 10:06 ` Wolfgang Grandegger
0 siblings, 1 reply; 8+ messages in thread
From: Toni Van Remortel @ 2003-10-17 8:59 UTC (permalink / raw)
To: Wolfgang Grandegger; +Cc: Linuxppc-Embedded
Op vr 17-10-2003, om 09:52 schreef Toni Van Remortel:
> Op vr 17-10-2003, om 09:33 schreef Wolfgang Grandegger:
> > ftp://ftp.denx.de/pub/RTAI/contrib/fp_ppc_8xx.tar.bz2
> > It links statically with the libm and the soft-float
> > library derived from libgcc.
> >
> > Hope it's useful.
>
> Seems useful. Let's check it out deeper and implement it into my module.
> I'll keep you informed.
It compiles, it runs. Very nice. Thank you a lot for the example. I had
only to add the extra linking to my compile command.
Regards,
--
Toni Van Remortel
Wetenschappelijk Medewerker - D-science lab
Real time Linux for embedded systems: http://linemb.d-sciencelab.com
Tel: +32 3 205 61 72 - Fax: +32 3 205 61 95
E-mail: t.vanremortel@ha.be
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Doing floating point calculations in kernel space
2003-10-17 8:59 ` Toni Van Remortel
@ 2003-10-17 10:06 ` Wolfgang Grandegger
2003-10-17 12:22 ` Gary Thomas
0 siblings, 1 reply; 8+ messages in thread
From: Wolfgang Grandegger @ 2003-10-17 10:06 UTC (permalink / raw)
To: t.vanremortel; +Cc: Linuxppc-Embedded
>-- Original Message --
>Subject: RE: Doing floating point calculations in kernel space
>From: Toni Van Remortel <t.vanremortel@ha.be>
>Reply-To: t.vanremortel@ha.be
>To: Wolfgang Grandegger <wolfgang.grandegger@bluewin.ch>
>Cc: Linuxppc-Embedded <linuxppc-embedded@lists.linuxppc.org>
>Date: Fri, 17 Oct 2003 10:59:29 +0200
>
>
>Op vr 17-10-2003, om 09:52 schreef Toni Van Remortel:
>> Op vr 17-10-2003, om 09:33 schreef Wolfgang Grandegger:
>> > ftp://ftp.denx.de/pub/RTAI/contrib/fp_ppc_8xx.tar.bz2
>> > It links statically with the libm and the soft-float
>> > library derived from libgcc.
>> >
>> > Hope it's useful.
>>
>> Seems useful. Let's check it out deeper and implement it into my module.
>> I'll keep you informed.
>
>It compiles, it runs. Very nice. Thank you a lot for the example. I had
>only to add the extra linking to my compile command.
Unfortunately, this soft-float implementation from GCC is very
very slow :-(. I'm just doing some benchmarking with soft-float
on IBM 405 and compare the result with the soft-float library
provided by VxWorks. And a simple add (__adddf3) is approx. 5
times faster on VxWorks. And a look to the assembler code makes
clear why. Has anybody else on this list made similar experience
or it there a better free implementation? Has this been improved
in GCC >= 3.2.
Thanks.
Wolfgang.
\x18
Wolfgang
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Doing floating point calculations in kernel space
@ 2003-10-17 12:16 ARIBAUD Albert
2003-10-17 12:37 ` Toni Van Remortel
0 siblings, 1 reply; 8+ messages in thread
From: ARIBAUD Albert @ 2003-10-17 12:16 UTC (permalink / raw)
To: Linuxppc-Embedded
> -----Message d'origine-----
> De : owner-linuxppc-embedded@lists.linuxppc.org
> [mailto:owner-linuxppc-embedded@lists.linuxppc.org]De la part de Toni
> Van Remortel
> Envoyé : vendredi 17 octobre 2003 09:16
> À : Linuxppc-Embedded
> Objet : Doing floating point calculations in kernel space
>
>
>
> Hi all,
>
> When I thought it was a /proc problem, it was a float problem.
> The CPU (405GP) has no FPU, but I need to calculate sin and cos in a
> kernel module.
Hmm... Bit off-topic, but why not use tables tailored to the
precision you need (if you want to compute any sin or cas any time)
or the equivalent of the Bresenham algorithm (if you only want to
draw arcs or ellipes) ?
HTH,
Albert.
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Doing floating point calculations in kernel space
2003-10-17 10:06 ` Wolfgang Grandegger
@ 2003-10-17 12:22 ` Gary Thomas
0 siblings, 0 replies; 8+ messages in thread
From: Gary Thomas @ 2003-10-17 12:22 UTC (permalink / raw)
To: Wolfgang Grandegger; +Cc: t.vanremortel, linuxppc embedded
On Fri, 2003-10-17 at 04:06, Wolfgang Grandegger wrote:
> >-- Original Message --
> >Subject: RE: Doing floating point calculations in kernel space
> >From: Toni Van Remortel <t.vanremortel@ha.be>
> >Reply-To: t.vanremortel@ha.be
> >To: Wolfgang Grandegger <wolfgang.grandegger@bluewin.ch>
> >Cc: Linuxppc-Embedded <linuxppc-embedded@lists.linuxppc.org>
> >Date: Fri, 17 Oct 2003 10:59:29 +0200
> >
> >
> >Op vr 17-10-2003, om 09:52 schreef Toni Van Remortel:
> >> Op vr 17-10-2003, om 09:33 schreef Wolfgang Grandegger:
> >> > ftp://ftp.denx.de/pub/RTAI/contrib/fp_ppc_8xx.tar.bz2
> >> > It links statically with the libm and the soft-float
> >> > library derived from libgcc.
> >> >
> >> > Hope it's useful.
> >>
> >> Seems useful. Let's check it out deeper and implement it into my module.
> >> I'll keep you informed.
> >
> >It compiles, it runs. Very nice. Thank you a lot for the example. I had
> >only to add the extra linking to my compile command.
>
> Unfortunately, this soft-float implementation from GCC is very
> very slow :-(. I'm just doing some benchmarking with soft-float
> on IBM 405 and compare the result with the soft-float library
> provided by VxWorks. And a simple add (__adddf3) is approx. 5
> times faster on VxWorks. And a look to the assembler code makes
> clear why. Has anybody else on this list made similar experience
> or it there a better free implementation? Has this been improved
> in GCC >= 3.2.
>
A long time ago (circa 1995, when I first started the Linux/PPC
port), Motorola volunteered a very fast floating point library. I
tested it (in user applications) and found the results to be quite good.
There was never any impetuous to try and put this in the kernel, but
it should work OK. The [more immediate] problem might be licensing
issues, as IIRC, they didn't want the sources to be public.
Maybe there are some Motorola "lurkers" who could comment.
--
Gary Thomas <gary@mlbassoc.com>
MLB Associates
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
* RE: Doing floating point calculations in kernel space
2003-10-17 12:16 ARIBAUD Albert
@ 2003-10-17 12:37 ` Toni Van Remortel
0 siblings, 0 replies; 8+ messages in thread
From: Toni Van Remortel @ 2003-10-17 12:37 UTC (permalink / raw)
To: ARIBAUD Albert; +Cc: Linuxppc-Embedded
> > The CPU (405GP) has no FPU, but I need to calculate sin and cos in a
> > kernel module.
>
> Hmm... Bit off-topic, but why not use tables tailored to the
> precision you need (if you want to compute any sin or cas any time)
> or the equivalent of the Bresenham algorithm (if you only want to
> draw arcs or ellipes) ?
Currently, the floating point problem is solved. I'm not going to use
default sin and cos, because they are darn too slow.
Lookuptables are way to inaccurate for the application (the formula used
can be viewed at http://www.geniaal.be/), but I'll use other faster
formula's (found a PDF from a Playstation programmer :)
Tnx for the comment.
--
Toni Van Remortel
Wetenschappelijk Medewerker - D-science lab
Real time Linux for embedded systems: http://linemb.d-sciencelab.com
Tel: +32 3 205 61 72 - Fax: +32 3 205 61 95
E-mail: t.vanremortel@ha.be
** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2003-10-17 12:37 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-10-17 7:15 Doing floating point calculations in kernel space Toni Van Remortel
2003-10-17 7:33 ` Wolfgang Grandegger
2003-10-17 7:52 ` Toni Van Remortel
2003-10-17 8:59 ` Toni Van Remortel
2003-10-17 10:06 ` Wolfgang Grandegger
2003-10-17 12:22 ` Gary Thomas
-- strict thread matches above, loose matches on Subject: below --
2003-10-17 12:16 ARIBAUD Albert
2003-10-17 12:37 ` Toni Van Remortel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).