29.7 Properties of Valid Executions
29.7.1 Valid Chosen Reads
A
- For each
ReadSharedMemory orReadModifyWriteSharedMemory event R ofSharedDataBlockEventSet (execution), do- Let chosenValueRecord be the element of execution.[[ChosenValues]] whose [[Event]] field is R.
- Let chosenValue be chosenValueRecord.[[ChosenValue]].
- Let readValue be
ValueOfReadEvent (execution, R). - Let chosenLen be the number of elements of chosenValue.
- Let readLen be the number of elements of readValue.
- If chosenLen ≠ readLen, then
- Return
false .
- Return
- If chosenValue[i] ≠ readValue[i] for any
integer value i in the range 0 through chosenLen, exclusive, then- Return
false .
- Return
- Return
true .
29.7.2 Coherent Reads
A
- For each
ReadSharedMemory orReadModifyWriteSharedMemory event R ofSharedDataBlockEventSet (execution), do- Let Ws be execution.[[ReadsBytesFrom]](R).
- Let byteLocation be R.[[ByteIndex]].
- For each element W of Ws, do
- If (R, W) is in execution.[[HappensBefore]], then
- Return
false .
- Return
- If there is a
WriteSharedMemory orReadModifyWriteSharedMemory event V that has byteLocation in its range such that the pairs (W, V) and (V, R) are in execution.[[HappensBefore]], then- Return
false .
- Return
- Set byteLocation to byteLocation + 1.
- If (R, W) is in execution.[[HappensBefore]], then
- Return
true .
29.7.3 Tear Free Reads
A
- For each
ReadSharedMemory orReadModifyWriteSharedMemory event R ofSharedDataBlockEventSet (execution), do- If R.[[NoTear]] is
true , thenAssert : The remainder of dividing R.[[ByteIndex]] by R.[[ElementSize]] is 0.- For each event W such that (R, W) is in execution.[[ReadsFrom]] and W.[[NoTear]] is
true , do- If R and W have equal ranges, and there is an event V such that V and W have equal ranges, V.[[NoTear]] is
true , W is not V, and (R, V) is in execution.[[ReadsFrom]], then- Return
false .
- Return
- If R and W have equal ranges, and there is an event V such that V and W have equal ranges, V.[[NoTear]] is
- If R.[[NoTear]] is
- Return
true .
An event's [[NoTear]] field is
Intuitively, this requirement says when a memory range is accessed in an aligned fashion via an
29.7.4 Sequentially Consistent Atomics
For a
- For each pair (E, D) in execution.[[HappensBefore]], (E, D) is in memory-order.
-
For each pair (R, W) in execution.[[ReadsFrom]], there is no
WriteSharedMemory orReadModifyWriteSharedMemory event V inSharedDataBlockEventSet (execution) such that V.[[Order]] isSeqCst , the pairs (W, V) and (V, R) are in memory-order, and any of the following conditions are true.- The pair (W, R) is in execution.[[SynchronizesWith]], and V and R have equal ranges.
- The pairs (W, R) and (V, R) are in execution.[[HappensBefore]], W.[[Order]] is
SeqCst , and W and V have equal ranges. - The pairs (W, R) and (W, V) are in execution.[[HappensBefore]], R.[[Order]] is
SeqCst , and V and R have equal ranges.
Note 1 This clause additionally constrains
SeqCst events on equal ranges. -
For each
WriteSharedMemory orReadModifyWriteSharedMemory event W inSharedDataBlockEventSet (execution), if W.[[Order]] isSeqCst , then it is not the case that there is an infinite number ofReadSharedMemory orReadModifyWriteSharedMemory events inSharedDataBlockEventSet (execution) with equal range that is memory-order before W.Note 2 This clause together with the forward progress guarantee on agents ensure the liveness condition that
SeqCst writes become visible toSeqCst reads with equal range in finite time.
A
While memory-order includes all events in
29.7.5 Valid Executions
A
- The
host provides ahost-synchronizes-with Relation for execution.[[HostSynchronizesWith]]. - execution.[[HappensBefore]] is a
strict partial order . - execution has valid chosen reads.
- execution has coherent reads.
- execution has tear free reads.
- execution has sequentially consistent atomics.
All programs have at least one valid execution.