Hi, a previous patch of Cesar's has made the middle-end omp-lowering
automatically create and insert a tofrom (i.e. present_or_copy) map for
parallel reductions.  This allowed the user to not need explicit
clauses to copy out the reduction result, but because reduction arguments
are not marked addressable, async does not work as expected,
i.e. the asynchronous copy-out results are not used in the compiler generated 
code.

This patch fixes this in the front-ends, I've tested this patch without
new regressions, and fixes some C++ OpenACC tests that regressed after
my last OpenACC async patch.  Is this okay for trunk?

Thanks,
Chung-Lin

2016-05-30  Chung-Lin Tang  <clt...@codesourcery.com>

        c/
        * c-typeck.c (c_finish_omp_clauses): Mark OpenACC reduction
        arguments as addressable.

        cp/
        * semantics.c (finish_omp_clauses): Mark OpenACC reduction
        arguments as addressable.

        fortran/
        * trans-openmp.c (gfc_trans_oacc_construct): Mark OpenACC reduction
        arguments as addressable.
        (gfc_trans_oacc_combined_directive): Likewise.
Index: c/c-typeck.c
===================================================================
--- c/c-typeck.c        (revision 236845)
+++ c/c-typeck.c        (working copy)
@@ -12575,6 +12575,8 @@ c_finish_omp_clauses (tree clauses, enum c_omp_reg
              remove = true;
              break;
            }
+         if (ort & C_ORT_ACC)
+           c_mark_addressable (t);
          type = TREE_TYPE (t);
          if (TREE_CODE (t) == MEM_REF)
            type = TREE_TYPE (type);
Index: cp/semantics.c
===================================================================
--- cp/semantics.c      (revision 236845)
+++ cp/semantics.c      (working copy)
@@ -5827,6 +5827,8 @@ finish_omp_clauses (tree clauses, enum c_omp_regio
                t = n;
              goto check_dup_generic_t;
            }
+         if (ort & C_ORT_ACC)
+           cxx_mark_addressable (t);
          goto check_dup_generic;
        case OMP_CLAUSE_COPYPRIVATE:
          copyprivate_seen = true;
Index: fortran/trans-openmp.c
===================================================================
--- fortran/trans-openmp.c      (revision 236845)
+++ fortran/trans-openmp.c      (working copy)
@@ -2704,6 +2704,10 @@ gfc_trans_oacc_construct (gfc_code *code)
   gfc_start_block (&block);
   oacc_clauses = gfc_trans_omp_clauses (&block, code->ext.omp_clauses,
                                        code->loc);
+  for (tree c = oacc_clauses; c; c = OMP_CLAUSE_CHAIN (c))
+    if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
+       && DECL_P (OMP_CLAUSE_DECL (c)))
+      TREE_ADDRESSABLE (OMP_CLAUSE_DECL (c)) = 1;
   stmt = gfc_trans_omp_code (code->block->next, true);
   stmt = build2_loc (input_location, construct_code, void_type_node, stmt,
                     oacc_clauses);
@@ -3501,6 +3505,10 @@ gfc_trans_oacc_combined_directive (gfc_code *code)
        construct_clauses.lists[OMP_LIST_REDUCTION] = NULL;
       oacc_clauses = gfc_trans_omp_clauses (&block, &construct_clauses,
                                            code->loc);
+      for (tree c = oacc_clauses; c; c = OMP_CLAUSE_CHAIN (c))
+       if (OMP_CLAUSE_CODE (c) == OMP_CLAUSE_REDUCTION
+           && DECL_P (OMP_CLAUSE_DECL (c)))
+         TREE_ADDRESSABLE (OMP_CLAUSE_DECL (c)) = 1;
     }
   if (!loop_clauses.seq)
     pblock = &block;

Reply via email to