From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id E61BE3846077; Tue, 6 Apr 2021 08:39:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E61BE3846077 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/99928] New: [OpenMP] reduction variable in combined target construct wrongly mapped as firstprivate Date: Tue, 06 Apr 2021 08:39:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: middle-end X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: openmp, wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 06 Apr 2021 08:39:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D99928 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 t= hat it is a combined target construct. int a[10]; int s2() { int s =3D 0; #pragma omp target data map(a,s) { #pragma omp target teams reduction(+:s) { for (int i=3D0; i < 10; i++) s +=3D 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: 4= 0]) #pragma omp target num_teams(0) thread_limit(0) firstprivate(s) map(tofrom:a [len: 40]) #pragma omp teams reduction(+:s) shared(a)=