public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Thomas Schwinge <thomas@codesourcery.com>
To: Julian Brown <julian@codesourcery.com>
Cc: <gcc-patches@gcc.gnu.org>, Joseph Myers <joseph@codesourcery.com>,
	Richard Biener <rguenther@suse.de>,
	Jakub Jelinek <jakub@redhat.com>, Jeff Law	<law@redhat.com>,
	Kwok Cheung Yeung <kcy@codesourcery.com>
Subject: Re: [PATCH] Fix decimal floating-point LTO streaming for offloading compilation
Date: Thu, 28 Nov 2019 15:23:00 -0000	[thread overview]
Message-ID: <8736e8m3qn.fsf@euler.schwinge.homeip.net> (raw)
In-Reply-To: <20191128142402.2949931d@squid.athome>

[-- Attachment #1: Type: text/plain, Size: 3647 bytes --]

Hi Julian!

On 2019-11-28T14:24:02+0000, Julian Brown <julian@codesourcery.com> wrote:
> As mentioned in PR91985, offloading compilation is broken at present
> because of an issue with LTO streaming. With thanks to Joseph for
> hints, here's a solution.
>
> Unlike e.g. the _FloatN types, when decimal floating-point types are
> enabled, common tree nodes are created for each float type size (e.g.
> dfloat32_type_node) and also a pointer to each type is created
> (e.g. dfloat32_ptr_type_node). tree-streamer.c:record_common_node emits
> these like:
>
>   <float:32>     (dfloat32_type_node)
>   <float:64>     (dfloat64_type_node)
>   <float:128>    (dfloat128_type_node)
>   <float:32> *   (dfloat32_ptr_type_node)
>   <float:32>
>   <float:64> *   (dfloat64_ptr_type_node)
>   <float:64>
>   <float:128> *  (dfloat128_ptr_type_node)
>   <float:128>
>
> I.e., with explicit emission of a copy of the pointed-to type following
> the pointer itself.

I also do see that, but I fail to understand why that duplication: the
first '<float:32>' and the second one (after the '<float:32> *') are the
same node, or aren't they?

> When DFP is disabled, we instead get:
>
>   <<< error >>>
>   <<< error >>>
>   <<< error >>>
>   <<< error >>>
>   <<< error >>>
>   <<< error >>>

(With that expectedly being any 'NULL_TREE's converted to
'error_mark_node' in 'gcc/tree-streamer.c:record_common_node'.)

> So, the number of nodes emitted during LTO write-out in the host/read-in
> in the offload compiler do not match.

ACK.

> This patch restores the number of nodes emitted by creating
> dfloatN_ptr_type_node as generic pointers rather than treating them as
> flat error_type_nodes. I don't think there's an easy way of creating an
> "error_type_node *", nor do I know if that would really be preferable.
>
> Tested with offloading to NVPTX & bootstrapped. OK to apply?

> commit 17119773a8a45af098364b4faafe68f2e868479a
> Author: Julian Brown <julian@codesourcery.com>
> Date:   Wed Nov 27 18:41:56 2019 -0800
>
>     Fix decimal floating-point LTO streaming for offloading compilation
>     
>             gcc/
>             * tree.c (build_common_tree_nodes): Use pointer type for
>             dfloat32_ptr_type_node, dfloat64_ptr_type_node and
>             dfloat128_ptr_type_node when decimal floating point support is disabled.
>
> diff --git a/gcc/tree.c b/gcc/tree.c
> index 5ae250ee595..db3f225ea7f 100644
> --- a/gcc/tree.c
> +++ b/gcc/tree.c
> @@ -10354,6 +10354,15 @@ build_common_tree_nodes (bool signed_char)
>        layout_type (dfloat128_type_node);
>        dfloat128_ptr_type_node = build_pointer_type (dfloat128_type_node);
>      }
> +  else
> +    {
> +      /* These must be pointers else tree-streamer.c:record_common_node will emit
> +	 a different number of nodes depending on DFP availability, which breaks
> +	 offloading compilation.  */
> +      dfloat32_ptr_type_node = ptr_type_node;
> +      dfloat64_ptr_type_node = ptr_type_node;
> +      dfloat128_ptr_type_node = ptr_type_node;
> +    }
>  
>    complex_integer_type_node = build_complex_type (integer_type_node, true);
>    complex_float_type_node = build_complex_type (float_type_node, true);

(Maybe that's indeed better than my "hamfisted" patch.)  ;-)

But it still reads a bit like a workaround (explicitly setting only
'dfloat*_ptr_type_node' here, leaving the actual 'dfloat*_type_node'
untouched (and then later on implicitly converted to 'error_mark_node' as
mentioned).

I guess we need somebody with more experience to review this.


Grüße
 Thomas

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 658 bytes --]

      parent reply	other threads:[~2019-11-28 15:15 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-22 16:47 Prevent all uses of DFP when unsupported (PR c/91985) Joseph Myers
2019-11-23 16:56 ` Jeff Law
2019-11-25 20:36 ` Rainer Orth
2019-11-26  1:05   ` Joseph Myers
2019-11-26 12:21     ` Jonathan Wakely
2019-11-27 12:18       ` Rainer Orth
2019-11-27 17:49         ` Joseph Myers
2019-11-27 18:01           ` Jakub Jelinek
2020-01-16 14:49             ` Szabolcs Nagy
2020-01-16 14:50               ` Jakub Jelinek
2019-11-26 14:02   ` Andreas Schwab
2019-11-27 21:55 ` Thomas Schwinge
2019-11-27 22:39   ` Joseph Myers
2019-11-28 14:22     ` Thomas Schwinge
2019-11-28 14:44       ` [PATCH] Fix decimal floating-point LTO streaming for offloading compilation Julian Brown
2019-11-28 15:15         ` Joseph Myers
2019-11-28 15:45           ` Segher Boessenkool
2019-11-28 18:25           ` Julian Brown
2019-11-28 19:22             ` Joseph Myers
2019-11-28 19:45           ` Richard Biener
2019-11-28 15:23         ` Thomas Schwinge [this message]

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=8736e8m3qn.fsf@euler.schwinge.homeip.net \
    --to=thomas@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=joseph@codesourcery.com \
    --cc=julian@codesourcery.com \
    --cc=kcy@codesourcery.com \
    --cc=law@redhat.com \
    --cc=rguenther@suse.de \
    /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).