From: adam Date: Mon, 26 Feb 2007 11:56:28 +0000 (+0100) Subject: add code to "balance" the switch fabric tree X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=48136174e089bb1650c0401cd885075a9fa243a1;p=fleet.git add code to "balance" the switch fabric tree --- diff --git a/src/edu/berkeley/fleet/slipway/Slipway.java b/src/edu/berkeley/fleet/slipway/Slipway.java index 39abe38..1de2f01 100644 --- a/src/edu/berkeley/fleet/slipway/Slipway.java +++ b/src/edu/berkeley/fleet/slipway/Slipway.java @@ -226,6 +226,8 @@ public class Slipway extends Fleet { } else if (prefix.equals("dest")) { p.addr = addr; p.bits = bits; + if (bits >= 11) + throw new RuntimeException("too many benkoboxen!"); int count = 0; for(Destination d : p.getDestinations()) { if (!(d instanceof SlipwayBenkoBox.VirtualPort)) continue; @@ -237,10 +239,24 @@ public class Slipway extends Fleet { return p; } int len = end-start; + int count = 0; + int count2 = 0; + int breakpt = 0; + if (end-start <= 2) { + breakpt = (start+end)/2; + } else { + for(int i=start; istart && count2 >= count/2) break; + } + } return new Node(name, component, - mkNode(name+"_0", component, ports, start, start+len/2, addr, bits+1), - mkNode(name+"_1", component, ports, start+len/2, end, addr | (1 << bits), bits+1), + mkNode(name+"_0", component, ports, start, breakpt, addr, bits+1), + mkNode(name+"_1", component, ports, breakpt, end, addr | (1 << bits), bits+1), addr, bits); } @@ -320,6 +336,13 @@ public class Slipway extends Fleet { return ship.getType() + ship.getOrdinal(); } + private static int count(Iterable it) { + int ret = 0; + for(Destination d : it) + ret++; + return ret; + } + public void expand(ShipDescription sd) { try { String filename = sd.getName().toLowerCase();