]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
OpenMP: Skip target-nesting warning for reverse offload
authorTobias Burnus <tobias@codesourcery.com>
Tue, 17 May 2022 20:09:16 +0000 (22:09 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Tue, 17 May 2022 20:09:16 +0000 (22:09 +0200)
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.

gcc/omp-low.cc
gcc/testsuite/c-c++-common/gomp/target-device-ancestor-5.c [new file with mode: 0644]

index b97e0e950923c1a7d495796b01c9a7a97635c419..c83af6c38656ff901fce6aa794cdf20efa17642c 100644 (file)
@@ -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 (file)
index 0000000..b6ff84b
--- /dev/null
@@ -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'" }  */
+       { }
+
+}