<html><head><title></title><style type="text/css">ol{margin:0;padding:0}p{margin:0}.c32{font-style:italic}.c55{line-height:1.15;text-indent:36.0pt;direction:ltr}.c5{color:#000099;font-size:11pt;text-decoration:underline;font-family:Arial}.c3{line-height:1.15;text-indent:0pt;direction:ltr}.c16{padding-top:18.0pt;padding-bottom:4.0pt}.c18{font-weight:bold}.c1{padding-top:24.0pt;line-height:1.15;text-indent:0pt;direction:ltr;padding-bottom:6.0pt}.c2{color:#000000;font-size:11pt;font-family:Arial}.c0{color:#000000;font-size:24pt;font-family:Arial;font-weight:bold}.c22{padding-top:14.0pt;padding-bottom:4.0pt}.c21{color:#000000;font-size:14pt;font-family:Arial}.c24{text-decoration:line-through}.c14{color:#000000;font-size:18pt;font-family:Arial;font-weight:bold}</style></head><body><p class="c1"><span class="c0">Coherence Requirements Detailed</span></p><p class="c3"><span class="c2">ISO/IEC JTC1 SC22 WG21 N3136 = 10-0126 - 2010-08-20</span></p><p class="c3"><span class="c2">Michael Wong, </span><span class="c5">michaelw@ca.ibm.com</span></p><p class="c3"><span class="c2">Benjamin Kosnik, bkoz@redhat.com</span></p><p class="c3"><span class="c2">Mark Batty, </span><span class="c5"><a href="mailto:mjb220@cl.cam.ac.uk">mjb220@cl.cam.ac.uk</a></span><span class="c2"> </span></p><p class="c3 c16"><span class="c14">Introduction</span></p><p class="c3"><span class="c2">This paper is based on discussions in the Concurrency Working Group in Rapperswil following the presentation of &ldquo;C++ Concurrency Discussion&rdquo; by Mark Batty and Peter Sewell. (From wiki.dinkumware.com/twiki/.../</span><span class="c2 c18">Concurrency</span><span class="c2">WorkingGroup/cpp-fcd-01.pdf)</span></p><p class="c3 c22"><span class="c18 c21">Proposed Changes</span></p><p class="c22 c3"><span class="c2">For the changes below, the new text is put in place with the older text it is replacing represented in </span><span class="c2 c24">strikethrough</span><span class="c2">.</span></p><p class="c3"><span class="c2">&nbsp;</span></p><p class="c3"><span class="c18 c2">1. Modify 1.10p13 as follows:</span></p><p class="c3"><span class="c2">The </span><span class="c2 c32">visible sequence of side effects</span><span class="c2"> on an atomic object M, with respect to a value computation B of M, is a maximal contiguous sub-sequence of side effects in the modification order of M, where the first side effect is visible with respect to B, and for every subsequent side effect, it is not the case that B happens before it.</span></p><p class="c3"><span class="c2">The value of an atomic object M, as determined by evaluation B, shall be the value stored by some operation in the a visible sequence of M with respect to B. [Note - It can be shown that the visible sequence of side effects of</span></p><p class="c3"><span class="c2">a value computation is unique given the coherence requirements below.</span></p><p class="c3"><span class="c2">- end note] </span><span class="c2 c24">Furthermore, if a value computation A of an atomic object M happens before a value computation B of M, and the value computed by A corresponds to the value stored</span></p><p class="c3"><span class="c2 c24">by side effect X, then the value computed by B shall either equal the value computed by A, or be the value stored by side effect Y, where Y follows X in the modification order of M. [ Note: This effectively disallows compiler reordering of atomic operations to a single object, even if both operations are &ldquo;relaxed&rdquo; loads. This effectively makes the &ldquo;cache coherence&rdquo; guarantee provided by most hardware available to C++ atomic operations. &mdash;end note ] [ Note: The visible sequence depends on the &ldquo;happens before&rdquo; relation, which depends on the values observed by loads of atomics, which we are restricting here. The intended reading is that there must exist an association of atomic loads with modifications they observe that, together with suitably chosen modification orders and the &ldquo;happens before&rdquo; relation derived as described above, satisfy the resulting constraints as imposed here. &mdash;end note ]</span></p><p class="c3"><span class="c2">&nbsp;</span></p><p class="c3"><span class="c18 c2">2. Insert new 1.10p14:</span></p><p class="c3"><span class="c2">We define the following </span><span class="c32 c2">Coherence Requirements</span></p><p class="c55"><span class="c2">-</span><span class="c32 c2">Write Write</span><span class="c2">:</span></p><p class="c3"><span class="c2"> &nbsp; &nbsp; If an operation A that modifies M happens-before an operation B that modifies M then A shall be earlier then B in the modification order of M</span></p><p class="c3"><span class="c2">&nbsp;</span></p><p class="c3"><span class="c2"> -</span><span class="c32 c2">Read Read</span><span class="c2">:</span></p><p class="c55"><span class="c2">If a value computation A of an atomic object M happens before a value</span></p><p class="c3"><span class="c2">computation B of M, and A takes its value from the side effect X, then</span></p><p class="c3"><span class="c2">the value computed by B shall either be the value stored by X, or the</span></p><p class="c3"><span class="c2">value stored by a side effect Y, where Y follows X &nbsp;in the</span></p><p class="c3"><span class="c2">modification order of M.</span></p><p class="c3"><span class="c2">&nbsp;</span></p><p class="c55"><span class="c2">-</span><span class="c32 c2">Read Write</span><span class="c2">:</span></p><p class="c3"><span class="c2"> &nbsp; &nbsp; If a value computation A of an atomic object M happens-before an operation B that modifies M then the value read by A shall be the value of a modification that is earlier in the modification order of M than the value stored by B</span></p><p class="c3"><span class="c2">&nbsp;</span></p><p class="c3"><span class="c2"> &nbsp; &nbsp; -</span><span class="c32 c2">Write Read</span><span class="c2">:</span></p><p class="c55"><span class="c2">If a side effect X that stores a value to an atomic object M happens-before a value computation B of M then the evaluation B shall return the value stored by X or a value later in the modification order of M</span></p><p class="c3"><span class="c2">&nbsp;</span></p><p class="c3"><span class="c18 c2">3. Insert new 1.10p15:</span></p><p class="c3"><span class="c2">[ Note: This effectively disallows compiler reordering of atomic operations to a single object, even if both operations are &ldquo;relaxed&rdquo; loads. This effectively makes the &ldquo;cache coherence&rdquo; guarantee provided by most hardware available to C++ atomic operations. &mdash;end note ]</span></p><p class="c3"><span class="c2">&nbsp;</span></p><p class="c3"><span class="c2">&nbsp;</span></p><p class="c3"><span class="c18 c2">4. Insert new 1.10p16:</span></p><p class="c3"><span class="c2">[ Note: The visible sequence depends on the &ldquo;happens before&rdquo; relation, which depends on the values observed by loads of atomics, which we are restricting here. The intended reading is that there must exist an association of atomic loads with modifications they observe that, together with suitably chosen modification orders and the &ldquo;happens before&rdquo; relation derived as described above, satisfy the resulting constraints as imposed here. &mdash;end note ] </span></p></body></html>