[93] in Pthreads mailing list archive

home help back first fref pref prev next nref lref last post

Re: Linux ELF

daemon@ATHENA.MIT.EDU (H.J. Lu)
Thu Aug 17 16:12:53 1995

From: hjl@nynexst.com (H.J. Lu)
To: raeburn@cygnus.com (Ken Raeburn)
Date: Thu, 17 Aug 95 15:58:19 EDT
Cc: pthreads@MIT.EDU
In-Reply-To: <199508171848.OAA00138@kr-laptop.cygnus.com>; from "Ken Raeburn" at Aug 17, 95 2:48 pm

> 
> 
>    From: hjl@nynexst.com (H.J. Lu)
>    Date: Thu, 17 Aug 95 9:29:58 EDT
> 
>    > I have, although I did use 2.6.3, an early ELF version from HJ Lu. Kernel
>    > versions I tested are 1.2.8,1.3.8 and 1.3.14. Only the floating point test
>    > fails to complete.
> 
> Fails to *complete* (i.e., runs forever), or completes with a failure
> indication?
> 

In my case, it aborted.

>    The reason of that failure is 10 byte long double is used internally
>    in x87. In any case, it is not recommended to use
> 
> 	   double x, y;
> 	   .....
> 	   if (x == y)
> 	   {
> 	     ...
> 	   }
> 
> What that test *should* be checking is that floating point state
> (registers and fpu internal state) for each thread is preserved.  I
> couldn't see how to test that in a CPU-independent way without making
> the assumption that a calculation could be run more than once and
> still produce the same result.  In this case, I think the equality
> test is the only reasonable test to perform.  *Any* difference
> indicates something strange happening.
> 

That is how gcc works. It only shows up if you use -O. Depending
on the x87 control word, by default, x87 may use 10 byte fp format for
fp computation internally. When you use

	double x, y;
	.....
	if (x == y)

x and y may be equal in 8 byte double format. But there may be
a small difference in 10 byte fp format. When -O is used, gcc
may use the x87 registers directly without converting 10 byte
fp into 8 byte double and than loading them into the 10 byte
registers. That is a good thing for optimization. But the
comparison may fail.


-- 
H.J. Lu
NYNEX Science and Technology, Inc.			hjl@nynexst.com

home help back first fref pref prev next nref lref last post