From: Tom de Vries <Tom_deVries@mentor.com>
To: "gcc-patches@gnu.org" <gcc-patches@gnu.org>
Subject: [gomp4, committed] Ignore reduction clauses in kernels region
Date: Tue, 29 Sep 2015 10:19:00 -0000 [thread overview]
Message-ID: <560A5EC5.5060009@mentor.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 156 bytes --]
Hi,
this patch filters out reduction clauses in an oacc kernels region. This
fixes an ICE in the test-case.
Committed to gomp-4_0-branch.
Thanks,
- Tom
[-- Attachment #2: 0001-Ignore-reduction-clauses-in-kernels-region.patch --]
[-- Type: text/x-patch, Size: 3223 bytes --]
Ignore reduction clauses in kernels region
2015-09-29 Tom de Vries <tom@codesourcery.com>
* omp-low.c (ctx_in_oacc_kernels_region): New function.
(scan_omp_for): Filter out reduction clauses in kernels region.
* c-c++-common/goacc/kernels-acc-loop-reduction.c: New test.
---
gcc/omp-low.c | 18 +++++++++++++++-
.../goacc/kernels-acc-loop-reduction.c | 25 ++++++++++++++++++++++
2 files changed, 42 insertions(+), 1 deletion(-)
create mode 100644 gcc/testsuite/c-c++-common/goacc/kernels-acc-loop-reduction.c
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index a5904eb..597035f 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2579,6 +2579,20 @@ oacc_loop_or_target_p (gimple *stmt)
&& gimple_omp_for_kind (stmt) == GF_OMP_FOR_KIND_OACC_LOOP));
}
+bool
+ctx_in_oacc_kernels_region (omp_context *ctx)
+{
+ for (;ctx != NULL; ctx = ctx->outer)
+ {
+ gimple *stmt = ctx->stmt;
+ if (gimple_code (stmt) == GIMPLE_OMP_TARGET
+ && gimple_omp_target_kind (stmt) == GF_OMP_TARGET_KIND_OACC_KERNELS)
+ return true;
+ }
+
+ return false;
+}
+
/* Scan a GIMPLE_OMP_FOR. */
static void
@@ -2592,6 +2606,7 @@ scan_omp_for (gomp_for *stmt, omp_context *outer_ctx)
bool auto_clause = false;
bool seq_clause = false;
int gwv_routine = 0;
+ bool in_oacc_kernels_region = ctx_in_oacc_kernels_region (outer_ctx);
if (outer_ctx)
outer_type = gimple_code (outer_ctx->stmt);
@@ -2665,7 +2680,8 @@ scan_omp_for (gomp_for *stmt, omp_context *outer_ctx)
/* Filter out any OpenACC clauses which aren't associated with
gangs, workers or vectors. Such reductions are no-ops. */
- if (extract_oacc_loop_mask (ctx) == 0)
+ if (extract_oacc_loop_mask (ctx) == 0
+ || in_oacc_kernels_region)
{
/* First filter out the clauses at the beginning of the chain. */
while (clauses && OMP_CLAUSE_CODE (clauses) == OMP_CLAUSE_REDUCTION)
diff --git a/gcc/testsuite/c-c++-common/goacc/kernels-acc-loop-reduction.c b/gcc/testsuite/c-c++-common/goacc/kernels-acc-loop-reduction.c
new file mode 100644
index 0000000..f3aa4e7
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/kernels-acc-loop-reduction.c
@@ -0,0 +1,25 @@
+/* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-ftree-parallelize-loops=32" } */
+/* { dg-additional-options "-fdump-tree-parloops_oacc_kernels-all" } */
+/* { dg-additional-options "-fdump-tree-optimized" } */
+
+unsigned int
+foo (int n, unsigned int *a)
+{
+ unsigned int sum = 0;
+
+#pragma acc kernels loop gang reduction(+:sum)
+ for (int i = 0; i < n; i++)
+ sum += a[i];
+
+ return sum;
+}
+
+/* Check that only one loop is analyzed, and that it can be parallelized. */
+/* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops_oacc_kernels" } } */
+/* { dg-final { scan-tree-dump-not "FAILED:" "parloops_oacc_kernels" } } */
+
+/* Check that the loop has been split off into a function. */
+/* { dg-final { scan-tree-dump-times "(?n);; Function .*foo.*\\._omp_fn\\.0" 1 "optimized" } } */
+
+/* { dg-final { scan-tree-dump-times "(?n)pragma omp target oacc_parallel.*num_gangs\\(32\\)" 1 "parloops_oacc_kernels" } } */
--
1.9.1
next reply other threads:[~2015-09-29 9:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-29 10:19 Tom de Vries [this message]
2015-09-29 11:23 ` Tom de Vries
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=560A5EC5.5060009@mentor.com \
--to=tom_devries@mentor.com \
--cc=gcc-patches@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).