public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tobias Burnus <burnus@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r13-573] OpenMP: Skip target-nesting warning for reverse offload
Date: Tue, 17 May 2022 20:09:53 +0000 (GMT)	[thread overview]
Message-ID: <20220517200953.8115F3858D3C@sourceware.org> (raw)

https://gcc.gnu.org/g:47554478a13f64bff1ee4b9bb0319ae63d42ca52

commit r13-573-g47554478a13f64bff1ee4b9bb0319ae63d42ca52
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Tue May 17 22:09:16 2022 +0200

    OpenMP: Skip target-nesting warning for reverse offload
    
    gcc/ChangeLog:
    
            * omp-low.cc (check_omp_nesting_restrictions): Skip warning for
            target inside target if inner is reverse offload.
    
    gcc/testsuite/ChangeLog:
    
            * c-c++-common/gomp/target-device-ancestor-5.c: New test.

Diff:
---
 gcc/omp-low.cc                                     | 10 ++++++++
 .../c-c++-common/gomp/target-device-ancestor-5.c   | 28 ++++++++++++++++++++++
 2 files changed, 38 insertions(+)

diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc
index b97e0e95092..c83af6c3865 100644
--- a/gcc/omp-low.cc
+++ b/gcc/omp-low.cc
@@ -3883,6 +3883,16 @@ check_omp_nesting_restrictions (gimple *stmt, omp_context *ctx)
 		}
 	      else
 		{
+		  if ((gimple_omp_target_kind (ctx->stmt)
+		       == GF_OMP_TARGET_KIND_REGION)
+		      && (gimple_omp_target_kind (stmt)
+			  == GF_OMP_TARGET_KIND_REGION))
+		    {
+		      c = omp_find_clause (gimple_omp_target_clauses (stmt),
+					   OMP_CLAUSE_DEVICE);
+		      if (c && OMP_CLAUSE_DEVICE_ANCESTOR (c))
+			break;
+		    }
 		  warning_at (gimple_location (stmt), 0,
 			      "%qs construct inside of %qs region",
 			      stmt_name, ctx_stmt_name);
diff --git a/gcc/testsuite/c-c++-common/gomp/target-device-ancestor-5.c b/gcc/testsuite/c-c++-common/gomp/target-device-ancestor-5.c
new file mode 100644
index 00000000000..b6ff84bcdab
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/gomp/target-device-ancestor-5.c
@@ -0,0 +1,28 @@
+#pragma omp requires reverse_offload  /* { dg-message "sorry, unimplemented: 'reverse_offload' clause on 'requires' directive not supported yet" } */
+
+void
+foo ()
+{
+  /* Good nesting - as reverse offload */
+  #pragma omp target
+   #pragma omp target device(ancestor:1)  /* valid -> no warning */   /* { dg-bogus "'target' construct inside of 'target' region" }  */
+    { }
+
+  /* Bad nesting */
+  #pragma omp target
+   #pragma omp target  /* { dg-warning "'target' construct inside of 'target' region" }  */
+     #pragma omp target  /* { dg-warning "'target' construct inside of 'target' region" }  */
+    { }
+
+  /* Good nesting - as reverse offload */
+  #pragma omp target
+   #pragma omp target  /* { dg-warning "'target' construct inside of 'target' region" }  */
+     #pragma omp target device(ancestor:1)  /* valid -> no warning */   /* { dg-bogus "'target' construct inside of 'target' region" }  */
+      { }
+
+  #pragma omp target
+   #pragma omp target device(ancestor:1)  /* valid -> no warning */   /* { dg-bogus "'target' construct inside of 'target' region" }  */
+     #pragma omp target device(ancestor:1) /* { dg-error "OpenMP constructs are not allowed in target region with 'ancestor'" }  */
+       { }
+
+}


                 reply	other threads:[~2022-05-17 20:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220517200953.8115F3858D3C@sourceware.org \
    --to=burnus@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).