From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BB67D393D00F; Tue, 13 Apr 2021 08:58:51 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BB67D393D00F From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug middle-end/100059] New: [OpenMP] wrong code with 'declare target link' and a scalar variable Date: Tue, 13 Apr 2021 08:58:51 +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 cf_gcctarget attachments.created 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, 13 Apr 2021 08:58:51 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D100059 Bug ID: 100059 Summary: [OpenMP] wrong code with 'declare target link' and a scalar variable 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: jakub at gcc dot gnu.org Target Milestone: --- Target: nvptx-none Created attachment 50578 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D50578&action=3Dedit Testcase, compile with 'gcc -fopenmp' with an (nvptx) offloading enabled compiler The attached testcase has four global vars: int a[N], b[N], c[N]; int i =3D 0; which are used with: #pragma omp declare target link(a,c,b,i)=20=20 and #pragma omp target map(to: i) map(tofrom: a, b, c)=20 update(); After the call, the one array is not updated but has the previous host valu= e: * For 'declare target link(a,c,b,i)': not updated array is 'b' * For 'declare target link(a,b,c,i)': not updated array is 'c' Namely, the testcase shows: i=3D5: A=3D5, B=3D6, C=3D7 // Original host value i=3D5: A=3D6, B=3D6, C=3D10 // target call to 'update': 'B' is not updated i=3D5: A=3D7, B=3D8, C=3D13 // host update, OK Additionally, when using 'for (int i' in 'update': The error only shows up = if there is 'i' And it occurs for the item before 'i', namely: link(a,c,b,i) =E2=86=92 'b' is wrong link(a,c,i,b) =E2=86=92 'c' is wrong The issue occurs with nvptx. It works without offloading and I think it wor= ks with GCN (did not show up in the test logs, but I have not manually verifie= d).=