@@ -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);