On Wed, Jun 01, 2016 at 09:32:26PM +0800, Chung-Lin Tang wrote:
> 2016-06-01  Chung-Lin Tang  <clt...@codesourcery.com>
> 
>       c/
>       * c-typeck.c (c_finish_omp_clauses): Mark OpenACC reduction
>       arguments as addressable when async clause exists.
> 
>       cp/
>       * semantics.c (finish_omp_clauses): Mark OpenACC reduction
>       arguments as addressable when async clause exists.

This LGTM.
> 
>       fortran/
>       * trans-openmp.c (gfc_trans_oacc_construct): Mark OpenACC reduction
>       arguments as addressable. when async clause exists.
>       (gfc_trans_oacc_combined_directive): Likewise.

> --- fortran/trans-openmp.c    (revision 236845)
> +++ fortran/trans-openmp.c    (working copy)
> @@ -2704,6 +2704,15 @@ 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_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;
> +      }
>    stmt = gfc_trans_omp_code (code->block->next, true);
>    stmt = build2_loc (input_location, construct_code, void_type_node, stmt,
>                    oacc_clauses);
> @@ -3501,6 +3510,15 @@ 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_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?

        Jakub

Reply via email to