linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: buhr@stat.wisc.edu (Kevin Buhr)
To: "Albert D. Cahalan" <acahalan@cs.uml.edu>
Cc: linux-kernel@vger.kernel.org
Subject: Re: RFC: changing precision control setting in initial FPU context
Date: 03 Mar 2001 04:26:06 -0600	[thread overview]
Message-ID: <vbar90ftagx.fsf@mozart.stat.wisc.edu> (raw)
In-Reply-To: <200103030931.f239Vvo124697@saturn.cs.uml.edu>
In-Reply-To: "Albert D. Cahalan"'s message of "Sat, 3 Mar 2001 04:31:57 -0500 (EST)"

"Albert D. Cahalan" <acahalan@cs.uml.edu> writes:
> 
> So you change it to 2... but what about the "float" type? It gets
> a mixture of 64-bit and 32-bit IEEE arithmetic depending rather
> unpredictably on compiler register allocations and optimizations???

Well, yes, but I'll try not to cry myself to sleep over it.  I'm
tempted to say that someone who chooses to use "float"s has given up
all pretense of caring about the answers they get.  And, if they
really want to do predictable math with floats they can change the FPU
control word from whatever its default is to PC==0.

I guess if I had to choose between two default control word settings
so that either (A) "float" arithmetic is unpredictable but "double"
arithmetic is predictable, corresponds to 64-bit IEEE arithmetic, is
invariant under different compiler optimization settings, matches the
compiler's handling of constant folding, and mimics the behavior on
i386 FreeBSD and NetBSD and most modern, non-i386 architectures; or
(B) "float" and "double" arithmetic are both unpredictable and
non-IEEE; I'd choose (A).

> If a "float" will have excess precision, then a "double" might
> as well have it too. Usually it helps, but sometimes it hurts.
> This is life with C on x86.

That's the way I initially felt, and it looks silly when it's written
down, so I'm glad I changed my mind.

I don't think extra precision that is unpredictable is ever helpful.
Extra precision that might be gained or lost depending on, say, which
branch of an if-statement is taken, is of no use to anyone.  It just
causes confusion.  The excess precision on "float" is a nuisance.  The
excess precision on "double" is another nuisance.  It would be nice to
eliminate one of those nuisances, at least by default.

> Ugh, more start-up crud.

The startup crud is already there.  It's used to allow linking with
"-lieee" to set a new control word value, for example, and it's
inelegant and ugly.  Because we don't want to set the control word on
a non-FPU program and defeat the lazy FPU context initialization, we
compare the value of the control word we want with a value hard-coded
into the library that's supposed to match the value hard-coded into
the kernel.  If the two values differ, we set the control word to the
new value (whether the program actually ends up ever executing an FPU
instruction or not).

To me, a system call (not necessarily a *new* system call, but some
way to get the desired FPU control word to the kernel) seems like a
more elegant solution.

On the other hand, I'm not married to the idea.  I'd rather just get
the default control word changed in the kernel.

Kevin <buhr@stat.wisc.edu>

  reply	other threads:[~2001-03-03 10:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-03  7:12 RFC: changing precision control setting in initial FPU context Kevin Buhr
2001-03-03  9:31 ` Albert D. Cahalan
2001-03-03 10:26   ` Kevin Buhr [this message]
2001-03-03 20:04     ` Albert D. Cahalan
2001-03-03 21:00       ` Jason Riedy
2001-03-03 23:17         ` Kevin Buhr
2001-03-04  4:21           ` Jason Riedy
2001-03-03 22:34       ` Kevin Buhr
2001-03-03 10:47 Adam J. Richter
2001-03-03 23:29 ` Kevin Buhr
2001-03-03 23:37   ` Alan Cox
2001-03-04  0:27     ` Kevin Buhr
2001-03-04  0:45       ` Ulrich Drepper

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=vbar90ftagx.fsf@mozart.stat.wisc.edu \
    --to=buhr@stat.wisc.edu \
    --cc=acahalan@cs.uml.edu \
    --cc=linux-kernel@vger.kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).