From 13ba24c890dc8bdb91cd9d23703ae6ba2ba2a837 Mon Sep 17 00:00:00 2001 From: megacz Date: Sat, 14 Mar 2009 18:17:45 -0700 Subject: [PATCH] break out dataflow nodes into separate classes --- src/edu/berkeley/fleet/dataflow/AluNode.java | 12 + src/edu/berkeley/fleet/dataflow/DataFlowGraph.java | 625 +------------------- src/edu/berkeley/fleet/dataflow/DebugNode.java | 10 + .../berkeley/fleet/dataflow/DownCounterNode.java | 13 + src/edu/berkeley/fleet/dataflow/ForeverNode.java | 29 + src/edu/berkeley/fleet/dataflow/MemoryNode.java | 100 ++++ src/edu/berkeley/fleet/dataflow/MergeSort.java | 166 ++++++ src/edu/berkeley/fleet/dataflow/Node.java | 243 ++++++++ src/edu/berkeley/fleet/dataflow/OnceNode.java | 39 ++ .../berkeley/fleet/dataflow/PunctuatorNode.java | 19 + src/edu/berkeley/fleet/dataflow/RepeatNode.java | 13 + .../berkeley/fleet/dataflow/SortedMergeNode.java | 13 + .../berkeley/fleet/dataflow/UnPunctuatorNode.java | 14 + 13 files changed, 678 insertions(+), 618 deletions(-) create mode 100644 src/edu/berkeley/fleet/dataflow/AluNode.java create mode 100644 src/edu/berkeley/fleet/dataflow/DebugNode.java create mode 100644 src/edu/berkeley/fleet/dataflow/DownCounterNode.java create mode 100644 src/edu/berkeley/fleet/dataflow/ForeverNode.java create mode 100644 src/edu/berkeley/fleet/dataflow/MemoryNode.java create mode 100644 src/edu/berkeley/fleet/dataflow/MergeSort.java create mode 100644 src/edu/berkeley/fleet/dataflow/Node.java create mode 100644 src/edu/berkeley/fleet/dataflow/OnceNode.java create mode 100644 src/edu/berkeley/fleet/dataflow/PunctuatorNode.java create mode 100644 src/edu/berkeley/fleet/dataflow/RepeatNode.java create mode 100644 src/edu/berkeley/fleet/dataflow/SortedMergeNode.java create mode 100644 src/edu/berkeley/fleet/dataflow/UnPunctuatorNode.java diff --git a/src/edu/berkeley/fleet/dataflow/AluNode.java b/src/edu/berkeley/fleet/dataflow/AluNode.java new file mode 100644 index 0000000..f6120a3 --- /dev/null +++ b/src/edu/berkeley/fleet/dataflow/AluNode.java @@ -0,0 +1,12 @@ +package edu.berkeley.fleet.dataflow; +import edu.berkeley.fleet.loops.*; +import edu.berkeley.fleet.api.*; + +public class AluNode extends Node { + public final Ship ship = dfg.pool.allocateShip("Alu"); + public final InPort in1 = new DockInPort("in1", ship.getDock("in1")); + public final InPort in2 = new DockInPort("in2", ship.getDock("in2")); + public final InPort inOp = new DockInPort("inOp", ship.getDock("inOp")); + public final OutPort out = new DockOutPort("out", ship.getDock("out")); + public AluNode(DataFlowGraph dfg) { super(dfg); } +} diff --git a/src/edu/berkeley/fleet/dataflow/DataFlowGraph.java b/src/edu/berkeley/fleet/dataflow/DataFlowGraph.java index 48a8720..6d4a5fd 100644 --- a/src/edu/berkeley/fleet/dataflow/DataFlowGraph.java +++ b/src/edu/berkeley/fleet/dataflow/DataFlowGraph.java @@ -34,6 +34,10 @@ public class DataFlowGraph { this.pool = pool; } + public void addNode(Node node) { + this.nodes.add(node); + } + public static int reset_count = 0; public static HashSet torpedoes = new HashSet(); @@ -50,469 +54,13 @@ public class DataFlowGraph { mod.reset(ctx, phase, ackDestination); } - public static class Node { - - void doReset(Context ctx, int phase, Dock dock, Port peer, Destination ackDestination, boolean peerUsed) { - if (dock.getShip().getType().equals("Debug")) return; - - switch(phase) { - - // Phase 0: torpedo every output dock, put it in - // collecting mode. Cannot combine with phase 1, - // because until output docks are in vacuum mode we - // cannot be sure that the tokens to the input docks - // will eventually succeed. This may cause the - // instructions sent after the tokens to back up into - // the switch fabric. - case 0: { - if (!dock.isInputDock()) { - torpedoes.add(dock); - LoopFactory lf = new LoopFactory(ctx, dock, 1); - lf.sendToken(ackDestination); - lf = lf.makeNext(0); - lf.abortLoopIfTorpedoPresent(); - lf.collectWord(); - reset_count++; - } - break; - } - - // Phase 1: torpedo every input dock, put it in loopback mode - case 1: { - if (dock.isInputDock()) { - torpedoes.add(dock); - LoopFactory lf = new LoopFactory(ctx, dock, 1); - lf.sendToken(ackDestination); - - // FIXME: this won't work right for ports that - // get "shared" by two senders (for example, - // inAddrRead1/2) - - if (peerUsed && peer!=null) { - lf = lf.makeNext(0); - lf.abortLoopIfTorpedoPresent(); - ((OutPort)peer).recvWord(lf); - ((OutPort)peer).sendToken(lf); - } - reset_count++; - } - break; - } - - // Phase 2: torpedo every output dock, have it absorb tokens - case 2: { - if (!dock.isInputDock()) { - torpedoes.add(dock); - LoopFactory lf = new LoopFactory(ctx, dock, 1); - if (peer != null) - for(int i=0; i<((InPort)peer).getTokensToAbsorb(); i++) - lf.recvToken(); - lf.sendToken(ackDestination); - reset_count++; - } - break; - } - - // Phase 3: torpedo every input dock, and we're done - case 3: { - if (dock.isInputDock()) { - if (peerUsed && peer!=null) { - torpedoes.add(dock); - } - LoopFactory lf = new LoopFactory(ctx, dock, 1); - lf.sendToken(ackDestination); - reset_count++; - } - break; - } - - - } - } - - public final DataFlowGraph dfg; - public Node(DataFlowGraph dfg) { - this.dfg = dfg; - dfg.nodes.add(this); - } - - private HashMap ports = new HashMap(); - - public InPort getInPort(String name) { return (InPort)ports.get(name); } - public OutPort getOutPort(String name) { return (OutPort)ports.get(name); } - - public void build(Context ctx) { for(Port p : ports.values()) p.build(ctx); } - public void reset(Context ctx, int phase, Destination ackDestination) { - for(Port p : ports.values()) p.reset(ctx, phase, ackDestination); - } - - public abstract class Port { - public final String name; - public Port(String name) { - this.name = name; - if (Node.this.ports.get(name)!=null) throw new RuntimeException(); - Node.this.ports.put(name,this); - } - public abstract void build(Context ctx); - public abstract void reset(Context ctx, int phase, Destination ackDestination); - } - - public abstract class InPort extends Port { - OutPort peer; - public InPort(String name) { super(name); } - public void connect(OutPort peer) { - this.setPeer(peer); - peer.setPeer(this); - } - public void setPeer(OutPort peer) { - if (this.peer!=null) throw new RuntimeException("cannot call setPeer() twice"); - this.peer = peer; - } - - /** this port's peer (an OutPort) invokes this to have "recvToken" or equivalent inserted */ - public abstract void recvToken(LoopFactory loopfactory_at_output_dock); - /** this port's peer (an OutPort) invokes this to have "sendWord" or equivalent inserted */ - public abstract void sendWord(LoopFactory loopfactory_at_output_dock); - - public int getTokensToAbsorb() { return 0; } - } - - public abstract class OutPort extends Port { - InPort peer; - public OutPort(String name) { super(name); } - public void connect(InPort peer) { - this.setPeer(peer); - peer.setPeer(this); - } - public void setPeer(InPort peer) { - if (this.peer!=null) throw new RuntimeException("cannot call setPeer() twice"); - this.peer = peer; - } - - /** this port's peer (an InPort) invokes this to have "sendToken" or equivalent inserted */ - public abstract void sendToken(LoopFactory loopfactory_at_input_dock); - /** this port's peer (an InPort) invokes this to have "recvWord" or equivalent inserted */ - public abstract void recvWord(LoopFactory loopfactory_at_input_dock); - } - - public final class DockInPort extends InPort { - final Dock dock; - int count; - BitVector[] pattern; - public DockInPort(String name, Dock dock) { this(name, dock, 0); } - public DockInPort(String name, Dock dock, int count) { this(name, dock, count, new BitVector[] { null }); } - public DockInPort(String name, Dock dock, int count, BitVector[] pattern) { - super(name); - this.dock = dock; - this.count = count; - this.pattern = pattern; - } - public void recvToken(LoopFactory lf) { lf.recvToken(); } - public void sendWord(LoopFactory lf) { lf.sendWord(dock.getDataDestination()); } - public void build(Context ctx) { build(ctx, new LoopFactory(ctx, dock, 1)); } - // number-in-flight is considered a property of the input dock in a pair - public int getInflight() { return 4; } - //public int getInflight() { return 1; } - public int getTokensToAbsorb() { return getInflight(); } - private boolean peerUsed() { - if (peer==null) return false; - for(int i=0; iout is - * maintained, but out is not flow-controlled, so be sure - * that every datum sent there is consumed synchronously wiht - * data items sent to out. - */ - public static class ForeverNode extends Node { - private BitVector bv; - public final OutPort out = new OutPort("out") { - public void sendToken(LoopFactory lf) { } - public void recvWord(LoopFactory lf) { } - public void build(Context ctx) { } - public void reset(Context ctx, int phase, Destination ackDestination) { } - public void setPeer(InPort peer) { - this.peer = peer; - DockInPort pip = ((DockInPort)peer); - for(int i=0; i= pip_pattern.length) j = 0; - } - pip.pattern = new BitVector[i]; - System.arraycopy(temp, 0, pip.pattern, 0, i); - pip.count = 1; - } - }; - public OnceNode(DataFlowGraph dfg, long l) { this(dfg, new BitVector(dfg.fleet.getWordWidth()).set(l)); } - public OnceNode(DataFlowGraph dfg, final BitVector bv) { super(dfg); this.bv = bv; } - } - - public static class DebugNode extends Node { - public final Ship ship = dfg.pool.allocateShip("Debug"); - public final InPort in = new DockInPort("in", ship.getDock("in")); - // NOTE: shutdown needs to treat this specially - public DebugNode(DataFlowGraph dfg) { super(dfg); } - } - - public static class UnPunctuatorNode extends Node { - private final Ship ship = dfg.pool.allocateShip("Counter"); - public final OutPort out = new DockOutPort("out", ship.getDock("out")); - public final InPort val = new DockInPort("in1", ship.getDock("in1")); - public final InPort count = new DockInPort("in2", ship.getDock("in2"), 0, new BitVector[] { null, dfg.bv(1) }); - public final InPort op = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] { - ship.getDock("inOp").getConstant("PASS_C2_V1"), - ship.getDock("inOp").getConstant("DROP_C2_V1") } ); - public UnPunctuatorNode(DataFlowGraph dfg) { super(dfg); } - } - - public static class PunctuatorNode extends Node { - private final long punc; - private final Ship ship = dfg.pool.allocateShip("Counter"); - public final OutPort out = new DockOutPort("out", ship.getDock("out")); - public final InPort val = new DockInPort("in1", ship.getDock("in1")); - public final InPort op = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] { - ship.getDock("inOp").getConstant("PASS_C2_V1"), - ship.getDock("inOp").getConstant("PASS_C2_V2") } ); - public final InPort count; - public PunctuatorNode(DataFlowGraph dfg, long punc) { - super(dfg); - this.punc = punc; - this.count = new DockInPort("in2", ship.getDock("in2"), 0, new BitVector[] { null, dfg.bv(1), dfg.bv(punc) }); - } - } - - public static class AluNode extends Node { - public final Ship ship = dfg.pool.allocateShip("Alu"); - public final InPort in1 = new DockInPort("in1", ship.getDock("in1")); - public final InPort in2 = new DockInPort("in2", ship.getDock("in2")); - public final InPort inOp = new DockInPort("inOp", ship.getDock("inOp")); - public final OutPort out = new DockOutPort("out", ship.getDock("out")); - public AluNode(DataFlowGraph dfg) { super(dfg); } - } - - public static class DownCounterNode extends Node { - public final Ship ship = dfg.pool.allocateShip("Counter"); - public final InPort start = new DockInPort("in1", ship.getDock("in1")); - public final InPort incr = new DockInPort("in2", ship.getDock("in2")); - public final InPort inOp = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] { - ship.getDock("inOp").getConstant("COUNT") }); - public final OutPort out = new DockOutPort("out", ship.getDock("out")); - public DownCounterNode(DataFlowGraph dfg) { super(dfg); } - } - - public static class RepeatNode extends Node { - public final Ship ship = dfg.pool.allocateShip("Counter"); - public final InPort count = new DockInPort("in1", ship.getDock("in1")); - public final InPort val = new DockInPort("in2", ship.getDock("in2")); - public final InPort inOP = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] { - ship.getDock("inOp").getConstant("REPEAT_C1_V2") }); - public final OutPort out = new DockOutPort("out", ship.getDock("out")); - public RepeatNode(DataFlowGraph dfg) { super(dfg); } - } - - public static class SortedMergeNode extends Node { - public final Ship ship = dfg.pool.allocateShip("Alu"); - public final InPort in1 = new DockInPort("in1", ship.getDock("in1")); - public final InPort in2 = new DockInPort("in2", ship.getDock("in2")); - public final InPort inOp = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] { - ship.getDock("inOp").getConstant("MAXMERGE") }); - public final OutPort out = new DockOutPort("out", ship.getDock("out")); - public SortedMergeNode(DataFlowGraph dfg) { super(dfg); } - } - - public static class MemoryNode extends Node { - public final Ship ship; - public final InPort inCBD; - public final InPort inAddrRead1; - public final InPort inAddrRead2; - public final InPort inAddrWrite; - public final InPort inDataWrite; - public final OutPort outRead1; - public final OutPort outRead2; - public final OutPort outWrite; - public MemoryNode(DataFlowGraph dfg, Ship memoryShip) { - super(dfg); - this.ship = memoryShip; - this.inCBD = ship.getType().equals("Memory") ? new DockInPort("inCBD", ship.getDock("inCBD")) : null; - this.inAddrWrite = new DockInPort("inAddrWrite", ship.getDock("inAddrWrite")); - this.inDataWrite = new DockInPort("inDataWrite", ship.getDock("inDataWrite")); - this.inAddrRead1 = new InPort("inAddrRead1") { - public void recvToken(LoopFactory lf) { lf.recvToken(); } - public void sendWord(LoopFactory lf) { lf.sendWord(ship.getDock("inAddrRead").getDataDestination(), new BitVector(1).set(0)); } - public void build(Context ctx) { } - public int getTokensToAbsorb() { return outRead1.peer.getTokensToAbsorb(); } - public void reset(Context ctx, int phase, Destination ackDestination) { - doReset(ctx, phase, ship.getDock("inAddrRead"), null, ackDestination, false); - } - }; - this.inAddrRead2 = new InPort("inAddrRead2") { - public void recvToken(LoopFactory lf) { lf.recvToken(); } - public void sendWord(LoopFactory lf) { lf.sendWord(ship.getDock("inAddrRead").getDataDestination(), new BitVector(1).set(1)); } - public void build(Context ctx) { } - public int getTokensToAbsorb() { return outRead2.peer.getTokensToAbsorb(); } - public void reset(Context ctx, int phase, Destination ackDestination) { } - }; - this.outRead1 = new OutPort("outRead1") { - public void sendToken(LoopFactory lf) { inAddrRead1.peer.sendToken(lf); } - public void recvWord(LoopFactory lf) { lf.recvWord(); } - public void build(Context ctx) { } - public void reset(Context ctx, int phase, Destination ackDestination) { } - }; - this.outRead2 = new OutPort("outRead2") { - public void sendToken(LoopFactory lf) { inAddrRead2.peer.sendToken(lf); } - public void recvWord(LoopFactory lf) { lf.recvWord(); } - public void build(Context ctx) { } - public void reset(Context ctx, int phase, Destination ackDestination) { } - }; - this.outWrite = new DockOutPort("out", ship.getDock("out")) { - protected void build(Context ctx, LoopFactory lf) { - lf = lf.makeNext(0); - lf.abortLoopIfTorpedoPresent(); - lf.collectWord(); - - lf.setFlags(FlagFunction.ZERO, FlagFunction.ZERO.add(FlagC)); - if (this.peer != null) { - lf.setPredicate(Predicate.FlagB); - lf.literal(77); - lf.abortLoopIfTorpedoPresent(); - this.peer.recvToken(lf); - this.peer.sendWord(lf); - } - - lf.setPredicate(Predicate.NotFlagB); - lf.abortLoopIfTorpedoPresent(); - lf.recvToken(); - lf.setFlags(FlagFunction.ZERO.add(NotFlagC).add(FlagB), FlagFunction.ZERO.add(FlagC).add(FlagB)); - if (outRead1.peer != null) { - lf.setPredicate(Predicate.NotFlagB); - outRead1.peer.sendWord(lf); - } - if (outRead2.peer != null) { - lf.setPredicate(Predicate.NotFlagA); - outRead2.peer.sendWord(lf); - } - lf.setPredicate(null); - } - }; - } - public void build(Context ctx) { - super.build(ctx); - LoopFactory lf; - - lf = new LoopFactory(ctx, ship.getDock("inAddrRead"), 0); - lf.abortLoopIfTorpedoPresent(); - lf.recvWord(); - lf.setFlags(FlagFunction.ZERO.add(FlagC), FlagFunction.ZERO); - lf.setPredicate(Predicate.NotFlagA); - lf.sendToken(ship.getDock("out").getDataDestination(), new BitVector(1).set(0)); - lf.setPredicate(Predicate.FlagA); - lf.sendToken(ship.getDock("out").getDataDestination(), new BitVector(1).set(1)); - lf.setPredicate(null); - lf.deliver(); - } - } - public static void main(String[] s) throws Exception { Fleet fleet = new Fpga(); //Fleet fleet = new Interpreter(false); @@ -549,7 +97,7 @@ public class DataFlowGraph { if (fp==null) fp = fleet.run(new Instruction[0]); // do the mergeSort - vals = mergeSort(fp, fleet, vals, vals_length, stride, mem1, mem2); + vals = MergeSort.mergeSort(fp, fleet, vals, vals_length, stride, mem1, mem2); // verify the cleanup //CleanupUtils.verifyClean(fp); @@ -568,165 +116,6 @@ public class DataFlowGraph { } - public static long[] mergeSort(FleetProcess fp, Fleet fleet, - long[] vals, int vals_length, int stride_length, - Ship memoryShip1, Ship memoryShip2) throws Exception { - - if (vals != null) { - BitVector[] mem = new BitVector[vals_length]; - for(int i=0; i ai = new ArrayList(); - proc.build(ctx); - ctx.emit(ai); - for(Instruction ins : ai) { - //System.out.println(ins); - fp.sendInstruction(ins); - } - fp.flush(); - - for(int i=0; iout is + * maintained, but out is not flow-controlled, so be sure + * that every datum sent there is consumed synchronously wiht + * data items sent to out. + */ +public class ForeverNode extends Node { + private BitVector bv; + public final OutPort out = new OutPort("out") { + public void sendToken(LoopFactory lf) { } + public void recvWord(LoopFactory lf) { } + public void build(Context ctx) { } + public void reset(Context ctx, int phase, Destination ackDestination) { } + public void setPeer(InPort peer) { + this.peer = peer; + DockInPort pip = ((DockInPort)peer); + for(int i=0; i ai = new ArrayList(); + proc.build(ctx); + ctx.emit(ai); + for(Instruction ins : ai) { + //System.out.println(ins); + fp.sendInstruction(ins); + } + fp.flush(); + + for(int i=0; i ports = new HashMap(); + + public InPort getInPort(String name) { return (InPort)ports.get(name); } + public OutPort getOutPort(String name) { return (OutPort)ports.get(name); } + + public void build(Context ctx) { for(Port p : ports.values()) p.build(ctx); } + public void reset(Context ctx, int phase, Destination ackDestination) { + for(Port p : ports.values()) p.reset(ctx, phase, ackDestination); + } + + public abstract class Port { + public final String name; + public Port(String name) { + this.name = name; + if (Node.this.ports.get(name)!=null) throw new RuntimeException(); + Node.this.ports.put(name,this); + } + public abstract void build(Context ctx); + public abstract void reset(Context ctx, int phase, Destination ackDestination); + } + + public abstract class InPort extends Port { + OutPort peer; + public InPort(String name) { super(name); } + public void connect(OutPort peer) { + this.setPeer(peer); + peer.setPeer(this); + } + public void setPeer(OutPort peer) { + if (this.peer!=null) throw new RuntimeException("cannot call setPeer() twice"); + this.peer = peer; + } + + /** this port's peer (an OutPort) invokes this to have "recvToken" or equivalent inserted */ + public abstract void recvToken(LoopFactory loopfactory_at_output_dock); + /** this port's peer (an OutPort) invokes this to have "sendWord" or equivalent inserted */ + public abstract void sendWord(LoopFactory loopfactory_at_output_dock); + + public int getTokensToAbsorb() { return 0; } + } + + public abstract class OutPort extends Port { + InPort peer; + public OutPort(String name) { super(name); } + public void connect(InPort peer) { + this.setPeer(peer); + peer.setPeer(this); + } + public void setPeer(InPort peer) { + if (this.peer!=null) throw new RuntimeException("cannot call setPeer() twice"); + this.peer = peer; + } + + /** this port's peer (an InPort) invokes this to have "sendToken" or equivalent inserted */ + public abstract void sendToken(LoopFactory loopfactory_at_input_dock); + /** this port's peer (an InPort) invokes this to have "recvWord" or equivalent inserted */ + public abstract void recvWord(LoopFactory loopfactory_at_input_dock); + } + + public final class DockInPort extends InPort { + final Dock dock; + int count; + BitVector[] pattern; + public DockInPort(String name, Dock dock) { this(name, dock, 0); } + public DockInPort(String name, Dock dock, int count) { this(name, dock, count, new BitVector[] { null }); } + public DockInPort(String name, Dock dock, int count, BitVector[] pattern) { + super(name); + this.dock = dock; + this.count = count; + this.pattern = pattern; + } + public void recvToken(LoopFactory lf) { lf.recvToken(); } + public void sendWord(LoopFactory lf) { lf.sendWord(dock.getDataDestination()); } + public void build(Context ctx) { build(ctx, new LoopFactory(ctx, dock, 1)); } + // number-in-flight is considered a property of the input dock in a pair + public int getInflight() { return 4; } + //public int getInflight() { return 1; } + public int getTokensToAbsorb() { return getInflight(); } + private boolean peerUsed() { + if (peer==null) return false; + for(int i=0; i= pip_pattern.length) j = 0; + } + pip.pattern = new BitVector[i]; + System.arraycopy(temp, 0, pip.pattern, 0, i); + pip.count = 1; + } + }; + public OnceNode(DataFlowGraph dfg, long l) { this(dfg, new BitVector(dfg.fleet.getWordWidth()).set(l)); } + public OnceNode(DataFlowGraph dfg, final BitVector bv) { super(dfg); this.bv = bv; } +} diff --git a/src/edu/berkeley/fleet/dataflow/PunctuatorNode.java b/src/edu/berkeley/fleet/dataflow/PunctuatorNode.java new file mode 100644 index 0000000..7fe4577 --- /dev/null +++ b/src/edu/berkeley/fleet/dataflow/PunctuatorNode.java @@ -0,0 +1,19 @@ +package edu.berkeley.fleet.dataflow; +import edu.berkeley.fleet.loops.*; +import edu.berkeley.fleet.api.*; + +public class PunctuatorNode extends Node { + private final long punc; + private final Ship ship = dfg.pool.allocateShip("Counter"); + public final OutPort out = new DockOutPort("out", ship.getDock("out")); + public final InPort val = new DockInPort("in1", ship.getDock("in1")); + public final InPort op = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] { + ship.getDock("inOp").getConstant("PASS_C2_V1"), + ship.getDock("inOp").getConstant("PASS_C2_V2") } ); + public final InPort count; + public PunctuatorNode(DataFlowGraph dfg, long punc) { + super(dfg); + this.punc = punc; + this.count = new DockInPort("in2", ship.getDock("in2"), 0, new BitVector[] { null, dfg.bv(1), dfg.bv(punc) }); + } +} diff --git a/src/edu/berkeley/fleet/dataflow/RepeatNode.java b/src/edu/berkeley/fleet/dataflow/RepeatNode.java new file mode 100644 index 0000000..7e9ae34 --- /dev/null +++ b/src/edu/berkeley/fleet/dataflow/RepeatNode.java @@ -0,0 +1,13 @@ +package edu.berkeley.fleet.dataflow; +import edu.berkeley.fleet.loops.*; +import edu.berkeley.fleet.api.*; + +public class RepeatNode extends Node { + public final Ship ship = dfg.pool.allocateShip("Counter"); + public final InPort count = new DockInPort("in1", ship.getDock("in1")); + public final InPort val = new DockInPort("in2", ship.getDock("in2")); + public final InPort inOP = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] { + ship.getDock("inOp").getConstant("REPEAT_C1_V2") }); + public final OutPort out = new DockOutPort("out", ship.getDock("out")); + public RepeatNode(DataFlowGraph dfg) { super(dfg); } +} diff --git a/src/edu/berkeley/fleet/dataflow/SortedMergeNode.java b/src/edu/berkeley/fleet/dataflow/SortedMergeNode.java new file mode 100644 index 0000000..4a6bea7 --- /dev/null +++ b/src/edu/berkeley/fleet/dataflow/SortedMergeNode.java @@ -0,0 +1,13 @@ +package edu.berkeley.fleet.dataflow; +import edu.berkeley.fleet.loops.*; +import edu.berkeley.fleet.api.*; + +public class SortedMergeNode extends Node { + public final Ship ship = dfg.pool.allocateShip("Alu"); + public final InPort in1 = new DockInPort("in1", ship.getDock("in1")); + public final InPort in2 = new DockInPort("in2", ship.getDock("in2")); + public final InPort inOp = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] { + ship.getDock("inOp").getConstant("MAXMERGE") }); + public final OutPort out = new DockOutPort("out", ship.getDock("out")); + public SortedMergeNode(DataFlowGraph dfg) { super(dfg); } +} diff --git a/src/edu/berkeley/fleet/dataflow/UnPunctuatorNode.java b/src/edu/berkeley/fleet/dataflow/UnPunctuatorNode.java new file mode 100644 index 0000000..9607730 --- /dev/null +++ b/src/edu/berkeley/fleet/dataflow/UnPunctuatorNode.java @@ -0,0 +1,14 @@ +package edu.berkeley.fleet.dataflow; +import edu.berkeley.fleet.loops.*; +import edu.berkeley.fleet.api.*; + +public class UnPunctuatorNode extends Node { + private final Ship ship = dfg.pool.allocateShip("Counter"); + public final OutPort out = new DockOutPort("out", ship.getDock("out")); + public final InPort val = new DockInPort("in1", ship.getDock("in1")); + public final InPort count = new DockInPort("in2", ship.getDock("in2"), 0, new BitVector[] { null, dfg.bv(1) }); + public final InPort op = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] { + ship.getDock("inOp").getConstant("PASS_C2_V1"), + ship.getDock("inOp").getConstant("DROP_C2_V1") } ); + public UnPunctuatorNode(DataFlowGraph dfg) { super(dfg); } +} -- 1.7.10.4