Memory Ordering Flashcards
What is memory ordering for?
Eliminating memory dependencies for Load and Store instructions
What is a Load-Store Queue?
It’s just like a ROB, but for Load and Store instructions. This allows us to Load values as soon as they’re available while only writing Store results on commit.
Has columns for: Instruction, address, value, and commit bit.
What is Store-to-Load Forwarding?
When we add a Load instruction to the Load to Store Queue, we check whether there are any previous Store instructions referring to the same address. If so, we use Store to Load Forwarding to forward the value used by the Store instruction to our Load instruction.
This saves our Load from having to go to memory.
How do modern processors generally decide where to get the value for a Load instruction? They could just go through all instructions in order, or wait for all Store instructions, or something else.
They just go anyway! If we add a Load to the LSQ and there are previous Stores with unknown addresses, we just go to memory to get the Load value. If, in ensuing cycles, it turns out that there is a previous Store with the same address as the load, we forward the Store result to this Load. If future instructions already used the value from Load, the new value must be forwarded to them too.
Which Store instruction should forward its value to Load when there are multiple matches on Load’s address?
The most recent one!
What entries do Load/Stores need vs other instructions?
Load/Store
- ROB entry
- LSQ entry
Others
- RS entry
- LSQ entry ( I don’t think that’s right!)
What process do we go through with Load/Stores after Issuing?
Execute Load/Store:
1) Compute address
2) Produce value
This order matters for Load, but not for Store.
Write result (only for Load)
- Broadcast result too
Commit Load/Stores
- Move ROB commit head
- Move LSQ commit head
This frees ROB and LSQ entries
Finally, for Stores only, we send the Committed value to memory