From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 5261D395A800; Wed, 13 May 2020 16:58:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5261D395A800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1589389124; bh=TgNPFnmPCEY5KCTpAkF6fW8vcVT5WVfuQuon+5auCag=; h=From:To:Subject:Date:In-Reply-To:References:From; b=akYBRe2q9VL1WPoXEe89YhqNbna/72Tbry3XPNS3StbxuIQEsFuD/21Ci4E7D2Fx1 FALC7qfVeoSkZMRCcMcHXlKbBwCr2WkY87RYYYUFXYBR9km7/gIfMRq/R9jcTVVUUb E2yEZRne7YUR5MKj6nK0g/bjPIQ6VAOEPc9WIsg8= From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: =?UTF-8?B?W0J1ZyBmb3J0cmFuLzk0NjkwXSBbT3Blbk1QXSBvbXAgLi4uIGRp?= =?UTF-8?B?c3RyaWJ1dGUg4oCTIGxhc3Rwcml2YXRlIG5vdCBwZXJtaXR0ZWQgYW5kIG1v?= =?UTF-8?B?cmUgaXNzdWVz?= Date: Wed, 13 May 2020 16:58:44 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Version: 10.0 X-Bugzilla-Keywords: openmp, rejects-valid X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: burnus at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: attachments.created Message-ID: In-Reply-To: References: 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: Wed, 13 May 2020 16:58:44 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D94690 --- Comment #10 from Tobias Burnus --- Created attachment 48522 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D48522&action=3Dedit Patch to add OpenMP 5 feature (private + lastprivate permitted for 'simd') The patch solves an independent issue, required for the test case below (namely, the "private(j)"). The *committed* patch causes gfortran.dg/gomp/target1.f90 to FAIL. The problem shows up with the following test case (reduced but modified): ------------- subroutine foo () integer :: s, i, j !$omp target teams !$omp distribute parallel do default(shared) & !$omp collapse (2) private(j) lastprivate (s) do i =3D 1, 10 do j =3D 1, 10 s =3D i * 10 + j end do end do !$omp end target teams end subroutine ------------- The problem is that this currently produces (-fdump-tree-original): #pragma omp teams private(i) private(j) Which later causes problems as it doesn't add a (last)private(i) when it should=20 (Search for "if (outer && lastprivate)" in gimplify_omp_for =E2=80=93 and l= ook through the lines below. As "i" is present, omp_check_private() returns true and a required omp_add_variable is not called. =E2=80=93 Leading later to the ICE= .) That's solved by: --- a/gcc/fortran/openmp.c +++ b/gcc/fortran/openmp.c @@ -5688,3 +5688,3 @@ gfc_resolve_do_iterator (gfc_code *code, gfc_symbol *= sym, bool add_clause) gfc_code *omp_code =3D omp_current_ctx->code->block; - for ( ; omp_code->next; omp_code =3D omp_code->next) + for ( ; omp_code; omp_code =3D omp_code->next) switch (omp_code->op) However, that leads to the odd result that: !$omp target teams !$omp distribute parallel do default(shared) & ! "do" !$omp collapse (2) private(j) lastprivate (s) ... !$omp distribute parallel do simd default(shared) & ! "do simd" (!) !$omp collapse (2) private(j) lastprivate (s) ... has "#pragma omp teams" [w/o private(i) private(j)] While removing the "simd" from the code above leads to no "private(i) private(j)", which does not make sense. The code (openmp.c's gfc_do_resolve_do_iterator) is supposed to do: /* !$omp do and !$omp parallel do iteration variable is predetermined private just in the !$omp do resp. !$omp parallel do construct, with no implications for the outer parallel constructs. */ But here it adds it to 'teams', which looks wrong/inconsistent.=