[OpenACC] Revert always-copyfrom behavior for 'GOMP_MAP_FORCE_FROM' in 'libgomp/oacc...
authorThomas Schwinge <thomas@codesourcery.com>
Thu, 14 May 2020 18:48:10 +0000 (20:48 +0200)
committerThomas Schwinge <thomas@codesourcery.com>
Fri, 3 Jul 2020 15:14:40 +0000 (17:14 +0200)
As done for 'GOMP_MAP_FROM', also for 'GOMP_MAP_FORCE_FROM' we should only
'gomp_copy_dev2host' if 'n->refcount == 0'.

This had gotten altered in commit 378da98fcc907d05002bcd3d6ff7951f0cf485e5
(r279621) "OpenACC reference count overhaul".

libgomp/
* oacc-mem.c (goacc_exit_data_internal): Revert always-copyfrom
behavior for 'GOMP_MAP_FORCE_FROM'.
* testsuite/libgomp.oacc-c-c++-common/pr92843-1.c: Adjust XFAIL.

libgomp/oacc-mem.c
libgomp/testsuite/libgomp.oacc-c-c++-common/pr92843-1.c

index 1a0cd4caf287b92df491cefec95b1806d2fd6ac0..4fb78ee963487c5a1b642c03fd32daa723490a71 100644 (file)
@@ -1144,16 +1144,17 @@ goacc_exit_data_internal (struct gomp_device_descr *acc_dev, size_t mapnum,
            else if (n->refcount > 0 && n->refcount != REFCOUNT_INFINITY)
              n->refcount--;
 
-           if (copyfrom
-               && (kind != GOMP_MAP_FROM || n->refcount == 0))
-             gomp_copy_dev2host (acc_dev, aq, (void *) cur_node.host_start,
-                                 (void *) (n->tgt->tgt_start + n->tgt_offset
-                                           + cur_node.host_start
-                                           - n->host_start),
-                                 cur_node.host_end - cur_node.host_start);
-
            if (n->refcount == 0)
              {
+               if (copyfrom)
+                 {
+                   void *d = (void *) (n->tgt->tgt_start + n->tgt_offset
+                                       + cur_node.host_start - n->host_start);
+                   gomp_copy_dev2host (acc_dev, aq,
+                                       (void *) cur_node.host_start, d,
+                                       cur_node.host_end - cur_node.host_start);
+                 }
+
                if (aq)
                  /* TODO We can't do the 'is_tgt_unmapped' checking -- see the
                     'gomp_unref_tgt' comment in
index f16c46a37bfb0ac3801ae0b7054b3fafcf2037d0..78fe1402ad464fce5d4ce5a3f48254f0ef3f9314 100644 (file)
@@ -1,10 +1,10 @@
 /* Verify that 'acc_copyout' etc. is a no-op if there's still a structured
    reference count.  */
 
-/* { dg-xfail-run-if "TODO PR92843" { *-*-* } } */
 /* { dg-skip-if "" { *-*-* } { "*" } { "-DACC_MEM_SHARED=0" } } */
 
 #include <assert.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <openacc.h>
 
@@ -135,7 +135,15 @@ test_acc_data ()
     assert (acc_is_present (h, sizeof h));
 
     assign_array (h, N, c1);
+    fprintf (stderr, "CheCKpOInT1\n");
+    // { dg-output ".*CheCKpOInT1(\n|\r\n|\r)" }
     acc_copyout_finalize (h, sizeof h);
+    //TODO     goacc_exit_datum: Assertion `is_tgt_unmapped || num_mappings > 1' failed.
+    //TODO { dg-output ".*\[Aa\]ssert.*is_tgt_unmapped" { target { ! openacc_host_selected } } } ! Scan for what we expect in the "XFAILed" case (without actually XFAILing).
+    //TODO { dg-shouldfail "XFAILed" { ! openacc_host_selected } } ! ... instead of 'dg-xfail-run-if' so that 'dg-output' is evaluated at all.
+    //TODO { dg-final { if { [dg-process-target { xfail { ! openacc_host_selected } }] == "F" } { xfail "[testname-for-summary] really is XFAILed" } } } ! ... so that we still get an XFAIL visible in the log.
+    fprintf (stderr, "CheCKpOInT2\n");
+    // { dg-output ".CheCKpOInT2(\n|\r\n|\r)" { target { openacc_host_selected } } }
     assert (acc_is_present (h, sizeof h));
     verify_array (h, N, c1);