dynamic scheduling
play

Dynamic Scheduling Hardware rearranges instruc/on execu/on to - PDF document

Dynamic Scheduling Hardware rearranges instruc/on execu/on to reduce stalls of dependent instruc/on (increases ILP) - permit out-of-order execu/on.


  1. Dynamic ¡Scheduling ¡ • Hardware ¡rearranges ¡instruc/on ¡execu/on ¡to ¡reduce ¡stalls ¡of ¡ dependent ¡instruc/on ¡(increases ¡ILP) ¡-­‑ ¡permit ¡out-­‑of-­‑order ¡ execu/on. ¡ • Handles ¡dependences ¡not ¡known ¡at ¡compile-­‑/me ¡ • Allows ¡code ¡compiled ¡for ¡one ¡pipeline ¡to ¡run ¡efficiently ¡on ¡ another ¡pipeline ¡ • Can ’ t ¡eliminate ¡true ¡dependences ¡-­‑ ¡try ¡to ¡work ¡around ¡them ¡ and ¡avoid ¡stalls ¡ Concepts ¡of ¡Dynamic ¡Scheduling ¡ • Consider ¡DLX ¡with ¡in-­‑order ¡issue: ¡ DIVD F0,F2,F4 ADDD F10,F0,F8 SUBD F12,F8,F14 Page 1

  2. Concepts ¡of ¡Dynamic ¡Scheduling ¡ • Consider ¡DLX ¡with ¡in-­‑order ¡issue: ¡ DIVD F0,F2,F4 ADDD F10,F0,F8 True dependence on F0 SUBD F12,F8,F14 • SUBD ¡stalls ¡yet ¡isn ’ t ¡dependent ¡on ¡ADDD ¡or ¡DIVD ¡ Concepts ¡of ¡Dynamic ¡Scheduling ¡ • Consider ¡DLX ¡with ¡in-­‑order ¡issue: ¡ DIVD F0,F2,F4 ADDD F10,F0,F8 True dependence on F0 SUBD F12,F8,F14 STALL • SUBD ¡stalls ¡yet ¡isn ’ t ¡dependent ¡on ¡ADDD ¡or ¡DIVD ¡ • Suppose ¡we ¡let ¡SUBD ¡ “ move ¡around ” the ¡stall ¡and ¡execute ¡out ¡ of ¡order? ¡ Page 2

  3. Out-­‑of-­‑Order ¡Execution ¡ • In-­‑order, ¡single ¡instruc/on ¡issue ¡ • Instruc/ons ¡begin ¡execu/on ¡as ¡soon ¡as ¡their ¡operands ¡and ¡ FUs ¡are ¡available ¡ • Excep/ons ¡will ¡be ¡a ¡problem....later.... ¡ • Instruc/on ¡issue ¡now ¡has ¡independent ¡checks ¡ ¡ • Check ¡of ¡structural ¡hazards ¡(FU ¡availability) ¡ • Data ¡hazards ¡(operand ¡availability) ¡ • Split ¡ID ¡(decode) ¡stage ¡into ¡ • Issue ¡-­‑ ¡Decode ¡instruc/on, ¡check ¡for ¡structural ¡hazards ¡ • Read ¡Operands ¡-­‑ ¡Wait ¡un/l ¡no ¡data ¡hazards, ¡then ¡read ¡operands ¡ Issue ¡and ¡Read ¡Operands ¡ • In-­‑order ¡issue: ¡Instruc/ons ¡pass ¡through ¡the ¡Issue ¡stage ¡in ¡ order ¡to ¡resolve ¡structural ¡hazards ¡ • Bypassing: ¡Instruc/ons ¡may ¡bypass ¡one ¡another ¡in ¡the ¡Read ¡ Operand ¡stage, ¡poten/ally ¡entering ¡the ¡execu/on ¡pipeline ¡out ¡ of ¡order ¡ • How ¡do ¡we ¡check ¡FU ¡and ¡operand ¡availability? ¡ • Scoreboarding ¡-­‑ ¡Introduced ¡in ¡the ¡CDC ¡6600 ¡(circa ¡1963!!!) ¡ Page 3

  4. New ¡Hazards ¡Possible ¡ • Out-­‑of-­‑order ¡execu/on ¡leads ¡to ¡WAR ¡hazards ¡ DIVD F0,F2,F4 ADDD F10,F0,F8 SUBD F8,F8,F14 New ¡Hazards ¡Possible ¡ • Out-­‑of-­‑order ¡execu/on ¡leads ¡to ¡WAR ¡hazards ¡ DIVD F0,F2,F4 WAR ADDD F10,F0,F8 SUBD F8,F8,F14 • Of ¡course, ¡WAW ¡hazards ¡are ¡now ¡also ¡possible ¡ Page 4

  5. Scoreboarding ¡ • Keep ¡track ¡of ¡instruc/ons, ¡func/onal ¡units, ¡and ¡registers ¡to ¡ handle ¡hazards ¡ • Goal: ¡CPI=1 ¡ • “ Pull ¡out” ¡ ¡independent ¡instruc/ons ¡later ¡in ¡the ¡“issue ¡window ” . ¡ • Wait ¡queue ¡a`er ¡Issue ¡to ¡hold ¡stalled ¡instruc/ons ¡wai/ng ¡for ¡ operands ¡(it ¡may ¡not ¡really ¡exist) ¡ • Mul/ple ¡or ¡pipelined ¡func/onal ¡units ¡(recall: ¡during ¡issue, ¡we ¡ stall ¡on ¡a ¡structural ¡hazard) ¡ What ¡does ¡the ¡Scoreboard ¡do??? ¡ • Record ¡data ¡dependencies ¡of ¡instruc/ons ¡ • Determines ¡when ¡an ¡instruc/on ¡can ¡read ¡its ¡operands ¡and ¡ begin ¡execu/on ¡ • Can ’ t ¡execute? ¡Monitor ¡state ¡of ¡operands ¡to ¡decide ¡when ¡ instruc/on ¡can ¡execute ¡ • Determines ¡when ¡an ¡instruc/on ¡can ¡write ¡its ¡result ¡ ⇒ ¡ Scoreboard ¡does ¡all ¡hazard ¡detec2on ¡and ¡resolu2on ¡ Page 5

  6. Scoreboard ¡Architecture ¡ Int ALU Write result FP multiply Register to memory File or registers FP divide Int Divide IF Queue ID Wait Queue Scoreboard (The “ wait queue ” is virtual and Instruction Issue Doesn’t necessarily exist – it’s part of the scoreboard.) Stage ¡of ¡Scoreboard ¡Control ¡ 1. Issue ¡(I) ¡-­‑ ¡decode ¡instruc/on, ¡check ¡for ¡structural ¡and ¡WAW ¡ hazards, ¡stall ¡when ¡necessary ¡ 2. Read ¡Operands ¡(RO) ¡ -­‑ ¡wait ¡un/l ¡no ¡RAW ¡hazards, ¡then ¡read ¡ operands, ¡send ¡opera/on ¡to ¡FU ¡ 3. Execu6on ¡(EX) ¡ -­‑ ¡FU ¡starts ¡execu/on ¡upon ¡receiving ¡the ¡ operands ¡and ¡no/fies ¡scoreboard ¡when ¡it ’ s ¡completed ¡ 4. Write ¡Result ¡(WR) ¡ -­‑ ¡Scoreboard ¡checks ¡for ¡WAR ¡hazards ¡and ¡ stalls ¡write ¡to ¡register ¡file ¡to ¡avoid ¡them ¡ Page 6

  7. Step ¡0: ¡Fetch ¡ ¡ Int ALU Write result FP multiply Register to memory File or registers FP divide Int Divide IF Queue ID Wait Queue Scoreboard Step ¡1: ¡Issue ¡ ¡ Int ALU Write result FP multiply Register to memory File or registers FP divide Int Divide IF Queue ID Wait Queue Scoreboard Page 7

  8. Step ¡1: ¡Read ¡Operands ¡ ¡ Int ALU Write result FP multiply Register to memory File or registers FP divide Int Divide IF Queue ID Wait Queue Scoreboard Step ¡3: ¡Execute ¡ ¡ Int ALU Write result FP multiply Register to memory File or registers FP divide Int Divide IF Queue ID Wait Queue Scoreboard Page 8

  9. Step ¡4: ¡Write ¡Result ¡ ¡ Int ALU Write result FP multiply Register to memory File or registers FP divide Int Divide IF Queue ID Wait Queue Scoreboard Scoreboard ¡Data ¡Structures ¡ • Instruc6on ¡status ¡ – ¡current ¡step ¡(of ¡4) ¡for ¡an ¡ ¡ • Func6onal ¡unit ¡status ¡ ¡Field ¡Descrip/on ¡ ¡Busy ¡Unit ¡busy ¡or ¡not ¡ ¡Op ¡Opera/on ¡to ¡perform ¡(e.g., ¡+, ¡-­‑) ¡ ¡Fi ¡ ¡Des/na/on ¡register ¡ ¡Fj,Fk ¡Source ¡register ¡numbers ¡ ¡Qj,Qk ¡FUs ¡producing ¡sources ¡Fj,Fk ¡ ¡Rj,Rk ¡Flags ¡indica/ng ¡Fj,Fk ¡are ¡ready ¡ • Register ¡result ¡status ¡ -­‑ ¡which ¡FU ¡writes ¡a ¡given ¡register ¡(used ¡ to ¡set ¡Qj, ¡Qk ¡when ¡issuing) ¡ Page 9

  10. Hazard ¡Detection ¡ • Structural ¡hazards ¡ -­‑ ¡in ¡I, ¡ensure ¡that ¡a ¡func/onal ¡unit ¡is ¡ available ¡(makes ¡a ¡ “ reserva/on”) ¡ • WAW ¡hazards ¡ -­‑ ¡in ¡I, ¡ensure ¡that ¡no ¡previous ¡ac/ve ¡instruc/on ¡ has ¡the ¡same ¡des/na/on ¡ • RAW ¡hazards ¡ -­‑ ¡in ¡RO, ¡check ¡that ¡no ¡previous ¡ac/ve ¡instruc/on ¡ writes ¡a ¡source ¡register ¡ • WAR ¡hazards ¡ -­‑ ¡in ¡WR, ¡before ¡wri/ng ¡a ¡result, ¡check ¡if ¡any ¡ previous ¡instruc/ons ¡that ¡haven ’ t ¡gone ¡past ¡RO ¡need ¡that ¡ register ¡as ¡a ¡source ¡ Scoreboard ¡Pipeline ¡Control ¡ Status ¡ ¡ Wait ¡un6l ¡ Bookkeeping ¡ Issue ¡ ¡FU ¡not ¡busy ¡Busy(FU) ← Y; ¡Op(FU) ← op; ¡Fi(FU) ← D; ¡ ¡ ¡ ¡&& ¡not ¡result ¡Fj(FU) ← S1; ¡Fk(FU) ← S2; ¡Qj ← Res(S1); ¡ ¡ ¡ ¡ ¡ ¡Qk ← Res(S2); ¡Rj ← !Qj; ¡Rk ← !Qk; ¡ ¡ ¡ ¡ ¡ ¡ ¡Res(D) ← FU ¡ ¡ Read ¡ops ¡Rj ¡&& ¡Rk ¡ ¡Rj ← N; ¡Rk ← N ¡ ¡ Executed ¡FU ¡done ¡ ¡ Write ¡dest ¡ ∀ f((Fj(f) ≠ Fi(FU)|| ¡ ¡ ∀ f(if ¡Qj(f)=FU, ¡Rj(f) ← Y); ¡ ¡ ¡ ¡ ¡ ¡ ¡Rj(f)=N) ¡&& ¡ ¡ ∀ f(if ¡Qk(f)=FU, ¡Rj(f) ← Y); ¡ ¡ ¡ ¡ ¡(Fk(f) ≠ Fi(FU) ¡|| ¡Result(Fi(FU)) ← 0; ¡Busy(FU) ← N ¡ ¡ ¡ ¡ ¡ ¡ ¡Rk(f)=N)) ¡ Page 10

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