On Fri, Jun 03, 2016 at 03:13:40PM +0800, Chung-Lin Tang wrote:
> On 2016/6/2 10:00 PM, Jakub Jelinek wrote:
> > Wouldn't it be better to pass either a bool openacc_async flag, or
> > whole clauses, down to gfc_trans_omp_reduction_list and handle it there
> > instead of walking the list after the fact?
>
> You mean this style? (patch attached)
> Tested again with no regressions.
>
> Thanks,
> Chung-Lin
>
> * trans-openmp.c (gfc_trans_omp_reduction_list): Add mark_addressable
> bool parameter, set reduction clause DECLs as addressable when true.
> (gfc_trans_omp_clauses): Pass clauses->async to
> gfc_trans_omp_reduction_list, add comment describing OpenACC
> situation.
Yep, thanks (and the C/C++ patch is ok too).
> Index: trans-openmp.c
> ===================================================================
> --- trans-openmp.c (revision 236845)
> +++ trans-openmp.c (working copy)
> @@ -1646,7 +1646,7 @@ gfc_trans_omp_array_reduction_or_udr (tree c, gfc_
>
> static tree
> gfc_trans_omp_reduction_list (gfc_omp_namelist *namelist, tree list,
> - locus where)
> + locus where, bool mark_addressable)
> {
> for (; namelist != NULL; namelist = namelist->next)
> if (namelist->sym->attr.referenced)
> @@ -1657,6 +1657,8 @@ gfc_trans_omp_reduction_list (gfc_omp_namelist *na
> tree node = build_omp_clause (where.lb->location,
> OMP_CLAUSE_REDUCTION);
> OMP_CLAUSE_DECL (node) = t;
> + if (mark_addressable)
> + TREE_ADDRESSABLE (t) = 1;
> switch (namelist->u.reduction_op)
> {
> case OMP_REDUCTION_PLUS:
> @@ -1747,7 +1749,10 @@ gfc_trans_omp_clauses (stmtblock_t *block, gfc_omp
> switch (list)
> {
> 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. */
> + omp_clauses = gfc_trans_omp_reduction_list (n, omp_clauses, where,
> + clauses->async);
> break;
> case OMP_LIST_PRIVATE:
> clause_code = OMP_CLAUSE_PRIVATE;
Jakub