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)
+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>
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);
+++ /dev/null
-/* 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 "" } */
+++ /dev/null
-/* 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 "" } */