public final Fleet fleet;
public final ShipPool pool;
+ private HashSet<Node> nodes = new HashSet<Node>();
+
+ public static int reset_count = 0;
+ public static HashSet<Dock> torpedoes = new HashSet<Dock>();
public DataFlowGraph(Fleet fleet) {
this(fleet, new ShipPool(fleet));
this.pool = pool;
}
- public void addNode(Node node) {
- this.nodes.add(node);
- }
-
- public static int reset_count = 0;
- public static HashSet<Dock> torpedoes = new HashSet<Dock>();
-
- private HashSet<Node> nodes = new HashSet<Node>();
+ public void addNode(Node node) { this.nodes.add(node); }
public void build(Context ctx) {
for(Node mod : nodes)
for(Node mod : nodes)
mod.reset(ctx, phase, ackDestination);
}
-
- BitVector bv(long l) { return new BitVector(fleet.getWordWidth()).set(l); }
- BitVector[] bv(long[] l) {
- BitVector[] ret = new BitVector[l.length];
- for(int i=0; i<ret.length; i++) ret[i] = bv(l[i]);
- return ret;
- }
-
- public static void main(String[] s) throws Exception {
- Fleet fleet = new Fpga();
- //Fleet fleet = new Interpreter(false);
-
- Random random = new Random(System.currentTimeMillis());
- long[] vals = new long[256];
- for(int i=0; i<vals.length; i++) {
- vals[i] = Math.abs(random.nextInt());
- }
-
- Ship mem1 = fleet.getShip("Memory", 0);
- Ship mem2 = fleet.getShip("Memory", 1);
- //Ship mem2 = fleet.getShip("DDR2", 0);
-
- FleetProcess fp;
- int stride = 1;
- fp = null;
-
- fp = fleet.run(new Instruction[0]);
- MemoryUtils.writeMem(fp, mem1, 0, vals);
- int vals_length = vals.length;
-
- // Disable readback/writeback inside the loop
- vals = null;
-
- while(stride < vals_length) {
-
- // reset the FleetProcess
- //fp.terminate(); fp = null;
-
- System.out.println("stride " + stride);
-
- // if we reset the FleetProcess, restart it
- if (fp==null) fp = fleet.run(new Instruction[0]);
-
- // do the mergeSort
- vals = MergeSort.mergeSort(fp, fleet, vals, vals_length, stride, mem1, mem2);
-
- // verify the cleanup
- //CleanupUtils.verifyClean(fp);
-
- Ship mem = mem1; mem1=mem2; mem2=mem;
-
- stride = stride * 2;
- System.out.println();
- }
-
- BitVector[] bvs = new BitVector[vals_length];
- MemoryUtils.readMem(fp, mem1, 0, bvs);
- System.out.println("results:");
- for(int i=0; i<vals_length; i++)
- System.out.println(bvs[i].toLong());
- }
-
-
-
- private BitVector[] longsToBitVectors(long[] initialValues) {
- BitVector[] bv = new BitVector[initialValues.length];
- for(int i=0; i<initialValues.length; i++)
- bv[i] = new BitVector(fleet.getWordWidth()).set(initialValues[i]);
- return bv;
- }
}
package edu.berkeley.fleet.dataflow;
import edu.berkeley.fleet.loops.*;
import edu.berkeley.fleet.api.*;
+import edu.berkeley.fleet.fpga.*;
import java.util.*;
public class MergeSort {
}
return ret;
}
-}
\ No newline at end of file
+
+ /** demo */
+ public static void main(String[] s) throws Exception {
+ Fleet fleet = new Fpga();
+ //Fleet fleet = new Interpreter(false);
+
+ Random random = new Random(System.currentTimeMillis());
+ long[] vals = new long[256];
+ for(int i=0; i<vals.length; i++) {
+ vals[i] = Math.abs(random.nextInt());
+ }
+
+ Ship mem1 = fleet.getShip("Memory", 0);
+ Ship mem2 = fleet.getShip("Memory", 1);
+ //Ship mem2 = fleet.getShip("DDR2", 0);
+
+ FleetProcess fp;
+ int stride = 1;
+ fp = null;
+
+ fp = fleet.run(new Instruction[0]);
+ MemoryUtils.writeMem(fp, mem1, 0, vals);
+ int vals_length = vals.length;
+
+ // Disable readback/writeback inside the loop
+ vals = null;
+
+ while(stride < vals_length) {
+
+ // reset the FleetProcess
+ //fp.terminate(); fp = null;
+
+ System.out.println("stride " + stride);
+
+ // if we reset the FleetProcess, restart it
+ if (fp==null) fp = fleet.run(new Instruction[0]);
+
+ // do the mergeSort
+ vals = MergeSort.mergeSort(fp, fleet, vals, vals_length, stride, mem1, mem2);
+
+ // verify the cleanup
+ //CleanupUtils.verifyClean(fp);
+
+ Ship mem = mem1; mem1=mem2; mem2=mem;
+
+ stride = stride * 2;
+ System.out.println();
+ }
+
+ BitVector[] bvs = new BitVector[vals_length];
+ MemoryUtils.readMem(fp, mem1, 0, bvs);
+ System.out.println("results:");
+ for(int i=0; i<vals_length; i++)
+ System.out.println(bvs[i].toLong());
+ }
+
+}
}
}
+ BitVector bv(long l) { return new BitVector(dfg.fleet.getWordWidth()).set(l); }
+ BitVector[] bv(long[] l) {
+ BitVector[] ret = new BitVector[l.length];
+ for(int i=0; i<ret.length; i++) ret[i] = bv(l[i]);
+ return ret;
+ }
}
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) });
+ this.count = new DockInPort("in2", ship.getDock("in2"), 0, new BitVector[] { null, bv(1), bv(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 count = new DockInPort("in2", ship.getDock("in2"), 0, new BitVector[] { null, dfg.bv(1) });
+ public final InPort count = new DockInPort("in2", ship.getDock("in2"), 0, new BitVector[] { null, 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") } );