diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2020-01-10 23:23:44 +0100 |
---|---|---|
committer | Thomas Schwinge <tschwinge@gcc.gnu.org> | 2020-01-10 23:23:44 +0100 |
commit | b3b75e664a619dae98571a0b3ac8034f5fa7c2be (patch) | |
tree | c557ed2e8d6ac3cf602df662f0fb8d72c3b56888 /libgomp | |
parent | 68be73fc42b969d8d595aeda98e3ea962a7a9ed5 (diff) | |
download | gcc-b3b75e664a619dae98571a0b3ac8034f5fa7c2be.zip gcc-b3b75e664a619dae98571a0b3ac8034f5fa7c2be.tar.gz gcc-b3b75e664a619dae98571a0b3ac8034f5fa7c2be.tar.bz2 |
Further changes for the OpenACC 'if_present' clause on the 'host_data' construct
gcc/
* tree.h (OMP_CLAUSE_USE_DEVICE_PTR_IF_PRESENT): New definition.
* tree-core.h: Document it.
* gimplify.c (gimplify_omp_workshare): Set it.
* omp-low.c (lower_omp_target): Use it.
* tree-pretty-print.c (dump_omp_clause): Print it.
gcc/testsuite/
* c-c++-common/goacc/host_data-1.c: Extend.
* gfortran.dg/goacc/host_data-tree.f95: Likewise.
gcc/
* omp-low.c (lower_omp_target) <OMP_CLAUSE_USE_DEVICE_PTR etc.>:
Assert that for OpenACC we always have 'GOMP_MAP_USE_DEVICE_PTR'.
libgomp/
* target.c (gomp_map_vars_internal)
<GOMP_MAP_USE_DEVICE_PTR_IF_PRESENT>: Clean up/elaborate code
paths.
From-SVN: r280149
Diffstat (limited to 'libgomp')
-rw-r--r-- | libgomp/ChangeLog | 6 | ||||
-rw-r--r-- | libgomp/target.c | 61 |
2 files changed, 44 insertions, 23 deletions
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog index 152e52c..81d0c16 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,9 @@ +2020-01-10 Thomas Schwinge <thomas@codesourcery.com> + + * target.c (gomp_map_vars_internal) + <GOMP_MAP_USE_DEVICE_PTR_IF_PRESENT>: Clean up/elaborate code + paths. + 2020-01-10 Jakub Jelinek <jakub@redhat.com> PR libgomp/93219 diff --git a/libgomp/target.c b/libgomp/target.c index 522b69e..38de1c0 100644 --- a/libgomp/target.c +++ b/libgomp/target.c @@ -740,22 +740,24 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep, cur_node.host_start = (uintptr_t) hostaddrs[i]; cur_node.host_end = cur_node.host_start; splay_tree_key n = gomp_map_lookup (mem_map, &cur_node); - if (n == NULL) + if (n != NULL) + { + cur_node.host_start -= n->host_start; + hostaddrs[i] + = (void *) (n->tgt->tgt_start + n->tgt_offset + + cur_node.host_start); + } + else if ((kind & typemask) == GOMP_MAP_USE_DEVICE_PTR) { - if ((kind & typemask) == GOMP_MAP_USE_DEVICE_PTR_IF_PRESENT) - { - /* If not present, continue using the host address. */ - tgt->list[i].offset = 0; - continue; - } gomp_mutex_unlock (&devicep->lock); gomp_fatal ("use_device_ptr pointer wasn't mapped"); } - cur_node.host_start -= n->host_start; - hostaddrs[i] - = (void *) (n->tgt->tgt_start + n->tgt_offset - + cur_node.host_start); - tgt->list[i].offset = ~(uintptr_t) 0; + else if ((kind & typemask) == GOMP_MAP_USE_DEVICE_PTR_IF_PRESENT) + /* If not present, continue using the host address. */ + ; + else + __builtin_unreachable (); + tgt->list[i].offset = OFFSET_INLINED; } else tgt->list[i].offset = 0; @@ -980,27 +982,40 @@ gomp_map_vars_internal (struct gomp_device_descr *devicep, case GOMP_MAP_FIRSTPRIVATE_INT: case GOMP_MAP_ZERO_LEN_ARRAY_SECTION: continue; - case GOMP_MAP_USE_DEVICE_PTR: case GOMP_MAP_USE_DEVICE_PTR_IF_PRESENT: + /* The OpenACC 'host_data' construct only allows 'use_device' + "mapping" clauses, so in the first loop, 'not_found_cnt' + must always have been zero, so all OpenACC 'use_device' + clauses have already been handled. (We can only easily test + 'use_device' with 'if_present' clause here.) */ + assert (tgt->list[i].offset == OFFSET_INLINED); + /* Nevertheless, FALLTHRU to the normal handling, to keep the + code conceptually simple, similar to the first loop. */ + case GOMP_MAP_USE_DEVICE_PTR: if (tgt->list[i].offset == 0) { cur_node.host_start = (uintptr_t) hostaddrs[i]; cur_node.host_end = cur_node.host_start; n = gomp_map_lookup (mem_map, &cur_node); - if (n == NULL) + if (n != NULL) + { + cur_node.host_start -= n->host_start; + hostaddrs[i] + = (void *) (n->tgt->tgt_start + n->tgt_offset + + cur_node.host_start); + } + else if ((kind & typemask) == GOMP_MAP_USE_DEVICE_PTR) { - if ((kind & typemask) - == GOMP_MAP_USE_DEVICE_PTR_IF_PRESENT) - /* If not present, continue using the host address. */ - continue; gomp_mutex_unlock (&devicep->lock); gomp_fatal ("use_device_ptr pointer wasn't mapped"); } - cur_node.host_start -= n->host_start; - hostaddrs[i] - = (void *) (n->tgt->tgt_start + n->tgt_offset - + cur_node.host_start); - tgt->list[i].offset = ~(uintptr_t) 0; + else if ((kind & typemask) + == GOMP_MAP_USE_DEVICE_PTR_IF_PRESENT) + /* If not present, continue using the host address. */ + ; + else + __builtin_unreachable (); + tgt->list[i].offset = OFFSET_INLINED; } continue; case GOMP_MAP_STRUCT: |