【正文】
DMem Ifetch Reg Reg ALU DMem Ifetch Reg Cycle 1 Cycle 2 Cycle 3 Cycle 4 Cycle 6 Cycle 7 Cycle 5 Reg ALU DMem Ifetch Reg Bubble Bubble Bubble Bubble Bubble 計(jì)算機(jī)體系結(jié)構(gòu) 結(jié)構(gòu)相關(guān)對(duì)性能的影響 ?例如 : 如果每條指令平均訪存 次,而每個(gè)時(shí)鐘周期只能訪存一次,那么 ? 在其他資源 100%利用的前提下,平均 CPI ? 計(jì)算機(jī)體系結(jié)構(gòu) 流水線的加速比計(jì)算 p i p e l i n e ddu n p i p e l i n e T i meC y c l e T i meC y c l e C P I s ta l l P i p e l i n e C P I I d e a ld e p th P i p e l i n e C P I I d e a l S p e e d u p ????p i p e l i n e ddu n p i p e l i n e T i meC y c l e T i meC y c l e C P I s ta l l P i p e l i n e 1d e p th P i p e l i n e S p e e d u p ???I ns tp er c y c l es S t al l A v er ag e CP I I deal CP I p i p e l i n e d ??For simple RISC pipeline, CPI = 1: 計(jì)算機(jī)體系結(jié)構(gòu) 例如: Dualport vs. Singleport ? 機(jī)器 A: Dual ported memory (“Harvard Architecture”) ? 機(jī)器 B: Single ported memory, 但其流水線實(shí)現(xiàn)時(shí)比非流水實(shí)現(xiàn)時(shí)鐘頻率快 倍 ? Ideal CPI = 1 for both ? 所執(zhí)行的指令中 Loads指令占 40% SpeedUpA = Pipeline Depth/(1 + 0) x (clockunpipe/clockpipe) = Pipeline Depth Cycle Timeunpipeb = CycleTimepipe SpeedUpB = Pipeline Depth/(1 + x 1) x (cycleTimeunpipe/(cycletimepipe) = (Pipeline Depth/) x = x Pipeline Depth SpeedUpA / SpeedUpB = Pipeline Depth/( x Pipeline Depth) = ? Machine A 比 MachineB快 計(jì)算機(jī)體系結(jié)構(gòu) I n s t r. O r d e r add r1,r2,r3 sub r4,r1,r3 and r6,r1,r7 or r8,r1,r9 xor r10,r1,r11 Reg ALU DMem Ifetch Reg Reg ALU DMem Ifetch Reg Reg ALU DMem Ifetch Reg Reg ALU DMem Ifetch Reg Reg ALU DMem Ifetch Reg 數(shù)據(jù)相關(guān)問(wèn)題(圖 Page 100) Time (clock cycles) IF ID/RF EX MEM WB 計(jì)算機(jī)體系結(jié)構(gòu) ?寫(xiě)后讀相關(guān) (Read After Write (RAW)) InstrJ tries to read operand before InstrI writes it ?由于實(shí)際的通信需求而引起的 三種基本的數(shù)據(jù)相關(guān) I: add r1,r2,r3 J: sub r4,r1,r3 計(jì)算機(jī)體系結(jié)構(gòu) ? 讀后寫(xiě)相關(guān) Write After Read (WAR) InstrJ writes operand before InstrI reads it ? 編譯器編寫(xiě)者稱之為 “antidependence”( 反相關(guān)),是由于重復(fù)使用寄存器名 “r1”引起的 . ? DLX 5 段流水線不會(huì)有此類(lèi)相關(guān)因?yàn)?: ? 所有的指令都是 5段 , 并且 ? 讀操作總是在第 2段,而 ? 寫(xiě)操作在第 5段 I: sub r4,r1,r3 J: add r1,r2,r3 K: mul r6,r1,r7 計(jì)算機(jī)體系結(jié)構(gòu) ? 寫(xiě)后寫(xiě)相關(guān)( Write After Write (WAW)) InstrJ writes operand before InstrI writes it. ? 編譯器編寫(xiě)者稱之為 “output dependence” , 也是由于重復(fù)使用寄存器名 “r1”引起的 . ? 在 DLX 5段流水線中,也不會(huì)發(fā)生。計(jì)算機(jī)體系結(jié)構(gòu) 第 3章 流水線技術(shù) 流水線的基本概念 DLX的基本流水線 流水線的相關(guān) 異常處理 DLX中多周期操作的處理 MIPS R4000流水線 計(jì)算機(jī)體系結(jié)構(gòu) 復(fù)習(xí) :性能評(píng)測(cè) ?平均 CPI? ? 每類(lèi)指令的 CPIstate diagram gives CPI for each instruction type ? 每類(lèi)指令的使用頻度 Type CPIi for type Frequency CPIi x freqIi Arith/Logic 4 40% Load 5 30% Store 4 10% branch 3 20% Average CPI: 計(jì)算機(jī)體系結(jié)構(gòu) 是否可以使 CPI ? Ideal Memory WrAdr Din RAdr 32 32 32 Dout MemWr 32 ALU 32 32 ALUOp ALU Control 32 IRWr Instruction Reg 32 Reg File Ra Rw busW Rb 5 5 32 busA 32 busB RegWr Rs Rt Mux 0 1 Rt Rd PCWr ALUSelA Mux 0 1 RegDst Mux 0 1 32 PC MemtoReg Extend ExtOp Mux 0 1 32 0 1 2 3 4 16 Imm 32 2 ALUSelB Mux 1 0 32 Zero Zero PCWrCond PCSrc 32 IorD Mem Data Reg ALU Out B A ?在一條指令執(zhí)行過(guò)程中下圖有許多空閑部件 ? 可以讓指令重疊執(zhí)行? ?? 計(jì)算機(jī)體系結(jié)構(gòu) The Big Picture: Where are We Now? ?The Five Classic Components of a Computer ?Next Topics: ? Pipelining by Analogy ? Pipeline hazards Control Datapath Memory Processor Input Output 計(jì)算機(jī)體系結(jié)構(gòu) ?洗衣為例 ?Ann, Brian, Cathy, Dave 每人進(jìn)行洗衣的動(dòng)作: wash, dry, and fold ?washer需要 30 minutes ?Dryer 需要 40 minutes ?“Folder” 需要 20 minutes A B C D 流水線的基本概念 計(jì)算機(jī)體系結(jié)構(gòu) Sequential Laundry ?順序完成這些任務(wù)需要 6 hours for 4 loads ?如果采用流水作業(yè) , 需要多長(zhǎng)時(shí)間 ? A B C D 30 40 20 30 40 20 30 40 20 30 40 20 6 PM 7 8 9 10 11 Midnight T a s k O r d e r Time 計(jì)算機(jī)體系結(jié)構(gòu) 流水線作業(yè) : 原則盡可能早地讓工作開(kāi)始 ?流水作業(yè)完成四人的洗衣任務(wù)只需要 hours A B C D 6 PM 7 8 9 10 11 Midnight T a s k O r d e r Time 30 40 40 40 40 20 計(jì)算機(jī)體系結(jié)構(gòu) 流水線技術(shù)要點(diǎn) ?流