public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Michael Meissner <meissner@linux.vnet.ibm.com>
To: Joseph Myers <joseph@codesourcery.com>
Cc: gcc-patches@gcc.gnu.org, fortran@gcc.gnu.org, jason@redhat.com,
	       richard.earnshaw@arm.com, nickc@redhat.com,
	       ramana.radhakrishnan@arm.com, marcus.shawcroft@arm.com,
	       dje.gcc@gmail.com, segher@kernel.crashing.org,
	       meissner@linux.vnet.ibm.com, murphyp@linux.vnet.ibm.com,
	bje@gnu.org,        Bill Schmidt <wschmidt@linux.vnet.ibm.com>,
	       Steve Munroe <sjmunroe@us.ibm.com>
Subject: Re: Implement C _FloatN, _FloatNx types [version 2]
Date: Tue, 21 Jun 2016 20:53:00 -0000	[thread overview]
Message-ID: <20160621205302.GA8544@ibm-tiger.the-meissners.org> (raw)
In-Reply-To: <alpine.DEB.2.20.1606211738200.31330@digraph.polyomino.org.uk>

On Tue, Jun 21, 2016 at 05:41:36PM +0000, Joseph Myers wrote:
> [Changes in version 2 of the patch:
> 
> * PowerPC always uses KFmode for _Float128 and _Float64x when those
>   types are supported, not TFmode.

While from one perspective, it would have been cleaner if the PowerPC
had separate internal types for IBM extended double and IEEE 128-bit floating
point.  But the way the compiler has been implemented is that TFmode is which
ever type is the default.  Typically, in the Linux environment, this is IBM
extended double, but we are hoping in the future to change the default to make
long double IEEE 128-bit.  So, I think we need to do something like:

static machine_mode
rs6000_floatn_mode (int n, bool extended)
{
  if (extended)
    {
      switch (n)
	{
	case 32:
	  return DFmode;

	case 64:
	  if (TARGET_FLOAT128)
	    return (TARGET_IEEEQUAD) ? TFmode : KFmode;
	  else
	    return VOIDmode;

	case 128:
	  return VOIDmode;

	default:
	  /* Those are the only valid _FloatNx types.  */
	  gcc_unreachable ();
	}
    }
  else
    {
      switch (n)
	{
	case 32:
	  return SFmode;

	case 64:
	  return DFmode;

	case 128:
	  if (TARGET_FLOAT128)
	    return (TARGET_IEEEQUAD) ? TFmode : KFmode;
	  else
	    return VOIDmode;

	default:
	  return VOIDmode;
	}
    }
}

As an aside, one of the issues, I'm currently grappling with is how to enable
the __float128 machinery without enabling the __float128 keyword (PR 70589).
The reason is we need to create the various built-in functions for IEEE 128-bit
functions, which means creating the type and keyword support.

As Richard Biener and I discussed, the way I created the types using
FRACTIONAL_FLOAT_MODE for IFmode/KFmode isn't really ideal.
https://gcc.gnu.org/ml/gcc-patches/2016-06/msg01114.html

It would have made things simpler if there was a MD hook to control what
automatically widens to what.  I tried to implement it in the early days, but I
never came up with code that did what I wanted.  I use rs6000_invalid_binary_op
to do this to some extent.

Another thing that I'm grappling with is how to identify when the floating
point emulation functions have been built.  Right now, it is only built for
64-bit Linux systems, and it is not built for AIX, BSD, or the various 32-bit
embedded targets.

> No GCC port supports a floating-point format suitable for _Float128x.
> Although there is HFmode support for ARM and AArch64, use of that for
> _Float16 is not enabled.  Supporting _Float16 would require additional
> work on the excess precision aspects of TS 18661-3: there are new
> values of FLT_EVAL_METHOD, which are not currently supported in GCC,
> and FLT_EVAL_METHOD == 0 now means that operations and constants on
> types narrower than float are evaluated to the range and precision of
> float.  Implementing that, so that _Float16 gets evaluated with excess
> range and precision, would involve changes to the excess precision
> infrastructure so that the _Float16 case is enabled by default, unlike
> the x87 case which is only enabled for -fexcess-precision=standard.
> Other differences between _Float16 and __fp16 would also need to be
> disentangled.

ISA 3.0 (Power9) does have instructions to convert to/from 16-bit floating
point to 32-bit floating point.  Right now, it is just conversion to/from
storage format to a more normal format (similar to _Decimal32 where there are
no instructions to operate on 32-bit decimal data).  At the moment, we don't
have support for these instructions, but we will likely do it in the future.

However, I suspect that in the future, we may have users that want to do
arithmetic in this format (particularly vectors).  This comes from people
wanting to interface with attached GPUs that often times support HFmode, and
with machine learning systems that does not need the precision.  So, we should
at least think what is needed to enable HFmode as a real type.

> GCC has some prior support for nonstandard floating-point types in the
> form of __float80 and __float128.  Where these were previously types
> distinct from long double, they are made by this patch into aliases
> for _Float64x / _Float128 if those types have the required properties.

And of course other machine dependent non-standard floating point types such as
IBM extended double.

In addition, there is the question of what to do on the embedded machines that
might use IEEE format for floating point, but does not support all of the
features in IEEE 754R such as NaNs, infinities, de-normal numbers, negative 0,
etc.

As I said in my previous message, what ever we do in this space needs to be
backwards compatible with existing usage in GCC 6.x.

-- 
Michael Meissner, IBM
IBM, M/S 2506R, 550 King Street, Littleton, MA 01460-6245, USA
email: meissner@linux.vnet.ibm.com, phone: +1 (978) 899-4797

  reply	other threads:[~2016-06-21 20:53 UTC|newest]

Thread overview: 78+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-21 12:07 Implement C _FloatN, _FloatNx types Joseph Myers
2016-06-21 15:17 ` FX
2016-06-21 15:38   ` Joseph Myers
2016-06-21 15:21 ` Bill Schmidt
2016-06-21 15:43   ` Joseph Myers
2016-06-21 17:42 ` Implement C _FloatN, _FloatNx types [version 2] Joseph Myers
2016-06-21 20:53   ` Michael Meissner [this message]
2016-06-21 21:18     ` Joseph Myers
2016-06-22 20:43   ` Joseph Myers
2016-06-22 21:45     ` FX
2016-06-23 14:20   ` Implement C _FloatN, _FloatNx types [version 3] Joseph Myers
2016-06-27 17:31     ` Ping " Joseph Myers
2016-06-27 21:20       ` Bill Schmidt
2016-06-27 21:24         ` Joseph Myers
2016-06-27 21:38           ` Segher Boessenkool
2016-07-19 13:54       ` Implement C _FloatN, _FloatNx types [version 4] Joseph Myers
2016-07-22 21:59         ` Implement C _FloatN, _FloatNx types [version 5] Joseph Myers
2016-07-29 17:37           ` Ping " Joseph Myers
2016-07-29 22:09             ` Michael Meissner
2016-08-04 23:54             ` Michael Meissner
2016-08-05  0:12               ` Joseph Myers
2016-08-10 11:33             ` Ping^2 " Joseph Myers
2016-08-10 17:14               ` Paul Richard Thomas
2016-08-11  7:05                 ` FX
2016-08-15 22:21               ` Ping^3 " Joseph Myers
2016-08-17 15:43           ` James Greenhalgh
2016-08-17 16:44             ` Joseph Myers
2016-08-17 20:17               ` Implement C _FloatN, _FloatNx types [version 6] Joseph Myers
     [not found]                 ` <CAFiYyc3xqcqJ1rK2X0rC+wwpx3akHbULVG1G47PRmtk4wTk=7A@mail.gmail.com>
2016-08-19 11:06                   ` Joseph Myers
2016-08-19 11:11                     ` Richard Biener
2016-08-19 14:40                       ` Joseph Myers
2016-08-19 15:52                         ` David Malcolm
2016-08-19 16:51                           ` Joseph Myers
2016-08-19 17:21                             ` David Malcolm
2016-09-07 12:18                     ` Advice sought for debugging a lto1 ICE (was: Implement C _FloatN, _FloatNx types [version 6]) Thomas Schwinge
2016-09-07 12:28                       ` Richard Biener
2016-09-08 11:53                         ` Thomas Schwinge
2016-09-14 10:24                           ` Richard Biener
2016-09-16  7:21                           ` [PR lto/77458] Avoid ICE in offloading with differing _FloatN, _FloatNx types (was: Advice sought for debugging a lto1 ICE (was: Implement C _FloatN, _FloatNx types [version 6])) Thomas Schwinge
2016-09-16  9:02                             ` Richard Biener
2016-09-16 14:00                               ` Thomas Schwinge
2016-09-16 18:02                                 ` Joseph Myers
2016-09-19  8:40                                   ` Richard Biener
2016-09-19 11:04                                     ` Thomas Schwinge
2016-09-19 13:22                                       ` Joseph Myers
2016-09-19  8:53                                 ` Richard Biener
2016-09-19 11:57                                   ` Thomas Schwinge
2016-09-19 12:07                                     ` Richard Biener
2016-09-29 13:26                                       ` [PR lto/77458] Avoid ICE in offloading with differing _FloatN, _FloatNx types Thomas Schwinge
2016-10-17 15:59                                         ` Thomas Schwinge
2016-10-19 10:58                                           ` Thomas Schwinge
2016-09-29 14:55                                       ` Explicitly list all tree codes in gcc/tree-streamer.c:record_common_node (was: [PR lto/77458] Avoid ICE in offloading with differing _FloatN, _FloatNx types) Thomas Schwinge
2016-09-30  8:10                                         ` Richard Biener
2016-10-17 15:57                                           ` Explicitly list all tree codes in gcc/tree-streamer.c:record_common_node Thomas Schwinge
2016-09-16 17:57                               ` [PR lto/77458] Avoid ICE in offloading with differing _FloatN, _FloatNx types (was: Advice sought for debugging a lto1 ICE (was: Implement C _FloatN, _FloatNx types [version 6])) Joseph Myers
2016-08-19 15:28                 ` Implement C _FloatN, _FloatNx types [version 6] Szabolcs Nagy
2016-08-19 16:24                   ` Joseph Myers
2016-08-31 16:58                     ` James Greenhalgh
2016-08-31 17:26                       ` Joseph Myers
2016-09-01 10:52                         ` Szabolcs Nagy
2016-09-01 15:40                           ` Joseph Myers
2016-08-21  9:50                 ` Andreas Schwab
2016-08-22 10:46                   ` Joseph Myers
2016-08-22  8:09                 ` [BUILDROBOT] x86_64: Segmentation fault during -fself-test (was: " Jan-Benedict Glaw
2016-08-22 11:23                   ` Joseph Myers
2016-08-22 10:48                 ` Matthew Wahab
2016-08-22 11:48                   ` Joseph Myers
2016-08-22 17:52                     ` Joseph Myers
2016-09-03 19:46                 ` Andreas Schwab
2016-09-05 11:45                   ` Joseph Myers
2016-09-06  9:02                     ` Richard Biener
2016-09-06 11:18                       ` Joseph Myers
2016-07-19 11:29     ` Implement C _FloatN, _FloatNx types [version 3] James Greenhalgh
2016-07-28 22:43       ` Joseph Myers
2016-08-09 15:26         ` James Greenhalgh
2016-08-09 20:44           ` Joseph Myers
2016-08-05  0:09 ` Implement C _FloatN, _FloatNx types Michael Meissner
2016-08-05  0:35   ` Joseph Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160621205302.GA8544@ibm-tiger.the-meissners.org \
    --to=meissner@linux.vnet.ibm.com \
    --cc=bje@gnu.org \
    --cc=dje.gcc@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=marcus.shawcroft@arm.com \
    --cc=murphyp@linux.vnet.ibm.com \
    --cc=nickc@redhat.com \
    --cc=ramana.radhakrishnan@arm.com \
    --cc=richard.earnshaw@arm.com \
    --cc=segher@kernel.crashing.org \
    --cc=sjmunroe@us.ibm.com \
    --cc=wschmidt@linux.vnet.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).