mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matt Mackall <mpm@selenic.com>
To: ndiamond@despammed.com
Cc: linux-kernel@vger.kernel.org
Subject: Re: How to use floating point in a module?
Date: Sun, 30 May 2004 22:59:00 -0500	[thread overview]
Message-ID: <20040531035900.GB5414@waste.org> (raw)
In-Reply-To: <200405310152.i4V1qNk03732@mailout.despammed.com>

On Sun, May 30, 2004 at 08:52:23PM -0500, ndiamond@despammed.com wrote:

> A driver, implemented as a module, must do some floating-point
> computations including trig functions. Fortunately the architecture
> is x86. A few hundred kilograms of searching (almost a ton of
> searching :-) seems to reveal the following possibilities.

[bizarre method deleted]

How about:

mask off interrupts locally
save floating point state
do floating point work
restore floating point state
restore interrupt mask

You will need to take care that you keep gcc from using library
functions, see the gcc manual.

Another approach is to do it all in fixed point, which is a simple
matter of doing some shifts after your multiplies. This only works if
you've got a fairly small dynamic range, but if you only need to
calculate a sine or two, it's not too painful and you can have about
8-10 decimal digits of accuracy. Or you can go quick and dirty with a
piecewise polynomial approximation for 2-5 digits of accuracy.

-- 
Mathematics is the supreme nostalgia of our time.

  parent reply	other threads:[~2004-05-31  3:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-31  1:52 ndiamond
2004-05-31  2:18 ` Måns Rullgård
2004-05-30 22:39   ` Calvin Spealman
2004-05-31  4:28   ` Linus Torvalds
2004-05-31  3:57     ` Calvin Spealman
2004-05-31  3:59 ` Matt Mackall [this message]
2004-05-31  4:11 ` Stephen Smoogen
2004-05-31 14:55 ` Scott Robert Ladd
2004-06-01  2:11 ` Richard B. Johnson
2004-05-31  2:50 ndiamond
2004-05-31  4:02 ` Chris Friesen
2004-05-31  5:44 ` Ian Kent
2004-05-31  6:13   ` Peter Williams
2004-05-31 13:39   ` Horst von Brand
2004-05-31 20:12   ` Michal Jaegermann
2004-05-31 20:23     ` Hugo Mills
2004-05-31 22:43     ` Peter Williams
2004-05-31 20:38 Manfred Spraul
2004-05-31 21:11 ` Horst von Brand
2004-06-01  0:38 ndiamond
2004-06-01 20:52 ` H. Peter Anvin
2004-06-01  2:27 ndiamond
2004-06-02  5:52 ndiamond
2004-06-02 19:31 ` Valdis.Kletnieks

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040531035900.GB5414@waste.org \
    --to=mpm@selenic.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ndiamond@despammed.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®