public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tobias Burnus <tobias@codesourcery.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>,
	Jakub Jelinek <jakub@redhat.com>,
	Andrew Stubbs <ams@codesourcery.com>
Subject: Re: [Patch] libgomp: enable reverse offload for AMDGCN
Date: Thu, 2 Feb 2023 15:59:43 +0100	[thread overview]
Message-ID: <e83c3329-2233-0155-6e19-0e7eac8b06bc@codesourcery.com> (raw)
In-Reply-To: <aaf61c75-5fda-58ac-8921-bf27dda19c8e@codesourcery.com>

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

Maybe it becomes better reviewable with an attached patch ...

On 02.02.23 15:31, Tobias Burnus wrote:
> Now that the stack handling has been changed for AMDGCN, this patch
> enables reverse offload.
> (cf. today's "[committed] amdgcn, libgomp: Manually allocated stacks"
> patch email/commit
> by Andrew).
>
> Any comments, suggestions?
>
> Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955

[-- Attachment #2: gcn-offload-v2.diff --]
[-- Type: text/x-patch, Size: 2618 bytes --]

libgomp: enable reverse offload for AMDGCN

libgomp/ChangeLog:

	* libgomp.texi (5.0 Impl. Status, gcn specifics): Update for
	reverse offload.
	* plugin/plugin-gcn.c (GOMP_OFFLOAD_get_num_devices): Accept
	reverse-offload requirement.

 libgomp/libgomp.texi        | 13 ++++++++-----
 libgomp/plugin/plugin-gcn.c |  3 ++-
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi
index 1f84b050eb2..698ae330942 100644
--- a/libgomp/libgomp.texi
+++ b/libgomp/libgomp.texi
@@ -227,8 +227,7 @@ The OpenMP 4.5 specification is fully supported.
 @item @code{allocate} directive @tab N @tab
 @item @code{allocate} clause @tab P @tab Initial support
 @item @code{use_device_addr} clause on @code{target data} @tab Y @tab
-@item @code{ancestor} modifier on @code{device} clause
-      @tab Y @tab Host fallback with GCN devices
+@item @code{ancestor} modifier on @code{device} clause @tab Y @tab
 @item Implicit declare target directive @tab Y @tab
 @item Discontiguous array section with @code{target update} construct
       @tab N @tab
@@ -4455,9 +4454,13 @@ The implementation remark:
 @item I/O within OpenMP target regions and OpenACC parallel/kernels is supported
       using the C library @code{printf} functions and the Fortran
       @code{print}/@code{write} statements.
-@item OpenMP code that has a requires directive with @code{unified_address},
-      @code{unified_shared_memory} or @code{reverse_offload} will remove
-      any GCN device from the list of available devices (``host fallback'').
+@item Reverse offload (i.e. @code{target} regions with
+      @code{device(ancestor:1)}) are processed serially per @code{target} region
+      such that the next reverse offload region is only executed after the previous
+      one returned.
+@item OpenMP code that has a requires directive with @code{unified_address} or
+      @code{unified_shared_memory} will remove any GCN device from the list of
+      available devices (``host fallback'').
 @end itemize
 
 
diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
index a7b35059ab3..11ce6b0fa8d 100644
--- a/libgomp/plugin/plugin-gcn.c
+++ b/libgomp/plugin/plugin-gcn.c
@@ -3262,7 +3262,8 @@ GOMP_OFFLOAD_get_num_devices (unsigned int omp_requires_mask)
     return 0;
   /* Return -1 if no omp_requires_mask cannot be fulfilled but
      devices were present.  */
-  if (hsa_context.agent_count > 0 && omp_requires_mask != 0)
+  if (hsa_context.agent_count > 0
+      && (omp_requires_mask & ~GOMP_REQUIRES_REVERSE_OFFLOAD) != 0)
     return -1;
   return hsa_context.agent_count;
 }

  reply	other threads:[~2023-02-02 14:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-02 14:31 Tobias Burnus
2023-02-02 14:59 ` Tobias Burnus [this message]
2023-02-02 15:25   ` Andrew Stubbs

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=e83c3329-2233-0155-6e19-0e7eac8b06bc@codesourcery.com \
    --to=tobias@codesourcery.com \
    --cc=ams@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.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).