[Numpy-discussion] [Numpy] quadruple precision
Wed Feb 29 14:17:33 CST 2012
Pierre Haessig <pierre.haessig <at> crans.org> writes:
> Le 29/02/2012 16:22, Paweł Biernat a écrit :
> > Is there any way to interact with Fortran's real(16) (supported by gcc
> > and Intel's ifort) data type from numpy? By real(16) I mean the
> > binary128 type as in IEEE 754. (In C this data type is experimentally
> > supported as __float128 (gcc) and _Quad (Intel's icc).)
> I googled a bit this "__float128". It seems a fairly new addition (GCC
> 4.6, released March 2011).
> The related point in the changelog  is :
> "GCC now ships with the LGPL-licensed libquadmath library, which
> provides quad-precision mathematical functions for targets with a
> __float128 datatype. __float128 is available for targets on 32-bit x86,
> x86-64 and Itanium architectures. The libquadmath library is
> automatically built on such targets when building the Fortran compiler."
> It seems this __float128 is newcomer in the "picture of data types" that
> Matthew just mentioned.
> As David says, arithmetic with such a 128 bits data type is probably not
> "hardwired" in most processors (I mean Intel & friends) which are
> limited to 80 bits ("long doubles") so it may be a bit slow. However,
> this GCC implementation with libquadmath seems to create some level of
> abstraction. Maybe this is one acceptably good way for a real "IEEE
> float 128" dtype in numpy ?
>  http://gcc.gnu.org/gcc-4.6/changes.html
> NumPy-Discussion mailing list
> NumPy-Discussion <at> scipy.org
Intel also has its own implementation of binary128, although not well
documented (as you said, it's software emulated, but still quite
The documentation is for Fortran's real(16), but I belive the same
holds for _Quad type in C.
My naive question is, is there a way to recompile numpy with "long
double" (or just "float128") replaced with "_Quad" or "__float128"?
There are at least two compilers that support the respective data
types, so this should be doable. I tested interoperability of
binary128 with Fortran and C (using gcc and Intel's compilers) and it
works like a charm.
The only problem that comes to my mind is i/o, because there is no
printf format for _Quad or __float128 and fortran routines have to be
used to do all i/o.
More information about the NumPy-Discussion