Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
* Float Pt Precision
@ 1999-07-29 13:24 Uncle George
  1999-07-29 14:03 ` Alvin Starr
                   ` (5 more replies)
  0 siblings, 6 replies; 18+ messages in thread
From: Uncle George @ 1999-07-29 13:24 UTC (permalink / raw)
  To: axp-list

[-- Attachment #1: Type: text/plain, Size: 1252 bytes --]

Been trying to determine why the double's between an Intel Box & and
Alpha box are different on postgresql.

The algoritms:
1a)    t1.q = result.A * pt1.x;
1b)   t2.q = pt1.y - t1.q;

and

2)    t3.q = result.C = pt1.y - result.A * pt1.x;

will produce the same results on the Alpha    0x402ec4ec4ec4ec50,
but will produce different results in the intel    0x402ec4ec4ec4ec50,
0x402ec4ec4ec4ec54

I suppose that this can be chalked up to the extended ( 80bit) precision
on the Intel box,
BUT IT MAKES MY life at porting postgres to the alpha, as well as other
projects very difficult to perform alike equally . A few more
calculations, and you begin to wonder where the least sig digit has gone
off to.

80 bit extended precision on alpha? This particular feature is not
mentioned too much ( if at all ) in the alpha literature. Nor are the
internal methods of processing floating points really described.

It seems that a lot of folks believe the FP is fast(er than the intel ),
but it seems to be at the cost of precision. Which for me would be of
some concern in massive numerical calculations.

gat

BTW as a side issue, there doesn't seem to be any way to get the
compiler to do different 'rounding' techniques.  Ie chopped, +infinity,
-Infinity.

[-- Attachment #2: a.c.gz --]
[-- Type: application/octet-stream, Size: 1281 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-29 13:24 Float Pt Precision Uncle George
@ 1999-07-29 14:03 ` Alvin Starr
  1999-07-29 14:32   ` Phil Carmody
  1999-07-29 14:17 ` Phil Carmody
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 18+ messages in thread
From: Alvin Starr @ 1999-07-29 14:03 UTC (permalink / raw)
  To: axp-list

On Thu, 29 Jul 1999, Uncle George wrote:

> Been trying to determine why the double's between an Intel Box & and
> Alpha box are different on postgresql.
> 
> The algoritms:
> 1a)    t1.q = result.A * pt1.x;
> 1b)   t2.q = pt1.y - t1.q;
> 
> and
> 
> 2)    t3.q = result.C = pt1.y - result.A * pt1.x;
> 
> will produce the same results on the Alpha    0x402ec4ec4ec4ec50,
> but will produce different results in the intel    0x402ec4ec4ec4ec50,
> 0x402ec4ec4ec4ec54
> 
> I suppose that this can be chalked up to the extended ( 80bit) precision
> on the Intel box,

Given Intel's track record on FP. I would want to check out this result
carefully.

> BUT IT MAKES MY life at porting postgres to the alpha, as well as other
> projects very difficult to perform alike equally . A few more
> calculations, and you begin to wonder where the least sig digit has gone
> off to.

that is the nature of floating point calculations. You need to be very
carefull. The idea that the compiler optimization level can change the
results of your calculations is a bit scary though.
 
> 80 bit extended precision on alpha? This particular feature is not
> mentioned too much ( if at all ) in the alpha literature. Nor are the
> internal methods of processing floating points really described.

To my knowledge(Just checked the alpha referance manual) there is no
80 bit floating point format for the alpha. I am also not sure if the 80
bit format is an IEEE standard like the 64 and 32 bit formats.

> It seems that a lot of folks believe the FP is fast(er than the intel ),
> but it seems to be at the cost of precision. Which for me would be of
> some concern in massive numerical calculations.

This is the argument between CISC and RISC. The intel FP is in some ways
all singing and all dancing. The Alpha FP is more limited but is much
faster. If you hit a special case Intel handles it in HW, on Alpha it
becomes a SW trap. 

You should get the precision that you expect constantly and not depending
on the order of the operands. A+B+C should allways be the "exact" same as
B+C+A and not "just about" the same. If you cannot guarentee that your
data will be presented in the same order all the time what would be the
point of trying to compare the results.

Extra precision on running calculations is fine but remember "systems that
do things for you often will do things to you"

Alvin Starr                   ||   voice: (416)585-9971
Interlink Connectivity        ||   fax:   (416)585-9974
alvin@iplink.net              ||


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-29 13:24 Float Pt Precision Uncle George
  1999-07-29 14:03 ` Alvin Starr
@ 1999-07-29 14:17 ` Phil Carmody
  1999-07-29 14:24 ` Christopher C Chimelis
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 18+ messages in thread
From: Phil Carmody @ 1999-07-29 14:17 UTC (permalink / raw)
  To: axp-list

On Thu, 29 Jul 1999, EXT Uncle George wrote:

> Been trying to determine why the double's between an Intel Box & and
> Alpha box are different on postgresql.
> 
> The algoritms:
> 1a)    t1.q = result.A * pt1.x;
> 1b)   t2.q = pt1.y - t1.q;
> 
> and
> 
> 2)    t3.q = result.C = pt1.y - result.A * pt1.x;
> 
> will produce the same results on the Alpha    0x402ec4ec4ec4ec50,
> but will produce different results in the intel    0x402ec4ec4ec4ec50,
> 0x402ec4ec4ec4ec54

To judge the errors involved, it would be easier if you'd converted these
to human readable form and provided us with the input values.

My guess is that you're suffering from canelling. It frequently happens
that subtraction can yield hopelessly imprecise answers.

> I suppose that this can be chalked up to the extended ( 80bit) precision
> on the Intel box,

Indeed, consider it to have 18 guard digits, to alpha's 2 (a guess)
Crays (e.g. Y-MPs) are worse... (0 guard digits)

> BUT IT MAKES MY life at porting postgres to the alpha, as well as other
> projects very difficult to perform alike equally . A few more
> calculations, and you begin to wonder where the least sig digit has gone
> off to.

Alas there's not much you can do, apart from reading "What every computer
scientist should know about floating point arithmetic" by Professer Kahan.
It comes bundled on every Sun system I've seen, and is freely available on
the internet. (it's name may be slightly different, but the gist is
there). Once armed with that you're as well equipt as anyone can be to
tackle the problem.

> 80 bit extended precision on alpha? This particular feature is not
> mentioned too much ( if at all ) in the alpha literature. Nor are the
> internal methods of processing floating points really described.
> 
> It seems that a lot of folks believe the FP is fast(er than the intel ),
> but it seems to be at the cost of precision. Which for me would be of
> some concern in massive numerical calculations.
> 
> gat
> 
> BTW as a side issue, there doesn't seem to be any way to get the
> compiler to do different 'rounding' techniques.  Ie chopped, +infinity,
> -Infinity.

In C there isn't a way to specify this. 
C defines the rounding which should be used, and it's non IEEE 754/854
compliant. Alas.


If there are any particular expresssions which are giving you problems,
then I'm sure there are other mathematicians on the list who'd be prepared
to cast a numerical analyst's eye to try to help find workarounds. It's
annoying keyhole work, but it sounds as if it may be necessary.

Good luck,
Phil

-- 
Phil Carmody.
Not speaking for or on behalf of Nokia Telecommunications

Quoted-Printable: a standard for mangling Internet messages
Quoted-Unreadable: the result of applying said standard
Unquoted-Unprintable: the comments from the recipients of the above
-- bf8 


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-29 13:24 Float Pt Precision Uncle George
  1999-07-29 14:03 ` Alvin Starr
  1999-07-29 14:17 ` Phil Carmody
@ 1999-07-29 14:24 ` Christopher C Chimelis
  1999-07-29 16:39 ` Wes Bauske
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 18+ messages in thread
From: Christopher C Chimelis @ 1999-07-29 14:24 UTC (permalink / raw)
  To: axp-list


On Thu, 29 Jul 1999, Uncle George wrote:

> I suppose that this can be chalked up to the extended ( 80bit) precision
> on the Intel box,
> BUT IT MAKES MY life at porting postgres to the alpha, as well as other
> projects very difficult to perform alike equally . A few more
> calculations, and you begin to wonder where the least sig digit has gone
> off to.
> 
> 80 bit extended precision on alpha? This particular feature is not
> mentioned too much ( if at all ) in the alpha literature. Nor are the
> internal methods of processing floating points really described.
> 
> It seems that a lot of folks believe the FP is fast(er than the intel ),
> but it seems to be at the cost of precision. Which for me would be of
> some concern in massive numerical calculations.
> 
> gat
> 
> BTW as a side issue, there doesn't seem to be any way to get the
> compiler to do different 'rounding' techniques.  Ie chopped, +infinity,
> -Infinity.

There was a thread about this on the egcs list (well, a similar issue that
sprang from the IA64 port and 80-bit spills).  It may be interesting
and/or helpful to look at some of the Alpha-ish posts about that issue.
The argument started originally about the -mieee switch being so
necessary and progressed on to precision issues.

C


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-29 14:03 ` Alvin Starr
@ 1999-07-29 14:32   ` Phil Carmody
  1999-07-29 15:57     ` Michael J. Donahue
  0 siblings, 1 reply; 18+ messages in thread
From: Phil Carmody @ 1999-07-29 14:32 UTC (permalink / raw)
  To: axp-list

On Thu, 29 Jul 1999, EXT Alvin Starr wrote:
> 
> To my knowledge(Just checked the alpha referance manual) there is no
> 80 bit floating point format for the alpha. I am also not sure if the 80
> bit format is an IEEE standard like the 64 and 32 bit formats.

There is an IEEE standard for this 'extended' precision.
  
> > It seems that a lot of folks believe the FP is fast(er than the intel ),
> > but it seems to be at the cost of precision. Which for me would be of
> > some concern in massive numerical calculations.
> 
> This is the argument between CISC and RISC. The intel FP is in some ways
> all singing and all dancing. The Alpha FP is more limited but is much
> faster. If you hit a special case Intel handles it in HW, on Alpha it
> becomes a SW trap. 
> 
> You should get the precision that you expect constantly and not depending
> on the order of the operands. A+B+C should allways be the "exact" same as
> B+C+A and not "just about" the same. If you cannot guarentee that your
> data will be presented in the same order all the time what would be the
> point of trying to compare the results.

Alas you're going to be disappointed, I wish it were true, but we're in a
finite universe.

For every architecture, where e = machine epsilon:
(-1 + 1) + e == e     
but
     (1 + e) - 1 == e

The a rule of thumb in these matters is to try to split the 'small'
data from the 'large' data, and handle all the 'small' data first before
it gets swamped by the 'large' data.


Oh - I was incorrect with my previous reference:
"What every computer scientist should know about floating point
arithmetic" is by Goldberg, not Kahan. However, it's 'in the style' of
similar things by Kahan.

Phil

-- 
Phil Carmody.
Not speaking for or on behalf of Nokia Telecommunications

The chief contribution of Protestantism to human thought is its massive proof
that God is a bore. -- Henry Louis Mencken (1880-1956) American editor & critic


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-29 14:32   ` Phil Carmody
@ 1999-07-29 15:57     ` Michael J. Donahue
  1999-07-29 18:51       ` Harvey J. Stein
  0 siblings, 1 reply; 18+ messages in thread
From: Michael J. Donahue @ 1999-07-29 15:57 UTC (permalink / raw)
  To: axp-list

Phil Carmody wrote:
>For every architecture, where e = machine epsilon:
>(-1 + 1) + e == e     
>but
>     (1 + e) - 1 == e

To be precise, e is the smallest number such that 1+e != 1.  So if we
take 0<e'<e, then

    (-1 + 1) + e' == e'
but
    (1 + e') - 1  == 0

>The a rule of thumb in these matters is to try to split the 'small'
>data from the 'large' data, and handle all the 'small' data first before
>it gets swamped by the 'large' data.
>
>
>Oh - I was incorrect with my previous reference:
>"What every computer scientist should know about floating point
>arithmetic" is by Goldberg, not Kahan. However, it's 'in the style' of
>similar things by Kahan.

You can find some of Kahan's work at http://www.cs.berkeley.edu/~wkahan/.
For example,

  How JAVA's Floating-Point Hurts Everyone Everywhere
   http://www.cs.berkeley.edu/~wkahan/JAVAhurt.pdf

and

  Miscalculating Area and Angles of a Needle-like Triangle
   http://www.cs.berkeley.edu/~wkahan/Triangle.pdf

The difference in the floating point calculations on the x86 vs the
Alpha trace back to the hardware implementations.  The extra precision
in the x86 makes life much easier---it narrows the window of numerical
instability in almost every situation.

-m

-- 
Michael J. Donahue
National Institute of Standards and Technology
Mathematical & Computational Sciences Division
100 Bureau Dr Stop 8910
Gaithersburg, MD 20899-8910
email: michael.donahue@nist.gov
voice: (301) 975-5424
  fax: (301) 990-4127
  web: http://math.nist.gov/mcsd/Staff/MDonahue/


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-29 13:24 Float Pt Precision Uncle George
                   ` (2 preceding siblings ...)
  1999-07-29 14:24 ` Christopher C Chimelis
@ 1999-07-29 16:39 ` Wes Bauske
  1999-07-29 23:42 ` Richard Henderson
  1999-07-30 11:18 ` Phil Carmody
  5 siblings, 0 replies; 18+ messages in thread
From: Wes Bauske @ 1999-07-29 16:39 UTC (permalink / raw)
  To: axp-list

Uncle George wrote:
> 
> Been trying to determine why the double's between an Intel Box & and
> Alpha box are different on postgresql.
> 
> The algoritms:
> 1a)    t1.q = result.A * pt1.x;
> 1b)   t2.q = pt1.y - t1.q;
> 
> and
> 
> 2)    t3.q = result.C = pt1.y - result.A * pt1.x;
> 
> will produce the same results on the Alpha    0x402ec4ec4ec4ec50,
> but will produce different results in the intel    0x402ec4ec4ec4ec50,
> 0x402ec4ec4ec4ec54
> 

That means the Alpha follows the IEEE rules well compared to
the Intel.

Anyway, never do bit compares with FP results. It's a waste of
your time. Only look at the magnitude of the difference.
In my types of code, I look at how many DB down the difference
is to decide if it's the same answer. Lots of things can
effect how the answer turns out. Order of calculation and
optimizations quite commonly change the answer slightly.
Either you want performance and take a non-bit level identical
answers between machine types, or you end up with poor performing
code that might get the same results if you enforce IEEE 64 bit 
arithmetic.

As long as your algorithm is not sensitive to low bit errors
you'll be fine. In other words you don't subtract almost
exactly the same numbers from each other. (finite differences)
If you do, then you need to worry about numerical viscosity
and how the HW rounds it's answers.

Keep in mind, FP representation is an approximation to the mathmetically 
correct answer when the exponent gets larger anyway.


Wes


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-29 15:57     ` Michael J. Donahue
@ 1999-07-29 18:51       ` Harvey J. Stein
  1999-07-29 19:47         ` Wes Bauske
  1999-07-29 21:07         ` Michael J. Donahue
  0 siblings, 2 replies; 18+ messages in thread
From: Harvey J. Stein @ 1999-07-29 18:51 UTC (permalink / raw)
  To: Michael Donahue; +Cc: axp-list, hjstein

"Michael J. Donahue" <donahue@saaz.cam.nist.gov> writes:

 > The difference in the floating point calculations on the x86 vs the
 > Alpha trace back to the hardware implementations.  The extra
 > precision in the x86 makes life much easier---it narrows the window
 > of numerical instability in almost every situation.

Can you substantiate this?  I've found x86 arithmetic to be
substantially harder to work with because the excess precision shows
up unpredicably.  After setting two different variables via the same
computation it's possible for the two variables to be not equal.  It
depends on exactly what goes into registers when.  This problem
doesn't exist on the alphas.

-- 
Harvey J. Stein
Bloomberg LP
hjstein@bfr.co.il


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-29 18:51       ` Harvey J. Stein
@ 1999-07-29 19:47         ` Wes Bauske
  1999-07-29 21:05           ` Harvey J. Stein
  1999-07-29 21:07         ` Michael J. Donahue
  1 sibling, 1 reply; 18+ messages in thread
From: Wes Bauske @ 1999-07-29 19:47 UTC (permalink / raw)
  To: axp-list

"Harvey J. Stein" wrote:
> 
> "Michael J. Donahue" <donahue@saaz.cam.nist.gov> writes:
> 
>  > The difference in the floating point calculations on the x86 vs the
>  > Alpha trace back to the hardware implementations.  The extra
>  > precision in the x86 makes life much easier---it narrows the window
>  > of numerical instability in almost every situation.
> 
> Can you substantiate this?  I've found x86 arithmetic to be
> substantially harder to work with because the excess precision shows
> up unpredicably.  After setting two different variables via the same
> computation it's possible for the two variables to be not equal.  It
> depends on exactly what goes into registers when.  This problem
> doesn't exist on the alphas.
> 

Just a programming style hint. Never do "if(fpval1 == fpval2)".
Alway do "if(ABS(fpval1-fpval2) < epsilon)". Pick an epsilon
that makes sense for your algorithm and the machine it's running
on.


Wes


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-29 19:47         ` Wes Bauske
@ 1999-07-29 21:05           ` Harvey J. Stein
  0 siblings, 0 replies; 18+ messages in thread
From: Harvey J. Stein @ 1999-07-29 21:05 UTC (permalink / raw)
  To: axp-list; +Cc: hjstein

"Wes Bauske" <wsb@paralleldata.com> writes:

 > Just a programming style hint. Never do "if(fpval1 == fpval2)".
 > Alway do "if(ABS(fpval1-fpval2) < epsilon)". Pick an epsilon that
 > makes sense for your algorithm and the machine it's running on.

This isn't the place to get into a discussion about this.  Let me just
say that in general when you have higher precision registers then 1)
using tolerances don't always help and 2) reordering & different
optimization levels can significantly change results.  There was a
long discussoin of this on the egcs mailing list.

-- 
Harvey J. Stein
Bloomberg LP
hjstein@bfr.co.il


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-29 18:51       ` Harvey J. Stein
  1999-07-29 19:47         ` Wes Bauske
@ 1999-07-29 21:07         ` Michael J. Donahue
  1 sibling, 0 replies; 18+ messages in thread
From: Michael J. Donahue @ 1999-07-29 21:07 UTC (permalink / raw)
  To: axp-list

Harvey J. Stein writes:
>"Michael J. Donahue" <donahue@saaz.cam.nist.gov> writes:
>
> > The difference in the floating point calculations on the x86 vs the
> > Alpha trace back to the hardware implementations.  The extra
> > precision in the x86 makes life much easier---it narrows the window
> > of numerical instability in almost every situation.
>
>Can you substantiate this?

Yes.  William Kahan had some nice examples using classical triangle
formulae.  See

  Miscalculating Area and Angles of a Needle-like Triangle
   http://www.cs.berkeley.edu/~wkahan/Triangle.pdf

Here's an excerpt:

 Nobody can say in advance how badly such inconsistencies might disrupt
 a program's logic. Prudence requires their extirpation, and that is
 straightforward if the specification of a triangle in object oriented
 software is designed by a programmer aware of the problems with
 classical formulas and acquainted with reliable numerical algorithms to
 solve some of those problems. A programmer unaware of the problems is
 unlikely to be enlightened by casual or random testing; those problems
 are confined to "ill conditioned" triangles in so tiny a sliver of the
 space of all triangles that its location, unknown to the unaware
 programmer, is likely to stay unknown.

 Fortunately, the same phenomenon as tends to keep the unaware
 programmer unenlightened tends to protect his unwitting clients from
 harm.  As arithmetic precision increases beyond what the data
 "deserve," the sliver of triangles treated too inaccurately by the
 program shrinks, the likelihood that the programmer will notice it
 shrinks, and the risk of harm to his clients shrinks, and usually
 shrinks quickly. As algebra has shown above and a picture will show
 below,

    Every three additional decimal digits of arithmetic precision
    carried, in excess of the precision to which data and results are
    stored, reduces the incidence of intolerably "ill conditioned"
    triangles by factors ...
       * near 1/1,000,000 for triangles too nearly right angled,
       * less than 1/1,000 for triangles too nearly needle like.
    Carrying arithmetic precision somewhat more than twice the precision
    to which data and results are stored practically eliminates
    intolerably "ill conditioned" triangles.

   Wider is better. Plus large, c'est mieux. Breiter ist besser. ...

Notice in the first case (right angled triangles) that you cut the
percentage of "bad triangles" by a factor of _100_ for each additional
decimal digit of precision.

>                              I've found x86 arithmetic to be
>substantially harder to work with because the excess precision shows
>up unpredicably.  After setting two different variables via the same
>computation it's possible for the two variables to be not equal.  It
>depends on exactly what goes into registers when.  This problem
>doesn't exist on the alphas.

You might want to try the -ffloat-store switch on gcc, although in
general relying on exact representations in floating point is tricky.
For example, (a+b)+c is in general not equal to a+(b+c).  If your
compiler is doing any optimizing it is hard to say what you are going to
get...

-m

-- 
Michael J. Donahue
National Institute of Standards and Technology
Mathematical & Computational Sciences Division
100 Bureau Dr Stop 8910
Gaithersburg, MD 20899-8910
email: michael.donahue@nist.gov
voice: (301) 975-5424
  fax: (301) 990-4127
  web: http://math.nist.gov/mcsd/Staff/MDonahue/


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-29 13:24 Float Pt Precision Uncle George
                   ` (3 preceding siblings ...)
  1999-07-29 16:39 ` Wes Bauske
@ 1999-07-29 23:42 ` Richard Henderson
  1999-07-30 13:19   ` Harvey J. Stein
  1999-07-30 14:55   ` Uncle George
  1999-07-30 11:18 ` Phil Carmody
  5 siblings, 2 replies; 18+ messages in thread
From: Richard Henderson @ 1999-07-29 23:42 UTC (permalink / raw)
  To: axp-list

On Thu, Jul 29, 1999 at 09:24:08AM -0400, Uncle George wrote:
> BTW as a side issue, there doesn't seem to be any way to get the
> compiler to do different 'rounding' techniques.  Ie chopped, +infinity,
> -Infinity.

-mfp-rounding-mode={n,m,c,d}

	n == round to nearest
	m == round to minus infinity
	c == round to zero
	d == dynamic rounding (mode comes from fpcr)



r~


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-29 13:24 Float Pt Precision Uncle George
                   ` (4 preceding siblings ...)
  1999-07-29 23:42 ` Richard Henderson
@ 1999-07-30 11:18 ` Phil Carmody
  1999-07-30 14:52   ` Uncle George
  5 siblings, 1 reply; 18+ messages in thread
From: Phil Carmody @ 1999-07-30 11:18 UTC (permalink / raw)
  To: axp-list

On Thu, 29 Jul 1999, EXT Uncle George wrote:

> Been trying to determine why the double's between an Intel Box & and
> Alpha box are different on postgresql.
> 
> The algoritms:
> 1a)    t1.q = result.A * pt1.x;
> 1b)   t2.q = pt1.y - t1.q;
> 
> and
> 
> 2)    t3.q = result.C = pt1.y - result.A * pt1.x;
> 
> will produce the same results on the Alpha    0x402ec4ec4ec4ec50,
> but will produce different results in the intel    0x402ec4ec4ec4ec50,
> 0x402ec4ec4ec4ec54

OK, so this is calculating the y axis intercept between two known points
using one point and the gradiant.

What do the alpha and x86 grok from the following when the bracketted
expressions are (a) precalulated and stored in temporaries (b) as is.

// optionally
double temp = 1.0 / (pt2.x - pt1.x);
// or temp = (pt2.x - pt1.x)
result.A = (pt2.y - pt1.y) * temp;
// or                      / temp
result.C = (pt1.y * pt2.x - pt2.y * pt1.x) * temp;
// or                                      / temp

which basically takes the weighted mean of the two y values.

Here on my ultrasparc, I get the same answer for each of my expressions,
and I get an inaccurate answer for your original expressions.

you had:
result->C=15.3846153846154(402ec4ec4ec4ec50)    (intel v1 and alpha both)
result->C=15.3846153846154(402ec4ec4ec4ec54)    (intel v2)
          12 3456789012345 12345678901234__
                               should be 4e
The decimal expression is correct to the precision shown.

so your expression has 2 or 6 ulp error (6 for intel)


My sparc gives get :
my expression:
one expression	15.384615384615385025313116784673(402ec4ec4ec4ec4f)
via temporary 	15.384615384615385025313116784673(402ec4ec4ec4ec4f)
                12 34567890123456^^^              123456789012345_
                       should be 461                   should be e
1 ulp

your expression:
one expression	15.384615384615358379960525780916(402ec4ec4ec4ec40)
via temporary	15.384615384615358379960525780916(402ec4ec4ec4ec40)
                12 3456789012345^^^^              123456789012345_
                   should be    8461                   should be e
14 ulp

           
Well, I'm not sure what this tells anyone, but it looks like the sparc
threw its guard digits out the window!
My expression seems more stable, but I'll defer to constructive criticism
from the direction of NIST, for example! (he knows what he's talking baout
guys!)

As with anything, if you want the greater accuracy and/or precision,
there's a cost. Mine takes more multiplies, is it really time critical?

If there's a conclusion, it appears that the alpha is the winner!

Cheerio,
Phil


-- 
Phil Carmody.
Not speaking for or on behalf of Nokia Telecommunications

How many things served us but yesterday as articles of faith, which today
we deem but fables?
-- Michel Eyquem de Montaigne (1533-1592) Essays, bk. 1, ch. 26, 
   "It Is Folly to Refer Truth or Falsehood to Our Sufficiency"



^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-29 23:42 ` Richard Henderson
@ 1999-07-30 13:19   ` Harvey J. Stein
  1999-07-30 14:38     ` Uncle George
  1999-07-30 14:55   ` Uncle George
  1 sibling, 1 reply; 18+ messages in thread
From: Harvey J. Stein @ 1999-07-30 13:19 UTC (permalink / raw)
  To: axp-list; +Cc: hjstein

Richard Henderson <rth@twiddle.net> writes:

 > On Thu, Jul 29, 1999 at 09:24:08AM -0400, Uncle George wrote:
 > > BTW as a side issue, there doesn't seem to be any way to get the
 > > compiler to do different 'rounding' techniques.  Ie chopped, +infinity,
 > > -Infinity.
 > 
 > -mfp-rounding-mode={n,m,c,d}
 > 
 > 	n == round to nearest
 > 	m == round to minus infinity
 > 	c == round to zero
 > 	d == dynamic rounding (mode comes from fpcr)

But doesn't this set the rounding mode at program start?  If so, it
means that it can be dangerous because libm might require a particular
rounding mode - switching it could cause libm inaccuracy.

-- 
Harvey J. Stein
Bloomberg LP
hjstein@bfr.co.il


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-30 13:19   ` Harvey J. Stein
@ 1999-07-30 14:38     ` Uncle George
  0 siblings, 0 replies; 18+ messages in thread
From: Uncle George @ 1999-07-30 14:38 UTC (permalink / raw)
  To: axp-list; +Cc: hjstein

I dont see how u can sugg this. the n/m/d/c have to be compiled into each float
instruction.  changing the fpcr does nothing if none of the instructions have a
/d switch.  If libm was compiled with the '\d' for dynamic rounding ( as per
the settings in the fpcr ),  then you may get different results.

What u do have is a mix of rounding - compiled as part of the standard
libraries, and that of the executable.
gat
BTW, I suppose that the floats are all done in 64bit precision ( ie there is no
such thing as 80bit extended precision at all ). Its amazing that none of the
alpha float folks ( people who bought it for the floating point speed) cared
enough to make this a 'I want/need' this precision issue :-\ oh-well



Harvey J. Stein wrote:

> Richard Henderson <rth@twiddle.net> writes:
>
>  > On Thu, Jul 29, 1999 at 09:24:08AM -0400, Uncle George wrote:
>  > > BTW as a side issue, there doesn't seem to be any way to get the
>  > > compiler to do different 'rounding' techniques.  Ie chopped, +infinity,
>  > > -Infinity.
>  >
>  > -mfp-rounding-mode={n,m,c,d}
>  >
>  >      n == round to nearest
>  >      m == round to minus infinity
>  >      c == round to zero
>  >      d == dynamic rounding (mode comes from fpcr)
>
> But doesn't this set the rounding mode at program start?  If so, it
> means that it can be dangerous because libm might require a particular
> rounding mode - switching it could cause libm inaccuracy.
>




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-30 11:18 ` Phil Carmody
@ 1999-07-30 14:52   ` Uncle George
  1999-07-30 15:31     ` Phil Carmody
  0 siblings, 1 reply; 18+ messages in thread
From: Uncle George @ 1999-07-30 14:52 UTC (permalink / raw)
  To: Phil Carmody, axp-list

Its interesting that u like the 'interpretative/printf' value of the hex
floating point value. For me these hex values are the tru representatiion (
as a hacker/porter ) of the float values ( what ever the decimal value is ) .

To me a piece of hardware conforming to some standard, of which i think intel
& alpha subscribe to that standard, apply the same rules to each  float
process.  If they dont then someone is breaking the rules, and should be
reported ( and properly villified )

Maybe, when I see how the precision ( 64 v. 80 bit ) is set on the
linux/intel box i'll set the intel to 64bit ( non-extended ) precision, and
see if I get the same results as the alpha.

gat







^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-29 23:42 ` Richard Henderson
  1999-07-30 13:19   ` Harvey J. Stein
@ 1999-07-30 14:55   ` Uncle George
  1 sibling, 0 replies; 18+ messages in thread
From: Uncle George @ 1999-07-30 14:55 UTC (permalink / raw)
  To: axp-list

Any thing in docs?, or I just gotta remember what the switches are ( Like
-miee has been around a while, but still not in man pages :-/ )
gat
Richard Henderson wrote:

> On Thu, Jul 29, 1999 at 09:24:08AM -0400, Uncle George wrote:
> > BTW as a side issue, there doesn't seem to be any way to get the
> > compiler to do different 'rounding' techniques.  Ie chopped, +infinity,
> > -Infinity.
>
> -mfp-rounding-mode={n,m,c,d}
>
>         n == round to nearest
>         m == round to minus infinity
>         c == round to zero
>         d == dynamic rounding (mode comes from fpcr)


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: Float Pt Precision
  1999-07-30 14:52   ` Uncle George
@ 1999-07-30 15:31     ` Phil Carmody
  0 siblings, 0 replies; 18+ messages in thread
From: Phil Carmody @ 1999-07-30 15:31 UTC (permalink / raw)
  To: EXT Uncle George; +Cc: axp-list

On Fri, 30 Jul 1999, EXT Uncle George wrote:

> Its interesting that u like the 'interpretative/printf' value of the hex
> floating point value. For me these hex values are the tru representatiion (
> as a hacker/porter ) of the float values ( what ever the decimal value is ) .

Hmmm, I can't get a feel for the value just from the hex.
Endianness/exponent/mantissa/sign/magnitude/twos-complement etc. just make
the hex less friendly.
I wouldn't want to be without the hex if I was looking at ulp errors, for
instance.
 
> To me a piece of hardware conforming to some standard, of which i think intel
> & alpha subscribe to that standard, apply the same rules to each  float
> process.  If they dont then someone is breaking the rules, and should be
> reported ( and properly villified )
> 
> Maybe, when I see how the precision ( 64 v. 80 bit ) is set on the
> linux/intel box i'll set the intel to 64bit ( non-extended ) precision, and
> see if I get the same results as the alpha.

Please report back if you have any interesting findings.
I meant to go home and muck around with my formulae on my alpha and i386
last night, but didn't have the time. Hence my sparc-only results.

Phil

-- 
Phil Carmody.
Not speaking for or on behalf of Nokia Telecommunications

Irreligion. The principal one of the great faiths of the world.
-- Ambrose Gwinett Bierce (1842-1914) The Devil's Dectionary


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~1999-07-30 15:31 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1999-07-29 13:24 Float Pt Precision Uncle George
1999-07-29 14:03 ` Alvin Starr
1999-07-29 14:32   ` Phil Carmody
1999-07-29 15:57     ` Michael J. Donahue
1999-07-29 18:51       ` Harvey J. Stein
1999-07-29 19:47         ` Wes Bauske
1999-07-29 21:05           ` Harvey J. Stein
1999-07-29 21:07         ` Michael J. Donahue
1999-07-29 14:17 ` Phil Carmody
1999-07-29 14:24 ` Christopher C Chimelis
1999-07-29 16:39 ` Wes Bauske
1999-07-29 23:42 ` Richard Henderson
1999-07-30 13:19   ` Harvey J. Stein
1999-07-30 14:38     ` Uncle George
1999-07-30 14:55   ` Uncle George
1999-07-30 11:18 ` Phil Carmody
1999-07-30 14:52   ` Uncle George
1999-07-30 15:31     ` Phil Carmody

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox