From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BD1AB3858D35; Mon, 8 May 2023 09:10:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BD1AB3858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1683537006; bh=NbqGbX/3ibZFWgTby3NltNzTSf4uoiR14MLGw+JeE0E=; h=From:To:Subject:Date:From; b=BoJTnDi6mWDP6Flhx7fXL+m0JkR1sjTxdt13yBKBSgjWyqnPuR4S90g6ETwb93Hex Rb4jnu76OnU0pW57QLZuXt+Y2bQ7JOLtISCYIBxLqqOvnSwG2SRWB7NgvsFLk0yBo5 X7T5mcij+xGApx1zTtcUViwnroySWlwwPtJ4w2W4= From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/109767] New: [OpenMP][5.2] Missing loop-variable privatization inside 'teams' Date: Mon, 08 May 2023 09:10:05 +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: 13.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 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 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D109767 Bug ID: 109767 Summary: [OpenMP][5.2] Missing loop-variable privatization inside 'teams' Product: gcc Version: 13.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 Target Milestone: --- Cf. https://github.com/SOLLVE/sollve_vv/issues/731 OpenMP 5.1 had: * "Loop iteration variables inside 'parallel' or task generating constructs= are private in the innermost such construct that encloses the loop." OpenMP 5.2 added 'teams': * "Loop iteration variables inside 'parallel', 'teams', or task generating constructs are private in the innermost such construct that encloses the lo= op." In GCC, the 'j' is shared, causing race issues. Testcases: =3D=3D> teams-loop-var.c <=3D=3D #define N 10 int main () { int x[N][N], y[N][N]; int j; #pragma omp teams // in GCC implied: shared(j) <<< (!) >>> // [but 'private(j) with gfortran] for (int i =3D 0; i < N; i++) for (j =3D 0; j < N; j++) // TR12: #pragma omp atomic write x[i][j] =3D 2*j; #pragma omp teams // in GCC implied: shared(j) <<< (!) >>> // [but 'private(j) with gfortran] #pragma omp loop // in GCC implied: omp parallel shared(j) <<< (!) >>> for (int i =3D 0; i < N; i++) for (j =3D 0; j < N; j++) // TR12: #pragma omp atomic write y[i][j] =3D j + x[i][j]; for (int i =3D 0; i < N; i++) for (j =3D 0; j < N; j++) if (y[i][j] !=3D j + 2*j) __builtin_abort (); return 0; } =3D=3D> teams-loop-var.f90 <=3D=3D implicit none integer, parameter :: N =3D 10 integer :: x(N,N), y(N,N) integer :: i, j !$omp teams ! in GCC implied: private(j) [but shared(j) with gcc/g++] do i =3D 1, N do j =3D 1, N ! TR12: !$omp atomic write x(j,i) =3D 2*j end do end do !$omp end teams !$omp teams ! in GCC implied: private(j) [but shared(j) with gcc/g++] !$omp loop ! gcc generated: omp parallel shared(j) <<< (!) >>> do i =3D 1, N do j =3D 1, N ! TR12: !$omp atomic write y(j,i) =3D j + x(j, i) end do end do !$omp end teams do i =3D 1, N do j =3D 1, N if (y(j,i) /=3D j + 2*j) & stop 1 end do end do end=