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

commit e24ff9e5b25d9ddccf4619a48448631d8f7b9174
Author: Andrew Stubbs <[email protected]>
Date:   Thu Oct 23 11:51:08 2025 +0000

    Revert "libgomp, nvptx: Cuda pinned memory"
    
    This reverts commit 86086c93cddee91aa5a5deda1f1a0ade0d868d66.

Diff:
---
 libgomp/config/linux/allocator.c             | 141 +++++++--------------------
 libgomp/libgomp-plugin.h                     |   2 -
 libgomp/libgomp.h                            |   4 -
 libgomp/libgomp.texi                         |  11 +--
 libgomp/libgomp_g.h                          |   1 -
 libgomp/plugin/plugin-nvptx.c                |  42 --------
 libgomp/target.c                             | 136 --------------------------
 libgomp/testsuite/libgomp.c/alloc-pinned-1.c |  26 -----
 libgomp/testsuite/libgomp.c/alloc-pinned-2.c |  26 -----
 libgomp/testsuite/libgomp.c/alloc-pinned-3.c |  45 ++-------
 libgomp/testsuite/libgomp.c/alloc-pinned-4.c |  44 +--------
 libgomp/testsuite/libgomp.c/alloc-pinned-5.c |  26 -----
 libgomp/testsuite/libgomp.c/alloc-pinned-6.c |  34 +------
 13 files changed, 50 insertions(+), 488 deletions(-)

diff --git a/libgomp/config/linux/allocator.c b/libgomp/config/linux/allocator.c
index 06b38cc2c6ea..0138d3fa517a 100644
--- a/libgomp/config/linux/allocator.c
+++ b/libgomp/config/linux/allocator.c
@@ -36,11 +36,6 @@
 
 /* Implement malloc routines that can handle pinned memory on Linux.
    
-   Given that pinned memory is typically used to help host <-> device memory
-   transfers, we attempt to allocate such memory using a device (really:
-   libgomp plugin), but fall back to mmap plus mlock if no suitable device is
-   available.
-
    It's possible to use mlock on any heap memory, but using munlock is
    problematic if there are multiple pinned allocations on the same page.
    Tracking all that manually would be possible, but adds overhead. This may
@@ -54,7 +49,6 @@
 #define _GNU_SOURCE
 #include <sys/mman.h>
 #include <string.h>
-#include <assert.h>
 #include "libgomp.h"
 #ifdef HAVE_INTTYPES_H
 # include <inttypes.h>  /* For PRIu64.  */
@@ -74,92 +68,50 @@ GOMP_enable_pinned_mode ()
     always_pinned_mode = true;
 }
 
-static int using_device_for_page_locked
-  = /* uninitialized */ -1;
-
 static void *
-linux_memspace_alloc (omp_memspace_handle_t memspace, size_t size, int pin,
-                     bool init0)
+linux_memspace_alloc (omp_memspace_handle_t memspace, size_t size, int pin)
 {
-  gomp_debug (0, "%s: memspace=%llu, size=%llu, pin=%d, init0=%d\n",
-             __FUNCTION__, (unsigned long long) memspace,
-             (unsigned long long) size, pin, init0);
-
-  void *addr;
+  (void)memspace;
 
   /* Explicit pinning may not be required.  */
   pin = pin && !always_pinned_mode;
 
   if (pin)
     {
-      int using_device
-       = __atomic_load_n (&using_device_for_page_locked,
-                          MEMMODEL_RELAXED);
-      gomp_debug (0, "  using_device=%d\n",
-                 using_device);
-      if (using_device != 0)
-       {
-         using_device = gomp_page_locked_host_alloc (&addr, size);
-         int using_device_old
-           = __atomic_exchange_n (&using_device_for_page_locked,
-                                  using_device, MEMMODEL_RELAXED);
-         gomp_debug (0, "  using_device=%d, using_device_old=%d\n",
-                     using_device, using_device_old);
-         assert (using_device_old == -1
-                 /* We shouldn't have concurrently changed our mind.  */
-                 || using_device_old == using_device);
-       }
-      if (using_device == 0)
-       {
-         gomp_debug (0, "  mmap\n");
-         addr = mmap (NULL, size, PROT_READ | PROT_WRITE,
-                      MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
-         if (addr == MAP_FAILED)
-           addr = NULL;
-         else
-           {
-             /* 'mmap' zero-initializes.  */
-             init0 = false;
+      /* Note that mmap always returns zeroed memory and is therefore also a
+        suitable implementation of calloc.  */
+      void *addr = mmap (NULL, size, PROT_READ | PROT_WRITE,
+                        MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+      if (addr == MAP_FAILED)
+       return NULL;
 
-             gomp_debug (0, "  mlock\n");
-             if (mlock (addr, size))
-               {
+      if (mlock (addr, size))
+       {
 #ifdef HAVE_INTTYPES_H
-                 gomp_debug (0, "libgomp: failed to pin %"PRIu64" bytes of"
-                             " memory (ulimit too low?)\n", (uint64_t) size);
+         gomp_debug (0, "libgomp: failed to pin %"PRIu64" bytes of"
+                     " memory (ulimit too low?)\n", (uint64_t) size);
 #else
-                 gomp_debug (0, "libgomp: failed to pin %lu bytes of memory"
-                             " (ulimit too low?)\n", (unsigned long) size);
+         gomp_debug (0, "libgomp: failed to pin %lu bytes of"
+                     " memory (ulimit too low?)\n", (unsigned long) size);
 #endif
-                 munmap (addr, size);
-                 addr = NULL;
-               }
-           }
+         munmap (addr, size);
+         return NULL;
        }
-    }
-  else
-    addr = malloc (size);
 
-  if (addr && init0)
-    {
-      gomp_debug (0, "  init0\n");
-      memset (addr, 0, size);
+      return addr;
     }
-
-  return addr;
+  else
+    return malloc (size);
 }
 
 static void *
 linux_memspace_calloc (omp_memspace_handle_t memspace, size_t size, int pin)
 {
-  gomp_debug (0, "%s: memspace=%llu, size=%llu, pin=%d\n",
-             __FUNCTION__, (unsigned long long) memspace, (unsigned long long) 
size, pin);
-
   /* Explicit pinning may not be required.  */
   pin = pin && !always_pinned_mode;
 
   if (pin)
-    return linux_memspace_alloc (memspace, size, pin, true);
+    return linux_memspace_alloc (memspace, size, pin);
   else
     return calloc (1, size);
 }
@@ -168,25 +120,13 @@ static void
 linux_memspace_free (omp_memspace_handle_t memspace, void *addr, size_t size,
                     int pin)
 {
-  gomp_debug (0, "%s: memspace=%llu, addr=%p, size=%llu, pin=%d\n",
-             __FUNCTION__, (unsigned long long) memspace, addr, (unsigned long 
long) size, pin);
+  (void)memspace;
 
   /* Explicit pinning may not be required.  */
   pin = pin && !always_pinned_mode;
 
   if (pin)
-    {
-      int using_device
-       = __atomic_load_n (&using_device_for_page_locked,
-                          MEMMODEL_RELAXED);
-      gomp_debug (0, "  using_device=%d\n",
-                 using_device);
-      if (using_device == 1)
-       gomp_page_locked_host_free (addr);
-      else
-       /* 'munlock'ing is implicit with following 'munmap'.  */
-       munmap (addr, size);
-    }
+    munmap (addr, size);
   else
     free (addr);
 }
@@ -195,25 +135,11 @@ static void *
 linux_memspace_realloc (omp_memspace_handle_t memspace, void *addr,
                        size_t oldsize, size_t size, int oldpin, int pin)
 {
-  gomp_debug (0, "%s: memspace=%llu, addr=%p, oldsize=%llu, size=%llu, 
oldpin=%d, pin=%d\n",
-             __FUNCTION__, (unsigned long long) memspace, addr, (unsigned long 
long) oldsize, (unsigned long long) size, oldpin, pin);
-
   /* Explicit pinning may not be required.  */
   pin = pin && !always_pinned_mode;
 
   if (oldpin && pin)
     {
-      /* We can only expect to be able to just 'mremap' if not using a device
-        for page-locked memory.  */
-      int using_device
-       = __atomic_load_n (&using_device_for_page_locked,
-                      MEMMODEL_RELAXED);
-      gomp_debug (0, "  using_device=%d\n",
-                 using_device);
-      if (using_device != 0)
-       goto manual_realloc;
-
-      gomp_debug (0, "  mremap\n");
       void *newaddr = mremap (addr, oldsize, size, MREMAP_MAYMOVE);
       if (newaddr == MAP_FAILED)
        return NULL;
@@ -221,19 +147,18 @@ linux_memspace_realloc (omp_memspace_handle_t memspace, 
void *addr,
       return newaddr;
     }
   else if (oldpin || pin)
-    goto manual_realloc;
-  else
-    return realloc (addr, size);
-
-manual_realloc:;
-  void *newaddr = linux_memspace_alloc (memspace, size, pin, false);
-  if (newaddr)
     {
-      memcpy (newaddr, addr, oldsize < size ? oldsize : size);
-      linux_memspace_free (memspace, addr, oldsize, oldpin);
-    }
+      void *newaddr = linux_memspace_alloc (memspace, size, pin);
+      if (newaddr)
+       {
+         memcpy (newaddr, addr, oldsize < size ? oldsize : size);
+         linux_memspace_free (memspace, addr, oldsize, oldpin);
+       }
 
-  return newaddr;
+      return newaddr;
+    }
+  else
+    return realloc (addr, size);
 }
 
 static int
@@ -244,7 +169,7 @@ linux_memspace_validate (omp_memspace_handle_t, unsigned, 
int)
 }
 
 #define MEMSPACE_ALLOC(MEMSPACE, SIZE, PIN) \
-  linux_memspace_alloc (MEMSPACE, SIZE, PIN, false)
+  linux_memspace_alloc (MEMSPACE, SIZE, PIN)
 #define MEMSPACE_CALLOC(MEMSPACE, SIZE, PIN) \
   linux_memspace_calloc (MEMSPACE, SIZE, PIN)
 #define MEMSPACE_REALLOC(MEMSPACE, ADDR, OLDSIZE, SIZE, OLDPIN, PIN) \
diff --git a/libgomp/libgomp-plugin.h b/libgomp/libgomp-plugin.h
index d0bcc237d7fe..dbfc62216122 100644
--- a/libgomp/libgomp-plugin.h
+++ b/libgomp/libgomp-plugin.h
@@ -167,8 +167,6 @@ extern int GOMP_OFFLOAD_load_image (int, unsigned, const 
void *,
 extern bool GOMP_OFFLOAD_unload_image (int, unsigned, const void *);
 extern void *GOMP_OFFLOAD_alloc (int, size_t);
 extern bool GOMP_OFFLOAD_free (int, void *);
-extern bool GOMP_OFFLOAD_page_locked_host_alloc (void **, size_t);
-extern bool GOMP_OFFLOAD_page_locked_host_free (void *);
 extern bool GOMP_OFFLOAD_dev2host (int, void *, const void *, size_t);
 extern bool GOMP_OFFLOAD_host2dev (int, void *, const void *, size_t);
 extern bool GOMP_OFFLOAD_dev2dev (int, void *, const void *, size_t);
diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h
index c584e0fc75b3..165483b9d219 100644
--- a/libgomp/libgomp.h
+++ b/libgomp/libgomp.h
@@ -1136,8 +1136,6 @@ extern int gomp_get_num_devices (void);
 extern bool gomp_target_task_fn (void *);
 extern void gomp_target_rev (uint64_t, uint64_t, uint64_t, uint64_t, uint64_t,
                             int, volatile int *, bool);
-extern bool gomp_page_locked_host_alloc (void **, size_t);
-extern void gomp_page_locked_host_free (void *);
 
 /* Splay tree definitions.  */
 typedef struct splay_tree_node_s *splay_tree_node;
@@ -1437,8 +1435,6 @@ struct gomp_device_descr
   __typeof (GOMP_OFFLOAD_unload_image) *unload_image_func;
   __typeof (GOMP_OFFLOAD_alloc) *alloc_func;
   __typeof (GOMP_OFFLOAD_free) *free_func;
-  __typeof (GOMP_OFFLOAD_page_locked_host_alloc) *page_locked_host_alloc_func;
-  __typeof (GOMP_OFFLOAD_page_locked_host_free) *page_locked_host_free_func;
   __typeof (GOMP_OFFLOAD_dev2host) *dev2host_func;
   __typeof (GOMP_OFFLOAD_host2dev) *host2dev_func;
   __typeof (GOMP_OFFLOAD_dev2dev) *dev2dev_func;
diff --git a/libgomp/libgomp.texi b/libgomp/libgomp.texi
index 5239822c58d2..0dfd8b425d13 100644
--- a/libgomp/libgomp.texi
+++ b/libgomp/libgomp.texi
@@ -6957,9 +6957,8 @@ a @code{nearest} allocation.
 
 Additional notes regarding the traits:
 @itemize
-@item The @code{pinned} trait is supported on Linux hosts, but is usually
-      subject to the OS @code{ulimit}/@code{rlimit} locked memory settings (see
-      @ref{Offload-Target Specifics} for exceptions).
+@item The @code{pinned} trait is supported on Linux hosts, but is subject to
+      the OS @code{ulimit}/@code{rlimit} locked memory settings.
 @item The default for the @code{pool_size} trait is no pool and for every
       (re)allocation the associated library routine is called, which might
       internally use a memory pool.
@@ -7066,12 +7065,6 @@ The implementation remark:
       @code{omp_thread_mem_alloc}, all use low-latency memory as first
       preference, and fall back to main graphics memory when the low-latency
       pool is exhausted.
-@item Pinned memory allocated using @code{omp_alloc} with the
-      @code{ompx_gnu_pinned_mem_alloc} allocator or the @code{pinned} trait is
-      obtained via the CUDA API when an NVPTX device is present.  This provides
-      a performance boost for NVPTX offload code and also allows unlimited use
-      of pinned memory regardless of the OS @code{ulimit}/@code{rlimit}
-      settings.
 @item The OpenMP routines @code{omp_target_memcpy_rect} and
       @code{omp_target_memcpy_rect_async} and the @code{target update}
       directive for non-contiguous list items use the 3D memory-copy function
diff --git a/libgomp/libgomp_g.h b/libgomp/libgomp_g.h
index cdc4fc8be396..e97585c1528a 100644
--- a/libgomp/libgomp_g.h
+++ b/libgomp/libgomp_g.h
@@ -375,7 +375,6 @@ extern bool GOMP_is_alloc (void *);
 
 extern void *GOMP_alloc (size_t, size_t, uintptr_t);
 extern void GOMP_free (void *, uintptr_t);
-extern void GOMP_enable_pinned_mode (void);
 
 /* error.c */
 
diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c
index 90c5916e3a18..0b787a3cfd5d 100644
--- a/libgomp/plugin/plugin-nvptx.c
+++ b/libgomp/plugin/plugin-nvptx.c
@@ -1826,48 +1826,6 @@ GOMP_OFFLOAD_free (int ord, void *ptr)
          && nvptx_free (ptr, ptx_devices[ord]));
 }
 
-bool
-GOMP_OFFLOAD_page_locked_host_alloc (void **ptr, size_t size)
-{
-  GOMP_PLUGIN_debug (0, "nvptx %s: ptr=%p, size=%llu\n",
-                    __FUNCTION__, ptr, (unsigned long long) size);
-
-  if (size == 0)
-    {
-      /* Special case to ensure omp_alloc specification compliance.  */
-      *ptr = NULL;
-      GOMP_PLUGIN_debug (0, "  -> *ptr=null\n");
-      return true;
-    }
-
-  CUresult r;
-
-  unsigned int flags = 0;
-  /* Given 'CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING', we don't need
-     'flags |= CU_MEMHOSTALLOC_PORTABLE;' here.  */
-  r = CUDA_CALL_NOCHECK (cuMemHostAlloc, ptr, size, flags);
-  if (r == CUDA_ERROR_OUT_OF_MEMORY)
-    *ptr = NULL;
-  else if (r != CUDA_SUCCESS)
-    {
-      GOMP_PLUGIN_error ("cuMemHostAlloc error: %s", cuda_error (r));
-      return false;
-    }
-  GOMP_PLUGIN_debug (0, "  -> *ptr=%p\n",
-                    *ptr);
-  return true;
-}
-
-bool
-GOMP_OFFLOAD_page_locked_host_free (void *ptr)
-{
-  GOMP_PLUGIN_debug (0, "nvptx %s: ptr=%p\n",
-                    __FUNCTION__, ptr);
-
-  CUDA_CALL (cuMemFreeHost, ptr);
-  return true;
-}
-
 void
 GOMP_OFFLOAD_openacc_exec (void (*fn) (void *),
                           size_t mapnum  __attribute__((unused)),
diff --git a/libgomp/target.c b/libgomp/target.c
index 1932e2a09fd4..a7a76b0fd30e 100644
--- a/libgomp/target.c
+++ b/libgomp/target.c
@@ -5037,140 +5037,6 @@ omp_target_free (void *device_ptr, int device_num)
   gomp_mutex_unlock (&devicep->lock);
 }
 
-/* Device (really: libgomp plugin) to use for paged-locked memory.  We
-   assume there is either none or exactly one such device for the lifetime of
-   the process.  */
-
-static struct gomp_device_descr *device_for_page_locked
-  = /* uninitialized */ (void *) -1;
-
-static struct gomp_device_descr *
-get_device_for_page_locked (void)
-{
-  gomp_debug (0, "%s\n",
-             __FUNCTION__);
-
-  struct gomp_device_descr *device;
-#ifdef HAVE_SYNC_BUILTINS
-  device
-    = __atomic_load_n (&device_for_page_locked, MEMMODEL_RELAXED);
-  if (device == (void *) -1)
-    {
-      gomp_debug (0, "  init\n");
-
-      gomp_init_targets_once ();
-
-      device = NULL;
-      for (int i = 0; i < num_devices; ++i)
-       {
-         gomp_debug (0, "  i=%d, target_id=%d\n",
-                     i, devices[i].target_id);
-
-         /* We consider only the first device of potentially several of the
-            same type as this functionality is not specific to an individual
-            offloading device, but instead relates to the host-side
-            implementation of the respective offloading implementation.  */
-         if (devices[i].target_id != 0)
-           continue;
-
-         if (!devices[i].page_locked_host_alloc_func)
-           continue;
-
-         gomp_debug (0, "  found device: %p (%s)\n",
-                     &devices[i], devices[i].name);
-         if (device)
-           gomp_fatal ("Unclear how %s and %s libgomp plugins may"
-                       " simultaneously provide functionality"
-                       " for page-locked memory",
-                       device->name, devices[i].name);
-         else
-           device = &devices[i];
-       }
-
-      struct gomp_device_descr *device_old
-       = __atomic_exchange_n (&device_for_page_locked, device,
-                              MEMMODEL_RELAXED);
-      gomp_debug (0, "  old device_for_page_locked: %p\n",
-                 device_old);
-      assert (device_old == (void *) -1
-             /* We shouldn't have concurrently found a different or no
-                device.  */
-             || device_old == device);
-    }
-#else /* !HAVE_SYNC_BUILTINS */
-  gomp_debug (0, "  not implemented for '!HAVE_SYNC_BUILTINS'\n");
-  (void) &device_for_page_locked;
-  device = NULL;
-#endif /* HAVE_SYNC_BUILTINS */
-
-  gomp_debug (0, "  -> device=%p (%s)\n",
-             device, device ? device->name : "[none]");
-  return device;
-}
-
-/* Allocate page-locked host memory.
-   Returns whether we have a device capable of that.  */
-
-attribute_hidden bool
-gomp_page_locked_host_alloc (void **ptr, size_t size)
-{
-  gomp_debug (0, "%s: ptr=%p, size=%llu\n",
-             __FUNCTION__, ptr, (unsigned long long) size);
-
-  struct gomp_device_descr *device = get_device_for_page_locked ();
-  gomp_debug (0, "  device=%p (%s)\n",
-             device, device ? device->name : "[none]");
-  if (device)
-    {
-      gomp_mutex_lock (&device->lock);
-      if (device->state == GOMP_DEVICE_UNINITIALIZED)
-       gomp_init_device (device);
-      else if (device->state == GOMP_DEVICE_FINALIZED)
-       {
-         gomp_mutex_unlock (&device->lock);
-         gomp_fatal ("Device %s used for for page-locked memory is finalized",
-                     device->name);
-       }
-      gomp_mutex_unlock (&device->lock);
-
-      if (!device->page_locked_host_alloc_func (ptr, size))
-       gomp_fatal ("Failed to allocate page-locked host memory"
-                   " via %s libgomp plugin",
-                   device->name);
-    }
-  return device != NULL;
-}
-
-/* Free page-locked host memory.
-   This must only be called if 'gomp_page_locked_host_alloc' returned
-   'true'.  */
-
-attribute_hidden void
-gomp_page_locked_host_free (void *ptr)
-{
-  gomp_debug (0, "%s: ptr=%p\n",
-             __FUNCTION__, ptr);
-
-  struct gomp_device_descr *device = get_device_for_page_locked ();
-  gomp_debug (0, "  device=%p (%s)\n",
-             device, device ? device->name : "[none]");
-  assert (device);
-
-  gomp_mutex_lock (&device->lock);
-  assert (device->state != GOMP_DEVICE_UNINITIALIZED);
-  if (device->state == GOMP_DEVICE_FINALIZED)
-    {
-      gomp_mutex_unlock (&device->lock);
-      return;
-    }
-  gomp_mutex_unlock (&device->lock);
-
-  if (!device->page_locked_host_free_func (ptr))
-    gomp_fatal ("Failed to free page-locked host memory"
-               " via %s libgomp plugin",
-               device->name);
-}
-
 int
 omp_target_is_present (const void *ptr, int device_num)
 {
@@ -6368,8 +6234,6 @@ gomp_load_plugin_for_device (struct gomp_device_descr 
*device,
   DLSYM (unload_image);
   DLSYM (alloc);
   DLSYM (free);
-  DLSYM_OPT (page_locked_host_alloc, page_locked_host_alloc);
-  DLSYM_OPT (page_locked_host_free, page_locked_host_free);
   DLSYM (dev2host);
   DLSYM (host2dev);
   DLSYM_OPT (memcpy2d, memcpy2d);
diff --git a/libgomp/testsuite/libgomp.c/alloc-pinned-1.c 
b/libgomp/testsuite/libgomp.c/alloc-pinned-1.c
index 693f9032c8d5..672f2453a783 100644
--- a/libgomp/testsuite/libgomp.c/alloc-pinned-1.c
+++ b/libgomp/testsuite/libgomp.c/alloc-pinned-1.c
@@ -2,8 +2,6 @@
 
 /* { dg-skip-if "Pinning not implemented on this host" { ! *-*-linux-gnu* } } 
*/
 
-/* { dg-additional-options -DOFFLOAD_DEVICE_NVPTX { target 
offload_device_nvptx } } */
-
 /* Test that pinned memory works.  */
 
 #include <stdio.h>
@@ -65,16 +63,10 @@ verify0 (char *p, size_t s)
 int
 main ()
 {
-#ifdef OFFLOAD_DEVICE_NVPTX
-  /* Go big or go home.
-     The OS ulimit does not affect memory locked via CUDA for NVPTX devices. */
-  const int SIZE = 40 * 1024 * 1024;
-#else
   /* Allocate at least a page each time, allowing space for overhead,
      but stay within the ulimit.  */
   const int SIZE = PAGE_SIZE - 128;
   CHECK_SIZE (SIZE * 5);  // This is intended to help diagnose failures
-#endif
 
   const omp_alloctrait_t traits[] = {
       { omp_atk_pinned, 1 }
@@ -96,39 +88,21 @@ main ()
     abort ();
 
   int amount = get_pinned_mem ();
-#ifdef OFFLOAD_DEVICE_NVPTX
-  /* This doesn't show up as process 'VmLck'ed memory.  */
-  if (amount != 0)
-    abort ();
-#else
   if (amount == 0)
     abort ();
-#endif
 
   p = omp_realloc (p, SIZE * 2, allocator, allocator);
 
   int amount2 = get_pinned_mem ();
-#ifdef OFFLOAD_DEVICE_NVPTX
-  /* This doesn't show up as process 'VmLck'ed memory.  */
-  if (amount2 != 0)
-    abort ();
-#else
   if (amount2 <= amount)
     abort ();
-#endif
 
   /* SIZE*2 ensures that it doesn't slot into the space possibly
      vacated by realloc.  */
   p = omp_calloc (1, SIZE * 2, allocator);
 
-#ifdef OFFLOAD_DEVICE_NVPTX
-  /* This doesn't show up as process 'VmLck'ed memory.  */
-  if (get_pinned_mem () != 0)
-    abort ();
-#else
   if (get_pinned_mem () <= amount2)
     abort ();
-#endif
 
   verify0 (p, SIZE * 2);
 
diff --git a/libgomp/testsuite/libgomp.c/alloc-pinned-2.c 
b/libgomp/testsuite/libgomp.c/alloc-pinned-2.c
index e7ac64e911f4..b6d1d83fb6f2 100644
--- a/libgomp/testsuite/libgomp.c/alloc-pinned-2.c
+++ b/libgomp/testsuite/libgomp.c/alloc-pinned-2.c
@@ -2,8 +2,6 @@
 
 /* { dg-skip-if "Pinning not implemented on this host" { ! *-*-linux-gnu* } } 
*/
 
-/* { dg-additional-options -DOFFLOAD_DEVICE_NVPTX { target 
offload_device_nvptx } } */
-
 /* Test that pinned memory works (pool_size code path).  */
 
 #include <stdio.h>
@@ -65,16 +63,10 @@ verify0 (char *p, size_t s)
 int
 main ()
 {
-#ifdef OFFLOAD_DEVICE_NVPTX
-  /* Go big or go home.
-     The OS ulimit does not affect memory locked via CUDA for NVPTX devices. */
-  const int SIZE = 40 * 1024 * 1024;
-#else
   /* Allocate at least a page each time, allowing space for overhead,
      but stay within the ulimit.  */
   const int SIZE = PAGE_SIZE - 128;
   CHECK_SIZE (SIZE * 5);  // This is intended to help diagnose failures
-#endif
 
   const omp_alloctrait_t traits[] = {
       { omp_atk_pinned, 1 },
@@ -97,28 +89,16 @@ main ()
     abort ();
 
   int amount = get_pinned_mem ();
-#ifdef OFFLOAD_DEVICE_NVPTX
-  /* This doesn't show up as process 'VmLck'ed memory.  */
-  if (amount != 0)
-    abort ();
-#else
   if (amount == 0)
     abort ();
-#endif
 
   p = omp_realloc (p, SIZE * 2, allocator, allocator);
   if (!p)
     abort ();
 
   int amount2 = get_pinned_mem ();
-#ifdef OFFLOAD_DEVICE_NVPTX
-  /* This doesn't show up as process 'VmLck'ed memory.  */
-  if (amount2 != 0)
-    abort ();
-#else
   if (amount2 <= amount)
     abort ();
-#endif
 
   /* SIZE*2 ensures that it doesn't slot into the space possibly
      vacated by realloc.  */
@@ -126,14 +106,8 @@ main ()
   if (!p)
     abort ();
 
-#ifdef OFFLOAD_DEVICE_NVPTX
-  /* This doesn't show up as process 'VmLck'ed memory.  */
-  if (get_pinned_mem () != 0)
-    abort ();
-#else
   if (get_pinned_mem () <= amount2)
     abort ();
-#endif
 
   verify0 (p, SIZE * 2);
 
diff --git a/libgomp/testsuite/libgomp.c/alloc-pinned-3.c 
b/libgomp/testsuite/libgomp.c/alloc-pinned-3.c
index 250cb557e6a2..11dc818d2a96 100644
--- a/libgomp/testsuite/libgomp.c/alloc-pinned-3.c
+++ b/libgomp/testsuite/libgomp.c/alloc-pinned-3.c
@@ -1,7 +1,5 @@
 /* { dg-do run } */
 
-/* { dg-additional-options -DOFFLOAD_DEVICE_NVPTX { target 
offload_device_nvptx } } */
-
 /* Test that pinned memory fails correctly.  */
 
 #include <stdio.h>
@@ -77,15 +75,8 @@ verify0 (char *p, size_t s)
 int
 main ()
 {
-#ifdef OFFLOAD_DEVICE_NVPTX
-  /* Go big or go home.
-     The OS ulimit does not affect memory locked via CUDA for NVPTX devices. */
-  const int SIZE = 40 * 1024 * 1024;
-#else
   /* This needs to be large enough to cover multiple pages.  */
   const int SIZE = PAGE_SIZE * 4;
-#endif
-  const int PIN_LIMIT = PAGE_SIZE * 2;
 
   /* Pinned memory, no fallback.  */
   const omp_alloctrait_t traits1[] = {
@@ -110,34 +101,23 @@ main ()
 #endif
 
   /* Ensure that the limit is smaller than the allocation.  */
-  set_pin_limit (PIN_LIMIT);
+  set_pin_limit (SIZE / 2);
 
   // Sanity check
   if (get_pinned_mem () != 0)
     abort ();
 
-  void *p1 = omp_alloc (SIZE, allocator1);
-#ifdef OFFLOAD_DEVICE_NVPTX
-  // Doesn't care about 'set_pin_limit'.
-  if (!p1)
-    abort ();
-#else
   // Should fail
+  void *p1 = omp_alloc (SIZE, allocator1);
   if (p1)
     abort ();
-#endif
 
-  void *p2 = omp_calloc (1, SIZE, allocator1);
-#ifdef OFFLOAD_DEVICE_NVPTX
-  // Doesn't care about 'set_pin_limit'.
-  if (!p2)
-    abort ();
-#else
   // Should fail
+  void *p2 = omp_calloc (1, SIZE, allocator1);
   if (p2)
     abort ();
-#endif
 
+  // Should fall back
   void *p3 = omp_alloc (SIZE, allocator2);
   if (!p3)
     abort ();
@@ -148,29 +128,16 @@ main ()
     abort ();
   verify0 (p4, SIZE);
 
+  // Should fail to realloc
   void *notpinned = omp_alloc (SIZE, omp_default_mem_alloc);
   void *p5 = omp_realloc (notpinned, SIZE, allocator1, omp_default_mem_alloc);
-#ifdef OFFLOAD_DEVICE_NVPTX
-  // Doesn't care about 'set_pin_limit'; does reallocate.
-  if (!notpinned || !p5 || p5 == notpinned)
-    abort ();
-#else
-  // Should fail to realloc
   if (!notpinned || p5)
     abort ();
-#endif
 
-#ifdef OFFLOAD_DEVICE_NVPTX
-  void *p6 = omp_realloc (p5, SIZE, allocator2, allocator1);
-  // Does reallocate.
-  if (p5 == p6)
-    abort ();
-#else
-  void *p6 = omp_realloc (notpinned, SIZE, allocator2, omp_default_mem_alloc);
   // Should fall back to no realloc needed
+  void *p6 = omp_realloc (notpinned, SIZE, allocator2, omp_default_mem_alloc);
   if (p6 != notpinned)
     abort ();
-#endif
 
   // No memory should have been pinned
   int amount = get_pinned_mem ();
diff --git a/libgomp/testsuite/libgomp.c/alloc-pinned-4.c 
b/libgomp/testsuite/libgomp.c/alloc-pinned-4.c
index b7a99665000e..2ecd01f02d56 100644
--- a/libgomp/testsuite/libgomp.c/alloc-pinned-4.c
+++ b/libgomp/testsuite/libgomp.c/alloc-pinned-4.c
@@ -1,7 +1,5 @@
 /* { dg-do run } */
 
-/* { dg-additional-options -DOFFLOAD_DEVICE_NVPTX { target 
offload_device_nvptx } } */
-
 /* Test that pinned memory fails correctly, pool_size code path.  */
 
 #include <stdio.h>
@@ -77,15 +75,8 @@ verify0 (char *p, size_t s)
 int
 main ()
 {
-#ifdef OFFLOAD_DEVICE_NVPTX
-  /* Go big or go home.
-     The OS ulimit does not affect memory locked via CUDA for NVPTX devices. */
-  const int SIZE = 40 * 1024 * 1024;
-#else
   /* This needs to be large enough to cover multiple pages.  */
   const int SIZE = PAGE_SIZE * 4;
-#endif
-  const int PIN_LIMIT = PAGE_SIZE * 2;
 
   /* Pinned memory, no fallback.  */
   const omp_alloctrait_t traits1[] = {
@@ -112,33 +103,21 @@ main ()
 #endif
 
   /* Ensure that the limit is smaller than the allocation.  */
-  set_pin_limit (PIN_LIMIT);
+  set_pin_limit (SIZE / 2);
 
   // Sanity check
   if (get_pinned_mem () != 0)
     abort ();
 
-  void *p = omp_alloc (SIZE, allocator1);
-#ifdef OFFLOAD_DEVICE_NVPTX
-  // Doesn't care about 'set_pin_limit'.
-  if (!p)
-    abort ();
-#else
   // Should fail
+  void *p = omp_alloc (SIZE, allocator1);
   if (p)
     abort ();
-#endif
 
-  p = omp_calloc (1, SIZE, allocator1);
-#ifdef OFFLOAD_DEVICE_NVPTX
-  // Doesn't care about 'set_pin_limit'.
-  if (!p)
-    abort ();
-#else
   // Should fail
+  p = omp_calloc (1, SIZE, allocator1);
   if (p)
     abort ();
-#endif
 
   // Should fall back
   p = omp_alloc (SIZE, allocator2);
@@ -151,29 +130,16 @@ main ()
     abort ();
   verify0 (p, SIZE);
 
+  // Should fail to realloc
   void *notpinned = omp_alloc (SIZE, omp_default_mem_alloc);
   p = omp_realloc (notpinned, SIZE, allocator1, omp_default_mem_alloc);
-#ifdef OFFLOAD_DEVICE_NVPTX
-  // Doesn't care about 'set_pin_limit'; does reallocate.
-  if (!notpinned || !p || p == notpinned)
-    abort ();
-#else
-  // Should fail to realloc
   if (!notpinned || p)
     abort ();
-#endif
 
-#ifdef OFFLOAD_DEVICE_NVPTX
-  void *p_ = omp_realloc (p, SIZE, allocator2, allocator1);
-  // Does reallocate.
-  if (p_ == p)
-    abort ();
-#else
-  p = omp_realloc (notpinned, SIZE, allocator2, omp_default_mem_alloc);
   // Should fall back to no realloc needed
+  p = omp_realloc (notpinned, SIZE, allocator2, omp_default_mem_alloc);
   if (p != notpinned)
     abort ();
-#endif
 
   // No memory should have been pinned
   int amount = get_pinned_mem ();
diff --git a/libgomp/testsuite/libgomp.c/alloc-pinned-5.c 
b/libgomp/testsuite/libgomp.c/alloc-pinned-5.c
index cc7776409ff7..0ba2feb8d969 100644
--- a/libgomp/testsuite/libgomp.c/alloc-pinned-5.c
+++ b/libgomp/testsuite/libgomp.c/alloc-pinned-5.c
@@ -2,8 +2,6 @@
 
 /* { dg-skip-if "Pinning not implemented on this host" { ! *-*-linux-gnu* } } 
*/
 
-/* { dg-additional-options -DOFFLOAD_DEVICE_NVPTX { target 
offload_device_nvptx } } */
-
 /* Test that ompx_gnu_pinned_mem_alloc works.  */
 
 #include <stdio.h>
@@ -65,16 +63,10 @@ verify0 (char *p, size_t s)
 int
 main ()
 {
-#ifdef OFFLOAD_DEVICE_NVPTX
-  /* Go big or go home.
-     The OS ulimit does not affect memory locked via CUDA for NVPTX devices. */
-  const int SIZE = 40 * 1024 * 1024;
-#else
   /* Allocate at least a page each time, allowing space for overhead,
      but stay within the ulimit.  */
   const int SIZE = PAGE_SIZE - 128;
   CHECK_SIZE (SIZE * 5);
-#endif
 
   // Sanity check
   if (get_pinned_mem () != 0)
@@ -85,40 +77,22 @@ main ()
     abort ();
 
   int amount = get_pinned_mem ();
-#ifdef OFFLOAD_DEVICE_NVPTX
-  /* This doesn't show up as process 'VmLck'ed memory.  */
-  if (amount != 0)
-    abort ();
-#else
   if (amount == 0)
     abort ();
-#endif
 
   p = omp_realloc (p, SIZE * 2, ompx_gnu_pinned_mem_alloc,
                   ompx_gnu_pinned_mem_alloc);
 
   int amount2 = get_pinned_mem ();
-#ifdef OFFLOAD_DEVICE_NVPTX
-  /* This doesn't show up as process 'VmLck'ed memory.  */
-  if (amount2 != 0)
-    abort ();
-#else
   if (amount2 <= amount)
     abort ();
-#endif
 
   /* SIZE*2 ensures that it doesn't slot into the space possibly
      vacated by realloc.  */
   p = omp_calloc (1, SIZE * 2, ompx_gnu_pinned_mem_alloc);
 
-#ifdef OFFLOAD_DEVICE_NVPTX
-  /* This doesn't show up as process 'VmLck'ed memory.  */
-  if (get_pinned_mem () != 0)
-    abort ();
-#else
   if (get_pinned_mem () <= amount2)
     abort ();
-#endif
 
   verify0 (p, SIZE * 2);
 
diff --git a/libgomp/testsuite/libgomp.c/alloc-pinned-6.c 
b/libgomp/testsuite/libgomp.c/alloc-pinned-6.c
index 6dd5544a8147..99f1269424fa 100644
--- a/libgomp/testsuite/libgomp.c/alloc-pinned-6.c
+++ b/libgomp/testsuite/libgomp.c/alloc-pinned-6.c
@@ -1,5 +1,4 @@
 /* { dg-do run } */
-/* { dg-additional-options -DOFFLOAD_DEVICE_NVPTX { target 
offload_device_nvptx } } */
 
 /* Test that ompx_gnu_pinned_mem_alloc fails correctly.  */
 
@@ -67,57 +66,32 @@ set_pin_limit (int size)
 int
 main ()
 {
-#ifdef OFFLOAD_DEVICE_NVPTX
-  /* Go big or go home.
-     The OS ulimit does not affect memory locked via CUDA for NVPTX devices. */
-  const int SIZE = 40 * 1024 * 1024;
-#else
   /* Allocate at least a page each time, but stay within the ulimit.  */
   const int SIZE = PAGE_SIZE * 4;
-#endif
-  const int PIN_LIMIT = PAGE_SIZE*2;
 
   /* Ensure that the limit is smaller than the allocation.  */
-  set_pin_limit (PIN_LIMIT);
+  set_pin_limit (SIZE / 2);
 
   // Sanity check
   if (get_pinned_mem () != 0)
     abort ();
 
-  void *p = omp_alloc (SIZE, ompx_gnu_pinned_mem_alloc);
-#ifdef OFFLOAD_DEVICE_NVPTX
-  // Doesn't care about 'set_pin_limit'.
-  if (!p)
-    abort ();
-#else
   // Should fail
+  void *p = omp_alloc (SIZE, ompx_gnu_pinned_mem_alloc);
   if (p)
     abort ();
-#endif
 
-  p = omp_calloc (1, SIZE, ompx_gnu_pinned_mem_alloc);
-#ifdef OFFLOAD_DEVICE_NVPTX
-  // Doesn't care about 'set_pin_limit'.
-  if (!p)
-    abort ();
-#else
   // Should fail
+  p = omp_calloc (1, SIZE, ompx_gnu_pinned_mem_alloc);
   if (p)
     abort ();
-#endif
 
+  // Should fail to realloc
   void *notpinned = omp_alloc (SIZE, omp_default_mem_alloc);
   p = omp_realloc (notpinned, SIZE, ompx_gnu_pinned_mem_alloc,
                   omp_default_mem_alloc);
-#ifdef OFFLOAD_DEVICE_NVPTX
-  // Doesn't care about 'set_pin_limit'; does reallocate.
-  if (!notpinned || !p || p == notpinned)
-    abort ();
-#else
-  // Should fail to realloc
   if (!notpinned || p)
     abort ();
-#endif
 
   // No memory should have been pinned
   int amount = get_pinned_mem ();

Reply via email to