https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94290

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |INVALID
             Status|UNCONFIRMED                 |RESOLVED

--- Comment #1 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
This is a test bug.  Please see
https://www.openmp.org/spec-html/5.0/openmpse22.html#x116-4340002.14
When you have a combined or composite constructs, clauses that apply to just
one of the constructs generally are applied to the construct which allows them,
while clauses that can be applied to multiple constructs have more complicated
clause distribution rules in that section.
When you have combined
!$omp target teams default(firstprivate) map(from:a)
then the default clause, as it applies to teams only and not target, goes to
teams, and map clauses go to target.
So, it is like
!$omp target map(from:a)
!$omp teams default(firstprivate)
Now, if you reference a in the teams region, there is no data sharing clause on
the teams construct for a, and the default is firstprivate, which means an
implicit firstprivate(a) clause is added to the teams construct.  The target
construct has a map clause, so a on that construct is mapped rather than
privatized, which means that each team will have its own privatized copy of a,
and the uninitialized original mapped a is then copied back.
Either don't use default(firstprivate) on the combined constructs because you
really want sharing for those vars, or you can use
!$omp target teams default(firstprivate) map(from:a) shared(a)
While OpenMP has a restriction that the same list item can't be specified in
mapping and data sharing clauses, my understanding is that this applies after
the clauses are distributed among the constituent constructs, and as target
construct doesn't allow shared clause and teams construct doesn't allow map
clause, each goes to one of them and should do what you want.
Adding shared(a, b, c, d) clause to both combined directives in your testcase
fixes it.  You can even just add shared(d), though in that case the a, b, c
arrays are mapped to the device and then copied from that to each of the teams
private copies.

Reply via email to