NYU CSCI-GA 2233 - Overcoming Data Hazards (39 pages)

Previewing pages 1, 2, 3, 18, 19, 37, 38, 39 of 39 page document View the full content.
View Full Document

Overcoming Data Hazards



Previewing pages 1, 2, 3, 18, 19, 37, 38, 39 of actual document.

View the full content.
View Full Document
View Full Document

Overcoming Data Hazards

62 views


Pages:
39
School:
New York University
Course:
Csci-Ga 2233 - Computer Systems Design
Unformatted text preview:

CS G22 2233 Computer Systems Design Spring 2007 Lecture 05 Overcoming Data Hazards Mohammad Banikazemi Slides from Prof Mary Jane Irwin PSU Adapted from Computer Organization and Design Patterson Hennessy 2005 UCB G22 2233 L06 Containing Control Hazards 1 Banikazemi NYU 2007 Review Why Pipeline For Performance Time clock cycles Reg IM Reg IM Reg ALU IM Reg ALU Inst 1 IM ALU O r d e r Inst 0 ALU I n s t r IM Reg Inst 2 Inst 3 DM Reg DM Reg DM Reg DM ALU Inst 4 Once the pipeline is full one instruction is completed every cycle so CPI 1 Reg DM Reg Time to fill the pipeline G22 2233 L06 Containing Control Hazards 2 Banikazemi NYU 2007 Review Can Pipelining Get Us Into Trouble Yes Pipeline Hazards O structural hazards attempt to use the same resource by two different instructions at the same time O data hazards attempt to use data before it is ready An instruction s source operand s are produced by a prior instruction still in the pipeline O control hazards attempt to make a decision about program control flow before the condition has been evaluated and the new PC target address calculated branch instructions Can always resolve hazards by waiting O pipeline control must detect the hazard O and take action to resolve hazards G22 2233 L06 Containing Control Hazards 3 Banikazemi NYU 2007 A Single Memory Would Be a Structural Hazard Time clock cycles Mem Inst 3 Inst 4 Mem Reg Mem Reg Mem Reg ALU Inst 2 Reg ALU Mem Reg ALU Reg Reading data from memory Mem ALU O r d e r Inst 1 Mem ALU I n s t r lw Mem Reg Mem Reading instruction from memory Reg Mem Reg Reg Fix with separate instr and data memories I and D G22 2233 L06 Containing Control Hazards 4 Banikazemi NYU 2007 How About Register File Access Time clock cycles Inst 1 Reg IM Reg IM Reg ALU IM ALU IM Reg Inst 2 add 2 1 G22 2233 L06 Containing Control Hazards 5 DM Reg DM Reg DM ALU O r d e r add 1 ALU I n s t r Reg DM Reg Banikazemi NYU 2007 How About Register File Access Time clock cycles Inst 1 Reg IM Reg IM Reg ALU IM ALU IM Reg Inst 2 add 2 1 clock edge that controls register writing G22 2233 L06 Containing Control Hazards 6 DM Reg DM Reg DM ALU O r d e r add 1 ALU I n s t r Fix register file access hazard by doing reads in the second half of the cycle and writes in the first half Reg DM Reg clock edge that controls loading of pipeline state registers Banikazemi NYU 2007 Register Usage Can Cause Data Hazards and 6 1 7 or 8 1 9 IM Reg IM Reg IM Reg ALU sub 4 1 5 Reg ALU IM ALU O r d e r add 1 ALU I n s t r Dependencies backward in time cause hazards IM Reg DM DM Reg DM Reg DM ALU xor 4 1 5 Reg Reg DM Reg Read before write data hazard G22 2233 L06 Containing Control Hazards 7 Banikazemi NYU 2007 Register Usage Can Cause Data Hazards Dependencies backward in time cause hazards or 8 1 9 IM Reg IM Reg IM Reg DM Reg DM Reg DM Reg DM ALU xor 4 1 5 Reg ALU and 6 1 7 IM ALU sub 4 1 5 Reg ALU IM ALU add 1 Reg DM Reg Read After Write RAW data hazard G22 2233 L06 Containing Control Hazards 8 Banikazemi NYU 2007 Loads Can Cause Data Hazards sub 4 1 5 and 6 1 7 or 8 1 9 Reg IM Reg IM Reg IM Reg ALU IM ALU 1 4 2 ALU O r d e r lw ALU I n s t r Dependencies backward in time cause hazards IM Reg DM DM Reg DM Reg DM ALU xor 4 1 5 Reg Reg DM Reg Load use RAW data hazard G22 2233 L06 Containing Control Hazards 9 Banikazemi NYU 2007 One Way to Fix a Data Hazard IM Reg DM Reg IM Reg ALU O r d e r add 1 ALU I n s t r Can fix data hazard by waiting stall but impacts CPI IM Reg stall stall sub 4 1 5 G22 2233 L06 Containing Control Hazards 10 ALU and 6 1 7 DM Reg DM Reg Banikazemi NYU 2007 Another Way to Fix a Data Hazard and 6 1 7 or 8 1 9 G22 2233 L06 Containing Control Hazards 11 Reg IM Reg IM Reg IM Reg DM Reg DM DM Reg DM ALU xor 4 1 5 IM ALU sub 4 1 5 Reg ALU IM ALU O r d e r add 1 ALU I n s t r Fix data hazards by forwarding results as soon as they are available to where they are Reg needed Reg DM Reg Banikazemi NYU 2007 Another Way to Fix a Data Hazard and 6 1 7 or 8 1 9 G22 2233 L06 Containing Control Hazards 12 Reg IM Reg IM Reg IM Reg DM Reg DM DM Reg DM ALU xor 4 1 5 IM ALU sub 4 1 5 Reg ALU IM ALU O r d e r add 1 ALU I n s t r Fix data hazards by forwarding results as soon as they are available to where they are Reg needed Reg DM Reg Banikazemi NYU 2007 Forwarding with Load use Data Hazards and 6 1 7 or 8 1 9 G22 2233 L06 Containing Control Hazards 13 Reg IM Reg IM Reg IM Reg DM Reg DM Reg DM Reg DM ALU xor 4 1 5 IM ALU sub 4 1 5 Reg ALU 1 4 2 IM ALU O r d e r lw ALU I n s t r Reg DM Reg Banikazemi NYU 2007 Forwarding with Load use Data Hazards and 6 1 7 or 8 1 9 Reg IM Reg IM Reg IM Reg DM Reg DM Reg DM Reg DM ALU xor 4 1 5 IM ALU sub 4 1 5 Reg ALU 1 4 2 IM ALU O r d e r lw ALU I n s t r Reg DM Reg Will still need one stall cycle even with forwarding G22 2233 L06 Containing Control Hazards 14 Banikazemi NYU 2007 Branch Instructions Cause Control Hazards lw Inst 3 G22 2233 L06 Containing Control Hazards 15 IM Reg IM Reg IM Reg DM Reg DM Reg DM ALU Inst 4 Reg ALU IM ALU O r d e r beq ALU I n s t r Dependencies backward in time cause hazards Reg DM Reg Banikazemi NYU 2007 One Way to Fix a Control Hazard beq O r d e r stall IM Reg ALU I n s t r DM Fix branch hazard by waiting stall but affects CPI Reg stall stall G22 2233 L06 Containing Control Hazards 16 Reg IM Reg DM ALU Inst 3 IM ALU lw Reg DM …


View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Overcoming Data Hazards and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Overcoming Data Hazards and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?