Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!news1.tnib.de!feed.news.tnib.de!news.tnib.de!feed.cnntp.org!news.cnntp.org!not-for-mail From: Anthony Williams Newsgroups: comp.programming.threads Subject: Re: questions about memory_order_seq_cst fence References: <43eb372b-6517-4914-b647-860f1f7136ba@k15g2000pri.googlegroups.com> <87tybsm5kq.fsf@justsoftwaresolutions.co.uk> <35ec803e-2871-41ce-97ea-8b615b29050f@r33g2000prh.googlegroups.com> <87hb7r5z03.fsf@justsoftwaresolutions.co.uk> Date: Thu, 16 Jun 2011 08:26:16 +0100 Message-ID: <87fwnafd9j.fsf@justsoftwaresolutions.co.uk> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) Cancel-Lock: sha1:ZFfFbkMJfivSFqUuoQOU0U9hErc= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Lines: 49 Organization: CNNTP NNTP-Posting-Host: 5dd50c2f.read.cnntp.org X-Trace: DXC=>PUiFWL@KNknI7b2f5Mc X-Complaints-To: abuse@cnntp.org Xref: x330-a1.tempe.blueboxinc.net comp.programming.threads:287 Anthony Williams writes: > Joshua Maurice writes: > >>> 29.3p7 of N3290 says: >>> >>> "For atomic operations A and B on an atomic object M, if there are >>> memory_order_seq_cst fences X and Y such that A is sequenced before X, Y >>> is sequenced before B, and X precedes Y in S, then B occurs later than A >>> in the modification order of M." >>> >> I think it's meant to read: >> [] >> For atomic **write (and atomic read-modify-write operations)** A and B >> on an atomic object M, if there are memory_order_seq_cst fences X and >> Y such that A is sequenced before X, Y is sequenced before B, and X >> precedes Y in S, then B occurs later than A in the modification order >> of M. >> [/] > > When we drafted this words, I think we meant "operation". It is the > reference to "modification order" that is the typo. What is meant is > that if A is a write and B is a read then B must read the value written > by A, or something later in the modification order; if A is a write and > B is a write then B must be later than A in the MO; if A is a read and B > is a write then A must read a value prior to B in the MO, and if A is a > read and B is a read then B must read the same value as A or a value > later in the MO. > After rereading this section of the standard several times, I'm no > longer sure. I'll have to check my notes. I've checked my notes. My recollection was wrong. We *discussed* requiring seq_cst fences to order loads like this, but decided to explicitly limit the orderings to writes. The approved wording said "where A and B modify M", but this somehow got lost. In particular, it was felt that requiring this would add complexity to the IA-64 implementation of fences, and potentially require that relaxed operations on that architecture would also have to be more expensive, thus requiring people to pay for features they didn't need. Anthony -- Author of C++ Concurrency in Action http://www.stdthread.co.uk/book/ just::thread C++0x thread library http://www.stdthread.co.uk Just Software Solutions Ltd http://www.justsoftwaresolutions.co.uk 15 Carrallack Mews, St Just, Cornwall, TR19 7UL, UK. Company No. 5478976