This patch was previously approved here, but I have not committed it yet (without the other patches in this series):
https://gcc.gnu.org/ml/gcc-patches/2019-10/msg01156.html Included for completeness. I will commit this alongside other patches if they are approved (or it could probably go in by itself anyway). Thanks, Julian ChangeLog 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. --- libgomp/libgomp.h | 1 + libgomp/oacc-parallel.c | 8 ++------ libgomp/target.c | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/libgomp/libgomp.h b/libgomp/libgomp.h index d20194bafbb..248d8dc5d63 100644 --- a/libgomp/libgomp.h +++ b/libgomp/libgomp.h @@ -1169,6 +1169,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); #ifdef RC_CHECKING extern void dump_tgt (const char *, struct target_mem_desc *); diff --git a/libgomp/oacc-parallel.c b/libgomp/oacc-parallel.c index eb281db323c..4cc0636aae1 100644 --- a/libgomp/oacc-parallel.c +++ b/libgomp/oacc-parallel.c @@ -312,12 +312,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); diff --git a/libgomp/target.c b/libgomp/target.c index 5712da5b64e..46b20c04865 100644 --- a/libgomp/target.c +++ b/libgomp/target.c @@ -673,7 +673,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) -- 2.23.0