SC模型是最直观的memory consistency model;
什么是single core sequential?
- 真正的执行顺序,和PO的顺序,是相同的;
什么是multi core sequential consistent?
- the operations of each individual processor (core) appear in this sequence in the order specified by its program
- (每个单核的执行顺序同PO顺序;)
- the result of any execution is the same as if the op erations of all processors (cores) were executed in some sequential order
- (多核之间的指令执行顺序是按照某种sequential order的,其执行结果是可预期的;)
什么是memory order?
上面描述的这种指令执行的总的顺序,称之为memory order;
什么是SC?
SC这种memory consistency model中,每个core的执行顺序和指令的PO顺序相同;
Under SC, memory order respects each core’s program order. “Respects” means that op1 <p op2 implies op1 <m op2.
<m: memory操作的顺序;
<p: program的顺序;
SC的实例:
在SC模型下,程序可能的执行顺序:
使用了SC模型后,表 3.1 程序的所有执行都以 r2 作为 NEW 终止。唯一的不确定性—— L1 在加载值 SET 一次之前加载 flag 为 0 的次数——并不重要。
另一个例子:
最后一个不满足SC;
SC模型的规则提取:
- L(a) and S(a) represent a load and a store, respectively, to address a;
- Orders <p and <m define program and global memory order;
SC需要满足如下一些规则:
- 所有load和store, 其操作内存的顺序,必须满足po, 不管地址是否相同;
- 访问相同地址的load, 拿到的数据,一定是之前该地址的store所写入的数据;
- Value of L(a) = Value of MAX <m {S(a) | S(a) <m L(a)}, where MAX <m denotes “latest in memory order.”
- RMW这类原子操作,要求load/store要紧挨着,中间不允许被其他内存操作所插入;
将上述的规则,转变成表格: