Skip to content

Incorrect finfo from PPC longdouble (Trac #2077) #2669

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
numpy-gitbot opened this issue Oct 19, 2012 · 6 comments
Closed

Incorrect finfo from PPC longdouble (Trac #2077) #2669

numpy-gitbot opened this issue Oct 19, 2012 · 6 comments

Comments

@numpy-gitbot
Copy link

Original ticket http://projects.scipy.org/numpy/ticket/2077 on 2012-03-10 by @matthew-brett, assigned to unknown.

In [1]: import numpy as np

In [2]: print np.finfo(np.longdouble)
/Users/mb312/dev_trees/numpy/numpy/core/machar.py:125: RuntimeWarning: overflow encountered in add
  a = a + a
/Users/mb312/dev_trees/numpy/numpy/core/machar.py:127: RuntimeWarning: invalid value encountered in subtract
  temp1 = temp - a
/Users/mb312/dev_trees/numpy/numpy/core/machar.py:136: RuntimeWarning: invalid value encountered in subtract
  itemp = int_conv(temp-a)
/Users/mb312/dev_trees/numpy/numpy/core/machar.py:160: RuntimeWarning: overflow encountered in add
  a = a + a
/Users/mb312/dev_trees/numpy/numpy/core/machar.py:162: RuntimeWarning: invalid value encountered in subtract
  temp1 = temp - a
/Users/mb312/dev_trees/numpy/numpy/core/machar.py:169: RuntimeWarning: invalid value encountered in subtract
  if any(temp-a != zero):
Machine parameters for float128
---------------------------------------------------------------------
precision= 75   resolution= 1e-75
machep=    -4   eps=        1.3817869701e-76
negep =    -4   epsneg=     1.3817869701e-76
minexp=    -1   tiny=       -1.08420217274e-19
maxexp=     1   max=        -9.22337203471e+18
nexp  =     1   min=        -max
---------------------------------------------------------------------


In [3]: print np.finfo(np.longdouble).nmant
1

In [4]: np.__version__
Out[4]: '1.7.0.dev-aae5b0a'

I think the correct answers for nexp, nmant are 11, 106 respectively; see:
https://developer.apple.com/library/mac/#documentation/Darwin/Reference/Manpages/man3/float.3.html

(np-devel)[mb312@jerry ~]$ uname -a
Darwin jerry.bic.berkeley.edu 8.11.0 Darwin Kernel Version 8.11.0: Wed Oct 10 18:26:00 PDT 2007; root:xnu-792.24.17~1/RELEASE_PPC Power Macintosh powerpc
(np-devel)[mb312@jerry ~]$ gcc -v
Using built-in specs.
Target: powerpc-apple-darwin8
Configured with: /var/tmp/gcc/gcc-5370~2/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=powerpc-apple-darwin8 --host=powerpc-apple-darwin8 --target=powerpc-apple-darwin8
Thread model: posix
gcc version 4.0.1 (Apple Computer, Inc. build 5370)
@numpy-gitbot
Copy link
Author

@mwiebe wrote on 2012-03-12

I seem to recall that the finfo code is using an algorithm that automatically detects these parameters by manipulating values of the given dtype. I guess either there's something wrong with the algorithm, or the long double on that platform is extremely non-conformant.

@numpy-gitbot
Copy link
Author

@charris wrote on 2012-03-12

The algorithm (which is kind of a mess) assumes an exponent/mantissa format, while the PPC long double is implemented using two doubles. I'm not even sure if eps really makes sense for it. I'd almost be inclined to hard code these values except that they may depend on compiler flags.

@charris
Copy link
Member

charris commented Feb 21, 2014

#3125 has some useful information.

@matthew-brett
Copy link
Contributor

Just started running tests on buildbot - failing on these double precision tests:

http://nipy.bic.berkeley.edu/builders/numpy-py2.6-osx-10.5-ppc/builds/0/steps/shell_3/logs/stdio

I wonder if something like a test for common precisions and backing off to hard coding would work. I'll have a think.

@charris
Copy link
Member

charris commented Feb 25, 2014

I'd like that, actually. The current code for determining float precision is a mess. Basically there are two types we need to deal with: IEEE and IBM, hardcoding would be pretty easy to maintain, IMHO, work better, and be much easier to comprehend. There should be a check for IBM long doubles, like for the various IEEE types, and after that a way to expose that info. Or we could just combine endianess with the known specs for the IBM type.

matthew-brett added a commit to matthew-brett/numpy that referenced this issue Jan 31, 2017
Hard-code the MachAr parameters for float64, float32, 80-bit extended
precision, to save time, and provide skeleton for more difficult types
such as the double double on PPC; see
numpy#2669
charris pushed a commit that referenced this issue Feb 3, 2017
* ENH: hard-code finfo parameters for known types

Hard-code the MachAr parameters for float64, float32, 80-bit extended
precision, to save time, and provide skeleton for more difficult types
such as the double double on PPC; see
#2669

* ENH: add PPC long double finfo

Add parameters for PPC long double, fixing long-standing bug for finfo
on PPC.

* BF: use Python floats for float64 finfo

For some reason (garrgh) np.exp2 with float64 gives a different answer on
Windows than it does on other platforms; use Python floating point
calculations instead, which do appear to be consistent.

* DOC: add release notes for finfo fixes

Add release note describing fixes for PPC long double ``finfo``.

* RF: try using byte string to identify floats

From suggestion by Chuck, and
https//perl5.git.perl.org/perl.git/blob/3118d7d684b56cbeb702af874f4326683c45f045:/Configure

* TST: add tests for reasonable finfo parameters

Check that finfo returns somewhat reasonable parameters for all floating
point types.

* RF: add warning for not-recognized float type

Warn if we don't have a signature for the float type.

* NF: add IEEE float128 type signature

Still needs test on platform with IEEE float128, to check MachAr-like
parameters are correct.
@charris
Copy link
Member

charris commented Feb 3, 2017

Should be closed by #8504.

@charris charris closed this as completed Feb 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants