From: David Mosberger <davidm@napali.hpl.hp.com>
To: linux-ia64@vger.kernel.org
Subject: [Linux-ia64] Re: set the precision of Intel's FPU.
Date: Tue, 03 Dec 2002 20:00:46 +0000 [thread overview]
Message-ID: <marc-linux-ia64-105590709805497@msgid-missing> (raw)
>>>>> On Tue, 3 Dec 2002 11:10:07 -0800, John Kern <jkern@numeritech.com> said:
John> The Intel processors (i.e., x86 and ia64) have 80-bit
John> (extended) floating point registers. By default, floating
John> point computations are done with extended precision on Intel.
On ia64, it _should_ default to regular precision for values of type
"double". The initial value of the floating-point control register
(ar.fpsr) is defined by the Itanium Software Conventions and Runtime
Architecture manual
(http://www.intel.com/design/itanium/downloads/245358.htm) in Table
13-1. As you can see there, only sf1 has the "Widest-range Exponent"
flag set and this status field is only used for special runtime
routines (e.g., integer division).
For example gcc translates:
double add (double x, double y) { return x + y; }
into:
6: 80 48 20 02 48 80 fadd.d.s0 f8ø,f9
which will use "IEEE real double" precision (since the sf0.wre bit is
cleared to zero by default).
John> I want to obtain bitwise identical results across platforms.
John> Extended precision simply requires at least 15 addition
John> bits. So, it various between platforms. For example, Solaris
John> and HP use 128-bit extended precision. The IEEE spec says
John> there must be a way to control precision. Setting the
John> precision to double, fixes the problem.
What floating-point type are you using here? long double?
John> On 32-bit Linux I can achieve this by #include <fpu_control.h>
John> fpu_control_t oldcw, newcw;
John> _FPU_GETCW(oldcw); newcw = (oldcw & ~_FPU_EXTENDED) |
John> _FPU_DOUBLE; _FPU_SETCW(newcw);
John> Unfortunately, this doesn't work with Linux/IA-64. I haven't
John> been able to find a reference on this topic. Can someone shed
John> some light on this?
This interface is x86-specific. AFAIK, the proper interface to use
here is the one defined by <fenv.h>. Specifically, the fesetenv()
routine can manipulate any bit in ar.fpsr.
--david
next reply other threads:[~2002-12-03 20:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-12-03 20:00 David Mosberger [this message]
2002-12-03 23:23 ` [Linux-ia64] RE: set the precision of Intel's FPU John Kern
2002-12-03 23:33 ` David Mosberger
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=marc-linux-ia64-105590709805497@msgid-missing \
--to=davidm@napali.hpl.hp.com \
--cc=linux-ia64@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.