Hi!

On Tue, 8 Jul 2014 07:28:24 -0700, Cesar Philippidis 
<cesar_philippi...@mentor.com> wrote:
> On 07/07/2014 02:55 AM, Thomas Schwinge wrote:
> 
> > On Sun, 6 Jul 2014 16:10:56 -0700, Cesar Philippidis 
> > <cesar_philippi...@mentor.com> wrote:
> >> This patch is the first step to enabling parallel reductions in openacc.

> I've committed this updated version
> of the patch.

In r217354, I just applied the following cleanup to gomp-4_0-branch:

commit 4fe8b3620b258ac904d9eade5f76dede69a80c98
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Nov 11 14:52:26 2014 +0000

    OpenACC reductions maintenance.
    
        gcc/
        * omp-low.c (maybe_lookup_reduction): Don't require an OpenACC
        context.
        (lower_oacc_offload): Simplify use of maybe_lookup_reduction.
    
        gcc/
        * omp-low.c (delete_omp_context): Dispose of reduction_map.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@217354 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog.gomp |  6 ++++++
 gcc/omp-low.c      | 56 +++++++++++++++++++++++++++++-------------------------
 2 files changed, 36 insertions(+), 26 deletions(-)

diff --git gcc/ChangeLog.gomp gcc/ChangeLog.gomp
index dacfad8..94a7f8c 100644
--- gcc/ChangeLog.gomp
+++ gcc/ChangeLog.gomp
@@ -1,5 +1,11 @@
 2014-11-11  Thomas Schwinge  <tho...@codesourcery.com>
 
+       * omp-low.c (delete_omp_context): Dispose of reduction_map.
+
+       * omp-low.c (maybe_lookup_reduction): Don't require an OpenACC
+       context.
+       (lower_oacc_offload): Simplify use of maybe_lookup_reduction.
+
        * omp-low.c (lower_omp_target): Restore two gcc_asserts.
 
 2014-11-06  Thomas Schwinge  <tho...@codesourcery.com>
diff --git gcc/omp-low.c gcc/omp-low.c
index c63ec4e..5695ec3 100644
--- gcc/omp-low.c
+++ gcc/omp-low.c
@@ -938,7 +938,7 @@ get_base_type (tree decl)
   return type;
 }
 
-/* Lookup variables in the decl or field splay trees.  The "maybe" form
+/* Lookup variables.  The "maybe" form
    allows for the variable form to not have been entered, otherwise we
    assert that the variable must have been entered.  */
 
@@ -975,17 +975,6 @@ lookup_sfield (tree var, omp_context *ctx)
 }
 
 static inline tree
-lookup_reduction (const char *id, omp_context *ctx)
-{
-  gcc_assert (is_gimple_omp_oacc_specifically (ctx->stmt));
-
-  splay_tree_node n;
-  n = splay_tree_lookup (ctx->reduction_map,
-                        (splay_tree_key) id);
-  return (tree) n->value;
-}
-
-static inline tree
 maybe_lookup_field (tree var, omp_context *ctx)
 {
   splay_tree_node n;
@@ -994,14 +983,22 @@ maybe_lookup_field (tree var, omp_context *ctx)
 }
 
 static inline tree
+lookup_reduction (const char *id, omp_context *ctx)
+{
+  gcc_assert (is_gimple_omp_oacc_specifically (ctx->stmt));
+
+  splay_tree_node n;
+  n = splay_tree_lookup (ctx->reduction_map, (splay_tree_key) id);
+  return (tree) n->value;
+}
+
+static inline tree
 maybe_lookup_reduction (tree var, omp_context *ctx)
 {
-  gcc_assert (is_gimple_omp_oacc_specifically (ctx->stmt));
-
-  splay_tree_node n;
-  n = splay_tree_lookup (ctx->reduction_map,
-                        (splay_tree_key) var);
-  return n ?(tree) n->value : NULL_TREE;
+  splay_tree_node n = NULL;
+  if (ctx->reduction_map)
+    n = splay_tree_lookup (ctx->reduction_map, (splay_tree_key) var);
+  return n ? (tree) n->value : NULL_TREE;
 }
 
 /* Return true if DECL should be copied by pointer.  SHARED_CTX is
@@ -1574,6 +1571,11 @@ delete_omp_context (splay_tree_value value)
     splay_tree_delete (ctx->field_map);
   if (ctx->sfield_map)
     splay_tree_delete (ctx->sfield_map);
+  if (ctx->reduction_map
+      /* Shared over several omp_contexts.  */
+      && (ctx->outer == NULL
+         || ctx->reduction_map != ctx->outer->reduction_map))
+    splay_tree_delete (ctx->reduction_map);
 
   /* We hijacked DECL_ABSTRACT_ORIGIN earlier.  We need to clear it before
      it produces corrupt debug information.  */
@@ -10481,10 +10483,14 @@ lower_oacc_offload (gimple_stmt_iterator *gsi_p, 
omp_context *ctx)
                            || (OMP_CLAUSE_MAP_KIND (c)
                                != OMP_CLAUSE_MAP_FORCE_DEVICEPTR)
                            || TREE_CODE (TREE_TYPE (ovar)) != ARRAY_TYPE);
-               if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
-                   && OMP_CLAUSE_MAP_KIND (c) == OMP_CLAUSE_MAP_POINTER
-                   && !OMP_CLAUSE_MAP_ZERO_BIAS_ARRAY_SECTION (c)
-                   && TREE_CODE (TREE_TYPE (ovar)) == ARRAY_TYPE)
+               if (maybe_lookup_reduction (var, ctx))
+                 {
+                   gimplify_assign (x, var, &ilist);
+                 }
+               else if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_MAP
+                        && OMP_CLAUSE_MAP_KIND (c) == OMP_CLAUSE_MAP_POINTER
+                        && !OMP_CLAUSE_MAP_ZERO_BIAS_ARRAY_SECTION (c)
+                        && TREE_CODE (TREE_TYPE (ovar)) == ARRAY_TYPE)
                  {
                    tree avar
                      = create_tmp_var (TREE_TYPE (TREE_TYPE (x)), NULL);
@@ -10494,8 +10500,7 @@ lower_oacc_offload (gimple_stmt_iterator *gsi_p, 
omp_context *ctx)
                    avar = build_fold_addr_expr (avar);
                    gimplify_assign (x, avar, &ilist);
                  }
-               else if (is_gimple_reg (var)
-                        && !maybe_lookup_reduction (var, ctx))
+               else if (is_gimple_reg (var))
                  {
                    tree avar = create_tmp_var (TREE_TYPE (var), NULL);
                    mark_addressable (avar);
@@ -10521,8 +10526,7 @@ lower_oacc_offload (gimple_stmt_iterator *gsi_p, 
omp_context *ctx)
                  }
                else
                  {
-                   if (!maybe_lookup_reduction (var, ctx))
-                     var = build_fold_addr_expr (var);
+                   var = build_fold_addr_expr (var);
                    gimplify_assign (x, var, &ilist);
                  }
              }


Grüße,
 Thomas

Attachment: signature.asc
Description: PGP signature

Reply via email to