public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jakub Jelinek <jakub@redhat.com>
To: Tobias Burnus <tobias@codesourcery.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [Patch] OpenMP: Support reverse offload (middle end part)
Date: Fri, 26 Aug 2022 11:53:39 +0200	[thread overview]
Message-ID: <YwiYI99rGy+xl/ZJ@tucnak> (raw)
In-Reply-To: <1654f119-fe0e-71c5-c28d-9b8fd40b6b87@codesourcery.com>

On Thu, Jul 21, 2022 at 02:33:32PM +0200, Tobias Burnus wrote:
> OpenMP: Support reverse offload (middle end part)
> 
> gcc/ChangeLog:
> 
> 	* internal-fn.cc (expand_GOMP_TARGET_REV): New.
> 	* internal-fn.def (GOMP_TARGET_REV): New.
> 	* lto-cgraph.cc (lto_output_node, verify_node_partition): Mark
> 	'omp target device_ancestor_host' as in_other_partition and don't
> 	error if absent.
> 	* omp-low.cc (create_omp_child_function): Mark as 'noclone'.
> 	* omp-expand.cc (expand_omp_target): For reverse offload, remove
> 	sorry, use device = GOMP_DEVICE_HOST_FALLBACK and create
> 	empty-body nohost function.
> 	* omp-offload.cc (execute_omp_device_lower): Handle
> 	IFN_GOMP_TARGET_REV.
> 	(pass_omp_target_link::execute): For ACCEL_COMPILER, don't
> 	nullify fn argument for reverse offload
> 
> libgomp/ChangeLog:
> 
> 	* libgomp.texi (OpenMP 5.0): Mark 'ancestor' as implemented but
> 	refer to 'requires'.
> 	* testsuite/libgomp.c-c++-common/reverse-offload-1-aux.c: New test.
> 	* testsuite/libgomp.c-c++-common/reverse-offload-1.c: New test.
> 	* testsuite/libgomp.fortran/reverse-offload-1-aux.f90: New test.
> 	* testsuite/libgomp.fortran/reverse-offload-1.f90: New test.
> 
> gcc/testsuite/ChangeLog:
> 
> 	* c-c++-common/gomp/reverse-offload-1.c: Remove dg-sorry.
> 	* c-c++-common/gomp/target-device-ancestor-4.c: Likewise.
> 	* gfortran.dg/gomp/target-device-ancestor-4.f90: Likewise.
> 	* gfortran.dg/gomp/target-device-ancestor-5.f90: Likewise.
> 	* c-c++-common/goacc/classify-kernels-parloops.c: Add 'noclone' to
> 	scan-tree-dump-times.
> 	* c-c++-common/goacc/classify-kernels-unparallelized-parloops.c:
> 	Likewise.
> 	* c-c++-common/goacc/classify-kernels-unparallelized.c: Likewise.
> 	* c-c++-common/goacc/classify-kernels.c: Likewise.
> 	* c-c++-common/goacc/classify-parallel.c: Likewise.
> 	* c-c++-common/goacc/classify-serial.c: Likewise.
> 	* c-c++-common/goacc/kernels-counter-vars-function-scope.c: Likewise.
> 	* c-c++-common/goacc/kernels-loop-2.c: Likewise.
> 	* c-c++-common/goacc/kernels-loop-3.c: Likewise.
> 	* c-c++-common/goacc/kernels-loop-data-2.c: Likewise.
> 	* c-c++-common/goacc/kernels-loop-data-enter-exit-2.c: Likewise.
> 	* c-c++-common/goacc/kernels-loop-data-enter-exit.c: Likewise.
> 	* c-c++-common/goacc/kernels-loop-data-update.c: Likewise.
> 	* c-c++-common/goacc/kernels-loop-data.c: Likewise.
> 	* c-c++-common/goacc/kernels-loop-g.c: Likewise.
> 	* c-c++-common/goacc/kernels-loop-mod-not-zero.c: Likewise.
> 	* c-c++-common/goacc/kernels-loop-n.c: Likewise.
> 	* c-c++-common/goacc/kernels-loop-nest.c: Likewise.
> 	* c-c++-common/goacc/kernels-loop.c: Likewise.
> 	* c-c++-common/goacc/kernels-one-counter-var.c: Likewise.
> 	* c-c++-common/goacc/kernels-parallel-loop-data-enter-exit.c: Likewise.
> 	* gfortran.dg/goacc/classify-kernels-parloops.f95: Likewise.
> 	* gfortran.dg/goacc/classify-kernels-unparallelized-parloops.f95:
> 	Likewise.
> 	* gfortran.dg/goacc/classify-kernels-unparallelized.f95: Likewise.
> 	* gfortran.dg/goacc/classify-kernels.f95: Likewise.
> 	* gfortran.dg/goacc/classify-parallel.f95: Likewise.
> 	* gfortran.dg/goacc/classify-serial.f95: Likewise.
> 	* gfortran.dg/goacc/kernels-loop-2.f95: Likewise.
> 	* gfortran.dg/goacc/kernels-loop-data-2.f95: Likewise.
> 	* gfortran.dg/goacc/kernels-loop-data-enter-exit-2.f95: Likewise.
> 	* gfortran.dg/goacc/kernels-loop-data-enter-exit.f95: Likewise.
> 	* gfortran.dg/goacc/kernels-loop-data-update.f95: Likewise.
> 	* gfortran.dg/goacc/kernels-loop-data.f95: Likewise.
> 	* gfortran.dg/goacc/kernels-loop-n.f95: Likewise.
> 	* gfortran.dg/goacc/kernels-loop.f95: Likewise.
> 	* gfortran.dg/goacc/kernels-parallel-loop-data-enter-exit.f95: Likewise.

Ok for trunk, just a comment regarding the FIXME below (can be handled
incrementally).

> +	  case IFN_GOMP_TARGET_REV:
> +	    {
> +#ifndef ACCEL_COMPILER
> +	      gimple_stmt_iterator gsi2 = gsi;
> +	      gsi_next (&gsi2);
> +	      gcc_assert (!gsi_end_p (gsi2));
> +	      gcc_assert (gimple_call_builtin_p (gsi_stmt (gsi2),
> +						 BUILT_IN_GOMP_TARGET));
> +	      tree old_decl
> +		= TREE_OPERAND (gimple_call_arg (gsi_stmt (gsi2), 1), 0);
> +	      tree new_decl = gimple_call_arg (gsi_stmt (gsi), 0);
> +	      gimple_call_set_arg (gsi_stmt (gsi2), 1, new_decl);
> +	      update_stmt (gsi_stmt (gsi2));
> +	      new_decl = TREE_OPERAND (new_decl, 0);
> +	      unsigned i;
> +	      unsigned num_funcs = vec_safe_length (offload_funcs);
> +	      for (i = 0; i < num_funcs; i++)
> +		{
> +		  if ((*offload_funcs)[i] == old_decl)
> +		    {
> +		      (*offload_funcs)[i] = new_decl;
> +		      break;
> +		    }
> +		  else if ((*offload_funcs)[i] == new_decl)
> +		    break;  /* This can happen due to inlining.  */
> +		}
> +	      gcc_assert (i < num_funcs);
> +#else
> +	      tree old_decl = TREE_OPERAND (gimple_call_arg (gsi_stmt (gsi), 0),
> +					    0);
> +#endif
> +	      /* FIXME: Find a way to actually prevent outputting the empty-body
> +		 old_decl as debug symbol + function in the assembly file.  */

The debug stuff ought to be through DECL_IGNORED_P on the FUNCTION_DECL.
If you want it set just on one side and clear on the other side, perhaps set
or clear it during lto streaming it in in offload lto1?
As for emitting it, perhaps turning it into an external declaration from
definition afterwards?

	Jakub


      reply	other threads:[~2022-08-26  9:53 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-21 10:55 Tobias Burnus
2022-07-21 12:33 ` Tobias Burnus
2022-08-26  9:53   ` Jakub Jelinek [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=YwiYI99rGy+xl/ZJ@tucnak \
    --to=jakub@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=tobias@codesourcery.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).