Is real(16) available on x86 platforms?

Erik Schnetter schnetter@cct.lsu.edu
Sun Jan 14 19:42:00 GMT 2007


On Jan 14, 2007, at 13:18:18, Steve Kargl wrote:

> On Sun, Jan 14, 2007 at 10:50:35AM -0600, Erik Schnetter wrote:
>> On Jan 14, 2007, at 09:46:57, Steve Kargl wrote:
>>
>>> On Sun, Jan 14, 2007 at 03:52:48PM +0100, Dominique Dhumieres wrote:
>>>> Trying to use real kind 16 on x86_64-unknown-linux-gnu
>>>> gfortran from gcc version 4.3.0 20061231, I get:
>>>>
>>>> Error: Invalid real kind 16
>>>>
>>>> Is real(16) available only on platforms not supporting
>>>> real(10)?
>>>
>>> Your question is sort of wrong.  real(16) is available on
>>> targets that support a 128-bit floating point type.  If
>>> this FP is unavailable on the target, then real(16) is also
>>> unavailable.  On these targets one sometimes fines an
>>> 80-bit FP type, so gfortran provides a real(10) (which I
>>> believe is padded out to 16 bytes).
>>
>> I think real(10) is "usually" padded to 12 bytes (on IA32 machines).
>> When the option -m128bit-long-double is given, it is padded to 16
>> bytes.  That means the kind number encodes the accuracy, not the
>> number of bytes.
>>
>
> See the comments in trans-types.c.  It adds 6 bytes of padding.
>
>       /* Only let float/double/long double go through because the  
> fortran
> 	 library assumes these are the only floating point types.  */
>
>       if (mode != TYPE_MODE (float_type_node)
> 	  && (mode != TYPE_MODE (double_type_node))
>           && (mode != TYPE_MODE (long_double_type_node)))
> 	continue;
>
>       /* Let the kind equal the precision divided by 8, rounding  
> up.  Again,
> 	 this insulates the programmer from the underlying byte size.
>
> 	 Also, it effectively deals with IEEE extended formats.  There, the
> 	 total size of the type may equal 16, but it's got 6 bytes of padding
> 	 and the increased size can get in the way of a real IEEE quad format
> 	 which may also be supported by the target.
>
> 	 We round up so as to handle IA-64 __floatreg (RFmode), which is an
> 	 82 bit type.  Not to be confused with __float80 (XFmode), which is
> 	 an 80 bit type also supported by IA-64.  So XFmode should come out
> 	 to be kind=10, and RFmode should come out to be kind=11.  Egads.  */

It does not always add 6 bytes of padding; the comment speaks of "may  
equal 16".  You could add the word "then" before "got".

The types are handled by the middle-end and back-end, and the padding  
is added there.  There is no distinction between Fortran and C  
types.  (I've also looked at the assembler output.  On x86, the  
default is 2 bytes of padding, and with -m128bit-long-double there  
are 6 bytes of padding.)

-erik

-- 
Erik Schnetter <schnetter@cct.lsu.edu>

My email is as private as my paper mail.  I therefore support encrypting
and signing email messages.  Get my PGP key from www.keyserver.net.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 186 bytes
Desc: This is a digitally signed message part
URL: <http://gcc.gnu.org/pipermail/fortran/attachments/20070114/5ddc1935/attachment.sig>


More information about the Fortran mailing list