Phobos unit testing uncovers a CPU bug

Don nospam at nospam.com
Fri Nov 26 22:26:54 PST 2010


Walter Bright wrote:
> Don wrote:
>> The code below compiles to a single machine instruction, yet the 
>> results are CPU manufacturer-dependent.
> 
> This is awesome work, Don. Kudos to you, David and Dmitry.
> 
> BTW, I've read that fine-grained CPU detection can be done, beyond what 
> CPUID gives, by examining slight differences in FPU results. I expect 
> that *, +, -, / should all give exactly the same answers. But the 
> transcendentals, and obviously yl2x, vary.

I believe that would have once been possible, I doubt it's true any more.
Basic arithmetic and sqrt all give correctly rounded results, so they're 
identical on all processors. The 387 gives greatly improved accuracy, 
compared to the 287. But AFAIK there have not been intentional changes 
since then.

The great tragedy was that an early AMD processor gave much accurate sin 
and cos than the 387. But, people complained that it was different from 
Intel! So, their next processor duplicated Intel's hopelessly wrong trig 
functions.
I haven't seen any examples of values which are calculated differently 
between the processors. I only found one vague reference in a paper from 
CERN.


More information about the Digitalmars-d-announce mailing list