]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Allow NULL for update directives in OpenACC 2.6
authorKwok Cheung Yeung <kcy@codesourcery.com>
Wed, 30 Jan 2019 18:43:47 +0000 (10:43 -0800)
committerThomas Schwinge <thomas@codesourcery.com>
Tue, 3 Mar 2020 11:14:56 +0000 (12:14 +0100)
A non-present passed-by-reference Fortran optional argument is represented
by a null pointer.  When passed to an update directive, it should be ignored
as variable mappings are not created for null pointers.  This should be
safe as it is not possible to change a non-present argument into a present
one (or vice-versa) in Fortran.

libgomp/
* oacc-mem.c (update_dev_host): Return early if the host address
is NULL.
        * testsuite/libgomp.oacc-c-c++-common/lib-43.c: Remove.
        * testsuite/libgomp.oacc-c-c++-common/lib-47.c: Likewise.

Reviewed-by: Julian Brown <julian@codesourcery.com>
Reviewed-by: Thomas Schwinge <thomas@codesourcery.com>
(cherry picked from openacc-gcc-9-branch commit
b930a8a1ee826ca52081c7c0e88554b3091afb62)

libgomp/ChangeLog.omp
libgomp/oacc-mem.c
libgomp/testsuite/libgomp.oacc-c-c++-common/lib-43.c [deleted file]
libgomp/testsuite/libgomp.oacc-c-c++-common/lib-47.c [deleted file]

index f338eb1cf4837aa738f73093c29e7ed060c83484..79baa0cfee10e500c86e55e959e8f7a0a2d402f3 100644 (file)
@@ -1,3 +1,10 @@
+2019-01-30  Kwok Cheung Yeung  <kcy@codesourcery.com>
+
+       * oacc-mem.c (update_dev_host): Return early if the host address
+       is NULL.
+       * testsuite/libgomp.oacc-c-c++-common/lib-43.c: Remove.
+       * testsuite/libgomp.oacc-c-c++-common/lib-47.c: Likewise.
+
 2018-12-11  Julian Brown  <julian@codesourcery.com>
            Chung-Lin Tang  <cltang@codesourcery.com>
 
index 2ff8d7f9147498c91df52bf5d2ddce4e81d3f75d..b3b37771da20ad12904af03c7000f9b2124ec38d 100644 (file)
@@ -692,6 +692,12 @@ update_dev_host (int is_dev, void *h, size_t s, int async)
   if (acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM)
     return;
 
+  /* Fortran optional arguments that are non-present result in a
+     null host address here.  This can safely be ignored as it is
+     not possible to 'update' a non-present optional argument.  */
+  if (h == NULL)
+    return;
+
   gomp_mutex_lock (&acc_dev->lock);
 
   n = lookup_host (acc_dev, h, s);
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-43.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-43.c
deleted file mode 100644 (file)
index 5db2912..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-/* Exercise acc_update_device with a NULL data address on nvidia targets.  */
-
-/* { dg-do run { target openacc_nvidia_accel_selected } } */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <openacc.h>
-
-int
-main (int argc, char **argv)
-{
-  const int N = 256;
-  int i;
-  unsigned char *h;
-  void *d;
-
-  h = (unsigned char *) malloc (N);
-
-  for (i = 0; i < N; i++)
-    {
-      h[i] = i;
-    }
-
-  d = acc_copyin (h, N);
-  if (!d)
-    abort ();
-
-  for (i = 0; i < N; i++)
-    {
-      h[i] = 0xab;
-    }
-
-  fprintf (stderr, "CheCKpOInT\n");
-  acc_update_device (0, N);
-
-  acc_copyout (h, N);
-
-  for (i = 0; i < N; i++)
-    {
-      if (h[i] != 0xab)
-       abort ();
-    }
-
-  free (h);
-
-  return 0;
-}
-
-/* { dg-output "CheCKpOInT(\n|\r\n|\r).*" } */
-/* { dg-output "\\\[\[^\n\r]*,256\\\] is not mapped" } */
-/* { dg-shouldfail "" } */
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-47.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/lib-47.c
deleted file mode 100644 (file)
index c214042..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/* Exercise acc_update_self with a NULL data mapping on nvidia targets.  */
-
-/* { dg-do run { target openacc_nvidia_accel_selected } } */
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
-#include <openacc.h>
-
-int
-main (int argc, char **argv)
-{
-  const int N = 256;
-  int i;
-  unsigned char *h;
-  void *d;
-
-  h = (unsigned char *) malloc (N);
-
-  for (i = 0; i < N; i++)
-    {
-      h[i] = i;
-    }
-
-  d = acc_copyin (h, N);
-  if (!d)
-    abort ();
-
-  memset (&h[0], 0, N);
-
-  fprintf (stderr, "CheCKpOInT\n");
-  acc_update_self (0, N);
-
-  for (i = 0; i < N; i++)
-    {
-      if (h[i] != i)
-       abort ();
-    }
-
-  acc_delete (h, N);
-
-  free (h);
-
-  return 0;
-}
-
-/* { dg-output "CheCKpOInT(\n|\r\n|\r).*" } */
-/* { dg-output "\\\[\[^\n\r]*,256\\\] is not mapped" } */
-/* { dg-shouldfail "" } */