csse232 computer architecture i
play

CSSE232 Computer Architecture I Control Hazards Pipelining - PowerPoint PPT Presentation

CSSE232 Computer Architecture I Control Hazards Pipelining From last =me Data Hazards: Create units to help with Forward data Detect when


  1. CSSE232 ¡ Computer ¡Architecture ¡I ¡ Control ¡Hazards ¡

  2. Pipelining ¡ • From ¡last ¡=me… ¡ • Data ¡Hazards: ¡ – Create ¡units ¡to ¡help ¡with ¡ • Forward ¡data ¡ • Detect ¡when ¡stalls ¡are ¡needed ¡

  3. Datapath ¡with ¡Hazard ¡Detec=on ¡

  4. Branching ¡ • Previous ¡datapaths ¡had ¡no ¡issues ¡with ¡ branching ¡ • Pipeline ¡datapath ¡ – Execu=ng ¡several ¡instruc=ons ¡in ¡parallel ¡ – Processing ¡branch ¡and ¡subsequent ¡instruc=ons! ¡

  5. Branch ¡Hazards ¡ Flush ¡these ¡ instruc=ons ¡ (Set ¡control ¡ values ¡to ¡0) ¡

  6. Flushing ¡ • Stall ¡ – Stopped ¡updates ¡to ¡IF, ¡ID ¡ – Cancelled ¡EX ¡for ¡current ¡instruc=on ¡ • Flush ¡ – Cancel ¡all ¡instruc=ons! ¡ – Set ¡control ¡to ¡zero ¡in ¡for ¡3 ¡instruc=ons ¡in ¡flight ¡

  7. Reducing ¡Flushed ¡Instruc=ons ¡ • How ¡to ¡reduce ¡wasted ¡instruc=ons? ¡

  8. Reducing ¡Branch ¡Flushing ¡ • Move ¡hardware ¡to ¡determine ¡outcome ¡to ¡ID ¡stage ¡ – Target ¡address ¡adder ¡ – Register ¡comparator ¡ • ALUs ¡are ¡slow ¡ – Subtac=on ¡is ¡slow ¡ • Equal ¡is ¡much ¡easier ¡ – Just ¡use ¡XOR ¡gates ¡

  9. Detec=ng ¡Control ¡Hazard ¡ • Hazard ¡unit ¡can ¡detect ¡branch ¡instruc=ons, ¡and ¡ automa=cally ¡flush ¡next ¡instruc=on ¡ • MIPS ¡does ¡not ¡detect ¡control ¡hazards ¡ – Does ¡not ¡flush! ¡ – Will ¡execute ¡1 ¡instruc=on ¡aZer ¡branch ¡ – Require ¡noop ¡aZer ¡all ¡branches? ¡ • Lets ¡programmer ¡choose ¡to ¡use ¡the ¡'delay ¡slot' ¡ – Can ¡increment ¡loop ¡counter ¡(or ¡something ¡else) ¡

  10. Other ¡Control ¡Hazards ¡ • Jump ¡and ¡link ¡ – Greencard ¡says ¡PC+8 ¡ – Assumes ¡a ¡delay ¡slot ¡ – Return ¡to ¡instruc=on ¡aZer ¡delay ¡slot ¡

  11. Other ¡complica=ons ¡ • Flushing ¡is ¡ ¡one ¡problem ¡ – MIPS ¡solu=on ¡is ¡to ¡reduce ¡to ¡single ¡delay ¡slot ¡ • What ¡about ¡ge`ng ¡branch ¡ready? ¡

  12. • If ¡a ¡comparison ¡register ¡is ¡a ¡des=na=on ¡of ¡2 nd ¡ or ¡3 rd ¡preceding ¡ALU ¡instruc=on ¡ IF ¡ ID ¡ EX ¡ MEM ¡ WB ¡ add $1, $2, $3 IF ¡ ID ¡ EX ¡ MEM ¡ WB ¡ add $4, $5, $6 IF ¡ ID ¡ EX ¡ MEM ¡ WB ¡ … IF ¡ ID ¡ EX ¡ MEM ¡ WB ¡ beq $1, $4, target n Can ¡resolve ¡using ¡forwarding ¡

  13. • If ¡a ¡comparison ¡register ¡is ¡a ¡des=na=on ¡of ¡ preceding ¡ALU ¡instruc=on ¡or ¡2 nd ¡preceding ¡ load ¡instruc=on ¡ – Need ¡1 ¡stall ¡cycle ¡ IF ¡ ID ¡ EX ¡ MEM ¡ WB ¡ lw $1, addr IF ¡ ID ¡ EX ¡ MEM ¡ WB ¡ add $4, $5, $6 IF ¡ ID ¡ beq stalled ID ¡ EX ¡ MEM ¡ WB ¡ beq $1, $4, target

  14. • If ¡a ¡comparison ¡register ¡is ¡a ¡des=na=on ¡of ¡ immediately ¡preceding ¡load ¡instruc=on ¡ – Need ¡2 ¡stall ¡cycles ¡ IF ¡ ID ¡ EX ¡ MEM ¡ WB ¡ lw $1, addr IF ¡ ID ¡ beq stalled ID ¡ beq stalled ID ¡ EX ¡ MEM ¡ WB ¡ beq $1, $0, target

  15. Dynamic ¡Branch ¡Predic=on ¡ • In ¡deeper ¡and ¡superscalar ¡pipelines, ¡branch ¡penalty ¡ is ¡more ¡significant ¡ • Use ¡dynamic ¡predic=on ¡ – Branch ¡predic=on ¡buffer ¡(aka ¡branch ¡history ¡table) ¡ – Indexed ¡by ¡recent ¡branch ¡instruc=on ¡addresses ¡ – Stores ¡outcome ¡(taken/not ¡taken) ¡ – To ¡execute ¡a ¡branch ¡ • Check ¡table, ¡expect ¡the ¡same ¡outcome ¡ • Start ¡fetching ¡from ¡fall-­‑through ¡or ¡target ¡ • If ¡wrong, ¡flush ¡pipeline ¡and ¡flip ¡predic=on ¡

  16. Review ¡and ¡Ques=ons ¡ • Hazards ¡ – Data ¡ – Control ¡ – Structural ¡ • Hazard ¡detec=on ¡ • Hazard ¡preven=on ¡

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