public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "jakub at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libgomp/94290] [gfortran] OpenMP target teams distribute default firstprivate causes failure to map back values from device
Date: Fri, 27 Mar 2020 19:32:03 +0000	[thread overview]
Message-ID: <bug-94290-4-9YRDOcst1t@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-94290-4@http.gcc.gnu.org/bugzilla/>

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	other threads:[~2020-03-27 19:32 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-23 18:47 [Bug libgomp/94290] New: " jhdavis at udel dot edu
2020-03-27 19:32 ` jakub at gcc dot gnu.org [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-94290-4-9YRDOcst1t@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).