News for hackers. Stuff that matters.
Re:GCC optimized code gives strange floating point results by dbcurtis on Sunday February 26, 2017 @07:12PM (#13740865)
I have also met Kahan. He gives new meaning to the word "pedantic".

The reality is that numerical anslysts want the computer do do exactly what they tell them to, in precisely the order described. The rest of the human race wants approximately the right answer reasonably quickly. (Floating point is a bad choice if you want exactly the right answer). And the people who make purchase decisions read benchmark reports they don't understand.

Re:GCC optimized code gives strange floating point results by smallnamespace on Sunday February 26, 2017 @08:15PM (#13741140)
> The rest of the human race wants approximately the right answer reasonably quickly

But numerical analysts really require being able to specify the semantics of calculations precisely in order to write libraries that mere mortals can use to get the approximate right answer.

A quick perusal of any numerical analysis textbook should convince you that order of evaluation, order of truncation, overflow modes, and the like are very relevant for being able to write a library that has the right order of error.

Something like Kahan summation will have vastly different results depend on whether intermediate calculations are done at a higher precision or whether the compiler is allowed to reorder expressions. In fact, an overly aggressive optimizing compiler will make Kahan summation simply fail [1].

If all you're doing is adding a few numbers together, by all means, you don't need or want to think about precise semantics. But if you've ever used BLAS or Numpy or any other math package, you very much depend on languages and compilers being pedantic as possible in spelling out how floating point gets evaluated.

[1] https://en.wikipedia.org/wiki/Kahan_summation_algorithm

Re:GCC optimized code gives strange floating point results by dbcurtis on Sunday February 26, 2017 @10:46PM (#13741720)
>But numerical analysts really require being able to specify the semantics of calculations precisely in order to write libraries that mere mortals can use to get the approximate right answer.

>A quick perusal of any numerical analysis textbook should convince you that order of evaluation, order of truncation, overflow modes, and the like are very relevant for being able to write a library that has the right order of error.

I see your point. I've done more than peruse numerical analysis textbooks, and as an old-school CPU logic designer, I've forgotten more about implementing floating point than most programmers know to start with.

But your point is not in conflict with mine. Numerical analysis requires precise operation ordering. Most people not only don't care, they don't have sufficient understanding of the issues that you could even convince them to care.

Re:GCC optimized code gives strange floating point results by alfalfasprout on Sunday February 26, 2017 @09:47PM (#13741458)
Actually, BLAS implementations usually do guarantee error bounds, but the implementation is almost always tailored for speed over precision. That said, you can always opt for extended precision at the cost of performance.
Re:GCC optimized code gives strange floating point results by cperciva on Sunday February 26, 2017 @11:40PM (#13741911)
The reality is that numerical anslysts want the computer do do exactly what they tell them to, in precisely the order described.

Not at all. As far as we're concerned, it's just fine if the computer works by consulting an oracle.

But we want the answers to be exactly the same as if the computer did what we told it to do. :-)