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

commit r17-841-ge81952eaad17afd579c6b81667f1828df74db6ed
Author: Tobias Burnus <[email protected]>
Date:   Wed May 27 16:16:05 2026 +0200

    libgomp: Fix ipr_vendor for OpenMP's interop
    
    omp_ipr_vendor and omp_ipr_vendor_name denote the vendor of the
    implementation (GCC / GNU compiler) and not the vendor of the
    foreign runtime (like Nvidia for CUDA or AMD for ROCm/HSA/HIP).
    
    Thus, use 5 / "gnu" per "Additional Definitions" document
    ("1.2 Supported vendor-name Values"), cf.
    https://www.openmp.org/specifications/
    
    [See also OpenMP Spec Issue #4766.]
    
    libgomp/ChangeLog:
    
            * libgomp.texi (Foreign-runtime support for AMD GPUs,
            Foreign-runtime support for Nvdia GPUs): Fix vendor
            value to match compiler not GPU vendor.
            * plugin/plugin-gcn.c (GOMP_OFFLOAD_get_interop_int,
            GOMP_OFFLOAD_get_interop_str): Return 5/"gnu" as ipr_vendor.
            * plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_interop_int,
            GOMP_OFFLOAD_get_interop_str): Likewise.
            * testsuite/libgomp.c/append-args-fr.h: Updated expected
            value.
            * testsuite/libgomp.c/interop-cuda-full.c: Likewise.
            * testsuite/libgomp.c/interop-fr-1.c: Likewise.
            * testsuite/libgomp.c/interop-hip.h: Likewise.
            * testsuite/libgomp.fortran/interop-hip.h: Likewise.

Diff:
---
 libgomp/libgomp.texi                            | 20 ++++++++++----------
 libgomp/plugin/plugin-gcn.c                     |  4 ++--
 libgomp/plugin/plugin-nvptx.c                   |  4 ++--
 libgomp/testsuite/libgomp.c/append-args-fr.h    |  8 ++++----
 libgomp/testsuite/libgomp.c/interop-cuda-full.c |  4 ++--
 libgomp/testsuite/libgomp.c/interop-fr-1.c      |  8 ++++----
 libgomp/testsuite/libgomp.c/interop-hip.h       | 11 +++++------
 libgomp/testsuite/libgomp.fortran/interop-hip.h | 13 ++++---------
 8 files changed, 33 insertions(+), 39 deletions(-)

diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi
index ab937e77b479..7bc313a6fabf 100644
--- a/libgomp/libgomp.texi
+++ b/libgomp/libgomp.texi
@@ -7329,8 +7329,8 @@ Available properties for an HIP interop object:
 @headitem Property          @tab C data type             @tab API routine @tab 
value (if constant)
 @item @code{fr_id}          @tab @code{omp_interop_fr_t} @tab int         @tab 
@code{omp_fr_hip}
 @item @code{fr_name}        @tab @code{const char *}     @tab str         @tab 
@code{"hip"}
-@item @code{vendor}         @tab @code{int}              @tab int         @tab 
@code{1}
-@item @code{vendor_name}    @tab @code{const char *}     @tab str         @tab 
@code{"amd"}
+@item @code{vendor}         @tab @code{int}              @tab int         @tab 
@code{5}
+@item @code{vendor_name}    @tab @code{const char *}     @tab str         @tab 
@code{"gnu"}
 @item @code{device_num}     @tab @code{int}              @tab int         @tab
 @item @code{platform}       @tab N/A                     @tab             @tab
 @item @code{device}         @tab @code{hipDevice_t}      @tab int         @tab
@@ -7345,8 +7345,8 @@ Available properties for an HSA interop object:
 @headitem Property          @tab C data type             @tab API routine @tab 
value (if constant)
 @item @code{fr_id}          @tab @code{omp_interop_fr_t} @tab int         @tab 
@code{omp_fr_hsa}
 @item @code{fr_name}        @tab @code{const char *}     @tab str         @tab 
@code{"hsa"}
-@item @code{vendor}         @tab @code{int}              @tab int         @tab 
@code{1}
-@item @code{vendor_name}    @tab @code{const char *}     @tab str         @tab 
@code{"amd"}
+@item @code{vendor}         @tab @code{int}              @tab int         @tab 
@code{5}
+@item @code{vendor_name}    @tab @code{const char *}     @tab str         @tab 
@code{"gnu"}
 @item @code{device_num}     @tab @code{int}              @tab int         @tab
 @item @code{platform}       @tab N/A                     @tab             @tab
 @item @code{device}         @tab @code{hsa_agent *}      @tab ptr         @tab
@@ -7514,8 +7514,8 @@ Available properties for a CUDA runtime API interop 
object:
 @headitem Property          @tab C data type             @tab API routine @tab 
value (if constant)
 @item @code{fr_id}          @tab @code{omp_interop_fr_t} @tab int         @tab 
@code{omp_fr_cuda}
 @item @code{fr_name}        @tab @code{const char *}     @tab str         @tab 
@code{"cuda"}
-@item @code{vendor}         @tab @code{int}              @tab int         @tab 
@code{11}
-@item @code{vendor_name}    @tab @code{const char *}     @tab str         @tab 
@code{"nvidia"}
+@item @code{vendor}         @tab @code{int}              @tab int         @tab 
@code{5}
+@item @code{vendor_name}    @tab @code{const char *}     @tab str         @tab 
@code{"gnu"}
 @item @code{device_num}     @tab @code{int}              @tab int         @tab
 @item @code{platform}       @tab N/A                     @tab             @tab
 @item @code{device}         @tab @code{int}              @tab int         @tab
@@ -7530,8 +7530,8 @@ Available properties for a CUDA driver API interop object:
 @headitem Property          @tab C data type             @tab API routine @tab 
value (if constant)
 @item @code{fr_id}          @tab @code{omp_interop_fr_t} @tab int         @tab 
@code{omp_fr_cuda_driver}
 @item @code{fr_name}        @tab @code{const char *}     @tab str         @tab 
@code{"cuda_driver"}
-@item @code{vendor}         @tab @code{int}              @tab int         @tab 
@code{11}
-@item @code{vendor_name}    @tab @code{const char *}     @tab str         @tab 
@code{"nvidia"}
+@item @code{vendor}         @tab @code{int}              @tab int         @tab 
@code{5}
+@item @code{vendor_name}    @tab @code{const char *}     @tab str         @tab 
@code{"gnu"}
 @item @code{device_num}     @tab @code{int}              @tab int         @tab
 @item @code{platform}       @tab N/A                     @tab             @tab
 @item @code{device}         @tab @code{CUdevice}         @tab int         @tab
@@ -7546,8 +7546,8 @@ Available properties for an HIP interop object:
 @headitem Property          @tab C data type             @tab API routine @tab 
value (if constant)
 @item @code{fr_id}          @tab @code{omp_interop_fr_t} @tab int         @tab 
@code{omp_fr_hip}
 @item @code{fr_name}        @tab @code{const char *}     @tab str         @tab 
@code{"hip"}
-@item @code{vendor}         @tab @code{int}              @tab int         @tab 
@code{11}
-@item @code{vendor_name}    @tab @code{const char *}     @tab str         @tab 
@code{"nvidia"}
+@item @code{vendor}         @tab @code{int}              @tab int         @tab 
@code{5}
+@item @code{vendor_name}    @tab @code{const char *}     @tab str         @tab 
@code{"gnu"}
 @item @code{device_num}     @tab @code{int}              @tab int         @tab
 @item @code{platform}       @tab N/A                     @tab             @tab
 @item @code{device}         @tab @code{hipDevice_t}      @tab int         @tab
diff --git a/libgomp/plugin/plugin-gcn.c b/libgomp/plugin/plugin-gcn.c
index 32f573f1b7f6..e47d8b2253b8 100644
--- a/libgomp/plugin/plugin-gcn.c
+++ b/libgomp/plugin/plugin-gcn.c
@@ -4998,7 +4998,7 @@ GOMP_OFFLOAD_get_interop_int (struct interop_obj_t *obj,
     case omp_ipr_vendor:
       if (ret_code)
        *ret_code = omp_irc_success;
-      return 1; /* amd */
+      return 5; /* gnu */
     case omp_ipr_vendor_name:
       if (ret_code)
        *ret_code = omp_irc_type_str;
@@ -5166,7 +5166,7 @@ GOMP_OFFLOAD_get_interop_str (struct interop_obj_t *obj,
     case omp_ipr_vendor_name:
       if (ret_code)
        *ret_code = omp_irc_success;
-      return "amd";
+      return "gnu";
     case omp_ipr_device_num:
       if (ret_code)
        *ret_code = omp_irc_type_int;
diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c
index a540e9d4cce8..e1c97a5fa2ed 100644
--- a/libgomp/plugin/plugin-nvptx.c
+++ b/libgomp/plugin/plugin-nvptx.c
@@ -2748,7 +2748,7 @@ GOMP_OFFLOAD_get_interop_int (struct interop_obj_t *obj,
     case omp_ipr_vendor:
       if (ret_code)
        *ret_code = omp_irc_success;
-      return 11; /* nvidia */
+      return 5; /* gnu */
     case omp_ipr_vendor_name:
       if (ret_code)
        *ret_code = omp_irc_type_str;
@@ -2895,7 +2895,7 @@ GOMP_OFFLOAD_get_interop_str (struct interop_obj_t *obj,
     case omp_ipr_vendor_name:
       if (ret_code)
        *ret_code = omp_irc_success;
-      return "nvidia";
+      return "gnu";
     case omp_ipr_device_num:
       if (ret_code)
        *ret_code = omp_irc_type_int;
diff --git a/libgomp/testsuite/libgomp.c/append-args-fr.h 
b/libgomp/testsuite/libgomp.c/append-args-fr.h
index 9f6ca04bbe9e..9c8c9d409f36 100644
--- a/libgomp/testsuite/libgomp.c/append-args-fr.h
+++ b/libgomp/testsuite/libgomp.c/append-args-fr.h
@@ -102,12 +102,12 @@ check_nvptx (omp_interop_t obj, int dev, omp_interop_fr_t 
expected_fr, _Bool is_
   ret_code = omp_irc_no_value;
   int vendor = (int) omp_get_interop_int (obj, omp_ipr_vendor, &ret_code);
   assert (ret_code == omp_irc_success);
-  assert (vendor == 11);  /* Nvidia */
+  assert (vendor == 5);  /* gnu (= compiler vendor) */
 
   ret_code = omp_irc_no_value;
   const char *vendor_name = omp_get_interop_str (obj, omp_ipr_vendor_name, 
&ret_code);
   assert (ret_code == omp_irc_success);
-  assert (strcmp (vendor_name, "nvidia") == 0);
+  assert (strcmp (vendor_name, "gnu") == 0);
 
   ret_code = omp_irc_no_value;
   int dev_num = (int) omp_get_interop_int (obj, omp_ipr_device_num, &ret_code);
@@ -216,12 +216,12 @@ check_gcn (omp_interop_t obj, int dev, omp_interop_fr_t 
expected_fr, _Bool is_ta
   ret_code = omp_irc_no_value;
   int vendor = (int) omp_get_interop_int (obj, omp_ipr_vendor, &ret_code);
   assert (ret_code == omp_irc_success);
-  assert (vendor == 1);  /* Amd */
+  assert (vendor == 5);  /* gnu (= compiler vendor) */
 
   ret_code = omp_irc_no_value;
   const char *vendor_name = omp_get_interop_str (obj, omp_ipr_vendor_name, 
&ret_code);
   assert (ret_code == omp_irc_success);
-  assert (strcmp (vendor_name, "amd") == 0);
+  assert (strcmp (vendor_name, "gnu") == 0);
 
   ret_code = omp_irc_no_value;
   int dev_num = (int) omp_get_interop_int (obj, omp_ipr_device_num, &ret_code);
diff --git a/libgomp/testsuite/libgomp.c/interop-cuda-full.c 
b/libgomp/testsuite/libgomp.c/interop-cuda-full.c
index c48a934978d9..6d3c12b602a7 100644
--- a/libgomp/testsuite/libgomp.c/interop-cuda-full.c
+++ b/libgomp/testsuite/libgomp.c/interop-cuda-full.c
@@ -74,11 +74,11 @@ main ()
 
   ivar = (int) omp_get_interop_int (obj_cuda, omp_ipr_vendor, &res);
   assert (res == omp_irc_success);
-  assert (ivar == 11);
+  assert (ivar == 5);  /* gnu (= compiler vendor) */
 
   ivar = (int) omp_get_interop_int (obj_cuda_driver, omp_ipr_vendor, &res);
   assert (res == omp_irc_success);
-  assert (ivar == 11);
+  assert (ivar == 5);  /* gnu (= compiler vendor) */
 
 
   /* Check whether the omp_ipr_device -> cudaDevice_t yields a valid device.  
*/
diff --git a/libgomp/testsuite/libgomp.c/interop-fr-1.c 
b/libgomp/testsuite/libgomp.c/interop-fr-1.c
index 9310c95644ef..5a139ac2a8af 100644
--- a/libgomp/testsuite/libgomp.c/interop-fr-1.c
+++ b/libgomp/testsuite/libgomp.c/interop-fr-1.c
@@ -271,12 +271,12 @@ check_nvptx (int dev)
       ret_code = omp_irc_no_value;
       int vendor = (int) omp_get_interop_int (obj, omp_ipr_vendor, &ret_code);
       assert (ret_code == omp_irc_success);
-      assert (vendor == 11);  /* Nvidia */
+      assert (vendor == 5);  /* gnu (= compiler vendor) */
 
       ret_code = omp_irc_no_value;
       const char *vendor_name = omp_get_interop_str (obj, omp_ipr_vendor_name, 
&ret_code);
       assert (ret_code == omp_irc_success);
-      assert (strcmp (vendor_name, "nvidia") == 0);
+      assert (strcmp (vendor_name, "gnu") == 0);
 
       ret_code = omp_irc_no_value;
       int dev_num = (int) omp_get_interop_int (obj, omp_ipr_device_num, 
&ret_code);
@@ -464,12 +464,12 @@ check_gcn (int dev)
       ret_code = omp_irc_no_value;
       int vendor = (int) omp_get_interop_int (obj, omp_ipr_vendor, &ret_code);
       assert (ret_code == omp_irc_success);
-      assert (vendor == 1);  /* Amd */
+      assert (vendor == 5);  /* gnu (= compiler vendor) */
 
       ret_code = omp_irc_no_value;
       const char *vendor_name = omp_get_interop_str (obj, omp_ipr_vendor_name, 
&ret_code);
       assert (ret_code == omp_irc_success);
-      assert (strcmp (vendor_name, "amd") == 0);
+      assert (strcmp (vendor_name, "gnu") == 0);
 
       ret_code = omp_irc_no_value;
       int dev_num = (int) omp_get_interop_int (obj, omp_ipr_device_num, 
&ret_code);
diff --git a/libgomp/testsuite/libgomp.c/interop-hip.h 
b/libgomp/testsuite/libgomp.c/interop-hip.h
index 20a1ccb78fb2..a35bd1af67e6 100644
--- a/libgomp/testsuite/libgomp.c/interop-hip.h
+++ b/libgomp/testsuite/libgomp.c/interop-hip.h
@@ -169,16 +169,15 @@ main ()
 
   ivar = (int) omp_get_interop_int (obj, omp_ipr_vendor, &res);
   assert (res == omp_irc_success);
-  int vendor_is_amd = ivar == 1;
+  assert (ivar == 5);  /* gnu (= compiler vendor) */
   #if defined(__HIP_PLATFORM_AMD__)
-    assert (ivar == 1);
+    bool device_vendor_is_amd = true;
   #elif defined(__HIP_PLATFORM_NVIDIA__)
-    assert (ivar == 11);
+    bool device_vendor_is_amd = false;
   #else
-    assert (0);
+    #error "Missing valid __HIP_PLATFORM_..."
   #endif
 
-
   /* Check whether the omp_ipr_device -> hipDevice_t yields a valid device.  */
 
   hipDevice_t hip_dev = (int) omp_get_interop_int (obj, omp_ipr_device, &res);
@@ -207,7 +206,7 @@ main ()
     hip_err = hipCtxGetApiVersion (hip_ctx, &ivar);
   #pragma GCC diagnostic pop
 
-  if (vendor_is_amd)
+  if (device_vendor_is_amd)
     assert (hip_err == hipErrorNotSupported && ivar == -99);
   else
     {
diff --git a/libgomp/testsuite/libgomp.fortran/interop-hip.h 
b/libgomp/testsuite/libgomp.fortran/interop-hip.h
index 753ccce5fd7d..b22c7dec4962 100644
--- a/libgomp/testsuite/libgomp.fortran/interop-hip.h
+++ b/libgomp/testsuite/libgomp.fortran/interop-hip.h
@@ -120,17 +120,12 @@ program main
   if (fr /= omp_ifr_hip) error stop 1
 
   ivar = omp_get_interop_int (obj, omp_ipr_vendor, res)
-  if (ivar == 1) then  ! AMD
-    vendor_is_amd = .true.
-  else if (ivar == 11) then  ! Nvidia
-    vendor_is_amd = .false.
-  else
-    error stop 1  ! Unknown
-  endif
+  if (res /= omp_irc_success) error stop 1
+  if (ivar /= 5) error stop 1  ! gnu (= compiler vendor)
 #if USE_CUDA_NAMES
-  if (vendor_is_amd) error stop 1
+    vendor_is_amd = .false.
 #else
-  if (.not. vendor_is_amd) error stop 1
+    vendor_is_amd = .true.
 #endif
 
   ! Check whether the omp_ipr_device -> hipDevice_t yields a valid device.

Reply via email to