This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [gomp4] private reductions
- From: Cesar Philippidis <cesar_philippidis at mentor dot com>
- To: "gcc-patches at gcc dot gnu dot org" <gcc-patches at gcc dot gnu dot org>
- Date: Fri, 8 Jan 2016 17:14:46 -0800
- Subject: Re: [gomp4] private reductions
- Authentication-results: sourceware.org; auth=none
- References: <568DE196 dot 3040907 at codesourcery dot com>
On 01/06/2016 07:55 PM, Cesar Philippidis wrote:
> @@ -1384,26 +1331,9 @@ build_outer_var_ref (tree var, omp_context *ctx, bool lastprivate = false)
> x = build_simple_mem_ref (x);
> }
> }
> - else if (is_oacc_parallel (ctx))
> - x = var;
> else if (ctx->outer)
> - {
> - /* OpenACC may have multiple outer contexts (one per loop). */
> - if (gimple_code (ctx->stmt) == GIMPLE_OMP_FOR
> - && gimple_omp_for_kind (ctx->stmt) == GF_OMP_FOR_KIND_OACC_LOOP)
> - {
> - do
> - {
> - ctx = ctx->outer;
> - x = maybe_lookup_decl (var, ctx);
> - }
> - while(!x);
> - }
> - else
> - x = lookup_decl (var, ctx->outer);
> - }
It turns out that this is still necessary for openacc. The attached
patch reverts this particular change. This fixes a bug that I
encountered in a program I which I didn't have time to reduce.
Basically, that program was doing something like this
#pragma acc loop vector(length:var)
where var is some variable declared outside of a kernels region. I'll
apply the patch to gomp4 now, and add a couple of more test cases next week.
Cesar
2016-01-08 Cesar Philippidis <cesar@codesourcery.com>
gcc/
* omp-low.c (build_outer_var_ref): Recursively scan for decls
in outer omp contexts.
diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 69dabfe..98422fb 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -1332,7 +1332,21 @@ build_outer_var_ref (tree var, omp_context *ctx, bool lastprivate = false)
}
}
else if (ctx->outer)
- x = lookup_decl (var, ctx->outer);
+ {
+ /* OpenACC may have multiple outer contexts (one per loop). */
+ if (gimple_code (ctx->stmt) == GIMPLE_OMP_FOR
+ && gimple_omp_for_kind (ctx->stmt) == GF_OMP_FOR_KIND_OACC_LOOP)
+ {
+ do
+ {
+ ctx = ctx->outer;
+ x = maybe_lookup_decl (var, ctx);
+ }
+ while(!x);
+ }
+ else
+ x = lookup_decl (var, ctx->outer);
+ }
else if (is_reference (var))
/* This can happen with orphaned constructs. If var is reference, it is
possible it is shared and as such valid. */