220 30977 <5db98f8a-68ee-4753-b46a-3409b89862a4@isocpp.org> article
Path: news.gmane.org!.POSTED!not-for-mail
From: Nicol Bolas <jmckesson@gmail.com>
Newsgroups: gmane.comp.lang.c++.isocpp.proposals
Subject: Re: Proposed alternative approach to specifying
 required memory operation ordering
Date: Fri, 17 Feb 2017 14:45:30 -0800 (PST)
Lines: 102
Approved: news@gmane.org
Message-ID: <5db98f8a-68ee-4753-b46a-3409b89862a4@isocpp.org>
References: <d0fdabcd-f04a-46e6-b93a-0b9ea85cb5bd@isocpp.org>
 <20170216004134.4902991.82070.24891@gmail.com>
 <8575c41d-1c8e-4e6f-9f12-a07bb70a7703@isocpp.org>
 <a17092d7-d348-4d8c-94f1-fa272ef9e630@isocpp.org>
 <e95d8da5-4d52-4582-be4c-1ed9c1c4c84e@isocpp.org>
 <eba54bb4-ee11-4b75-975f-0dbf80d332ad@isocpp.org>
 <cb0cc405-f052-4cb1-8a00-ca2cc2c38186@isocpp.org>
Reply-To: std-proposals@isocpp.org
NNTP-Posting-Host: blaine.gmane.org
Mime-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1474_903571175.1487371530887"
X-Trace: blaine.gmane.org 1487371533 28623 195.159.176.226 (17 Feb 2017 22:45:33 GMT)
X-Complaints-To: usenet@blaine.gmane.org
NNTP-Posting-Date: Fri, 17 Feb 2017 22:45:33 +0000 (UTC)
Cc: inkwizytoryankes@gmail.com
To: ISO C++ Standard - Future Proposals <std-proposals@isocpp.org>
Original-X-From: std-proposals+bncBCEKFTV6ZUMBBC72TXCQKGQEACO7IVQ@isocpp.org Fri Feb 17 23:45:29 2017
Return-path: <std-proposals+bncBCEKFTV6ZUMBBC72TXCQKGQEACO7IVQ@isocpp.org>
Envelope-to: gclcip-std-proposals@m.gmane.org
Original-Received: from mail-oi0-f69.google.com ([209.85.218.69])
	by blaine.gmane.org with esmtp (Exim 4.84_2)
	(envelope-from <std-proposals+bncBCEKFTV6ZUMBBC72TXCQKGQEACO7IVQ@isocpp.org>)
	id 1cerHK-0006mg-Fo
	for gclcip-std-proposals@m.gmane.org; Fri, 17 Feb 2017 23:45:26 +0100
Original-Received: by mail-oi0-f69.google.com with SMTP id a194sf64603485oib.5
        for <gclcip-std-proposals@m.gmane.org>; Fri, 17 Feb 2017 14:45:32 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=isocpp-org.20150623.gappssmtp.com; s=20150623;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=OP7xs8AYz2sOz7HlW9R6nMl4Jchh7v+m92TmQSJ0RZY=;
        b=EWHmqZ/DYL5NOpif9hud75eGR1k2+M4uykOt1OLAyahzjxHfpbVeAH04cvvKrrTLFP
         ysI5CYLdYLBQhxPlYRIKKcWGvme99J6/Q+DAE5O7o/RjBl/GoyJEv0D7WNQhR7dwzzcP
         mQvdjQdHIwK9uBCpzYiXrap6OjN5R8rW+ElIi+PnHUMfoK0foaSlFzAMqwKykogB79lG
         RIWAij3mAx+JpEtu44dfmwliyFqbWcLEI8tn8KJay3gvO/qhxSjpKP1frCd8aUoNmVut
         RPKQW0tXE+y/Lfr6MLI3dpsMRg+8g3S1XoCK7eF4ekLRtVzSAimZCnl/nzSk+vchxJyA
         I1Gg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20161025;
        h=date:from:to:cc:message-id:in-reply-to:references:subject
         :mime-version:x-original-sender:reply-to:precedence:mailing-list
         :list-id:x-spam-checked-in-group:list-post:list-help:list-archive
         :list-subscribe:list-unsubscribe;
        bh=OP7xs8AYz2sOz7HlW9R6nMl4Jchh7v+m92TmQSJ0RZY=;
        b=u73sdYaHyws/4tEeAJ8z9GkzGx9HseFXqVbPiMyux9LpUF55kAYveqrww0qEDnZEvF
         xYzpUQfR2KXSo/SXu30yagC79UlH1ggw6uPrZsI6YKtxMULl49y0aidHvbwTipM7hp9K
         RSC+LopV4rAXtCL77IQ3DrfwMuOlQ6q3m7yEFtcpUvGRxvmDpnWmWq5B0JcuKTUHDnNK
         BgF8mirlYemYivxL3qUEseubGT4n+HB3dXWLSjq3NhMCFk7TJHaYBbBrmRB5MDy23QAk
         n234gefdy8s26ArmGZ9u2qBXgCqVjFbHI7E8o3RaGTxd6HWooNWLTQEUcd4hdhw2ZeOY
         aPSQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20161025;
        h=x-gm-message-state:date:from:to:cc:message-id:in-reply-to
         :references:subject:mime-version:x-original-sender:reply-to
         :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post
         :list-help:list-archive:list-subscribe:list-unsubscribe;
        bh=OP7xs8AYz2sOz7HlW9R6nMl4Jchh7v+m92TmQSJ0RZY=;
        b=BIR97Un74gZXFZZzTiQ4SdLpPEYoh1ivnFzz9h0BJJnN5rjwtaJpq478XLeyQtYJTO
         7+qzfDJ/Qwnak5WoDk7NoKGxomZ/g1sNshXzcEav3UiW+eqYnPs9BZp4fKwcKM05HiHu
         FXpAwflj2JD94zdBygV/MAfAYQ+S9E3CQeVCTYRTPvpSW8LFygndmWKQa9ZkMMH7QS+l
         TqX0b31fUtHKTank5y2Z1Hk/FQMbga8hd8F8yqa2NwXfq+L/u22zdNs1DShiCiv7mUyc
         TANlx47fLgfrrT/NCHqhvpyrxrGhaAlfAxIQqH2DXnmaa1ofRSgROzDlpRZwSuloZq4D
         cMIw==
X-Gm-Message-State: AMke39nS337sI3XdWVh+1bpIC4fRA0+pcnWIW8k8zCIxOWJj77C37qm/x9V4JAsrE/G2LQ==
X-Received: by 10.157.48.23 with SMTP id d23mr3164658otc.51.1487371532153;
        Fri, 17 Feb 2017 14:45:32 -0800 (PST)
X-BeenThere: std-proposals@isocpp.org
Original-Received: by 10.157.56.105 with SMTP id r38ls5895447otd.15.gmail; Fri, 17 Feb
 2017 14:45:31 -0800 (PST)
X-Received: by 10.157.20.145 with SMTP id d17mr906835ote.18.1487371531454;
        Fri, 17 Feb 2017 14:45:31 -0800 (PST)
In-Reply-To: <cb0cc405-f052-4cb1-8a00-ca2cc2c38186@isocpp.org>
X-Original-Sender: jmckesson@gmail.com
Precedence: list
Mailing-list: list std-proposals@isocpp.org; contact std-proposals+owners@isocpp.org
List-ID: <std-proposals.isocpp.org>
X-Google-Group-Id: 399137483710
List-Post: <https://groups.google.com/a/isocpp.org/group/std-proposals/post>, <mailto:std-proposals@isocpp.org>
List-Help: <https://support.google.com/a/isocpp.org/bin/topic.py?topic=25838>, <mailto:std-proposals+help@isocpp.org>
List-Archive: <https://groups.google.com/a/isocpp.org/group/std-proposals/>
List-Subscribe: <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>,
 <mailto:std-proposals+subscribe@isocpp.org>
List-Unsubscribe: <mailto:googlegroups-manage+399137483710+unsubscribe@googlegroups.com>,
 <https://groups.google.com/a/isocpp.org/group/std-proposals/subscribe>
Xref: news.gmane.org gmane.comp.lang.c++.isocpp.proposals:30977
Archived-At: <http://permalink.gmane.org/gmane.comp.lang.c++.isocpp.proposals/30977>

------=_Part_1474_903571175.1487371530887
Content-Type: multipart/alternative; 
	boundary="----=_Part_1475_762578859.1487371530887"

------=_Part_1475_762578859.1487371530887
Content-Type: text/plain; charset=UTF-8

On Friday, February 17, 2017 at 5:34:30 PM UTC-5, inkwizyt...@gmail.com 
wrote:
>
>
>
> On Friday, February 17, 2017 at 11:26:48 PM UTC+1, Nicol Bolas wrote:
>>
>> On Friday, February 17, 2017 at 5:14:55 PM UTC-5, Nicol Bolas wrote:
>>>
>>> Actually, it does use synchronization. `operator*` executes a `load()` 
>>> on the atomic object. That forces synchronization.
>>>
>>
>> Sorry, I said that wrong. `operator unsigned()` performs a `load()`. The 
>> default load mechanism performs a full sync on the variable. So once the 
>> other thread is passed its `release` fence, then this thread will be able 
>> to see the new value.
>>
>
> I was answering:
> "When I don't enable optimization, this code works fine, whether access to 
> the thread-shared variables is atomic or non-atomic.  When I enable 
> optimization. the threads get into infinite loops if the access to the 
> thread-shared variables is non-atomic.  But atomic access, even with 
> relaxed order, causes the code to work fine with optimization." 
> This mean when `using Cardinal = unsigned;` and we don't have any load.
>

Hmm. I assumed that "but atomic access" was referring to using `Cardinal` 
class, not `using Cardinal = unsigned". But it's possible that he was 
referring to the use of `std::atomic_thread_fence`.

If that's the case, then you're right; that particular fence is not a 
guarantee that `Cardinal` works.

-- 
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/5db98f8a-68ee-4753-b46a-3409b89862a4%40isocpp.org.

------=_Part_1475_762578859.1487371530887
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">On Friday, February 17, 2017 at 5:34:30 PM UTC-5, inkwizyt=
....@gmail.com wrote:<blockquote class=3D"gmail_quote" style=3D"margin: 0;ma=
rgin-left: 0.8ex;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=
=3D"ltr"><br><br>On Friday, February 17, 2017 at 11:26:48 PM UTC+1, Nicol B=
olas wrote:<blockquote class=3D"gmail_quote" style=3D"margin:0;margin-left:=
0.8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir=3D"ltr">On Frid=
ay, February 17, 2017 at 5:14:55 PM UTC-5, Nicol Bolas wrote:<blockquote cl=
ass=3D"gmail_quote" style=3D"margin:0;margin-left:0.8ex;border-left:1px #cc=
c solid;padding-left:1ex"><div dir=3D"ltr"><div>Actually, it does use synch=
ronization. `operator*` executes a `load()` on the atomic object. That forc=
es synchronization.<br></div></div></blockquote><div><br>Sorry, I said that=
 wrong. `operator unsigned()` performs a `load()`. The default load mechani=
sm performs a full sync on the variable. So once the other thread is passed=
 its `release` fence, then this thread will be able to see the new value.<b=
r></div></div></blockquote><div><br>I was answering:<br>&quot;When I don&#3=
9;t enable optimization, this code works=20
fine, whether access to the thread-shared variables is atomic or=20
non-atomic. =C2=A0When I enable optimization. the threads get into infinite=
=20
loops if the access to the thread-shared variables is non-atomic. =C2=A0But=
=20
atomic access, even with relaxed order, causes the code to work fine=20
with optimization.&quot; <br>This mean when `using Cardinal =3D unsigned;` =
and we don&#39;t have any load.<br></div></div></blockquote><div><br>Hmm. I=
 assumed that &quot;but atomic access&quot; was referring to using `Cardina=
l` class, not `using Cardinal =3D unsigned&quot;. But it&#39;s possible tha=
t he was referring to the use of `std::atomic_thread_fence`.<br><br>If that=
&#39;s the case, then you&#39;re right; that particular fence is not a guar=
antee that `Cardinal` works.<br></div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/5db98f8a-68ee-4753-b46a-3409b89862a4%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/5db98f8a-68ee-4753-b46a-3409b89862a4=
%40isocpp.org</a>.<br />

------=_Part_1475_762578859.1487371530887--

------=_Part_1474_903571175.1487371530887--

.
