Re: Phobos unit testing uncovers a CPU bug

2010-12-02 Thread Kagamin
Andrew Wiley Wrote: What programmer? What algorithm? As far as I can tell, this was found when testing a library explicitly for accuracy, not in an application, so your argument doesn't apply. Hmm... Really... I've messed this.

Re: Phobos unit testing uncovers a CPU bug

2010-12-01 Thread Ali Çehreli
Kagamin wrote: It's not me, it's the programmer. He was disgusted that his algorithm produced garbage, which means, the error was unacceptable. Mat be it was 1%, may be 80%, I don't, that was his decision, that the result was unacceptable. The bug description assumes the problem was in the

Re: Phobos unit testing uncovers a CPU bug

2010-11-30 Thread Kagamin
Walter Bright Wrote: How do you decide how many bits should be enough for any algorithm? The thing is, the FPU has 53 bits of precision and so ought to be correct to the last bit. It's not me, it's the programmer. He was disgusted that his algorithm produced garbage, which means, the

Re: Phobos unit testing uncovers a CPU bug

2010-11-30 Thread Andrew Wiley
On Tue, Nov 30, 2010 at 1:43 PM, Kagamin s...@here.lot wrote: Walter Bright Wrote: How do you decide how many bits should be enough for any algorithm? The thing is, the FPU has 53 bits of precision and so ought to be correct to the last bit. It's not me, it's the programmer. He was

Re: Phobos unit testing uncovers a CPU bug

2010-11-29 Thread so
import std.conv: to; void main() { auto r = to!real(0x1.0076fc5cc7933866p+40L); auto d = to!double(0x1.0076fc5cc7933866p+40L); auto f = to!float(0x1.0076fc5cc7933866p+40L); } Regarding unit tests, I should really use them :( Yep, and DbC too, and compile your D code with -w.

Re: Phobos unit testing uncovers a CPU bug

2010-11-29 Thread so
The same question goes to you. Why do you call this bug? It is approximate, but approximation is not an undefined behavior. It is same as 2 + 1 = 4. -- Using Opera's revolutionary email client: http://www.opera.com/mail/

Re: Phobos unit testing uncovers a CPU bug

2010-11-29 Thread Bruno Medeiros
On 27/11/2010 06:26, Don wrote: 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. And because of that comment, I've once again checked http://hasthelargehadroncolliderdestroyedtheworldyet.com/

Re: Phobos unit testing uncovers a CPU bug

2010-11-29 Thread bearophile
so: I have an unrelated question, this is not a criticism but an honest one. Why don't you write these 3 lines like: auto r = to!real (0x1.0076fc5cc7933866p+40L); auto d = to!double(0x1.0076fc5cc7933866p+40L); auto f = to!float (0x1.0076fc5cc7933866p+40L); I have a certain

Re: Phobos unit testing uncovers a CPU bug

2010-11-29 Thread Jonathan M Davis
On Monday, November 29, 2010 12:36:00 bearophile wrote: so: I have an unrelated question, this is not a criticism but an honest one. Why don't you write these 3 lines like: auto r = to!real (0x1.0076fc5cc7933866p+40L); auto d = to!double(0x1.0076fc5cc7933866p+40L);

Re: Phobos unit testing uncovers a CPU bug

2010-11-29 Thread Kagamin
Walter Bright Wrote: Really? I think, the answer is neither correct nor wrong. It's approximate. The rules for rounding the mathematical value to the representation are precise, and so there is such a thing as the correctly rounded result and the wrong result. Well, maybe, but the

Re: Phobos unit testing uncovers a CPU bug

2010-11-29 Thread Jonathan M Davis
On Monday 29 November 2010 21:30:31 s...@so.do wrote: LOL. I couldn't figure out what was different about those lines (the extra space apparently; the fact that the text isn't monospaced makes it harder to see though). But no one's over going to get people to agree on spacing any more

Re: Phobos unit testing uncovers a CPU bug

2010-11-29 Thread so
but I wouldn't have thought that it would be worth calling someone on it. It just seems nitpicky, honestly. - Jonathan M Davis I am sorry if it seems that way, wasn't my intention. -- Using Opera's revolutionary email client: http://www.opera.com/mail/

Re: Phobos unit testing uncovers a CPU bug

2010-11-28 Thread Kagamin
Don Wrote: The Intel CPU gives the correct answer, but AMD's is wrong. They should both give the correct result. Really? I think, the answer is neither correct nor wrong. It's approximate. If your friend's program operates on ~0x1p+40 values and critically depends on on the value of the last

Re: Phobos unit testing uncovers a CPU bug

2010-11-28 Thread Mike James
If it happens once its a bug, if its repeatable its a feature ;-) -=mike=- Kagamin s...@here.lot wrote in message news:icth6h$1nq...@digitalmars.com... Don Wrote: The Intel CPU gives the correct answer, but AMD's is wrong. They should both give the correct result. Really? I think, the

Re: Phobos unit testing uncovers a CPU bug

2010-11-28 Thread Walter Bright
Kagamin wrote: Don Wrote: The Intel CPU gives the correct answer, but AMD's is wrong. They should both give the correct result. Really? I think, the answer is neither correct nor wrong. It's approximate. The rules for rounding the mathematical value to the representation are precise, and

Re: Phobos unit testing uncovers a CPU bug

2010-11-27 Thread KennyTM~
On Nov 27, 10 05:25, Simen kjaeraas wrote: Don nos...@nospam.com wrote: The difference was discovered through the unit tests for the mathematical Special Functions which will be included in the next compiler release. Discovery of the discrepancy happened only because of several features of D:

Re: Phobos unit testing uncovers a CPU bug

2010-11-27 Thread Dmitry Olshansky
On 26.11.2010 23:02, Don wrote: The code below compiles to a single machine instruction, yet the results are CPU manufacturer-dependent. import std.math; void main() { assert( yl2x(0x1.0076fc5cc7933866p+40L, LN2) == 0x1.bba4a9f774f49d0ap+4L); // Pass on Intel, fails on AMD }

Re: Phobos unit testing uncovers a CPU bug

2010-11-27 Thread Kagamin
Don Wrote: 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. The same question goes to you. Why do you call

Re: Phobos unit testing uncovers a CPU bug

2010-11-27 Thread Lionello Lunesu
On 28-11-2010 5:49, Dmitry Olshansky wrote: On 26.11.2010 23:02, Don wrote: The code below compiles to a single machine instruction, yet the results are CPU manufacturer-dependent. import std.math; void main() { assert( yl2x(0x1.0076fc5cc7933866p+40L, LN2) == 0x1.bba4a9f774f49d0ap+4L); //

Re: Phobos unit testing uncovers a CPU bug

2010-11-27 Thread Don
Kagamin wrote: Don Wrote: 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. The same question goes to you. Why

Phobos unit testing uncovers a CPU bug

2010-11-26 Thread Don
The code below compiles to a single machine instruction, yet the results are CPU manufacturer-dependent. import std.math; void main() { assert( yl2x(0x1.0076fc5cc7933866p+40L, LN2) == 0x1.bba4a9f774f49d0ap+4L); // Pass on Intel, fails on AMD } The results for

Re: Phobos unit testing uncovers a CPU bug

2010-11-26 Thread %u
== Quote from Don (nos...@nospam.com)'s article The code below compiles to a single machine instruction, yet the results are CPU manufacturer-dependent. import std.math; void main() { assert( yl2x(0x1.0076fc5cc7933866p+40L, LN2) == 0x1.bba4a9f774f49d0ap+4L); // Pass on

Re: Phobos unit testing uncovers a CPU bug

2010-11-26 Thread Walter Bright
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

Re: Phobos unit testing uncovers a CPU bug

2010-11-26 Thread Walter Bright
%u wrote: Slightly related, do you have some code to convert a hex float string to float? Hex float literals are supported by D.

Re: Phobos unit testing uncovers a CPU bug

2010-11-26 Thread bearophile
Walter: %u wrote: Slightly related, do you have some code to convert a hex float string to float? Hex float literals are supported by D. hex float string != Hex float literal. Bye, bearophile

Re: Phobos unit testing uncovers a CPU bug

2010-11-26 Thread Don
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