Course: Computer Architectures · Lecture: Lecture 10 - Dynamic Scheduling

1. Why rearrange instructions during execution?

A simple in-order pipeline can hold up an independent instruction behind one waiting for data:

1. f0  = f2 / f4      slow division
2. f10 = f0 + f8      needs the division's result
3. f12 = f8 - f14     inputs already available

Instruction 2 has a true read-after-write (RAW) dependency on instruction 1. Instruction 3 has no such dependency: sharing a read of f8 causes no conflict. Dynamic scheduling lets hardware execute ready work while other instructions wait. It must preserve the intended values and required program behavior. If instruction 3 also read f0, it would have to wait too.

This builds on Instruction Dependencies, Register Renaming and Pipelining. The source mentions scoreboarding but develops Tomasulo’s method; it does not teach a full scoreboarding algorithm.

2. Accepting an instruction is different from executing it

In the lecture model, issue is in program order. Issue decodes an instruction and assigns an available holding slot. Operand waiting and execution can then happen out of order. If there is no suitable slot, issue stalls; dynamic scheduling does not remove structural limits.

Tomasulo uses reservation stations to hold an operation and its inputs. An input is represented by either a ready value or the identifier of the producer that will supply it. Once both inputs and a suitable execution unit are available, the operation may execute.

Issue → wait for missing values → execute → write/broadcast result

Station names identify pending producers. They are not the architectural register names in the program. The simplified arithmetic examples below assume enough stations and that all indicated instructions issue before results are broadcast.

3. Broadcast makes a missing operand available

Suppose Div1 computes f0 and Add1 needs that result. Add1 records Div1, rather than repeatedly reading f0. The Common Data Bus (CDB) broadcasts a producer identifier together with its value. When (Div1, 6) appears, every station waiting for Div1 can capture 6.

Several consumers can safely receive the same result. They are reading copies of the correct produced value; they do not overwrite one another. This satisfies RAW dependencies rather than violating them. A station waiting for another identifier ignores the broadcast.

4. Read a reservation station without mixing inputs and output

For Add1: f0 = f6 + f8, assume f6 is still being produced by Div1 and f8 already contains 10:

FieldMeaningInitial contents
BusyStation occupiedYes
OpOperationAdd
VjFirst operand value, if readyNot ready
QjProducer of missing first operandDiv1
VkSecond operand value, if ready10
QkProducer of missing second operandNone

After (Div1, 6), Vj becomes 6 and Qj clears. Both values are ready. A clear tag means no producer is pending; it does not mean the value is zero. j and k simply label the two inputs. The A field in the lecture’s load/store buffers holds address-related information, initially an immediate and later an effective address.

The instruction-status table in the slides is a teaching record of progress, not a required additional hardware structure.

5. Qi versus Qj and Qk

The register-status entry Qi names the latest issued producer expected to update a register. A station’s Qj/Qk identify the producers its own inputs need. They store the same kind of identifier but retain different relationships.

When an instruction issues, it examines the current source-register mappings and saves values or producer tags. A later writer can change a register’s Qi without changing the older consumer’s saved tags. Sources must be captured before assigning a new destination mapping when an instruction also reads its destination register.

Four-instruction trace: two versions of f6

This added teaching example uses f2=12, f4=2, f8=10, f10=3 and f12=4:

1. Div1: f6  = f2 / f4
2. Add1: f0  = f6 + f8
3. Mul1: f6  = f10 * f12
4. Add2: f14 = f6 + f0
Issue eventRegister mapping changedInputs saved by the new station
Div1f6.Qi = Div1Values 12 and 2
Add1f0.Qi = Add1Qj=Div1; Vk=10
Mul1f6.Qi = Mul1Values 3 and 4
Add2f14.Qi = Add2Qj=Mul1; Qk=Add1

After all four issue, f6.Qi names Mul1, while Add1.Qj still names Div1. Add1 needs the earlier version; Add2 needs the later version. Add1 is its own output identifier, not evidence that its missing input is ready.

Suppose Mul1 finishes first:

  1. Mul1 broadcasts 12. Add2 saves 12 and clears Qj; f6 accepts 12 because its Qi names Mul1, then clears Qi. Add1 ignores this tag.
  2. Div1 broadcasts 6. Add1 saves 6 and clears Qj. Div1 does not overwrite f6, because f6 no longer names Div1. Waiting consumers still get Div1’s value.
  3. Add1 computes 6+10=16 and broadcasts. Add2 receives 16 and clears Qk; f0 accepts the result if its mapping still names Add1.
  4. Add2 can compute 12+16=28.

The register file accepts a broadcast only when its pending-producer tag matches. This prevents an older writer finishing late from overwriting a newer version (WAW). A consumer’s saved value or producer tag prevents a younger writer from changing the input it needs (WAR). True dependencies remain.

6. Renaming does not itself provide rollback

If an older instruction faults after a younger operation has changed visible registers or memory, precise recovery is difficult. Saving one consumer’s operand does not preserve a recoverable snapshot of all architectural state.

A reorder buffer with in-order commit is a common additional mechanism: younger results remain speculative until earlier instructions can commit safely. If an older instruction faults, discard younger speculative work and restore the appropriate state/mappings. Earlier committed effects are preserved; this is not undoing the entire program. This is an added connection to Precise Exceptions, not a claim that the deck’s basic Tomasulo diagram already contains a ROB.

The source’s basic scheme restricts execution past unresolved branches. The later loop example explicitly adds speculation; see Branch Prediction Fundamentals and Control Dependencies and Speculation.

7. Ready does not mean unlimited resources

An instruction can wait for an input, an execution unit or a broadcast opportunity. With one CDB carrying one result per cycle, two operations finishing together cannot both broadcast immediately. Consumers of the delayed result must still wait. Hardware also needs comparisons between broadcast tags and waiting inputs, adding complexity.

More stations increase how much pending work can be held; they do not automatically increase execution or broadcast bandwidth. Lab 05 - Superscalar Execution and Load Store Units illustrates why removing one local resource delay may not shorten the limiting execution path.

8. Overlapping loop iterations

The source’s loop loads f0, multiplies it into f4, stores f4, decrements x1 by 8 and branches back. Each iteration reuses f0 and f4, but distinct pending instances get distinct tags:

Iteration 1: Load1 at A     → Mult1 → Store1 at A
Iteration 2: Load2 at A − 8 → Mult2 → Store2 at A − 8

Both multiply stations have a ready copy of f2, the shared multiplier. Mult1 waits for Load1, Mult2 for Load2; stores wait for their corresponding multiply. After issuing both iterations, f0.Qi=Load2 and f4.Qi=Mult2, while older consumers retain the first iteration’s tags. Address information is captured separately so updating x1 does not move the earlier store’s destination.

The example assumes predicted-taken branches and speculation to reach the next iteration. Compiler unrolling is not required for this overlap, but true loop-carried dependencies and finite resources still limit it. Loop Unrolling and SIMD explains the related static technique. Memory Disambiguation in Dynamic Scheduling explains why distinct register versions alone cannot guarantee safe memory ordering.

9. Recall and check

  1. In the four-instruction trace, why must Add1 ignore Mul1’s broadcast even though both writers target f6?
  2. If Div1 finishes before Mul1 but after all four issue, may it overwrite f6? What can still capture its result?
  3. Why can a second loop iteration issue without changing the first multiply’s input producer?
  4. What is missing if basic renaming is used to claim precise rollback after every exception?

Answers: 1. Add1 needs Div1’s earlier version. 2. No: f6.Qi names Mul1; consumers tagged Div1 can capture it. 3. Saved tags remain bound to the appropriate dynamic instruction. 4. Architectural recovery and controlled commitment, not just operand tracking.

Hardware speculation connection

The next lecture develops the additional buffer and commitment machinery: ROB-tagged results remain usable by consumers while architectural updates wait in order. Hardware Speculation and the Reorder Buffer