1 / 26

IP Lookup: Some subtle concurrency issues Arvind Computer Science & Artificial Intelligence Lab

IP Lookup: Some subtle concurrency issues Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology. but first a correction from the last lecture …. One-Element Pipeline FIFO. module mkPipelineFIFO1 (FIFO#(t)); Reg#(t) data <- mkRegU();

uyen
Download Presentation

IP Lookup: Some subtle concurrency issues Arvind Computer Science & Artificial Intelligence Lab

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. IP Lookup: Some subtle concurrency issues Arvind Computer Science & Artificial Intelligence Lab Massachusetts Institute of Technology http://csg.csail.mit.edu/6.375

  2. but first a correction from the last lecture … http://csg.csail.mit.edu/6.375

  3. One-Element Pipeline FIFO module mkPipelineFIFO1 (FIFO#(t)); Reg#(t) data <- mkRegU(); Reg#(Bool) full <- mkReg(False); RWire#(void) deqEN <- mkRWire(); Bool deqp = isValid (deqEN.wget())); method Action enq(t x) if (!full || deqp); full <= True; data <= x; endmethod method Action deq() if (full); full <= False; deqEN.wset(?); endmethod method t first() if (full); return (data); endmethod method Action clear(); full <= False; endmethod endmodule This actually won’t work! This works correctly in both cases (fifo full and fifo empty). !full enab enq rdy or !full enab rdy deq !empty first < enq deq < enq FIFO module enq < clear deq < clear http://csg.csail.mit.edu/6.375

  4. One-Element Pipeline FIFOAnalysis module mkPipelineFIFO1 (FIFO#(t)); Reg#(t) data <- mkRegU(); Reg#(Bool) full <- mkReg(False); RWire#(void) deqEN <- mkRWire(); Bool deqp = isValid (deqEN.wget())); method Action enq(t x) if (!full || deqp); full <= True; data <= x; endmethod method Action deq() if (full); full <= False; deqEN.wset(?); endmethod ... Rwire allows us to create a combinational path between enq and deq but does not affect the conflict analysis !full enab enq rdy or !full enab rdy deq !empty Conflict analysis: FIFO module http://csg.csail.mit.edu/6.375

  5. Solution- Config registers Lie a little • ConfigReg is a Register (Reg#(a)) Reg#(t) full <- mkConfigRegU; • Same HW as Register, but the definition says read and write can happen in either order • However, just like a HW register, a read after a write gets the old value • Primarily used to fool the compiler analysis to do the right thing http://csg.csail.mit.edu/6.375

  6. One-Element Pipeline FIFOA correct solution module mkLFIFO1 (FIFO#(t)); Reg#(t) data <- mkRegU(); Reg#(Bool) full <- mkConfigReg(False); RWire#(void) deqEN <- mkRWire(); Bool deqp = isValid (deqEN.wget())); method Action enq(t x) if (!full || deqp); full <= True; data <= x; endmethod method Action deq() if (full); full <= False; deqEN.wset(?); endmethod method t first() if (full); return (data); endmethod method Action clear(); full <= False; endmethod endmodule No conflicts around full: when both enq and deq happen; if we want deq < enq then full must be set to True in case enq occurs. !full enab enq rdy or !full enab rdy deq !empty Scheduling constraint on deqEn forces deq < enq FIFO module first < enq deq < enq enq < clear deq < clear http://csg.csail.mit.edu/6.375

  7. An asideUnsafe modules • Bluespec allows you to import Verilog modules by identifying wires that correspond to methods • Such modules can be made safe either by asserting the correct scheduling properties of the methods or by wrapping the unsafe modules in appropriate Bluespec code Config Reg is an example of an unsafe module http://csg.csail.mit.edu/6.375

  8. back to today’s lecture … http://csg.csail.mit.edu/6.375

  9. Line Card (LC) Arbitration Packet Processor Control Processor SRAM (lookup table) Switch Queue Manager IP Lookup Exit functions LC LC LC IP Lookup block in a router • A packet is routed based on the “Longest Prefix Match” (LPM) of it’s IP address with entries in a routing table • Line rate and the order of arrival must be maintained line rate  15Mpps for 10GE http://csg.csail.mit.edu/6.375

  10. 7.14.*.* A 7 B … … … … … … … … … … … … … … … A C A C A A F F F F F F F F F 7.14.7.3 B 10.18.200.* C 10.18.200.5 D 5.*.*.* E * F 5 D Sparse tree representation 0 14 3 5 E F 7 10 18 255 200 2 3 In this lecture: Level 1: 16 bits Level 2: 8 bits Level 3: 8 bits  1 to 3 memory accesses 1 4 http://csg.csail.mit.edu/6.375

  11. 0 0 0 … … … 28 -1 28 -1 … 216 -1 “C” version of LPM int lpm (IPA ipa) /* 3 memory lookups */ { int p; /* Level 1: 16 bits */ p = RAM [ipa[31:16]]; if (isLeaf(p)) return value(p); /* Level 2: 8 bits */ p = RAM [ptr(p) + ipa [15:8]]; if (isLeaf(p)) return value(p); /* Level 3: 8 bits */ p = RAM [ptr(p) + ipa [7:0]]; return value(p); /* must be a leaf */ } Not obvious from the C code how to deal with - memory latency - pipelining Memory latency ~30ns to 40ns Must process a packet every 1/15 ms or 67 ns Must sustain 3 memory dependent lookups in 67 ns http://csg.csail.mit.edu/6.375

  12. Rigid pipeline Linear pipeline Inefficient memory usage but simple design Efficient memory usage through memory port replicator 1 2 3 Longest Prefix Match for IP lookup:3 possible implementation architectures Circular pipeline Efficient memory with most complex control Designer’s Ranking: Which is “best”? http://csg.csail.mit.edu/6.375 Arvind, Nikhil, Rosenband & Dave ICCAD 2004

  13. outQ inQ yes enter? done? RAM no fifo Circular pipeline The fifo holds the request while the memory access is in progress The architecture has been simplified for the sake of the lecture. Otherwise, a “completion buffer” has to be added at the exit to make sure that packets leave in order. Next lecture http://csg.csail.mit.edu/6.375

  14. n FIFO interface FIFO#(type t); method Action enq(t x); // enqueue an item method Action deq(); // remove oldest entry method t first(); // inspect oldest item endinterface enab enq rdy not full n = # of bits needed to represent a value of type t enab FIFO module rdy deq not empty n first rdy not empty http://csg.csail.mit.edu/6.375

  15. ctr++ Ready (ctr > 0) Ack ctr deq deq enq Enable Data Ready Synch Mem Latency N req ctr-- peek Data Addr Request-Response Interface for Synchronous Memory interface Mem#(type addrT, type dataT); method Action req(addrT x); method Action deq(); method dataT peek(); endinterface Making a synchronous component latency- insensitive http://csg.csail.mit.edu/6.375

  16. inQ enter? done? RAM fifo Circular Pipeline Code rule enter (True); IP ip = inQ.first(); ram.req(ip[31:16]); fifo.enq(ip[15:0]); inQ.deq(); endrule done? Is the same as isLeaf rule recirculate (True); TableEntry p = ram.peek(); ram.deq(); IP rip = fifo.first(); if (isLeaf(p)) outQ.enq(p); else begin fifo.enq(rip << 8); ram.req(p + rip[15:8]); end fifo.deq(); endrule When can enter fire? inQ has an element and ram & fifo each has space http://csg.csail.mit.edu/6.375

  17. inQ enter? done? RAM fifo Circular Pipeline Code: discussion rule enter (True); IP ip = inQ.first(); ram.req(ip[31:16]); fifo.enq(ip[15:0]); inQ.deq(); endrule rule recirculate (True); TableEntry p = ram.peek(); ram.deq(); IP rip = fifo.first(); if (isLeaf(p)) outQ.enq(p); else begin fifo.enq(rip << 8); ram.req(p + rip[15:8]); end fifo.deq(); endrule When can recirculate fire? ram & fifo each has an element and ram, fifo & outQ each has space Is this possible? http://csg.csail.mit.edu/6.375

  18. Ordinary FIFO won’t work but a pipeline FIFO would http://csg.csail.mit.edu/6.375

  19. Problem solved! PipelineFIFO fifo <- mkPipelineFIFO; // use a Pipeline fifo • RWire has been safely encapsulated inside the Pipeline FIFO – users of the fifo need not be aware of RWires rule recirculate (True); TableEntry p = ram.peek(); ram.deq(); IP rip = fifo.first(); if (isLeaf(p)) outQ.enq(p); else begin fifo.enq(rip << 8); ram.req(p + rip[15:8]); end fifo.deq(); endrule http://csg.csail.mit.edu/6.375

  20. inQ enter? done? RAM fifo Dead cycles rule enter (True); IP ip = inQ.first(); ram.req(ip[31:16]); fifo.enq(ip[15:0]); inQ.deq(); endrule assume simultaneous enq & deq is allowed rule recirculate (True); TableEntry p = ram.peek(); ram.deq(); IP rip = fifo.first(); if (isLeaf(p)) outQ.enq(p); else begin fifo.enq(rip << 8); ram.req(p + rip[15:8]); end fifo.deq(); endrule Can a new request enter the system when an old one is leaving? Is this worth worrying about? http://csg.csail.mit.edu/6.375

  21. yes in enter done? RAM no fifo The Effect of Dead Cycles Circular Pipeline • RAM takes several cycles to respond to a request • Each IP request generates 1-3 RAM requests • FIFO entries hold base pointer for next lookup and unprocessed part of the IP address What is the performance loss if “exit” and “enter” don’t ever happen in the same cycle? http://csg.csail.mit.edu/6.375

  22. Scheduling conflicting rules • When two rules conflict on a shared resource, they cannot both execute in the same clock • The compiler produces logic that ensures that, when both rules are applicable, only one will fire • Which one? source annotations (* descending_urgency = “recirculate, enter” *) http://csg.csail.mit.edu/6.375

  23. inQ enter? done? RAM fifo So is there a dead cycle? rule enter (True); IP ip = inQ.first(); ram.req(ip[31:16]); fifo.enq(ip[15:0]); inQ.deq(); endrule rule recirculate (True); TableEntry p = ram.peek(); ram.deq(); IP rip = fifo.first(); if (isLeaf(p)) outQ.enq(p); else begin fifo.enq(rip << 8); ram.req(p + rip[15:8]); end fifo.deq(); endrule http://csg.csail.mit.edu/6.375

  24. Rule Spliting rule fooT (p); r1 <= 5; endrule rule fooF (!p); r2 <= 7; endrule rule foo (True); if (p) r1 <= 5; else r2 <= 7; endrule  rule fooT and fooF can be scheduled independently with some other rule http://csg.csail.mit.edu/6.375

  25. Spliting the recirculate rule rule recirculate (!isLeaf(ram.peek())); IP rip = fifo.first(); fifo.enq(rip << 8); ram.req(ram.peek() + rip[15:8]); fifo.deq(); ram.deq(); endrule rule exit (isLeaf(ram.peek())); outQ.enq(ram.peek()); fifo.deq(); ram.deq(); endrule rule enter (True); IP ip = inQ.first(); ram.req(ip[31:16]); fifo.enq(ip[15:0]); inQ.deq(); endrule Now rules enter and exit can be scheduled simultaneously, assuming fifo.enq and fifo.deq can be done simultaneously http://csg.csail.mit.edu/6.375

  26. outQ inQ Packaging a module:Turning a rule into a method enter? done? RAM fifo rule enter (True); IP ip = inQ.first(); ram.req(ip[31:16]); fifo.enq(p[15:0]); inQ.deq(); endrule http://csg.csail.mit.edu/6.375

More Related