[PATCH] [gfortran] Add support for allocate clause (OpenMP 5.0).

Jakub Jelinek jakub@redhat.com
Tue Nov 2 17:54:17 GMT 2021


On Tue, Nov 02, 2021 at 05:27:14PM +0100, Jakub Jelinek via Gcc-patches wrote:
> I'm not sure this is what the standard says, certainly C/C++ FE do this
> quite differently for combined/composite constructs.
> In particular, we first split the clauses to the individual leaf constructs
> in c_omp_split_clauses, which for allocate clause is even more complicated
> because as clarified in 5.2:
> "The effect of the allocate clause is as if it is applied to all leaf constructs that permit the clause
> and to which a data-sharing attribute clause that may create a private copy of the same list item is
> applied."
> so there is the has_dup_allocate stuff, we first duplicate it to all leaf
> constructs that allow the allocate clause and set has_dup_allocate if it is
> put on more than one construct, and then if has_dup_allocate is set, do
> more detailed processing.  And finally then {,c_}finish_omp_clauses
> diagnoses what you are trying above, but only on each leaf construct
> separately.
> 
> Now, Fortran is performing the splitting of clauses only much later in
> trans-openmp.c, I wonder if it doesn't have other issues on
> combined/composite constructs if it performs other checks only on the
> clauses on the whole combined/composite construct and not just each leaf
> separately.  I'd say we should move that diagnostics and perhaps other
> similar later on into a separate routine that is invoked only after the
> clauses are split or for non-combined/composite construct clauses.

Testcases unrelated to allocate clause that have same problematic behavior:

void
foo (int x)
{
  #pragma omp parallel for simd shared (x) private (x)
  for (int i = 0; i < 32; i++)
    ;
}

is correctly accepted, as per
Clauses on Combined and Composite Constructs
shared clause goes to parallel construct, private goes to innermost
leaf aka simd, so there is no leaf construct with multiple data sharing
clauses for x.

But:

subroutine foo (x)
  integer :: x, i
  !$omp parallel do simd shared (x) private (x)
  do i = 1, 32
  end do
end subroutine

is incorrectly rejected with:
    3 |   !$omp parallel do simd shared (x) private (x)
      |                                 1
Error: Symbol ‘x’ present on multiple clauses at (1)

	Jakub



More information about the Gcc-patches mailing list