CET 520/ Gannod1 Section A.8 Dynamic Scheduling using a Scoreboard
CET 520/ Gannod2 Motivation In the pipeline that we’ve looked at, if there is an unavoidable hazard, we must stall until the hazard is resolved. –no new instructions can be fetched or issued even if they are independent. –e.g., suppose FP ADD/SUB is 2 cycles, MUL is 10 cycles and DIV is 40 cycles. L.DF6, 34(R2) L.DF2, 45(R3) MUL.DF0, F2, F4 SUB.DF8, F6, F2 DIV.DF10, F0, F6 ADD.DF6, F8, F2
CET 520/ Gannod3 Static Scheduling The compiler can attempt to reorder instructions (schedule instructions) to avoid hazards. The compiler (software) approach is called static scheduling. e.g, How should the compiler schedule the following: 1: ADD.DF1, F12, F5 2: ADD.DF2, F3, F4 3: ADD.DF2, F2, F1 4: ADD.DF6, F2, F11 5: SUB.DF1, F8, F7 6: ADD.DF5, F5, F5
CET 520/ Gannod4 Example How many cycles required?
CET 520/ Gannod5 Example cont... List all potential data hazards Find all legal orderings ideal ordering? How many cycles?
CET 520/ Gannod6 Dynamic Scheduling Previous example is a SOFTWARE solution. –instructions MUST execute in the order in which they are fetched. –the compiler’s job is to make sure the instructions are fetched in the best order. –this is not so easy In dynamic scheduling, the HARDWARE rearranges the instruction execution. –separate ID into two stages: issue and read operands –instructions can be issued in order –instructions can be exectued out-of- order –instructions can be completed out-of- order
CET 520/ Gannod7 Dynamic Pipeline w/ Scoreboard have several functional units. Let’s assume 2 FP mult, 1 FP adder, 1 FP div, and 1 integer Scoreboard –records data dependences –determines when an instruction can read its operands and begin execution –controls when an instruction can write into its destination register. –takes care of all hazard detection and resolution
CET 520/ Gannod8 Pipeline Stages IF Issue (IS) –if there is free functional unit and no WAW hazard, issue the instr. Read Operands (OP) –Monitors operands, and tells instr when operands can be read and proceed to execution Execution (EX) –complete execution and notify scoreboard Write Result (WB) –check for WAR hazard and stall if necessary.
CET 520/ Gannod9 Scoreboard There are 3 parts to the scoreboard: –Instruction Status (Issue? Read Operands? Execution Complete? Write Result?) –Functional Unit Status Busy – Is it busy? Op – operation being performed Fi – destination register Fj, Fk – source registers Qj, Qk – functional units producing Fj, Fk Rj, Rk – Flags indicating when Fj, Fk are ready and not yet read –Register Result Status indicates which functional unit will write each register
CET 520/ Gannod10 Example L.DF6, 34(R2) L.DF2, 45(R3) MUL.DF0, F2, F4 SUB.DF8, F6, F2 DIV.DF10, F0, F6 ADD.DF6, F8, F2 InstructionIssueRead 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
CET 520/ Gannod11 NameBusyOpFiFjFkQjQkRjRk Integer Mult1 Mult2 Add Divide Functional Unit Status Register Result Status F0F2F4F6F8F10...F30 FU