https://gcc.gnu.org/g:9d130c58afb445def5afec0238b9e034397aee9a

commit r17-6525-g9d130c58afb445def5afec0238b9e034397aee9a
Author: Thomas Schwinge <[email protected]>
Date:   Wed Nov 11 10:50:37 2026 +0100

    libgomp NVIDIA GPU plugin: Require NVIDIA/CUDA Driver version 340 or newer
    
    The NVIDIA/CUDA Driver version 340 was released one decade ago.  Require 
that
    version or newer.
    
            libgomp/
            * plugin/plugin-nvptx.c: Require NVIDIA/CUDA Driver version 340 or
            newer.
            * plugin/cuda-lib.def: Adjust.

Diff:
---
 libgomp/plugin/cuda-lib.def   |  8 ++----
 libgomp/plugin/plugin-nvptx.c | 65 ++++++-------------------------------------
 2 files changed, 12 insertions(+), 61 deletions(-)

diff --git a/libgomp/plugin/cuda-lib.def b/libgomp/plugin/cuda-lib.def
index fc96642c5aae..54c47bb49129 100644
--- a/libgomp/plugin/cuda-lib.def
+++ b/libgomp/plugin/cuda-lib.def
@@ -10,7 +10,7 @@ CUDA_ONE_CALL (cuDeviceGet)
 CUDA_ONE_CALL (cuDeviceGetAttribute)
 CUDA_ONE_CALL (cuDeviceGetCount)
 CUDA_ONE_CALL (cuDeviceGetName)
-CUDA_ONE_CALL_MAYBE_NULL (cuDeviceGetPCIBusId)
+CUDA_ONE_CALL (cuDeviceGetPCIBusId)
 CUDA_ONE_CALL_MAYBE_NULL (cuDeviceGetUuid)
 CUDA_ONE_CALL_MAYBE_NULL (cuDeviceGetUuid_v2)
 CUDA_ONE_CALL (cuDeviceTotalMem)
@@ -22,14 +22,12 @@ CUDA_ONE_CALL (cuEventQuery)
 CUDA_ONE_CALL (cuEventRecord)
 CUDA_ONE_CALL (cuEventSynchronize)
 CUDA_ONE_CALL (cuFuncGetAttribute)
-CUDA_ONE_CALL_MAYBE_NULL (cuGetErrorString)
+CUDA_ONE_CALL (cuGetErrorString)
 CUDA_ONE_CALL (cuInit)
 CUDA_ONE_CALL (cuLaunchKernel)
 CUDA_ONE_CALL (cuLinkAddData)
-CUDA_ONE_CALL_MAYBE_NULL (cuLinkAddData_v2)
 CUDA_ONE_CALL (cuLinkComplete)
 CUDA_ONE_CALL (cuLinkCreate)
-CUDA_ONE_CALL_MAYBE_NULL (cuLinkCreate_v2)
 CUDA_ONE_CALL (cuLinkDestroy)
 CUDA_ONE_CALL (cuMemAlloc)
 CUDA_ONE_CALL (cuMemAllocHost)
@@ -55,7 +53,7 @@ CUDA_ONE_CALL (cuModuleGetGlobal)
 CUDA_ONE_CALL (cuModuleLoad)
 CUDA_ONE_CALL (cuModuleLoadData)
 CUDA_ONE_CALL (cuModuleUnload)
-CUDA_ONE_CALL_MAYBE_NULL (cuOccupancyMaxPotentialBlockSize)
+CUDA_ONE_CALL (cuOccupancyMaxPotentialBlockSize)
 CUDA_ONE_CALL (cuPointerGetAttribute)
 CUDA_ONE_CALL (cuStreamAddCallback)
 CUDA_ONE_CALL (cuStreamCreate)
diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c
index 31e11d7e0d59..52d647c99bf2 100644
--- a/libgomp/plugin/plugin-nvptx.c
+++ b/libgomp/plugin/plugin-nvptx.c
@@ -76,12 +76,6 @@ static void* create_target_indirect_map (size_t *, size_t,
 
 #if CUDA_VERSION < 8000
 # error "Compile against CUDA 8.0 or newer"
-#else
-#undef cuLinkCreate
-#undef cuLinkAddData
-CUresult cuLinkAddData (CUlinkState, CUjitInputType, void *, size_t,
-                       const char *, unsigned, CUjit_option *, void **);
-CUresult cuLinkCreate (unsigned, CUjit_option *, void **, CUlinkState *);
 #endif
 
 #define DO_PRAGMA(x) _Pragma (#x)
@@ -196,9 +190,6 @@ cuda_error (CUresult r)
   const char *fallback = "unknown cuda error";
   const char *desc;
 
-  if (!CUDA_CALL_EXISTS (cuGetErrorString))
-    return fallback;
-
   r = CUDA_CALL_NOCHECK (cuGetErrorString, r, &desc);
   if (r == CUDA_SUCCESS)
     return desc;
@@ -515,19 +506,8 @@ nvptx_open_device (int n)
                  &pi, CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK, dev);
   ptx_dev->regs_per_block = pi;
 
-  /* CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR is defined only
-     in CUDA 6.0 and newer.  */
-  r = CUDA_CALL_NOCHECK (cuDeviceGetAttribute, &pi,
-                        CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR,
-                        dev);
-  /* Fallback: use limit of registers per block, which is usually equal.  */
-  if (r == CUDA_ERROR_INVALID_VALUE)
-    pi = ptx_dev->regs_per_block;
-  else if (r != CUDA_SUCCESS)
-    {
-      GOMP_PLUGIN_error ("cuDeviceGetAttribute error: %s", cuda_error (r));
-      return NULL;
-    }
+  CUDA_CALL_ERET (NULL, cuDeviceGetAttribute,
+                 &pi, CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_MULTIPROCESSOR, 
dev);
   ptx_dev->regs_per_sm = pi;
 
   CUDA_CALL_ERET (NULL, cuDeviceGetAttribute,
@@ -779,24 +759,16 @@ link_ptx (CUmodule *module, const struct targ_ptx_obj 
*ptx_objs,
       nopts++;
     }
 
-  if (CUDA_CALL_EXISTS (cuLinkCreate_v2))
-    CUDA_CALL (cuLinkCreate_v2, nopts, opts, optvals, &linkstate);
-  else
-    CUDA_CALL (cuLinkCreate, nopts, opts, optvals, &linkstate);
+  CUDA_CALL (cuLinkCreate, nopts, opts, optvals, &linkstate);
 
   for (; num_objs--; ptx_objs++)
     {
       /* cuLinkAddData's 'data' argument erroneously omits the const
         qualifier.  */
       GOMP_PLUGIN_debug (0, "Loading:\n---\n%s\n---\n", ptx_objs->code);
-      if (CUDA_CALL_EXISTS (cuLinkAddData_v2))
-       r = CUDA_CALL_NOCHECK (cuLinkAddData_v2, linkstate, CU_JIT_INPUT_PTX,
-                              (char *) ptx_objs->code, ptx_objs->size,
-                              0, 0, 0, 0);
-      else
-       r = CUDA_CALL_NOCHECK (cuLinkAddData, linkstate, CU_JIT_INPUT_PTX,
-                              (char *) ptx_objs->code, ptx_objs->size,
-                              0, 0, 0, 0);
+      r = CUDA_CALL_NOCHECK (cuLinkAddData, linkstate, CU_JIT_INPUT_PTX,
+                            (char *) ptx_objs->code, ptx_objs->size,
+                            0, 0, 0, 0);
       if (r != CUDA_SUCCESS)
        {
          GOMP_PLUGIN_error ("Link error log %s\n", &elog[0]);
@@ -939,24 +911,7 @@ nvptx_exec (void (*fn), unsigned *dims, void 
*targ_mem_desc,
        for (i = 0; i != GOMP_DIM_MAX; i++)
          default_dim_p[i] = !dims[i];
 
-       if (!CUDA_CALL_EXISTS (cuOccupancyMaxPotentialBlockSize))
-         {
-           for (i = 0; i != GOMP_DIM_MAX; i++)
-             if (default_dim_p[i])
-               dims[i] = nvthd->ptx_dev->default_dims[i];
-
-           if (default_dim_p[GOMP_DIM_VECTOR])
-             dims[GOMP_DIM_VECTOR]
-               = MIN (dims[GOMP_DIM_VECTOR],
-                      (targ_fn->max_threads_per_block / warp_size
-                       * warp_size));
-
-           if (default_dim_p[GOMP_DIM_WORKER])
-             dims[GOMP_DIM_WORKER]
-               = MIN (dims[GOMP_DIM_WORKER],
-                      targ_fn->max_threads_per_block / dims[GOMP_DIM_VECTOR]);
-         }
-       else
+       if (true)
          {
            /* Handle the case that the compiler allows the runtime to choose
               the vector-length conservatively, by ignoring
@@ -1344,7 +1299,6 @@ GOMP_OFFLOAD_get_uid (int ord)
 int
 GOMP_OFFLOAD_get_numa_node (int ord)
 {
-  CUresult r = CUDA_ERROR_NOT_FOUND;
   char bus_id[14] = {};
   struct ptx_device *dev = ptx_devices[ord];
 
@@ -1354,9 +1308,8 @@ GOMP_OFFLOAD_get_numa_node (int ord)
 
   dev->numa_node = -1;
 
-  if (CUDA_CALL_EXISTS (cuDeviceGetPCIBusId))
-    r = CUDA_CALL_NOCHECK (cuDeviceGetPCIBusId, bus_id, sizeof (bus_id)-1,
-                          dev->dev);
+  CUresult r = CUDA_CALL_NOCHECK (cuDeviceGetPCIBusId,
+                                 bus_id, sizeof (bus_id)-1, dev->dev);
   if (bus_id[0] == '\0' || r != CUDA_SUCCESS)
     return -1;

Reply via email to