basics of pipelining - university of kentuckyweb.engr.uky.edu/~heath/appendixa.pdf · 3. control...

28
Heath 1 BASICS OF PIPELINING APPENDIX A

Upload: hanhu

Post on 31-Jul-2019

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 1

BASICS OF PIPELINING

APPENDIX A

Page 2: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 2

WHAT IS PIPELINING ALL ABOUT???

Page 3: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 3

ANOTHER VIEW OF PIPELINING

Page 4: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 4

PIPELINE PERFORMANCE

• Speedup from Pipelining = (Average Instruction Time Un-pipelined)/(Average Instruction Time Pipelined)= (CPI Un-pipelined)/(CPI Pipelined) x (Clock cycle Time Un-Pipelined)/(Clock Cycle Time

Pipelined)Where CPI Pipelined = 1 + Pipeline stall clock cycles per instruction.

Now – Assuming Equal Cycle Time:Speedup = CPI Un-Pipelined / (1 + Pipeline stall cycles per Instruction)

Speedup = Pipeline Depth / 1 + Pipeline stall cycles per instruction.

Page 5: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 5

PIPELINE HAZARDS (Detriment to Performance)

1. Structural – Caused by Resource Conflicts.

2. Data Hazards – Caused when Proper Instances of Data is Not Available.

3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that Change the PC (Pipeline is Emptied!! – Nothing Happening in Some Pipeline Stages – No Work is Being Done in These Stages).

Page 6: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 6

ELIMINATION OF STRUCTURAL HAZARDS (Memory – Combined Instruction/Data Memories vs Separate Instruction/Data Memories)

Page 7: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 7

DATA HAZARDS

• DATA HAZARDS

Examples: DADD R1, R2, R3DSUB R4, R1, R5AND R6, R1, R7OR R8, R1, R9XOR R10, R1, R11

ELIMINATION: FORWARDING!!!!

Page 8: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 8

FORWARDING CONCEPT

Page 9: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 9

BRANCH PENALITIES AND ELIMINATION

Page 10: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 10

BRANCH DELAY SLOT SCHEDULING

Page 11: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 11

BRANCH AND CPI PENALITIES

Page 12: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 12

MIPS PIPELINE

Page 13: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 13

MIPS SYSTEM FLOW CHART

Page 14: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 14

DATA HAZARDS – WHEN????

Page 15: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 15

DATA HAZARDS – HOW DETERMINED????

Page 16: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 16

CHECKS FOR DATA HAZARDS

Page 17: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 17

HAZARD ELIMINATION VIA “FORWARDING”

Page 18: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 18

REDUCTION OF STALLS DUE TO BRANCH HAZARDS (Zero Test and Branch Target Calculation Moved to ID Stage)

Page 19: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 19

REVISED PIPELINE STRUCTURE

Page 20: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 20

MULTICYCLE OPERATIONS IN A PIPELINE (Use Another Faster Clock For Certain Functional Units)

Page 21: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 21

DETAILS OF MIPS PIPELINE TO SUPPORT FP OPERATIONS (Latency and Initiation Intervals are Issues

Initiation Interval = 1 or 25Latency = 0

Latency = 6

Latency = 3

Latency = 24

Latency: Number of intervening cycles between an instruction that produces a result and an instruction that uses the result.

Initiation Interval: Number of cycles that must elaspebetween issuing two operations of a given type.

Page 22: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 22

SCOREBOARDING (Performance!!!!!) – A Way to Implement Instruction Level Parallelism (ILP) – An Instruction Executes When Its Operands are Valid.

Parallel ALU Units and Operations.

Page 23: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 23

SCOREBOARDING: Replaces the ID, EX, and WB Stages of MIPS Pipeline.

• Four Steps to Scoreboarding:1. Issue – An instruction is issued and its internal data structure is updated if a

functional unit for the instruction is free and no other active instruction has the same destination register. Eliminates WAW hazards. IF a WAW hazard exists for some unknown reason, Issue is stalled.

2. Read Operands – Source operands are available if no other earlier issued activeinstruction needs to write to the operand. The scoreboard dynamically resolves RAW hazards in this step and instructions can go into execution out of order. (Steps 1. and 2. replace ID stage of MIPS pipeline).

3. Execution – Functional unit begins execution upon receiving operands. Scoreboard is notified of completion of execution by execution unit. (Replaces EX stage of MIPS pipeline).

4. Write Result – When a functional unit completes, it may not write its result if there is an instruction that has not read its operands that precedes (in order of issue) the completing instruction and one of the operands is the same register as the result of the completing instruction.

EX:

MULT.D F0, F2, F4

ADD.D F12, F0, F6 (Potential Problem)

SUB.D F6, F6, F14

Page 24: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 24

EXAMPLE SCOREBOARD• Instruction SequenceL.D F6, 34(R2)L.D F2, 45(R3)MUL.D F0, F2, F4SUB.DF8, F6, F2DIV.D F10, F0, F6ADD.D F6, F8, F2

THREE (3) PARTS TO SCOREBOARD1. Instruction Status (Issue, Read Operands, Execution Complete, or Write Result)2. Functional Unit Status (Indicated by Nine (9) Fields) –• Busy-Indicates if unit is busy or not.• Op-Operation to be performed by functional unit.• Fi-Destination register.• Fj, Fk-Source-register numbers• Qj, Qk-Fct. Units producing source registers Fj, Fk.• Rj, Rk-Flags indicating when Fj, Fk are ready and not yet read. Set to No after

opernads are read.3. Register Result Status-Indicates which functional unit will write each register and if

the register is the destination of an active instruction.

Page 25: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 25

SCOREBOARD PARTS – Lets Take a Look!!

Page 26: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 26

SCOREBOARD PARTS – Lets Take a Further Look (prior to MUL.D writing result)!!

Page 27: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 27

SCOREBOARD PARTS – Lets Take a Further Look (prior to DIV.D writing result)!!

Page 28: BASICS OF PIPELINING - University of Kentuckyweb.engr.uky.edu/~heath/AppendixA.pdf · 3. Control Hazards – Caused by Pipelining of Branch Instructions and Other Instructions that

Heath 28

SCOREBOARD PARTS – Checks and Bookkeeping for Each Step in Instruction Execution)!!