From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 34FEB3857C68; Fri, 4 Sep 2020 08:29:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 34FEB3857C68 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1599208145; bh=Vt/wewUvDP7BY9K2xFWuKPyowjeBxbeWitubXypMFRM=; h=From:To:Subject:Date:From; b=E6U6v+BEly4vYVEC0Jqrg72noWXQL7fjVKWbxHEzylQqAadKWZmUbCiU4MKPoxTOP tRFefXn2NlqA4MloTRfV+Krd3U3K2PEJnFVUpUs45Ah2nMBckZI8EGejVnKEcxJCAO B2gnZ+xLSnJZqH20f53NHKf/+b07Qplief8pDHO8= From: "vries at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/96932] New: [nvptx] atomic_exchange missing barrier Date: Fri, 04 Sep 2020 08:29:04 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 11.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: vries 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 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 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: Fri, 04 Sep 2020 08:29:05 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96932 Bug ID: 96932 Summary: [nvptx] atomic_exchange missing barrier Product: gcc Version: 11.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: vries at gcc dot gnu.org Target Milestone: --- After digging into GOMP_atomic_start/end I realized these also imply barrier semantics. And looking at the source code used for nvptx in libgomp/config/accel/mutex= .h, that should be fine: ... static inline void gomp_mutex_lock (gomp_mutex_t *mutex) { while (__sync_lock_test_and_set (mutex, 1)) /* spin */ ; } static inline void gomp_mutex_unlock (gomp_mutex_t *mutex) { __sync_lock_release (mutex); } ... However, when looking at the resulting code in libgomp.a we see there's no barrier for GOMP_atomic_start: ... .visible .func GOMP_atomic_start { .reg .u32 %r22; .reg .pred %r23; $L2: .loc 1 51 10 atom.global.exch.b32 %r22,[atomic_lock],1; .loc 1 51 9 setp.ne.u32 %r23,%r22,0; @ %r23 bra $L2; .loc 2 43 1 ret; } ... While there is for GOMP_atomic_end: ... .visible .func GOMP_atomic_end { .reg .u32 %r22; .loc 1 58 3 membar.sys; mov.u32 %r22,0; st.global.u32 [atomic_lock],%r22; .loc 2 49 1 ret; } ...=