Use gomp_map_val for OpenACC host-to-device address translation
authorJulian Brown <julian@codesourcery.com>
Fri, 20 Dec 2019 01:20:19 +0000 (01:20 +0000)
committerJulian Brown <jules@gcc.gnu.org>
Fri, 20 Dec 2019 01:20:19 +0000 (01:20 +0000)
libgomp/
* libgomp.h (gomp_map_val): Add prototype.
* oacc-parallel.c (GOACC_parallel_keyed): Use gomp_map_val instead of
open-coding device-address calculation.
* target.c (gomp_map_val): Make global. Use OFFSET_POINTER in
non-present case.

Co-Authored-By: Cesar Philippidis <cesar@codesourcery.com>
From-SVN: r279622

libgomp/ChangeLog
libgomp/libgomp.h
libgomp/oacc-parallel.c
libgomp/target.c

index c08d7b0c457cd19dba528939fbfd3aaf648a37e9..6c146217fe2540f6d2b9932aa4bf6917b7a85e7e 100644 (file)
@@ -1,3 +1,12 @@
+2019-12-19  Julian Brown  <julian@codesourcery.com>
+           Cesar Philippidis  <cesar@codesourcery.com>
+
+       * libgomp.h (gomp_map_val): Add prototype.
+       * oacc-parallel.c (GOACC_parallel_keyed): Use gomp_map_val instead of
+       open-coding device-address calculation.
+       * target.c (gomp_map_val): Make global. Use OFFSET_POINTER in
+       non-present case.
+
 2019-12-19  Julian Brown  <julian@codesourcery.com>
 
        * libgomp.h (struct splay_tree_key_s): Substitute dynamic_refcount
index b9301bd70f81d0c72092210534d8f1a52bc3d185..8139cd7de08678c62efdc2b3153138fadc9e2884 100644 (file)
@@ -1157,6 +1157,7 @@ extern void gomp_copy_host2dev (struct gomp_device_descr *,
 extern void gomp_copy_dev2host (struct gomp_device_descr *,
                                struct goacc_asyncqueue *, void *, const void *,
                                size_t);
+extern uintptr_t gomp_map_val (struct target_mem_desc *, void **, size_t);
 
 extern struct target_mem_desc *gomp_map_vars (struct gomp_device_descr *,
                                              size_t, void **, void **,
index 5c13a7e43487d4d096986efd73f641709b906180..c853f01b27f7390e4cee87b9f6785542bf1982d2 100644 (file)
@@ -303,12 +303,8 @@ GOACC_parallel_keyed (int flags_m, void (*fn) (void *),
   
   devaddrs = gomp_alloca (sizeof (void *) * mapnum);
   for (i = 0; i < mapnum; i++)
-    if (tgt->list[i].key != NULL)
-      devaddrs[i] = (void *) (tgt->list[i].key->tgt->tgt_start
-                             + tgt->list[i].key->tgt_offset
-                             + tgt->list[i].offset);
-    else
-      devaddrs[i] = NULL;
+    devaddrs[i] = (void *) gomp_map_val (tgt, hostaddrs, i);
+
   if (aq == NULL)
     acc_dev->openacc.exec_func (tgt_fn, mapnum, hostaddrs, devaddrs, dims,
                                tgt);
index f2a60614e598ed1b2593c4b0893a2d804d25dc26..ef8e9ab14fcd7c36b24498b36cdc2d827264a85d 100644 (file)
@@ -493,7 +493,7 @@ gomp_map_fields_existing (struct target_mem_desc *tgt,
              (void *) cur_node.host_end);
 }
 
-static inline uintptr_t
+attribute_hidden uintptr_t
 gomp_map_val (struct target_mem_desc *tgt, void **hostaddrs, size_t i)
 {
   if (tgt->list[i].key != NULL)
@@ -713,7 +713,7 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep,
            {
              /* Not present, hence, skip entry - including its MAP_POINTER,
                 when existing.  */
-             tgt->list[i].offset = 0;
+             tgt->list[i].offset = OFFSET_POINTER;
              if (i + 1 < mapnum
                  && ((typemask & get_kind (short_mapkind, kinds, i + 1))
                      == GOMP_MAP_POINTER))