高级计算机体系结构设计及其在数据中心和云计算的应用Lecture 10Speculation and Traps in Out-of-Order Cores
高级计算机体系结构设计及其在数据中心和云计算的应用 Lecture 10 Speculation and Traps in Out-of-Order Cores
高级计算机体系结构设计及其在数据中心和云计算的应用What is wrong with Tomasulo's?Branchinstructions Need branch prediction to guess what to fetch next- Need speculative execution to“clean up"wrong guessesExceptionsandTraps("software"interrupts)-Needtohandleuncommon execution cases.Jumptoasoftwarehandler- Should follow the insn.on which they were triggered-Often referred to as precise interruptsDon'tknowrelativeorderof instructionsin Rs
高级计算机体系结构设计及其在数据中心和云计算的应用 What is wrong with Tomasulo’s? • Branch instructions – Need branch prediction to guess what to fetch next – Need speculative execution to “clean up” wrong guesses • Exceptions and Traps (“software” interrupts) – Need to handle uncommon execution cases • Jump to a software handler – Should follow the insn. on which they were triggered – Often referred to as precise interrupts Don’t know relative order of instructions in RS
高级计算机体系结构设计及其在数据中心和云计算的应用Speculation and Precise InterruptsWhenbranchismis-speculatedbypredictor- Must reset state (e.g,. regs) to time of branchSequential semantics for interrupts-Allinsns.beforeinterruptshouldbecomplete- All insns. after interrupt should look as if never started (abort)Whatmakesthisdifficult?-Youngerinsns.finishbeforebranch→>mustundo writebacks Older insns. not done when young branch resolves → must wait.Olderinsn.takespagefault ordividebyzero→forget thebranchSameproblem→Samesolution
高级计算机体系结构设计及其在数据中心和云计算的应用 Speculation and Precise Interrupts • When branch is mis-speculated by predictor – Must reset state (e.g,. regs) to time of branch • Sequential semantics for interrupts – All insns. before interrupt should be complete – All insns. after interrupt should look as if never started (abort) • What makes this difficult? – Younger insns. finish before branch must undo writebacks – Older insns. not done when young branch resolves must wait • Older insn. takes page fault or divide by zero forget the branch Same problem Same solution
高级计算机体系结构设计及其在数据中心和云计算的应用Precise State·Speculative execution requires- (Ability to) abort & restart at every branch- Abort & restart at every load (covered in later lecture): Synchronous (exception and trap) events require- Abort & restart at every load, store, divide, ...Asynchronous(hardware)interruptsrequire- Abort & restart at every ??Real world: bite the bullet-Implementabort&restartateveryinsn-Calledprecisestate
高级计算机体系结构设计及其在数据中心和云计算的应用 Precise State • Speculative execution requires – (Ability to) abort & restart at every branch – Abort & restart at every load (covered in later lecture) • Synchronous (exception and trap) events require – Abort & restart at every load, store, divide, . • Asynchronous (hardware) interrupts require – Abort & restart at every ?? • Real world: bite the bullet – Implement abort & restart at every insn. – Called precise state
高级计算机体系结构设计及其在数据中心和云计算的应用Precise State Implementation Options: Imprecise state: ignore the problem!- Makes page faults (any restartable exceptions) difficult- Makes speculative execution practically impossibleForce in-order completion (W): stall pipe if necessary- Slow (takes away benefit of Out-of-Order)Keeptrackofprecisestateinhardware- Reset current state from precise state when neededEverythingisbetterinhardware
高级计算机体系结构设计及其在数据中心和云计算的应用 Precise State Implementation Options • Imprecise state: ignore the problem! – Makes page faults (any restartable exceptions) difficult – Makes speculative execution practically impossible • Force in-order completion (W): stall pipe if necessary – Slow (takes away benefit of Out Slow (takes away benefit of Out-of-Order) • Keep track of precise state in hardware – Reset current state from precise state when needed Everything is better in hardware