[Patch][Fortran] OpenMP 5 – permit more sharing clauses for SIMD (PR94690)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view

[Patch][Fortran] OpenMP 5 – permit more sharing clauses for SIMD (PR94690)

Tobias Burnus-3
Another issue found when looking into PR94690 and its
regression/additional issues.

This patch lifts a restriction of Data-sharing Attribute
Rules for Variables Referenced in a Construct.

OpenMP 4.5 had:
* The loop iteration variable(s) in the associated do-loop(s) of a
   do, parallel do, taskloop, or distribute construct may be listed in
   a *private* or *lastprivate* clause.
* The loop iteration variable in the associated do-loop of a simd
   construct with just one associated do-loop may be listed in a
   *linear* clause with a linear-step that is the increment of the
   associated loop.
* The loop iteration variables in the associated do-loops of a simd
   construct with multiple associated do-loops may be listed in a
   *lastprivate* clause.

OpenMP 5.0 changed this in to
* (unchanged)
* ... a simd construct with just one associated for-loop may be
   listed in a private, lastprivate, or linear ...
* simd construct with multiple associated for-loops may be listed
   in a private or lastprivate clause

Namely: private + lastprivate is now allowed in all cases.

OK for the trunk?


PS: The remaining issue of the PR (PR94690) is about predetermined
'private' for loop variables to which complicated rules apply. Those
have been implemented on the ME side which does not recognize Fortran
loops ("while(1)" constructs*); OpenMP-ed loops use "for(..." and those
are handled by the ME.

For that reason, the FE adds a bunch of 'private' but not always to
the right OpenMP construct and not always recognizing that the user
already had specified one. (Causing ICEs or reject value issues.)
teams/distribute + workshare cause the extra complexity.

[* The while(1) loops are used be the FE to match the Fortran semantic
regarding overflowing handling for  "i + step" exceeding INT_MAX
(stop iteration instead of overflowing and continuing).]

Mentor Graphics (Deutschland) GmbH, Arnulfstraße 201, 80634 München / Germany
Registergericht München HRB 106955, Geschäftsführer: Thomas Heurung, Alexander Walter

omp5-simd.diff (3K) Download Attachment
Reply | Threaded
Open this post in threaded view

Re: [Patch][Fortran] OpenMP 5 – permit more sharing clauses for SIMD (PR94690)

gcc - fortran mailing list
On Fri, May 15, 2020 at 12:53:41PM +0200, Tobias Burnus wrote:
> [Fortran] OpenMP 5 – permit more sharing clauses for SIMD (PR94690)
> gcc/fortran/
> PR fortran/94690
> * openmp.c (resolve_omp_do):

I'd hope Martin's script would reject such a commit.  You didn't say what
you've changed.

> gcc/testsuite/
> PR fortran/94690
> * gfortran.dg/gomp/openmp-simd-4.f90: New test.

Otherwise LGTM, except that I think (but that can be done incrementally)
that it would be highly desirable to have also a runtime testcase that tests
the values after the loop when lastprivate or linear clauses are used
or are predetermined.  Some of that is hopefully already in the testsuite
somewhere (the cases that were valid before), and one really can't test
after private (explicit or predetermined), because the value is undefined.
So that boils down to lastprivate on simd collapse(1) or simd without
collapse, and various kinds of do loops (step 1, -1, constant other,
variable), ideally some that can be actually vectorized.  And that
test doesn't need to be in libgomp, but could be in gfortran.dg/vect/
with -fopenmp-simd.