riscv / riscv-isa-manual

RISC-V Instruction Set Manual
https://riscv.org/
Creative Commons Attribution 4.0 International
3.7k stars 645 forks source link

Confusion about "CoRR" (Coherence for Read-Read pairs) in RVWMO. #1713

Closed diantaowang closed 2 weeks ago

diantaowang commented 2 weeks ago

The original text is as follows:

I can't understand the rule-2 (the load-load situation).

I guess that:

hart0 hart1
(a) li t0, 2 (c) li t0, 1
(b) sw t0,0(s0) (d) sw t0,0(s0)
(e) lw a0,0(s0)
(f) lw a1,0(s0)

Global memory order (d)(f)(b)(e) is prohibited because (e) and (f) return values from the same address written by different memory operations.

Thanks!

aswaterman commented 2 weeks ago

"Program order" is the sequence of a single hart's dynamic instruction stream.

The example you gave is more complicated than is necessary to demonstrate the CoRR requirement. Consider this simpler one:

hart 0 hart 1
(a) li t0, 1 (c) lw a0,0(s0)
(b) sw t0,0(s0) (d) lw a1,0(s0)

The three legal outcomes are a0=a1=0, a0=a1=1, and a0=0/a1=1. a0=1/a1=0 is not a legal outcome because (c) precedes (d) in the global memory order.

diantaowang commented 2 weeks ago

Thanks! I got it.