|
What is Program Order?
- Any legal re-ordering is allowed
- The program order is the order of instructions from a sequential piece of code where programmer's intuition is preserved
- The order must produce the result a programmer expects
- Can out-of-order execution violate program order?
- No. All microprocessors commit instructions in-order and that is where the state becomes visible
- For modern microprocessors the program order is really the commit order
- Can out-of-order (OOO) execution violate SC?
- Yes. Need extra logic to support SC on top of OOO
OOO and SC
- Consider a simple example (all are zero initially)
P0: x=w+1; r=y+1;
P1: y=2; w=y+1;
- Suppose the load that reads w takes a miss and so w is not ready for a long time; therefore, x=w+1 cannot complete immediately; eventually w returns with value 3
- Inside the microprocessor r=y+1 completes (but does not commit) before x=w+1 and gets the old value of y (possibly from cache); eventually instructions commit in order with x=4, r=1 , y=2, w=3 – So we have the following partial orders
P0: x=w+1 < r=y+1 and P1: y=2 < w=y+1
Cross-thread: w=y+1 < x=w+1 and r=y+1 < y=2
- Combine these to get a contradictory total order
- What went wrong? We will discuss it in detail later
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|