Search code examples
cachingconcurrencycpu-architecturedistributed-systemconsistency

Does sequential consistency implies cache coherence?


The definition of cache coherence says that:

  1. A read must return the most recent write.
  2. Every write must eventually be accessible via a read.
  3. Writes to a given location are seen in the same order by all processors

In sequential consistency

  1. There is a total order for all operations
  2. Every operation is atomic.
  3. The total order should follow the program order.

If we conform to the sequential consistency, every condition of cache coherence seems to be fulfilled. So I guess the sequential consistency implies cache coherence (and sequential consistency is stronger than cache coherence).


Solution

  • Yes. Coherence can be seen as sequential consistency per location.

    So for sequential consistency: if the results of the execution can be explained by a different execution with the following properties:

    1. there should be a total order of the loads/stores over all locations.

    2. this order is consistent with the program order of each of the cores.

    3. a read should see the most recent write before it in this order.

    then the execution is sequentially consistent.

    For coherence, you only need a total order per location, but otherwise, the same rules apply as with sequential consistency.

    So any execution that is sequentially consistent, is coherent. But the converse doesn't need to be true.