[cpp-threads] Brief example ITANIUM Implementation for C/C++MemoryModel

Alexander Terekhov alexander.terekhov at gmail.com
Fri Jan 2 17:50:00 GMT 2009


On Fri, Jan 2, 2009 at 5:39 PM, Peter Dimov <pdimov at mmltd.net> wrote:
> Alexander Terekhov:
>
>> That would be the case if C/C++ would offer only seq_cst atomic
>> operations without any relaxed ones (I mean release/acquire/relaxed).
>> But that is not the case under the current draft. So my interpretation
>> is based on simple reasoning: seq_cst means fully-fenced (with
>> redundant fencing being eligible for removal by optimizers).
>
> I don't think that it does. The C++MM (if my understanding is correct)
> doesn't prohibit load-relaxed (or an ordinary load) sinking below
> load-seq-cst.

IOW,

P1: Y.store(1, seq_cst);
P2: Z.store(1, seq_cst); a = Y.load(relaxed);
P3: b = Y.load(relaxed); fence(seq_cst); c = Z.load(relaxed);

may legitimately yield a=0, b=1, c=0 just like in case of

P1: Y.store(1, seq_cst);
P2: Z.store(1, seq_cst); a = Y.load(relaxed);
P3: b = Y.load(relaxed); c = Z.load(seq_cst);

with both examples above actually meaning

P1: Y.store(1, seq_cst);
P2: Z.store(1, seq_cst); a = Y.load(relaxed);
P3: b = Y.load(relaxed); c = Z.load(relaxed);

right? WOW.

You'll have a hard time explaining this... ;-)

regards,
alexander.



More information about the cpp-threads mailing list