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

commit r15-9730-gcf619d4a366ad428421fdb7ad617b4749799cf93
Author: Tobias Burnus <tbur...@baylibre.com>
Date:   Fri May 23 11:30:48 2025 +0200

    libgomp.c-c++-common/metadirective-1.c: Expect 'error:' for nvptx compile 
[PR118694]
    
    OpenMP's 'target teams' is strictly coupled with 'teams'; if the latter
    exists, the kernel is launched in directly with multiple teams. Thus,
    the host has to know whether the teams construct exists or not. For
    
       #pragma omp target
         #pragma omp metadirective when (device={arch("nvptx")}: teams loop)
    
    it is simple when 'nvptx' offloading is not supported, otherwise it depends
    on the default device at runtime as the user code asks for a single team for
    host fallback and gcn offload and multiple for nvptx offload.
    
    In any case, this commit ensures that no FAIL is printed, whatever a
    future solution might look like. Instead of a dg-bogus combined with an
    'xfail offload_target_nvptx', one an also argue that a dg-error for
    'target offload_target_nvptx' would be more appropriate.
    
    libgomp/ChangeLog:
    
            PR middle-end/118694
            * testsuite/libgomp.c-c++-common/metadirective-1.c: xfail when
            compiling (also) for nvptx offloading as an error is then expected.
    
    (cherry picked from commit b3d07ec7ac2ccd935a79b29e1a0e2eb16225286a)

Diff:
---
 libgomp/testsuite/libgomp.c-c++-common/metadirective-1.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/libgomp/testsuite/libgomp.c-c++-common/metadirective-1.c 
b/libgomp/testsuite/libgomp.c-c++-common/metadirective-1.c
index a57d6fd56714..fbe4ac3a954e 100644
--- a/libgomp/testsuite/libgomp.c-c++-common/metadirective-1.c
+++ b/libgomp/testsuite/libgomp.c-c++-common/metadirective-1.c
@@ -1,4 +1,5 @@
-/* { dg-do run } */
+/* { dg-do run { target { ! offload_target_nvptx } } } */
+/* { dg-do compile { target offload_target_nvptx } } */
 
 #define N 100
 
@@ -7,12 +8,17 @@ f (int x[], int y[], int z[])
 {
   int i;
 
+  // The following fails as on the host the target side cannot be
+  // resolved - and the 'teams' or not status affects how 'target'
+  // is called.
+  // Note also the dg-do compile above for offload_target_nvptx
   #pragma omp target map(to: x[0:N], y[0:N]) map(from: z[0:N])
     #pragma omp metadirective \
        when (device={arch("nvptx")}: teams loop) \
        default (parallel loop)
       for (i = 0; i < N; i++)
        z[i] = x[i] * y[i];
+  /* { dg-bogus "'target' construct with nested 'teams' construct contains 
directives outside of the 'teams' construct" "PR118694" { xfail 
offload_target_nvptx } .-6 }  */
 }
 
 int

Reply via email to