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

commit r17-6046-gbccef7957b593def5fbe481588764d31f3922e52
Author: Thomas Schwinge <[email protected]>
Date:   Mon Nov 9 09:18:25 2026 +0100

    libgomp: Add omp_{s,g}et_device_{num_teams,teams_thread_limit}: Adjust 
'libgomp.c-c++-common/teams-nteams-icv-1.c'
    
    After commit 00513d11fb2b5a6b9a036ff3cb170e06e78ca18b
    "libgomp: Add omp_{s,g}et_device_{num_teams,teams_thread_limit}",
    I saw all testing with code offloading enabled regress:
    
        PASS: libgomp.c/../libgomp.c-c++-common/teams-nteams-icv-4.c (test for 
excess errors)
        [-PASS:-]{+FAIL:+} 
libgomp.c/../libgomp.c-c++-common/teams-nteams-icv-4.c execution test
    
        PASS: libgomp.c++/../libgomp.c-c++-common/teams-nteams-icv-4.c (test 
for excess errors)
        [-PASS:-]{+FAIL:+} 
libgomp.c++/../libgomp.c-c++-common/teams-nteams-icv-4.c execution test
    
    ..., and on a system with two GPUs, additionally:
    
        PASS: libgomp.c/../libgomp.c-c++-common/teams-nteams-icv-2.c (test for 
excess errors)
        [-PASS:-]{+FAIL:+} 
libgomp.c/../libgomp.c-c++-common/teams-nteams-icv-2.c execution test
    
        PASS: libgomp.c++/../libgomp.c-c++-common/teams-nteams-icv-2.c (test 
for excess errors)
        [-PASS:-]{+FAIL:+} 
libgomp.c++/../libgomp.c-c++-common/teams-nteams-icv-2.c execution test
    
    ..., and:
    
        PASS: libgomp.c/../libgomp.c-c++-common/teams-nteams-icv-3.c (test for 
excess errors)
        [-PASS:-]{+FAIL:+} 
libgomp.c/../libgomp.c-c++-common/teams-nteams-icv-3.c execution test
    
        PASS: libgomp.c++/../libgomp.c-c++-common/teams-nteams-icv-3.c (test 
for excess errors)
        [-PASS:-]{+FAIL:+} 
libgomp.c++/../libgomp.c-c++-common/teams-nteams-icv-3.c execution test
    
    Have to adjust the underlying 'libgomp.c-c++-common/teams-nteams-icv-1.c' in
    the same way as other test cases had gotten adjusted in the aforementioned
    commit.
    
            libgomp/
            * testsuite/libgomp.c-c++-common/teams-nteams-icv-1.c: Change from
            invalid ICV setting on the device to setting it on the host.

Diff:
---
 .../testsuite/libgomp.c-c++-common/teams-nteams-icv-1.c   | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/libgomp/testsuite/libgomp.c-c++-common/teams-nteams-icv-1.c 
b/libgomp/testsuite/libgomp.c-c++-common/teams-nteams-icv-1.c
index c3c21091e970..afbe3f4524fe 100644
--- a/libgomp/testsuite/libgomp.c-c++-common/teams-nteams-icv-1.c
+++ b/libgomp/testsuite/libgomp.c-c++-common/teams-nteams-icv-1.c
@@ -147,8 +147,19 @@ main ()
   /* For each device, including host fallback.  */
   for (int dev = 0; dev <= omp_get_num_devices (); dev++)
     {
-      #pragma omp target device(dev) firstprivate(dev)
-       omp_set_num_teams (7 + dev);
+      /* The following is required per OpenMP semantic:
+
+        An omp_set_num_teams region must be a strictly nested region of the
+        implicit parallel region that surrounds the whole OpenMP program.
+
+        That's not the case inside 'target' and GCC fails unless the device 
ICVs
+        are copied back to the host at the beginning or end of GOMP_target_ext.
+
+        Hence set it on the host:  */
+
+      omp_set_device_num_teams (7 + dev, dev);
+      // #pragma omp target device(dev) firstprivate(dev)
+       // invalid: omp_set_num_teams (7 + dev);
 
       #pragma omp target device(dev) map(from: nteams)
        nteams = omp_get_max_teams ();

Reply via email to