[issue30104] Float rounding errors on AMD64 FreeBSD CURRENT Debug 3.x buildbot

2017-04-21 Thread Mark Dickinson

Mark Dickinson added the comment:

Dimitry: thank you! Indeed, that looks like the very same issue. It's a shame 
to have to use -fno-strict-aliasing here, since that might prevent legitimate 
optimisations elsewhere in the code. But if that's what we have to do to 
maintain correctness with clang, then I guess we have little choice.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] Float rounding errors on AMD64 FreeBSD CURRENT Debug 3.x buildbot

2017-04-20 Thread Ed Maste

Changes by Ed Maste :


--
nosy: +emaste

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] Float rounding errors on AMD64 FreeBSD CURRENT Debug 3.x buildbot

2017-04-20 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +1344

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] Float rounding errors on AMD64 FreeBSD CURRENT Debug 3.x buildbot

2017-04-20 Thread Dimitry Andric

Dimitry Andric added the comment:

This is most likely the same issue we found in https://bugs.freebsd.org/216770, 
which was reported upstream to LLVM here: 
https://bugs.llvm.org//show_bug.cgi?id=31928, and resulted in a very long and 
not really productive discussion about whether type punning in this way is 
officially allowed, or a GNU extension.  I will gladly leave it to language 
lawyers. :)

In our case, easy fix was to use -fno-strict-aliasing, as we did here:
https://svnweb.freebsd.org/changeset/base/313706

--
nosy: +dim

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] Float rounding errors on AMD64 FreeBSD CURRENT Debug 3.x buildbot

2017-04-20 Thread STINNER Victor

STINNER Victor added the comment:

> Why is -ffast-math being used? That seems like it's asking for trouble.

Sorry, my comment was unclear: I only tried to list all compiler options which 
have an impact on floating point numbers.

> So this is smelling like a compiler bug to me.

Right, I will report it to LLVM (clang).

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] Float rounding errors on AMD64 FreeBSD CURRENT Debug 3.x buildbot

2017-04-20 Thread Mark Dickinson

Mark Dickinson added the comment:

Hmm. Just looked at dto5.c; nice work reducing it to something so simple.

This is looking a bit like either a strict-aliasing related problem, or a 
compiler bug, or both. My understanding of the "union trick" that dtoa.c uses 
is that it's well-defined under C99+TC3 (though that wasn't clear under the 
original C99), so it shouldn't be legitimate for an optimisation to cause 
different results to be produced.

So this is smelling like a compiler bug to me.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] Float rounding errors on AMD64 FreeBSD CURRENT Debug 3.x buildbot

2017-04-20 Thread Mark Dickinson

Mark Dickinson added the comment:

Why is -ffast-math being used? That seems like it's asking for trouble.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] Float rounding errors on AMD64 FreeBSD CURRENT Debug 3.x buildbot

2017-04-20 Thread STINNER Victor

STINNER Victor added the comment:

Much simpler test:

[haypo@freebsd ~/prog/python/master]$ clang40 -O1 dtoa5.c -o x && ./x
k=1
aadj=3.364
test ok
[haypo@freebsd ~/prog/python/master]$ clang40 -O2 dtoa5.c -o x && ./x
k=1
aadj=1.682
test FAILED: BUG!

--
Added file: http://bugs.python.org/file46818/dtoa5.c

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] Float rounding errors on AMD64 FreeBSD CURRENT Debug 3.x buildbot

2017-04-20 Thread STINNER Victor

STINNER Victor added the comment:

> Still ok with clang 3.8 with -O1:

Sorry, you should read clang 4.0 here.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] Float rounding errors on AMD64 FreeBSD CURRENT Debug 3.x buildbot

2017-04-20 Thread STINNER Victor

STINNER Victor added the comment:

I created a test case: attached dtoa2.c.

Ok with GCC 6.3.1 (on Fedora 25) and clang 3.8 (on FreeBSD 11) with -O3:

haypo@selma$ gcc -O3 dtoa2.c -o x && ./x
text: 29865e170 -> float: 2.9865e+174
0x1.8265ea9f864bcp+579
{bc 64 f8 a9 5e 26 28 64}

[haypo@freebsd ~/prog/python/master]$ clang -O3 dtoa2.c -o x && ./x
text: 29865e170 -> float: 2.9865e+174
0x1.8265ea9f864bcp+579
{bc 64 f8 a9 5e 26 28 64}


Still ok with clang 3.8 with -O1:

[haypo@freebsd ~/prog/python/master]$ clang40 -O1 dtoa2.c -o x && ./x
text: 29865e170 -> float: 2.9865e+174
0x1.8265ea9f864bcp+579
{bc 64 f8 a9 5e 26 28 64}


Error with clang 4.0 using -O2 (on FreeBSD 11):

[haypo@freebsd ~/prog/python/master]$ clang40 -O2 dtoa2.c -o x && ./x
text: 29865e170 -> float: 2.9865e+174
0x1.8265ea9f864bdp+579<~ HERE, bd instead of bc
{bd 64 f8 a9 5e 26 28 64} <~ HERE, bd instead of bc

--
Added file: http://bugs.python.org/file46817/dtoa2.c

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] Float rounding errors on AMD64 FreeBSD CURRENT Debug 3.x buildbot

2017-04-20 Thread STINNER Victor

STINNER Victor added the comment:

test_strtod fails on FreeBSD using clang 4.0, but pass using clang 3.8.

Links:

* https://gcc.gnu.org/wiki/FloatingPointMath
* https://gcc.gnu.org/wiki/Math_Optimization_Flags
* ICC fp-model: https://software.intel.com/en-us/node/682946

GCC options:

* -ffp-contract=off / -ffp-contract=fast
* -fp-model (not supported by clang)
* -mfpmath=sse: no effect on Clang, it's already the default and -mfpmath=387 
is not supported on x86_64 ISA
* -ffast-math
* -fexcess-precision=standard: not supported by clang

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] Float rounding errors on AMD64 FreeBSD CURRENT Debug 3.x buildbot

2017-04-19 Thread STINNER Victor

Changes by STINNER Victor :


--
components: +Interpreter Core, Tests
nosy: +mark.dickinson

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue30104] Float rounding errors on AMD64 FreeBSD CURRENT Debug 3.x buildbot

2017-04-19 Thread STINNER Victor

New submission from STINNER Victor:

Since the build 154, many tests fail on the AMD64 FreeBSD CURRENT Debug 3.x 
buildbot slave because of float rounding errors. Failing tests:

* test_cmath
* test_float
* test_json
* test_marshal
* test_math
* test_statistics
* test_strtod

http://buildbot.python.org/all/builders/AMD64%20FreeBSD%20CURRENT%20Non-Debug%203.x/builds/154/steps/test/logs/stdio

Problem: none of build 154 changes are related to floats

* commit f9f87f0934ca570293ba7194bed3448a7f9bf39c
* commit 947629916a5ecb1f6f6792e9b9234e084c5bf274

It looks more like a libc change of the FreeBSD CURRENT slave.

Example of errors:

==
FAIL: test_specific_values (test.test_cmath.CMathTests)
--
Traceback (most recent call last):
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/test/test_cmath.py",
 line 420, in test_specific_values
msg=error_message)
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/test/test_cmath.py",
 line 149, in rAssertAlmostEqual
'{!r} and {!r} are not sufficiently close'.format(a, b))
AssertionError: acos0036: acos(complex(-1.0002, 0.0))
Expected: complex(3.141592653589793, -0.04471763360830684)
Received: complex(3.141592653589793, -0.04471763360829195)
Received value insufficiently close to expected value.

==
FAIL: test_floats (test.test_json.test_float.TestPyFloat)
--
Traceback (most recent call last):
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/test/test_json/test_float.py",
 line 8, in test_floats
self.assertEqual(float(self.dumps(num)), num)
AssertionError: 1.9275814160560202e-50 != 1.9275814160560204e-50

FAIL: test_bigcomp (test.test_strtod.StrtodTests)
--
Traceback (most recent call last):
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/test/test_strtod.py",
 line 213, in test_bigcomp
self.check_strtod(s)
  File 
"/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/test/test_strtod.py",
 line 104, in check_strtod
"expected {}, got {}".format(s, expected, got))
AssertionError: '0x1.8265ea9f864bcp+579' != '0x1.8265ea9f864bdp+579'
- 0x1.8265ea9f864bcp+579
? ^
+ 0x1.8265ea9f864bdp+579
? ^
 : Incorrectly rounded str->float conversion for 29865e170: expected 
0x1.8265ea9f864bcp+579, got 0x1.8265ea9f864bdp+579

--
messages: 291901
nosy: haypo, koobs
priority: normal
severity: normal
status: open
title: Float rounding errors on AMD64 FreeBSD CURRENT Debug 3.x buildbot
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com