[pypy-dev] msvc and floating point compiler flags

Kenny Lasse Hoff Levinsen kennylevinsen at gmail.com
Wed Apr 9 22:44:02 CEST 2014


Sorry to butt in here, but… I just saw the comparison, and all my alarm bells with regards to extended precision and other platform-dependent magic started ringing.
What kind of voodoo and virgin goat blood (Am I doing the occult rituals right?) was needed to make that work on other compilers?

Jokes aside, adding /fp:fast should tell the compiler to ignore all rules, and makes the result much more platform dependent than they already were. Literals are no longer trustable either.
MS docs: http://msdn.microsoft.com/en-us/library/e7s85ffb.aspx
SO note on fast-math: http://stackoverflow.com/a/16069874

Shouldn’t the comparison just account for some lack of precision? I suggest having the macro do (a > b*0.99999 && a < b*0.00001) or the likes, after deciding how many digits of precision is wanted for that specific test. It looks stupid (And introduces even more floating point arithmetics!), but it works.

But maybe you should wait for another reply, I may just be too tired to function.

Kenny

On 09 Apr 2014, at 22:10, matti picus <matti.picus at gmail.com> wrote:

> looking at this test failure
> http://buildbot.pypy.org/summary/longrepr?testname=test_math&builder=own-win-x86-32&build=86&mod=jit.backend.x86.test.test_zmath
> which tests that atan2(0.23/1.23) == 1.3.... via OP_FLOAT_EQ(double value, double value)
> OP_FLOAT_EQ is a compiler define to (a == b), which is tricky with double values.
> Here is a nice discussion of the issue on MSVC
> http://www.gamasutra.com/view/news/167402/Indepth_Intermediate_floatingpoint_precision.php
> The link even has a flow chart for choosing msvc or intel compiler flags.
> The test passes if I add /fp:fast to the msvc compile flag
> Would anyone object if I add this to the default MSVC flags?
> 
> FWIW, the "fast" is misleading, apparently it can be slower than the default for some cases.
> Matti
> _______________________________________________
> pypy-dev mailing list
> pypy-dev at python.org
> https://mail.python.org/mailman/listinfo/pypy-dev

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/pypy-dev/attachments/20140409/cfa60a6d/attachment.html>


More information about the pypy-dev mailing list