Presentation is loading. Please wait.

Presentation is loading. Please wait.

Realistic Memories and Caches – Part III Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology April 4, 2012L15-1.

Similar presentations


Presentation on theme: "Realistic Memories and Caches – Part III Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology April 4, 2012L15-1."— Presentation transcript:

1 Realistic Memories and Caches – Part III Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology April 4, 2012L15-1 http://csg.csail.mit.edu/6.S078

2 2-level Data Cache Interface (0,n) interface mkL2Cache; method ActionValue#(Bool) req(MemReq r); method ActionValue#(Maybe#(Data)) resp; endinterface L1 cache Processor DRAM ReqRespMem req accepted resp L2 cache req accepted resp April 4, 2012 L15-2http://csg.csail.mit.edu/6.S078

3 2-level Data Cache Internals L1 Cache req accepted resp hit wire missFifo evict wire miss wire TagData Store L2 Cache req accepted resp missFifo ReqRespMem TagData Store respFifo reqFifo Let’s build an inclusive L2 with our earlier direct-mapped L1 April 4, 2012 L15-3http://csg.csail.mit.edu/6.S078

4 L2 cache: hit case rule procReq(!missFifo.notEmpty); let req = reqFifo.first; let hitOrMiss <- store.tagLookup(req.addr); if(hitOrMiss.hit) begin let line <- store.dataAccess( getCacheDataReqLine(hitOrMiss.id, req)); if(req.op == Ld) respFifo.enq(unpack(pack(line.Line))); reqFifo.deq; end : endrule April 4, 2012 L15-4http://csg.csail.mit.edu/6.S078

5 dirty case else if (hitOrMiss.dirty) begin let line <- store.dataAccess(CacheDataReq{id: hitOrMiss.id, reqType: tagged InvalidateLine}); mem.reqEnq(MemReq{op: St, addr: hitOrMiss.addr, data: unpack(pack(line.Line))}); end else What about corresponding line in L1? April 4, 2012 L15-5http://csg.csail.mit.edu/6.S078

6 miss case else begin missFifo.enq(tuple2(hitOrMiss.id, req)); req.op = Ld; mem.reqEnq(req); reqFifo.deq; end April 4, 2012 L15-6http://csg.csail.mit.edu/6.S078

7 Process miss from memory rule procMiss; match {.id,.req} = missFifo.first; Line line = req.op == Ld? unpack(pack (mem.respFirst)) : unpack(pack(req.data)); Bool dirty = req.op == Ld? False: True; let l <- store.dataAccess(CacheDataReq{id: id, reqType: tagged FillLine (tuple3(line, req.addr, dirty))}); if(req.op == Ld) respFifo.enq(unpack(pack(line))); missFifo.deq; mem.respDeq; endrule April 4, 2012 L15-7http://csg.csail.mit.edu/6.S078

8 How will inclusive L2 need to change to interface with a n-way set-associative L1? L1 Cache req accepted resp hit wire missFifo evict wire miss wire TagData Store L2 Cache req accepted resp missFifo ReqRespMem TagData Store respFifo reqFifo When a L2 cache line is evicted, the corresponding L1 cache line needs to be invalidated - Interface: + Invalidate information - L1 cache logic: tagLookup, invalidate April 4, 2012 L15-8http://csg.csail.mit.edu/6.S078

9 Multi-Level Cache Organizations Inclusive vs. Non-Inclusive vs. Exclusive Memory disk L1 Icache L1 Dcache regs L2 Cache Processor Separate data and instruction caches, vs. a Unified cache April 4, 2012 L15-9http://csg.csail.mit.edu/6.S078

10 Write-Back vs. Write-Through Caches in Multi-Level Caches Write back Writes only go into top level of hierarchy Maintain a record of “dirty” lines Faster write speed (only has to go to top level to be considered complete) Write through All writes go into L1 cache and then also write through into subsequent levels of hierarchy Better for “cache coherence” issues No dirty/clean bit records required Faster evictions 10

11 Summary Choice of cache interfaces Combinational vs non-combinational responses Blocking vs non-blocking FIFO vs non-FIFO responses Many possible internal organizations Direct Mapped and n-way set associative are the most basic ones Writeback vs Write-through Write allocate or not Multi-level caches: Likely organizations? Associativity, Block Size? next integrating into the pipeline April 4, 2012 L15-11http://csg.csail.mit.edu/6.S078

12 Recap: Six Stage Pipeline F Fetch D Decode R Reg Read X Execute M Memory W Write- back Writeback feeds back directly to ReadReg rather than through FIFO April 4, 2012 L15-12http://csg.csail.mit.edu/6.S078

13 Multi-cycle execute M Incorporating a multi-cycle operation into a stage R M2 M3 M1 X D C η B ζ A April 4, 2012 L15-13http://csg.csail.mit.edu/6.S078

14 Multi-cycle function unit module mkMultistage(Multistage); State1 m1 <- mkReg(); State2 m2 <- mkReg(); method Action request(Operand operand); m1.enq(doM1(operand)); endmethod rule s1; m2.enq(doM2(m1.first)); m1.deq(); endrule method ActionValue Result response(); return doM3(m2.first); m2.deq(); endmethod endmodule  Perform first stage of pipeline  Perform middle stage(s) of pipeline  Perform last stage of pipeline and return result April 4, 2012 L15-14http://csg.csail.mit.edu/6.S078

15 Single/Multi-cycle pipe stage rule doExec;... initialization let done = False; if (! waiting) begin if(isMulticycle(...)) begin multicycle.request(...); waiting <= True; end else begin result = singlecycle.exec(...); done = True; end end else begin result <- multicycle.response(); done = True; waiting <= False; end if (done)...finish up endrule  If not busy start multicycle operation, or…  …perform single cycle operation  If busy, wait for response  Finish up if have a result April 4, 2012 L15-15http://csg.csail.mit.edu/6.S078

16 Adding a cache (multi-cycle unit!) into the pipeline Architectural state: Which stages need to be modified? InstCache iCache <- mkInstCache(dualMem.iMem); ReqRespMem l2Cache <- mkL2Cache(dualMem.dMem); DataCache dCache <- mkDataCache(l2Cache); April 4, 2012 L15-16http://csg.csail.mit.edu/6.S078

17 Instruction fetch stage Processor sends request to I$ Processor receives response from I$ if(!inFlight) inFlight <- iCache.req(fetchPc); let instResp <- iCache.resp; if(instResp matches tagged Valid.d) : April 4, 2012 L15-17http://csg.csail.mit.edu/6.S078

18 Memory read stage Processor sends request to D$ Processor receives response from D$ if(! poisoned && (decInst.i_type==Ld || decInst.i_type==St) && ! memInFlight && mr.notFull) inFlight <- dCache.req(MemReq{op:execInst.itype==Ld ? Ld : St, addr:execInst.addr, data:execInst.data}); let data <- dCache.resp; if(! poisoned && (decInst.i_type == Ld || decInst.i_type == St )) if(isValid(data)) April 4, 2012 L15-18http://csg.csail.mit.edu/6.S078

19 Put it all together: Pipeline+Caches Instruction Fetch Hit F Fetch D Decode R Reg Read X Execute M Memory W Write- back L1 cache Processor DRAM ReqRespMem req accepted resp L2 cache req accepted resp April 4, 2012 L15-19http://csg.csail.mit.edu/6.S078

20 Put it all together: Pipeline+Caches Instruction Fetch Miss F Fetch D Decode R Reg Read X Execute M Memory W Write- back L1 cache Processor DRAM ReqRespMem req accepted resp L2 cache req accepted resp April 4, 2012 L15-20http://csg.csail.mit.edu/6.S078

21 Put it all together: Pipeline+Caches Instruction Fetch not accepted F Fetch D Decode R Reg Read X Execute M Memory W Write- back L1 cache Processor DRAM ReqRespMem req accepted resp L2 cache req accepted resp April 4, 2012 L15-21http://csg.csail.mit.edu/6.S078

22 Put it all together: Pipeline+Caches Multiple instructions with non-blocking caches L1 cache Processor DRAM ReqRespMem req accepted resp L2 cache req accepted resp F Fetch D Decode R Reg Read X Execute M Memory W Write- back missFifo April 4, 2012 L15-22http://csg.csail.mit.edu/6.S078

23 Where are the caches? April 4, 2012 L15-23http://csg.csail.mit.edu/6.S078


Download ppt "Realistic Memories and Caches – Part III Li-Shiuan Peh Computer Science & Artificial Intelligence Lab. Massachusetts Institute of Technology April 4, 2012L15-1."

Similar presentations


Ads by Google