Cache coherence makes no guarantees about maintaing order among different processors of writes to different locations in memory. Coherence only guarantees that the order of writes to a given location will be observed in the same order across all processors.
This comment was marked helpful 4 times.
iamk_d___g
Question: why should we care the order of R/W to different locations?
This comment was marked helpful 0 times.
crs
@iamk_d___g I think one case is when you have copies of data at different locations like in distributed systems. You want data to be consistent across all locations if they are updated.
This comment was marked helpful 0 times.
bxb
@iamk_d___g You can also think about it in regards to program order. If one processor is reading and writing to multiple locations, then the data from those reads and writes should propagate through before it is actually needed to maintain accuracy of program execution. When you bring multiple processors into the mix, now "program order" also includes "processor access order" to maintain accuracy of the system.
This comment was marked helpful 0 times.
kayvonf
@iam_d__g: consider this situation, where flag is initialized to zero:
// thread 1, running on processor 1
int x = do_important_stuff();
int flag = 1;
// thread 2, running on processor 2
while (flag);
... do more important stuff using x
Consider what might happen if for some reason processor 2 became aware of the update to flag prior to learning about the update to x. Memory coherence only guarantees that processor 2 sees updates to x in the correct order. It provides no guarantees about the relative ordering of updates to different addresses. The latter is an issue of memory consistency, which will be discussed in Lecture 13.
This comment was marked helpful 2 times.
kkz
Do modern memory implementations abide by memory consistency? ie. will the above code always work as intended?
Cache coherence makes no guarantees about maintaing order among different processors of writes to different locations in memory. Coherence only guarantees that the order of writes to a given location will be observed in the same order across all processors.
This comment was marked helpful 4 times.
Question: why should we care the order of R/W to different locations?
This comment was marked helpful 0 times.
@iamk_d___g I think one case is when you have copies of data at different locations like in distributed systems. You want data to be consistent across all locations if they are updated.
This comment was marked helpful 0 times.
@iamk_d___g You can also think about it in regards to program order. If one processor is reading and writing to multiple locations, then the data from those reads and writes should propagate through before it is actually needed to maintain accuracy of program execution. When you bring multiple processors into the mix, now "program order" also includes "processor access order" to maintain accuracy of the system.
This comment was marked helpful 0 times.
@iam_d__g: consider this situation, where
flag
is initialized to zero:Consider what might happen if for some reason processor 2 became aware of the update to flag prior to learning about the update to
x
. Memory coherence only guarantees that processor 2 sees updates tox
in the correct order. It provides no guarantees about the relative ordering of updates to different addresses. The latter is an issue of memory consistency, which will be discussed in Lecture 13.This comment was marked helpful 2 times.
Do modern memory implementations abide by memory consistency? ie. will the above code always work as intended?
This comment was marked helpful 0 times.
Modern processors implement relaxed memory consistency models.
This comment was marked helpful 0 times.