Re: Floating point performance issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2011-12-24 12:02:24 +0100, David Brown wrote:
> And (regarding other examples in your posts) if floating-point code
> depends on things like the order of calculations, it is also wrong -
> thus "-ffast-math" will not affect the correctness of the program,
> but will sometimes greatly improve the speed.

Whether you like it or not, a floating-point result does depend on the
order of calculations in general. How would you write code to compute
the mathematical expression a + b - c where you know that you have the
property 1/2 <= a/c <= 2 on the inputs? Or code to compute a*a - b*b
where a and b are close to each other? With the IEEE 754 rules, one
can use formulas that give very accurate results, but if the compiler
is allowed to rewrite the code (without control from the developer who
wrote the code), the results may no longer be accurate (and may even
be quite wrong).

> I don't think I'm alone in wishing that more programmers used stricter
> coding practices

On the contrary, we are very strict on coding practices in order to
get accurate results.

-- 
Vincent Lefèvre <vincent@xxxxxxxxxx> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux