290 likes | 409 Views
Scoreboarding. The following four steps replace ID, EX and WB steps ID: Issue – if a functional unit for instruction is free and no other active instruction has the same destination register (WAW) it can proceed, otherwise it stalls
E N D
Scoreboarding • The following four steps replace ID, EX and WB steps • ID: Issue – if a functional unit for instruction is free and no other active instruction has the same destination register (WAW) it can proceed, otherwise it stalls • ID: Read operands – a source operand is available if no earlier instruction is going to write it • EX: Execute – once the execution is complete this stage notifies the scoreboard • WB: Write results – scoreboard checks for WAR hazards and may stall write back
Scoreboarding • Operands are always read from register file – no advantage is taken of forwarding • This is no large penalty as write occurs immediately after the execution and not after MEM stage • Read operand and write result stages cannot overlap so we have 1 cycle latency
Time =1 Issue first load Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU Yes Load F6 R2 Yes FP Mult1 FP Mult2 FP Add FP Div Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Integer
Time =2 First load reads operands Second load cannot be issued due to structural hazard Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU Yes Load F6 R2 Yes No FP Mult1 FP Mult2 FP Add FP Div Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Integer
Time =3 First load completes execution Second load cannot be issued due to structural hazard Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU Yes Load F6 R2 No FP Mult1 FP Mult2 FP Add FP Div Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Integer
Time =4 First load writes the result and frees ALU Second load cannot be issued due to structural hazard Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU Yes Load F6 R2 No FP Mult1 FP Mult2 FP Add FP Div Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Integer
Time =5 Second load is issued Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU Yes Load F2 R3 Yes FP Mult1 FP Mult2 FP Add FP Div Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Integer
Time =6 Second load reads operands Mult is issued Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU Yes Load F2 R3 No Yes Yes FP Mult1 No Integer Yes Mult F0 F2 F4 FP Mult2 FP Add FP Div Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Mult1 Integer
Time =7 Second load completes execution Mult is stalled waiting for F2 Instruction status Sub is issued Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU Yes Load F2 R3 No Yes FP Mult1 No Integer Yes Mult F0 F2 F4 FP Mult2 FP Add Yes Integer No Sub F8 F6 F2 Yes FP Div Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Add Mult1 Integer
Time =8 Second load writes result Mult is stalled waiting for F2 Sub is stalled waiting for F2 Instruction status Div is issued Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU Yes Load F2 R3 No Yes FP Mult1 Yes No Integer Yes Mult F0 F2 F4 FP Mult2 FP Add Yes Integer No Sub F8 F6 F2 Yes Yes Yes FP Div Mult1 Div F10 F0 F6 Yes No Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Mult1 Add Divide Integer
Time =9 Mult reads operands Sub reads operands Div is stalled waiting for F0 Instruction status Add cannot be issueddue to structural hazard Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU Yes No FP Mult1 Yes No Yes Mult F0 F2 F4 FP Mult2 FP Add Yes No Sub F8 F6 F2 Yes No Yes Yes FP Div Mult1 Div F10 F0 F6 Yes No Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Mult1 Add Divide
Time =10 Mult in execution (1 out of 10) Sub in execution (1 out of 2) Div is stalled waiting for F0 Instruction status Add cannot be issueddue to structural hazard Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 10 SUB.D F8, F6, F2 10 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU No FP Mult1 No Yes Mult F0 F2 F4 FP Mult2 FP Add Yes No Sub F8 F6 F2 No Yes FP Div Mult1 Div F10 F0 F6 Yes No Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Mult1 Add Divide
Time =11 Mult in execution (2 out of 10) Sub completes execution Div is stalled waiting for F0 Instruction status Add cannot be issueddue to structural hazard Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 10 SUB.D F8, F6, F2 10 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU No FP Mult1 No Yes Mult F0 F2 F4 FP Mult2 FP Add Yes No Sub F8 F6 F2 No Yes FP Div Mult1 Div F10 F0 F6 Yes No Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Mult1 Add Divide
Time =12 Mult in execution (3 out of 10) Sub writes result, frees adder Div is stalled waiting for F0 Instruction status Add cannot be issueddue to structural hazard Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 10 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU No FP Mult1 No Yes Mult F0 F2 F4 FP Mult2 FP Add Yes No Sub F8 F6 F2 No Yes FP Div Mult1 Div F10 F0 F6 Yes No Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Mult1 Add Divide
Time =13 Add is issued Mult in execution (4 out of 10) Div is stalled waiting for F0 Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 10 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU No FP Mult1 No Yes Mult F0 F2 F4 FP Mult2 Add F6 F8 F2 FP Add Yes Yes Yes Yes FP Div Mult1 Div F10 F0 F6 Yes No Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Mult1 Add Divide
Time =14 Mult in execution (5 out of 10) Div is stalled waiting for F0 Add reads operands Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 10 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU No FP Mult1 No Yes Mult F0 F2 F4 FP Mult2 Add F6 F8 F2 FP Add Yes No Yes No Yes Yes FP Div Mult1 Div F10 F0 F6 Yes No Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Mult1 Add Divide
Time =15 Mult in execution (6 out of 10) Div is stalled waiting for F0 Add in execution (1 out of 2) Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 10 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 15 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU No FP Mult1 No Yes Mult F0 F2 F4 FP Mult2 Add F6 F8 F2 FP Add Yes No No Yes FP Div Mult1 Div F10 F0 F6 Yes No Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Mult1 Add Divide
Time =16 Mult in execution (7 out of 10) Div is stalled waiting for F0 Add completes execution Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 10 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 15 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU No FP Mult1 No Yes Mult F0 F2 F4 FP Mult2 Add F6 F8 F2 FP Add Yes No No Yes FP Div Mult1 Div F10 F0 F6 Yes No Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Mult1 Add Divide
Time =17 Mult in execution (8 out of 10) Div is stalled waiting for F0 Add is stalled, WAR hazard Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU No FP Mult1 No Yes Mult F0 F2 F4 FP Mult2 Add F6 F8 F2 FP Add Yes No No Yes FP Div Mult1 Div F10 F0 F6 Yes No Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Mult1 Add Divide
Time =19 Mult completes execution Div is stalled waiting for F0 Add is stalled, WAR hazard Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU No FP Mult1 No Yes Mult F0 F2 F4 FP Mult2 Add F6 F8 F2 FP Add Yes No No Yes FP Div Mult1 Div F10 F0 F6 Yes No Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Mult1 Add Divide
Time =20 Mult writes result Div is stalled waiting for F0 Add is stalled, WAR hazard Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU No FP Mult1 No Yes Mult F0 F2 F4 FP Mult2 Add F6 F8 F2 FP Add Yes No No Yes FP Div Mult1 Div F10 F0 F6 Yes Yes No Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Mult1 Divide Add
Time =21 Div reads operands Add is stalled, WAR hazard Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU FP Mult1 FP Mult2 Add F6 F8 F2 FP Add Yes No No No Yes FP Div Div F10 F0 F6 Yes No Yes Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Divide Add
Time =22 Div in execution (1 out of 40) Add writes result Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 22 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU FP Mult1 FP Mult2 Add F6 F8 F2 Yes FP Add No No No FP Div Div F10 F0 F6 Yes No Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Add Divide
Time =61 Div completes execution Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU FP Mult1 FP Mult2 FP Add No FP Div Div F10 F0 F6 Yes No Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Divide
Time =62 Div writes result Instruction status Issue Read operands Execution complete Write result L.D F6, 34(R2) L.D F2, 45(R3) MUL.D F0, F2, F4 SUB.D F8, F6, F2 DIV.D F10, F0, F6 ADD.D F6, F8, F2 Functional unit status Busy Op Fi FjFk QjQk RjRk Integer ALU FP Mult1 FP Mult2 FP Add No FP Div Div F10 F0 F6 Yes No Register result status F0 … F2 … F4 … F6 … F8 … F10 … F12 Functional unit Divide
Tomasulo’s Algorithm • Use reservation stations that will hold operands for instructions waiting to issue • Reservation station fetches the operand as soon as it is available • Pending instructions read operands from reservation stations • When writes overlap in execution, only the last write actually updates the register
Tomasulo’s Algorithm Frominstruction unit Common data bus Instructionqueue FP registers LOAD-STOREOPERATIONS Store buffers FPOPERATIONS Load buffers Address unit 4 3 2 1 4 3 2 1 Reservationstations Data Address Memory unit FP multipliers FP adders
Tomasulo’s Algorithm • Each reservation station holds the opcode for the pending instruction and either operand values or names of reservation stations that will provide them • Load and store buffers hold data and addresses for memory access • Transfer of all data goes over the common data bus
Homework • Due Tuesday, October 19 by the end of the class • Submit either in class (paper) or by E-mail (PS or PDF only) or bring the paper copy to my office • Show scheduling of the following code using scoreboard(assume one integer ALU, two FP multipliers, one FP adder and one FP divider) LD F2, 0(R2) LD F4, 100(R3) ADD F8, F2, F2 MUL F6, F4, F8 SUB F6, F2, F4