Hi! On Tue, 11 Nov 2014 16:03:05 +0100, I wrote: > 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
I further tried to tidy this up as follows -- but that is causing the reduction execution tests to fail; indeed -fdump-tree-all already shows unexpected changes during gimplification. (I first suspected that variables are added to a "GIMPLE_OMP_FOR" reduction_map, and then not found when reading from "GIMPLE_OACC_PARALLEL" one, but now I'm not at all sure about this theory.) Cesar, is cleanup like that useful at all, and if yes, could you look into that, later on? (Definitely not urgent.) commit 3ef04b65c1b5d3db5aa4b903a1ec0f693bb75ca8 Author: Thomas Schwinge <tho...@codesourcery.com> Date: Tue Nov 11 13:04:00 2014 +0100 [WIP] Make reduction_map per context. --- gcc/omp-low.c | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git gcc/omp-low.c gcc/omp-low.c index 5695ec3..44ed9a0 100644 --- gcc/omp-low.c +++ gcc/omp-low.c @@ -987,8 +987,19 @@ 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); + splay_tree_node n = NULL; + do + { + if (ctx->reduction_map != NULL) + n = splay_tree_lookup (ctx->reduction_map, (splay_tree_key) id); + if (n != NULL) + break; + /* If not found, recurse into outer context. */ + ctx = ctx->outer; + } + while (ctx != NULL + /* && ctx->reduction_map != NULL */); + gcc_assert (n != NULL); return (tree) n->value; } @@ -996,8 +1007,17 @@ static inline tree maybe_lookup_reduction (tree var, omp_context *ctx) { splay_tree_node n = NULL; - if (ctx->reduction_map) - n = splay_tree_lookup (ctx->reduction_map, (splay_tree_key) var); + do + { + if (ctx->reduction_map != NULL) + n = splay_tree_lookup (ctx->reduction_map, (splay_tree_key) var); + if (n != NULL) + break; + /* If not found, recurse into outer context. */ + ctx = ctx->outer; + } + while (ctx != NULL + /* && ctx->reduction_map != NULL */); return n ? (tree) n->value : NULL_TREE; } @@ -1498,8 +1518,6 @@ new_omp_context (gimple stmt, omp_context *outer_ctx) ctx->cb = outer_ctx->cb; ctx->cb.block = NULL; ctx->depth = outer_ctx->depth + 1; - /* FIXME: handle reductions recursively. */ - ctx->reduction_map = outer_ctx->reduction_map; } else { @@ -1513,7 +1531,6 @@ new_omp_context (gimple stmt, omp_context *outer_ctx) ctx->cb.eh_lp_nr = 0; ctx->cb.transform_call_graph_edges = CB_CGE_MOVE; ctx->depth = 1; - //TODO ctx->reduction_map = TODO; } ctx->cb.decl_map = new hash_map<tree, tree>; @@ -1571,10 +1588,7 @@ 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)) + if (ctx->reduction_map) splay_tree_delete (ctx->reduction_map); /* We hijacked DECL_ABSTRACT_ORIGIN earlier. We need to clear it before @@ -1765,6 +1779,7 @@ scan_sharing_clauses (tree clauses, omp_context *ctx) install_var_local (array, c); /* Insert it into the current context. */ + //TODO splay_tree_insert (ctx->reduction_map, (splay_tree_key) omp_get_id(var), (splay_tree_value) array); @@ -2394,8 +2409,8 @@ scan_oacc_offload (gimple stmt, omp_context *outer_ctx) DECL_ARTIFICIAL (name) = 1; DECL_NAMELESS (name) = 1; TYPE_NAME (ctx->record_type) = name; - create_omp_child_function (ctx, false); ctx->reduction_map = splay_tree_new (splay_tree_compare_pointers, 0, 0); + create_omp_child_function (ctx, false); gimple_omp_set_child_fn (stmt, ctx->cb.dst_fn); @@ -2658,6 +2673,8 @@ scan_omp_for (gimple stmt, omp_context *outer_ctx) size_t i; ctx = new_omp_context (stmt, outer_ctx); + if (gimple_omp_for_kind (stmt) == GF_OMP_FOR_KIND_OACC_LOOP) + ctx->reduction_map = splay_tree_new (splay_tree_compare_pointers, 0, 0); scan_sharing_clauses (gimple_omp_for_clauses (stmt), ctx); Grüße, Thomas
signature.asc
Description: PGP signature