November 26, 2010
On 26.11.2010 7:25, Don Clugston wrote:
> import std.mathspecial;
> import std.stdio;
>
> void main()
> {
>      real a = 0x1.ff1275ae5b939bcap-41L;
>      real b = 0x1.034f2a66cd21p+62L;
>      real x = 0x1.4f5afe0ce690d95cp-63L;
>      real s = 0x1.0076fc5cc795a06cp+40L;
>
>      real u = a * log(x);
>      real t = logGamma(b) - logGamma(a) - logGamma(b) + u + log(s);
>      real y = exp(t);
>      writefln("%a %a %a %a", logGamma(a), logGamma(b), u, t);
>      writefln("%a %a %a %a", log(s), log(x), log(a), log(b));
>      assert(y==0x1.c91a61a8fc916338p-7L); // Intel
> //    assert(y==0x1.c91a61a8fc91633ap-7L); // AMD
> }
>
> On my Intel box, this prints:
>
> 0x1.bba4a9f774f49d0ap+4 0x1.543ef272830d3ed4p+67 -0x1.5a8e8efc9cec0dbp-35 -0x1.1
> 16d582237016688p+2
> 0x1.bba4a9f774f4c37ap+4 -0x1.5b2fa254744c96d8p+5 -0x1.bba4a9f774fdd508p+4 0x1.57
> e75c552cc1d47ep+5

On my AMD desktop, this produces:
> 0x1.bba4a9f774f49d0cp+4 0x1.543ef272830d3ed4p+67 -0x1.5a8e8efc9cec0dbp-35 -0x1.116d582237016688p+2 0x1.bba4a9f774f4c37ap+4 -0x1.5b2fa254744c96d8p+5 -0x1.bba4a9f774fdd508p+4 0x1.57e75c552cc1d47ep+5 core.exception.AssertError at test_amd(16): Assertion failure
replacing the first assert with the second one make it pass, of course.

> I suspect that we'll ever see a difference in the last line, which
> would indicate a one-bit error in log.
> But if all the numbers are the same, and the assert still fails, it's
> a one-bit error in exp.
> If the values in the last line are the same, but the ones in the first
> line are different, it's an error in poly.
> Either way, if the assert fails on AMD, we're just about down the asm.
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos

November 26, 2010
Excellent! I predict this fails on AMD. (This test is a single instruction).

import std.math;

void main()
{
     assert( yl2x(0x1.0076fc5cc7933866p+40L, LN2) ==
0x1.bba4a9f774f49d0ap+4L, "YL2X fails");
}
November 26, 2010
On 26.11.2010 20:37, Don Clugston wrote:
> Excellent! I predict this fails on AMD. (This test is a single instruction).
And  the answer is ... yes, it fails :-)
So what's the next direction, maybe ask the AMD folks?

> import std.math;
>
> void main()
> {
>       assert( yl2x(0x1.0076fc5cc7933866p+40L, LN2) ==
> 0x1.bba4a9f774f49d0ap+4L, "YL2X fails");
> }
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos

November 26, 2010
On 26 November 2010 19:14, Dmitry Olshansky <dmitry.olsh at gmail.com> wrote:
> On 26.11.2010 20:37, Don Clugston wrote:
>>
>> Excellent! I predict this fails on AMD. (This test is a single
>> instruction).
>
> And ?the answer is ... yes, it fails :-)

Awesome!!! In terms of Phobos, that's all we need to know -- the failure is not our fault, so I should just relax the tolerance on the test.

I'm extremely pleased about this result. "The unit testing in the D standard library uncovered an CPU issue" is a pretty good story. The test exists because I was trying to improve the code coverage of the math library to >95% -- and I was only doing that because DMD has built-in code coverage. The bug also wouldn't have been uncovered unless D supported the hex format for floats.


> So what's the next direction, maybe ask the AMD folks?

Good question. I will certainly ask Agner Fog if he's heard of it.
Perhaps somebody may be motivated to find the exact values where AMD
and Intel differ.
One interesting question is what VIA processors do. Do they follow
Intel, or AMD? I don't even know which is more accurate. Probably, the
correctly rounded result is almost exactly between them, so it's only
an error of a fraction of a bit -- it's significant only in that the
processors give different results.

I could only find two references to AMD/Intel differences in the fyl2x instruction.

This one is from CERN. It's clearly the same issue, although they don't give any details (no test cases). http://boinc.berkeley.edu/MOM1MP01.pdf

This one sounds like the same thing, although note that it wasn't confirmed. http://forums.amd.com/forum/messageview.cfm?catid=29&threadid=135771&enterthread=y

>
>> import std.math;
>>
>> void main()
>> {
>> ? ? ?assert( yl2x(0x1.0076fc5cc7933866p+40L, LN2) ==
>> 0x1.bba4a9f774f49d0ap+4L, "YL2X fails");
>> }
1 2 3
Next ›   Last »