public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-12] OpenMP: Skip target-nesting warning for reverse offload
@ 2022-07-05  8:10 Tobias Burnus
  0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2022-07-05  8:10 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:d89bf164516d06684f120a42d9f8d351f8e5dd2f

commit d89bf164516d06684f120a42d9f8d351f8e5dd2f
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Tue Jul 5 08:36:42 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.
    
    (cherry picked from commit 47554478a13f64bff1ee4b9bb0319ae63d42ca52)

Diff:
---
 gcc/ChangeLog.omp                                  |  8 +++++++
 gcc/omp-low.cc                                     | 10 ++++++++
 gcc/testsuite/ChangeLog.omp                        |  7 ++++++
 .../c-c++-common/gomp/target-device-ancestor-5.c   | 28 ++++++++++++++++++++++
 4 files changed, 53 insertions(+)

diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index e146e14e6f8..06a194e744c 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,11 @@
+2022-07-05  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backport from mainline:
+	2022-05-17  Tobias Burnus  <tobias@codesourcery.com>
+
+	* omp-low.cc (check_omp_nesting_restrictions): Skip warning for
+	target inside target if inner is reverse offload.
+
 2022-07-04  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backport from mainline:
diff --git a/gcc/omp-low.cc b/gcc/omp-low.cc
index c366fb55c80..adefaa527a7 100644
--- a/gcc/omp-low.cc
+++ b/gcc/omp-low.cc
@@ -4377,6 +4377,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/ChangeLog.omp b/gcc/testsuite/ChangeLog.omp
index 0bfd4f2a3b7..4bd6d97f8a0 100644
--- a/gcc/testsuite/ChangeLog.omp
+++ b/gcc/testsuite/ChangeLog.omp
@@ -1,3 +1,10 @@
+2022-07-05  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backport from mainline:
+	2022-05-17  Tobias Burnus  <tobias@codesourcery.com>
+
+	* c-c++-common/gomp/target-device-ancestor-5.c: New test.
+
 2022-07-04  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backport from mainline:
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'" }  */
+       { }
+
+}


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-05  8:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-05  8:10 [gcc/devel/omp/gcc-12] OpenMP: Skip target-nesting warning for reverse offload Tobias Burnus

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).