public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Cesar Philippidis <cesar_philippidis@mentor.com>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: Re: [gomp4] private reductions
Date: Sat, 09 Jan 2016 01:14:00 -0000	[thread overview]
Message-ID: <56905F06.1080608@mentor.com> (raw)
In-Reply-To: <568DE196.3040907@codesourcery.com>

[-- Attachment #1: Type: text/plain, Size: 1127 bytes --]

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


[-- Attachment #2: nested_ctx.diff --]
[-- Type: text/x-patch, Size: 971 bytes --]

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.  */

  parent reply	other threads:[~2016-01-09  1:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-02 16:10 [0/3] OpenACC reductions Nathan Sidwell
2015-10-18 23:20 ` [gomp4] fortran testcase Nathan Sidwell
2015-11-02 16:18 ` [1/3] OpenACC reductions Nathan Sidwell
2015-11-03 15:46   ` Jakub Jelinek
2015-11-03 16:02     ` Nathan Sidwell
2015-11-04 10:31       ` Jakub Jelinek
2015-11-04 13:58         ` Nathan Sidwell
2015-11-04 14:08           ` Jakub Jelinek
2015-11-04  9:59   ` Jakub Jelinek
2015-11-06 10:47   ` [gomp4] " Thomas Schwinge
2016-01-07  3:55     ` [gomp4] private reductions Cesar Philippidis
2016-01-07 16:53       ` Cesar Philippidis
2016-01-09  1:14       ` Cesar Philippidis [this message]
2016-01-11 12:10       ` Thomas Schwinge
2016-01-11 14:55         ` Cesar Philippidis
2021-08-09 11:37   ` [1/3] OpenACC reductions Thomas Schwinge
2015-11-02 16:35 ` [2/3] " Nathan Sidwell
2015-11-04 10:01   ` Jakub Jelinek
2015-11-04 13:57     ` Nathan Sidwell
2015-11-04 13:27   ` Bernd Schmidt
2015-11-04 14:09     ` Nathan Sidwell
2015-11-04 16:59     ` Nathan Sidwell
2015-11-06 10:48       ` [gomp4] " Thomas Schwinge
2015-11-02 16:38 ` [3/3] " Nathan Sidwell
2015-11-04 10:03   ` Jakub Jelinek
2015-11-06 10:49   ` [gomp4] " 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=56905F06.1080608@mentor.com \
    --to=cesar_philippidis@mentor.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).