From b1a1b32adf7f7a1d9a3fe5ea30a3b67741e8dc47 Mon Sep 17 00:00:00 2001 From: megacz Date: Fri, 13 Mar 2009 11:09:03 -0700 Subject: [PATCH] move Gadgets to MemoryUtils, discard a ton of obsolete junk --- src/edu/berkeley/fleet/ir/Process.java | 18 +-- src/edu/berkeley/fleet/loops/Context.java | 8 ++ src/edu/berkeley/fleet/loops/LoopFactory.java | 27 ++--- .../{ir/Gadgets.java => loops/MemoryUtils.java} | 128 +------------------- 4 files changed, 29 insertions(+), 152 deletions(-) rename src/edu/berkeley/fleet/{ir/Gadgets.java => loops/MemoryUtils.java} (50%) diff --git a/src/edu/berkeley/fleet/ir/Process.java b/src/edu/berkeley/fleet/ir/Process.java index 6b35112..47a6604 100644 --- a/src/edu/berkeley/fleet/ir/Process.java +++ b/src/edu/berkeley/fleet/ir/Process.java @@ -521,7 +521,7 @@ public class Process { fp = null; fp = fleet.run(new Instruction[0]); - Gadgets.writeMem(fp, mem1, 0, bv(vals)); + MemoryUtils.writeMem(fp, mem1, 0, bv(vals)); int vals_length = vals.length; // Disable readback/writeback inside the loop @@ -550,7 +550,7 @@ public class Process { } BitVector[] bvs = new BitVector[vals_length]; - Gadgets.readMem(fp, mem1, 0, bvs); + MemoryUtils.readMem(fp, mem1, 0, bvs); System.out.println("results:"); for(int i=0; i ai; + emit(ai = new ArrayList()); + for(Instruction ins : ai) { + fp.sendInstruction(ins); + } + } + } diff --git a/src/edu/berkeley/fleet/loops/LoopFactory.java b/src/edu/berkeley/fleet/loops/LoopFactory.java index 4873c79..d7b6648 100644 --- a/src/edu/berkeley/fleet/loops/LoopFactory.java +++ b/src/edu/berkeley/fleet/loops/LoopFactory.java @@ -221,7 +221,7 @@ public class LoopFactory { /** sets the data latch to a literal value */ public void literal(BitVector literal) { // FIXME: code duplication here - // FIXME: be more intelligent here to avoid shifts if possible? + // FEATURE: be more intelligent here to avoid shifts if possible? int counter = 0; while(counter < dock.getShip().getFleet().getWordWidth()) counter += ctx.fleet.getShiftWidth(); while(counter > 0) { @@ -263,7 +263,6 @@ public class LoopFactory { newFlagB)); } - // FIXME: what if we're using an ILC-loop? /** abort the loop immediately (if predicate is met) and invoke the successor loop */ public void abort() { flush_pending(); @@ -297,11 +296,12 @@ public class LoopFactory { * */ public void emit(ArrayList ic) { + emit(ic, dock.getInstructionFifoSize()); + } + private void emit(ArrayList ic, int capacity) { flush_pending(); optimize(); - // FIXME: if this loop is a count==1 loop, we can emit the successor loop along with it... - // the number of instructions after and including the first blocking instruction int numInstructionsNotIncludingNonblockingPrefix = 0; int loopSize = 0; @@ -323,8 +323,7 @@ public class LoopFactory { } if (count==1) { - if (/*!instructionFifoSizeCheckDisabled &&*/ - numInstructionsNotIncludingNonblockingPrefix > dock.getInstructionFifoSize()) + if (numInstructionsNotIncludingNonblockingPrefix > capacity) throw new RuntimeException("instruction sequence is too long for instruction fifo at " + dock); } else { if (count != 0) { @@ -334,13 +333,10 @@ public class LoopFactory { loopSize++; } } - if (count!=1) { + if (count!=1) ic.add(new Instruction.Abort(dock, Predicate.FlagD)); - } - if (ctx.autoflush && !"Debug".equals(dock.getShip().getType()) && next==null) { - if (dock.isInputDock()) - ic.add(new Instruction.Flush(dock, true, Predicate.FlagD)); - } + if (ctx.autoflush && next==null && dock.isInputDock()) + ic.add(new Instruction.Flush(dock, true, Predicate.FlagD)); // FIXME: need to somehow deal with count!=0 loops that are // torpedoable; they need to wait for a torpedo to arrive @@ -348,16 +344,13 @@ public class LoopFactory { if (count!=1) { ic.add(new Instruction.Tail(dock)); - if (/*!instructionFifoSizeCheckDisabled &&*/ - loopSize > dock.getInstructionFifoSize()) + if (loopSize > capacity) throw new RuntimeException("instruction loop is too long for instruction fifo"); } if (next != null) { if (count != 1) throw new RuntimeException("no support for successor loops when count!=1 yet"); - // FIXME: must include check based on reduced FIFO capacity - // FIXME: review this - next.emit(ic); + next.emit(ic, capacity - loopSize); } } diff --git a/src/edu/berkeley/fleet/ir/Gadgets.java b/src/edu/berkeley/fleet/loops/MemoryUtils.java similarity index 50% rename from src/edu/berkeley/fleet/ir/Gadgets.java rename to src/edu/berkeley/fleet/loops/MemoryUtils.java index 8e0c19c..05d14a9 100644 --- a/src/edu/berkeley/fleet/ir/Gadgets.java +++ b/src/edu/berkeley/fleet/loops/MemoryUtils.java @@ -1,4 +1,4 @@ -package edu.berkeley.fleet.ir; +package edu.berkeley.fleet.loops; import edu.berkeley.fleet.loops.*; import java.util.concurrent.Semaphore; import java.util.*; @@ -9,27 +9,11 @@ import edu.berkeley.fleet.api.*; import edu.berkeley.fleet.api.Instruction.*; import edu.berkeley.fleet.api.Instruction.Set; import edu.berkeley.fleet.api.Instruction.Set.*; -import static edu.berkeley.fleet.util.BitManipulations.*; -import edu.berkeley.fleet.api.Instruction.Set.FlagFunction; -import edu.berkeley.fleet.api.Instruction.Set; import edu.berkeley.fleet.api.Instruction.Set.SetDest; import edu.berkeley.fleet.api.Instruction.Set.FlagFunction; import static edu.berkeley.fleet.api.Predicate.*; -/* - - Change Alu behavior to "drain one" - - DROP1, DROP2 - - secondary DDR chip - - facility for launching and Concluding a context - - implement the merge operation and test it - - test case for DRAM ship - - hideously ugly hacks in Verilog.java! - - dispatch ALWAYS needs to go via memory first, unless transmissions to - debugIn are flow-controlled properly - - current write-to-mem transformation screws up -- it can clog - */ - -public class Gadgets { +public class MemoryUtils { public static void readMem(FleetProcess fp, Ship memory, long offset, BitVector[] vals) throws RuntimeException { doMem(true, fp, memory, offset, vals); @@ -120,114 +104,6 @@ public class Gadgets { System.out.println(); } - /** returns the output Dock at which the merged values may be collected */ - public static Dock mergeSort(FleetProcess fp, - Context ctx, - Ship sourceMem, - Ship destMem, - long read_start, - long write_start, - int stride_length, /* per arity */ - int num_strides, - int arity - ) - throws RuntimeException { - - if (arity != 2) throw new RuntimeException(); - if (num_strides != 1) throw new RuntimeException(); - LoopFactory lf; - - Dock mem_inAddrData = sourceMem.getDock("inAddrData"); - Dock mem_out = sourceMem.getDock("out"); - - Ship merger = ctx.allocateShip("Alu"); - Dock[] merger_inputs = new Dock[] { merger.getDock("in1"), merger.getDock("in2") }; - Dock merger_inOp = merger.getDock("inOp"); - - // Address Generators (arity-many) ///////////////////////////////////////////////////////////////////// - - Ship[] address_generators = new Ship[arity]; - for(int i=0; i ai; - ctx.emit(ai = new ArrayList()); - for(Instruction ins : ai) { - fp.sendInstruction(ins); - } - } - public static void main(String[] s) throws Exception { Random random = new Random(System.currentTimeMillis()); Fleet fleet = new Fpga(); -- 1.7.10.4