LR/SC 说明和发布一致性

The LR/SC instructions and Release Consistency

介绍 Release Consistency 的论文("Memory Consistency and Event Ordering in Scalable Shared-Memory Multiprocessors" by K. Gharachorloo et al.)提到了一个 class 内存操作,称为 "non-synchronization" (nsync),旨在用于竞争,但不同步,访问混沌松弛算法中其他线程的数据。

我是否误以为 RISC-V 中的 LR 和 SC 指令,清除了 AQ 和 RL 位,是 nsync-class 指令?我问是因为 RISC-V 手册(版本 20190608-Base-Ratified,第 50 页)指出,清除 AQ 和 RL 位后,LR 和 SC 是:“......适用于使用 LR/SC 序列时实现并行归约操作。

我不这么认为。前面的句子(在我的草稿中)指出:

If neither bit is set on both LR and SC, the LR/SC sequence can be observed to occur before orafter surrounding memory operations from the same RISC-V hart. This can be appropriate ....

我认为他们的意思是 lr/sc 只会与链接地址(好的,缓存行)同步,因此 lr/sc 之间的其他内存位置可以保持松散的顺序比这个。换句话说,lr/sc 不必等待存储缓冲区中的前面项目进入 RAM,除非有其他一些类似栅栏的操作未决。

因此,它不适合实现互斥量(因为大多数多线程程序将互斥量视为内存排序点),但非常适合计数器或堆栈索引。