On 2016/6/1 09:38 PM, Jakub Jelinek wrote: >> 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_ASYNC) >> > + { >> > + for (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; >> > + break; >> > + } >> > } > These 2 look wrong to me. 1) you really don't need to walk all the clauses > to find if there is OMP_CLAUSE_ASYNC, you can just test the > async field of struct gfc_omp_clauses. And, 2) is there any reason why you > can't just do this in gfc_trans_omp_clauses instead, when crating > OMP_CLAUSE_REDUCTION if clauses->async is set? Or are there some cases > where on OpenACC constructs you don't want to do this?
Thanks for reminding, I didn't notice there was such a gfc_omp_clauses->async field. Here's a much more succinct patch that does it inside gfc_trans_omp_clauses. Again re-tested gfortran and libgomp without regressions. Is this and the C/C++ patches (and the new testsuite cases) okay for trunk? Thanks, Chung-Lin fortran/ * trans-openmp.c (gfc_trans_omp_clauses): Mark OpenACC reduction arguments as addressable when async clause exists.
Index: trans-openmp.c =================================================================== --- trans-openmp.c (revision 236845) +++ trans-openmp.c (working copy) @@ -1748,6 +1748,12 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp { case OMP_LIST_REDUCTION: omp_clauses = gfc_trans_omp_reduction_list (n, omp_clauses, where); + /* An OpenACC async clause indicates the need to set reduction + arguments addressable, to allow asynchronous copy-out. */ + if (clauses->async) + for (c = omp_clauses; c; c = OMP_CLAUSE_CHAIN (c)) + if (DECL_P (OMP_CLAUSE_DECL (c))) + TREE_ADDRESSABLE (OMP_CLAUSE_DECL (c)) = 1; break; case OMP_LIST_PRIVATE: clause_code = OMP_CLAUSE_PRIVATE;