diff options
author | Jakub Jelinek <jakub@redhat.com> | 2020-02-09 08:17:10 +0100 |
---|---|---|
committer | Jakub Jelinek <jakub@redhat.com> | 2020-02-09 08:17:10 +0100 |
commit | 9bc3b95dfefd37d860c5dc0004f8a53f6290fbb1 (patch) | |
tree | 3c52ec4eaaf12982e117be6ae6dd5ed634055cbf /gcc | |
parent | a5691173e6142b11c5d45bed073ff65bfe1f2d73 (diff) | |
download | gcc-9bc3b95dfefd37d860c5dc0004f8a53f6290fbb1.zip gcc-9bc3b95dfefd37d860c5dc0004f8a53f6290fbb1.tar.gz gcc-9bc3b95dfefd37d860c5dc0004f8a53f6290fbb1.tar.bz2 |
openmp: Optimize DECL_IN_CONSTANT_POOL vars in target regions
DECL_IN_CONSTANT_POOL are shared and thus don't really get emitted in the
BLOCK where they are used, so for OpenMP target regions that have initializers
gimplified into copying from them we actually map them at runtime from host to
offload devices. This patch instead marks them as "omp declare target", so
that they are on the target device from the beginning and don't need to be
copied there.
2020-02-09 Jakub Jelinek <jakub@redhat.com>
* gimplify.c (gimplify_adjust_omp_clauses_1): Promote
DECL_IN_CONSTANT_POOL variables into "omp declare target" to avoid
copying them around between host and target.
* testsuite/libgomp.c/target-38.c: New test.
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/gimplify.c | 16 |
2 files changed, 22 insertions, 0 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b46ea4f..34c0811 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2020-02-09 Jakub Jelinek <jakub@redhat.com> + + * gimplify.c (gimplify_adjust_omp_clauses_1): Promote + DECL_IN_CONSTANT_POOL variables into "omp declare target" to avoid + copying them around between host and target. + 2020-02-08 Andrew Pinski <apinski@marvell.com> PR target/91927 diff --git a/gcc/gimplify.c b/gcc/gimplify.c index aafef78..a6205d6 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -9906,6 +9906,22 @@ gimplify_adjust_omp_clauses_1 (splay_tree_node n, void *data) error ("%<_Atomic%> %qD in implicit %<map%> clause", decl); return 0; } + if (VAR_P (decl) + && DECL_IN_CONSTANT_POOL (decl) + && !lookup_attribute ("omp declare target", + DECL_ATTRIBUTES (decl))) + { + tree id = get_identifier ("omp declare target"); + DECL_ATTRIBUTES (decl) + = tree_cons (id, NULL_TREE, DECL_ATTRIBUTES (decl)); + varpool_node *node = varpool_node::get (decl); + if (node) + { + node->offloadable = 1; + if (ENABLE_OFFLOADING) + g->have_offload = true; + } + } } else if (flags & GOVD_SHARED) { |