csci341
play

CSCI341 Lecture 36, Pipelining & Hazards RECALL... RECALL... - PowerPoint PPT Presentation

CSCI341 Lecture 36, Pipelining & Hazards RECALL... RECALL... HAZARDS Data Hazards Control Hazards Dukes of Hazzard DATA HAZARD Hardware solution: Include forwarding paths in the machines datapath. Even though results have not


  1. CSCI341 Lecture 36, Pipelining & Hazards

  2. RECALL...

  3. RECALL... HAZARDS • Data Hazards • Control Hazards Dukes of Hazzard

  4. DATA HAZARD Hardware solution: Include forwarding paths in the machine’s datapath. Even though results have not yet reached the writeback stage, the needed information is forwarded from a pipeline register to the input of the ALU (for example).

  5. HAZARD “DETECTION” • Control logic inspects instruction registers used by neighboring stages. • eg, “If EX/MEM’s Rd = ID/EX’s Rs and EX/MEM’s Rd = ID/ EX’s Rt”

  6. HAZARD

  7. FORWARDING

  8. “FORWARDING UNIT”

  9. DATA HAZARD Can’t always solve this w/ hardware. For example: lw followed by add

  10. DATA HAZARD

  11. DATA HAZARD One solution: Rearrange the assembly instructions so the instruction following a load is not one that uses the value fetched from memory. (Pipelined loads are often called “delayed loads.”)

  12. DATA HAZARD What if the instructions can’t be rearranged? Then we insert a nop instruction. (“No Operation”)

  13. NOP 0000 0000 0000 0000 0000 0000 0000 0000 ( sll $0, $0, 0 )

  14. STALLING

  15. HAZARD DETECTION

  16. CONTROL HAZARDS Associated with every branch/jump instruction.

  17. ONE SOLUTION Assume the branch is not taken. (If it is, then we must flush the instructions that have already begun flowing through the pipeline.)

  18. AN IMPROVED SOLUTION Determine the branch condition earlier (using additional logic circuitry.) The goal is to slightly reduce the number of “wasted” instructions (and cycles) that have entered the pipeline.

  19. DELAY SLOT At the assembly level, organize the instructions such that the instruction immediately following a branch instruction is a useful one. Loop: Loop: add $t0, $t0, $v0 addi $v0, $v0, -1 addi $v0, $v0, -1 bnez $v0, Loop bnez $v0, Loop add $t0, $t0, $v0 li $v0, 4 li $v0, 4 ... ...

  20. DYNAMIC BRANCH PREDICTION In a nutshell: Keeping track of branch instruction histories, and consulting previous branch decisions to best predict the current one.

  21. EXCEPTIONS aka “Interrupts” I/O device request Invoke the OS Overflow HW Malfunction Important when considering pipelined architectures!

  22. WHAT HAPPENS? Save the address of the exceptional instruction (in the EPC, exception program counter). Transfer control to the OS at some specified address. OS can terminate the program or continue.

  23. OS EXCEPTION HANDLING • What was the reason? (MIPS uses a “cause register”) • Which instruction was the culprit? (EPC)

  24. EXCEPTIONS & PIPELINING In essence, an exception is treated like a control hazard.

  25. NEXT.... Parallelism

  26. HOMEWORK • Reading 30 • Project 8: “Flip Ya!” Flip it good!

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend