From: Jakub Jelinek <jakub@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [committed] Fix OpenMP VLA implicit determination in task (PR middle-end/80809)
Date: Mon, 22 May 2017 19:06:00 -0000 [thread overview]
Message-ID: <20170522190327.GG8499@tucnak> (raw)
Hi!
If a VLA is shared e.g. on parallel or task construct, we firstprivatize
a pointer pointing to it, and add a private VLA variable that will have a
DECL_VALUE_EXPR for debug info purposes. But, standardwise, the VLA is
still shared on the parallel/task, it is just implementation detail what we
are doing with it. So, for the purpose of implicit data sharing
determination we want to treat it still as shared and only when emitting or
changing the clause we want to emit private with OMP_CLAUSE_PRIVATE_DEBUG.
The following patch does that, bootstrapped/regtested on x86_64-linux and
i686-linux, committed to trunk, queued for release branches.
2017-05-22 Jakub Jelinek <jakub@redhat.com>
PR middle-end/80809
* gimplify.c (omp_add_variable): For GOVD_DEBUG_PRIVATE use
GOVD_SHARED rather than GOVD_PRIVATE with it.
(gimplify_adjust_omp_clauses_1, gimplify_adjust_omp_clauses): Expect
GOVD_SHARED rather than GOVD_PRIVATE with GOVD_DEBUG_PRIVATE.
* testsuite/libgomp.c/pr80809-1.c: New test.
--- gcc/gimplify.c.jj 2017-05-22 10:50:07.000000000 +0200
+++ gcc/gimplify.c 2017-05-22 13:07:00.520162436 +0200
@@ -6693,7 +6693,7 @@ omp_add_variable (struct gimplify_omp_ct
of PRIVATE. The sharing would take place via the pointer variable
which we remapped above. */
if (flags & GOVD_SHARED)
- flags = GOVD_PRIVATE | GOVD_DEBUG_PRIVATE
+ flags = GOVD_SHARED | GOVD_DEBUG_PRIVATE
| (flags & (GOVD_SEEN | GOVD_EXPLICIT));
/* We're going to make use of the TYPE_SIZE_UNIT at least in the
@@ -8616,7 +8616,7 @@ gimplify_adjust_omp_clauses_1 (splay_tre
return 0;
if (flags & GOVD_DEBUG_PRIVATE)
{
- gcc_assert ((flags & GOVD_DATA_SHARE_CLASS) == GOVD_PRIVATE);
+ gcc_assert ((flags & GOVD_DATA_SHARE_CLASS) == GOVD_SHARED);
private_debug = true;
}
else if (flags & GOVD_MAP)
@@ -8878,7 +8878,7 @@ gimplify_adjust_omp_clauses (gimple_seq
{
gcc_assert ((n->value & GOVD_DEBUG_PRIVATE) == 0
|| ((n->value & GOVD_DATA_SHARE_CLASS)
- == GOVD_PRIVATE));
+ == GOVD_SHARED));
OMP_CLAUSE_SET_CODE (c, OMP_CLAUSE_PRIVATE);
OMP_CLAUSE_PRIVATE_DEBUG (c) = 1;
}
--- libgomp/testsuite/libgomp.c/pr80809-1.c.jj 2017-05-22 12:52:11.445135718 +0200
+++ libgomp/testsuite/libgomp.c/pr80809-1.c 2017-05-22 12:51:10.000000000 +0200
@@ -0,0 +1,29 @@
+/* PR middle-end/80809 */
+/* { dg-do run } */
+
+__attribute__((noinline, noclone)) void
+foo (int x)
+{
+ int i, j, v[x], *w[16];
+ for (i = 0; i < x; i++)
+ v[i] = i;
+#pragma omp parallel
+#pragma omp single
+ for (i = 0; i < 16; i++)
+ /* Make sure v is implicitly determined shared in task, because it
+ is shared on the parallel. */
+#pragma omp task private (j)
+ w[i] = v;
+ for (i = 0; i < 16; i++)
+ if (w[i] != v)
+ __builtin_abort ();
+}
+
+int
+main ()
+{
+ foo (4);
+ foo (27);
+ foo (196);
+ return 0;
+}
Jakub
reply other threads:[~2017-05-22 19:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20170522190327.GG8499@tucnak \
--to=jakub@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
/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).