public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug middle-end/99928] New: [OpenMP] reduction variable in combined target construct wrongly mapped as firstprivate
@ 2021-04-06  8:39 burnus at gcc dot gnu.org
  2021-04-06  9:20 ` [Bug middle-end/99928] " jakub at gcc dot gnu.org
                   ` (21 more replies)
  0 siblings, 22 replies; 23+ messages in thread
From: burnus at gcc dot gnu.org @ 2021-04-06  8:39 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 99928
           Summary: [OpenMP] reduction variable in combined target
                    construct wrongly mapped as firstprivate
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Keywords: openmp, wrong-code
          Severity: normal
          Priority: P3
         Component: middle-end
          Assignee: unassigned at gcc dot gnu.org
          Reporter: burnus at gcc dot gnu.org
                CC: anlauf at gcc dot gnu.org, jakub at gcc dot gnu.org
  Target Milestone: ---

Reported by Harald at
https://gcc.gnu.org/pipermail/fortran/2021-March/055896.html
with a Fortran program. But it also occurs for C as shown below.

OpenMP 5.1 has:
"If a list item appears in a reduction, lastprivate or linear clause
 on a combined target construct then it is treated as if it also appears
 in a map clause with a map-type of tofrom." (2.21.7)

Likewise OpenMP 5.0 in 2.19.7.

The FE chops the target-teams into target + teams and for target;
's' is implicitly mapped as 'firstprivate' instead of as 'map(tofrom:'.

It seems as if this is best done on the C/C++/Fortran FE which still sees that
it is a combined target construct.

int a[10];

int s2()
{
  int s = 0;
  #pragma omp target data map(a,s)
  {
    #pragma omp target teams reduction(+:s)
    {
      for (int i=0; i < 10; i++)
        s += a[i];
    }
  }
  return s;
}

Original dump:

 #pragma omp target data map(tofrom:s) map(tofrom:a)
  #pragma omp target
        #pragma omp teams reduction(+:s)

omplower dump:

        #pragma omp target data map(tofrom:s [len: 4]) map(tofrom:a [len: 40])
#pragma omp target num_teams(0) thread_limit(0) firstprivate(s) map(tofrom:a
[len: 40])
#pragma omp teams reduction(+:s) shared(a)

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2023-05-03 17:36 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-06  8:39 [Bug middle-end/99928] New: [OpenMP] reduction variable in combined target construct wrongly mapped as firstprivate burnus at gcc dot gnu.org
2021-04-06  9:20 ` [Bug middle-end/99928] " jakub at gcc dot gnu.org
2021-04-10 17:23 ` burnus at gcc dot gnu.org
2021-05-06 15:59 ` jakub at gcc dot gnu.org
2021-05-06 16:23 ` burnus at gcc dot gnu.org
2021-05-06 16:35 ` jakub at gcc dot gnu.org
2021-05-13 15:16 ` cvs-commit at gcc dot gnu.org
2021-05-13 19:39 ` burnus at gcc dot gnu.org
2021-05-13 20:13 ` jakub at gcc dot gnu.org
2021-05-19  7:30 ` cvs-commit at gcc dot gnu.org
2021-05-20  7:20 ` cvs-commit at gcc dot gnu.org
2021-05-21 19:15 ` cvs-commit at gcc dot gnu.org
2021-05-21 19:20 ` cvs-commit at gcc dot gnu.org
2021-05-25  9:08 ` cvs-commit at gcc dot gnu.org
2021-05-28  9:34 ` cvs-commit at gcc dot gnu.org
2021-05-29  8:08 ` cvs-commit at gcc dot gnu.org
2021-06-01 10:48 ` cvs-commit at gcc dot gnu.org
2021-06-02  9:48 ` cvs-commit at gcc dot gnu.org
2021-06-04 10:08 ` cvs-commit at gcc dot gnu.org
2021-06-04 10:19 ` cvs-commit at gcc dot gnu.org
2021-06-04 12:04 ` burnus at gcc dot gnu.org
2021-06-08  7:52 ` cvs-commit at gcc dot gnu.org
2023-05-03 17:36 ` anlauf at gcc dot gnu.org

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).