From: Jakub Jelinek <jakub@redhat.com>
To: Ilya Verbin <iverbin@gmail.com>
Cc: gcc-patches@gcc.gnu.org, Kirill Yukhin <kirill.yukhin@gmail.com>
Subject: Re: [gomp4.1] Various accelerator updates from OpenMP 4.1
Date: Mon, 07 Sep 2015 12:48:00 -0000 [thread overview]
Message-ID: <20150907124815.GR1847@tucnak.redhat.com> (raw)
In-Reply-To: <20150904180702.GB10772@msticlxl57.ims.intel.com>
On Fri, Sep 04, 2015 at 09:07:02PM +0300, Ilya Verbin wrote:
> It seems that there is a bug some here:
>
> Here is the reproducer:
>
> #pragma omp declare target
> int a[1];
> #pragma omp end declare target
>
> void foo ()
> {
> #pragma omp target map(to: a[0:1])
> a;
> }
>
>
> lookup_decl (var, ctx) tries to lookup for 'a', but ctx->cb.decl_map->get ()
> returns null-pointer.
Fixed thusly, tested on x86_64-linux, committed to gomp4.1 branch.
2015-09-07 Jakub Jelinek <jakub@redhat.com>
* omp-low.c (scan_sharing_clauses): Don't ignore map with
declare target vars for GOMP_MAP_FIRSTPRIVATE_POINTER,
unless the decl is an array.
(lower_omp_target): Ignore GOMP_MAP_FIRSTPRIVATE_POINTER map with
declare target var if it is an array.
* testsuite/libgomp.c/target-26.c: New test.
--- gcc/omp-low.c.jj 2015-09-04 11:34:45.000000000 +0200
+++ gcc/omp-low.c 2015-09-07 14:10:36.198517500 +0200
@@ -2060,6 +2060,8 @@ scan_sharing_clauses (tree clauses, omp_
directly. */
if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
&& DECL_P (decl)
+ && (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FIRSTPRIVATE_POINTER
+ || TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
&& is_global_var (maybe_lookup_decl_in_outer_ctx (decl, ctx))
&& varpool_node::get_create (decl)->offloadable)
break;
@@ -2284,6 +2286,8 @@ scan_sharing_clauses (tree clauses, omp_
break;
decl = OMP_CLAUSE_DECL (c);
if (DECL_P (decl)
+ && (OMP_CLAUSE_MAP_KIND (c) != GOMP_MAP_FIRSTPRIVATE_POINTER
+ || TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
&& is_global_var (maybe_lookup_decl_in_outer_ctx (decl, ctx))
&& varpool_node::get_create (decl)->offloadable)
break;
@@ -13358,6 +13362,10 @@ lower_omp_target (gimple_stmt_iterator *
{
if (TREE_CODE (TREE_TYPE (var)) == ARRAY_TYPE)
{
+ if (is_global_var (maybe_lookup_decl_in_outer_ctx (var, ctx))
+ && varpool_node::get_create (var)->offloadable)
+ continue;
+
tree type = build_pointer_type (TREE_TYPE (var));
tree new_var = lookup_decl (var, ctx);
x = create_tmp_var_raw (type, get_name (new_var));
@@ -14081,6 +14089,12 @@ lower_omp_target (gimple_stmt_iterator *
HOST_WIDE_INT offset = 0;
gcc_assert (prev);
var = OMP_CLAUSE_DECL (c);
+ if (DECL_P (var)
+ && TREE_CODE (TREE_TYPE (var)) == ARRAY_TYPE
+ && is_global_var (maybe_lookup_decl_in_outer_ctx (var,
+ ctx))
+ && varpool_node::get_create (var)->offloadable)
+ break;
if (TREE_CODE (var) == INDIRECT_REF
&& TREE_CODE (TREE_OPERAND (var, 0)) == COMPONENT_REF)
var = TREE_OPERAND (var, 0);
--- libgomp/testsuite/libgomp.c/target-26.c.jj 2015-09-07 11:59:08.665425993 +0200
+++ libgomp/testsuite/libgomp.c/target-26.c 2015-09-07 12:38:56.000000000 +0200
@@ -0,0 +1,36 @@
+extern void abort (void);
+#pragma omp declare target
+int a[4] = { 2, 3, 4, 5 }, *b;
+#pragma omp end declare target
+
+int
+main ()
+{
+ int err;
+ int c[3] = { 6, 7, 8 };
+ b = c;
+ #pragma omp target map(to: a[0:2], b[0:2]) map(from: err)
+ err = a[0] != 2 || a[1] != 3 || a[2] != 4 || a[3] != 5 || b[0] != 6 || b[1] != 7;
+ if (err)
+ abort ();
+ a[1] = 9;
+ a[2] = 10;
+ #pragma omp target map(always,to:a[1:2]) map(from: err)
+ err = a[0] != 2 || a[1] != 9 || a[2] != 10 || a[3] != 5;
+ if (err)
+ abort ();
+ #pragma omp parallel firstprivate(a, b, c, err) num_threads (2)
+ #pragma omp single
+ {
+ b = c + 1;
+ a[0] = 11;
+ a[2] = 13;
+ c[1] = 14;
+ int d = 0;
+ #pragma omp target map(to: a[0:3], b[d:2]) map (from: err)
+ err = a[0] != 11 || a[1] != 9 || a[2] != 13 || b[0] != 14 || b[1] != 8;
+ if (err)
+ abort ();
+ }
+ return 0;
+}
Jakub
next prev parent reply other threads:[~2015-09-07 12:48 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-29 11:44 [gomp4.1] Initial support for some OpenMP 4.1 construct parsing Jakub Jelinek
2015-04-29 11:55 ` Thomas Schwinge
2015-04-29 12:31 ` Jakub Jelinek
2015-04-29 15:20 ` Thomas Schwinge
2015-06-09 18:39 ` Ilya Verbin
2015-06-09 20:25 ` Jakub Jelinek
2015-06-25 19:47 ` Ilya Verbin
2015-06-25 20:31 ` Jakub Jelinek
2015-07-17 16:47 ` Ilya Verbin
2015-07-17 16:54 ` Jakub Jelinek
2015-07-20 16:18 ` Jakub Jelinek
2015-07-20 18:31 ` Jakub Jelinek
2015-07-23 0:50 ` Jakub Jelinek
2015-07-24 20:33 ` Jakub Jelinek
2015-07-29 17:30 ` [gomp4.1] Various accelerator updates from OpenMP 4.1 Jakub Jelinek
2015-09-04 18:17 ` Ilya Verbin
2015-09-04 18:25 ` Jakub Jelinek
2015-09-07 12:48 ` Jakub Jelinek [this message]
2015-07-20 19:40 ` [gomp4.1] Initial support for some OpenMP 4.1 construct parsing Ilya Verbin
2015-08-24 12:38 ` Jakub Jelinek
2015-08-24 19:10 ` Ilya Verbin
2015-06-11 12:52 ` [gomp4.1] map clause parsing improvements Jakub Jelinek
2015-10-19 10:34 ` Thomas Schwinge
2015-10-19 10:46 ` Jakub Jelinek
2015-10-19 15:14 ` Thomas Schwinge
2015-10-20 10:10 ` Jakub Jelinek
2015-10-26 13:04 ` Ilya Verbin
2015-10-26 13:17 ` Jakub Jelinek
2015-10-26 14:16 ` Ilya Verbin
2016-03-17 14:34 ` Thomas Schwinge
2016-03-17 14:37 ` Jakub Jelinek
2016-03-17 14:55 ` Jakub Jelinek
2016-03-17 15:13 ` Rename GOMP_MAP_FORCE_DEALLOC to GOMP_MAP_DELETE (was: [gomp4.1] map clause parsing improvements) Thomas Schwinge
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150907124815.GR1847@tucnak.redhat.com \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=iverbin@gmail.com \
--cc=kirill.yukhin@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).