]> gcc.gnu.org Git - gcc.git/commit
OpenMP/Fortran: Combined directives with map/firstprivate of same symbol
authorJulian Brown <julian@codesourcery.com>
Wed, 21 Dec 2022 17:45:51 +0000 (18:45 +0100)
committerTobias Burnus <tobias@codesourcery.com>
Wed, 21 Dec 2022 17:45:51 +0000 (18:45 +0100)
commitc4d7c7ee9173323f9db3d84ef7b96894dc2ac664
tree8b559a926c9594cc8509367095852e35b7019160
parent10aec76c90dc9ba0a8ccf52c8980c61bf684c79a
OpenMP/Fortran: Combined directives with map/firstprivate of same symbol

This patch fixes a case where a combined directive (e.g. "!$omp target
parallel ...") contains both a map and a firstprivate clause for the
same variable.  When the combined directive is split into two nested
directives, the outer "target" gets the "map" clause, and the inner
"parallel" gets the "firstprivate" clause, like so:

  !$omp target parallel map(x) firstprivate(x)

  -->

  !$omp target map(x)
    !$omp parallel firstprivate(x)
      ...

When there is no map of the same variable, the firstprivate is distributed
to both directives, e.g. for 'y' in:

  !$omp target parallel map(x) firstprivate(y)

  -->

  !$omp target map(x) firstprivate(y)
    !$omp parallel firstprivate(y)
      ...

This is not a recent regression, but appear to fix a long-standing ICE.
(The included testcase is based on one by Tobias.)

2022-12-06  Julian Brown  <julian@codesourcery.com>

gcc/fortran/
* trans-openmp.cc (gfc_add_firstprivate_if_unmapped): New function.
(gfc_split_omp_clauses): Call above.

libgomp/
* testsuite/libgomp.fortran/combined-directive-splitting-1.f90: New
test.

(cherry picked from commit 9316ad3b4354cbf2980f86902e54884e918c472a)
gcc/fortran/ChangeLog.omp
gcc/fortran/trans-openmp.cc
gcc/testsuite/ChangeLog.omp
libgomp/testsuite/libgomp.fortran/combined-directive-splitting-1.f90 [new file with mode: 0644]
This page took 0.065629 seconds and 6 git commands to generate.