1 package edu.berkeley.fleet.ir;
2 import edu.berkeley.fleet.loops.*;
3 import java.util.concurrent.Semaphore;
6 import edu.berkeley.fleet.two.*;
7 import edu.berkeley.fleet.api.*;
8 import edu.berkeley.fleet.fpga.*;
9 import edu.berkeley.fleet.api.Instruction.*;
10 import edu.berkeley.fleet.api.Instruction.Set;
11 import edu.berkeley.fleet.api.Instruction.Set.*;
12 import static edu.berkeley.fleet.api.Predicate.*;
13 import static edu.berkeley.fleet.util.BitManipulations.*;
15 // does peer.recvWord() have to honor the currently-set predicate?
17 // public class ReplaceModule extends Module { }
18 // public class CountMergeModule extends Module { }
19 // public class SortMergeModule extends Module { }
20 // public class FanOutModule extends Module { }
21 // public class MemoryModule extends Module { }
22 // public class DoneModule extends Module { }
24 public class Process {
27 public static int reset_count = 0;
28 public static HashSet<Dock> torpedoes = new HashSet<Dock>();
30 public final Fleet fleet;
31 public final ShipPool pool;
33 public Process(Fleet fleet) {
35 this.pool = new ShipPool(fleet);
38 private HashSet<Module> modules = new HashSet<Module>();
40 public void build(Context ctx) {
41 for(Module mod : modules)
44 public void reset(Context ctx, int phase, Destination ackDestination) {
47 for(Module mod : modules)
48 mod.reset(ctx, phase, ackDestination);
53 void doReset(Context ctx, int phase, Dock dock, Port peer, Destination ackDestination, boolean peerUsed) {
54 if (dock.getShip().getType().equals("Debug")) return;
58 // Phase 0: torpedo every output dock, put it in
59 // collecting mode. Cannot combine with phase 1,
60 // because until output docks are in vacuum mode we
61 // cannot be sure that the tokens to the input docks
62 // will eventually succeed. This may cause the
63 // instructions sent after the tokens to back up into
66 if (!dock.isInputDock()) {
68 LoopFactory lf = new LoopFactory(ctx, dock, 1);
69 lf.sendToken(ackDestination);
71 lf.abortLoopIfTorpedoPresent();
78 // Phase 1: torpedo every input dock, put it in loopback mode
80 if (dock.isInputDock()) {
82 LoopFactory lf = new LoopFactory(ctx, dock, 1);
83 lf.sendToken(ackDestination);
85 // FIXME: this won't work right for ports that
86 // get "shared" by two senders (for example,
89 if (peerUsed && peer!=null) {
91 lf.abortLoopIfTorpedoPresent();
92 ((OutPort)peer).recvWord(lf);
93 ((OutPort)peer).sendToken(lf);
100 // Phase 2: torpedo every output dock, have it absorb tokens
102 if (!dock.isInputDock()) {
104 LoopFactory lf = new LoopFactory(ctx, dock, 1);
106 for(int i=0; i<((InPort)peer).getTokensToAbsorb(); i++)
108 lf.sendToken(ackDestination);
114 // Phase 3: torpedo every input dock, and we're done
116 if (dock.isInputDock()) {
117 if (peerUsed && peer!=null) {
120 LoopFactory lf = new LoopFactory(ctx, dock, 1);
121 lf.sendToken(ackDestination);
132 Process.this.modules.add(this);
135 private HashMap<String,Port> ports = new HashMap<String,Port>();
137 public InPort getInPort(String name) { return (InPort)ports.get(name); }
138 public OutPort getOutPort(String name) { return (OutPort)ports.get(name); }
140 public void build(Context ctx) { for(Port p : ports.values()) p.build(ctx); }
141 public void reset(Context ctx, int phase, Destination ackDestination) {
142 for(Port p : ports.values()) p.reset(ctx, phase, ackDestination);
145 public abstract class Port {
146 public final String name;
147 public Port(String name) {
149 if (Module.this.ports.get(name)!=null) throw new RuntimeException();
150 Module.this.ports.put(name,this);
152 public abstract void build(Context ctx);
153 public abstract void reset(Context ctx, int phase, Destination ackDestination);
156 public abstract class InPort extends Port {
158 public InPort(String name) { super(name); }
159 public void connect(OutPort peer) {
163 public void setPeer(OutPort peer) {
164 if (this.peer!=null) throw new RuntimeException("cannot call setPeer() twice");
168 /** this port's peer (an OutPort) invokes this to have "recvToken" or equivalent inserted */
169 public abstract void recvToken(LoopFactory loopfactory_at_output_dock);
170 /** this port's peer (an OutPort) invokes this to have "sendWord" or equivalent inserted */
171 public abstract void sendWord(LoopFactory loopfactory_at_output_dock);
173 public int getTokensToAbsorb() { return 0; }
176 public abstract class OutPort extends Port {
178 public OutPort(String name) { super(name); }
179 public void connect(InPort peer) {
183 public void setPeer(InPort peer) {
184 if (this.peer!=null) throw new RuntimeException("cannot call setPeer() twice");
188 /** this port's peer (an InPort) invokes this to have "sendToken" or equivalent inserted */
189 public abstract void sendToken(LoopFactory loopfactory_at_input_dock);
190 /** this port's peer (an InPort) invokes this to have "recvWord" or equivalent inserted */
191 public abstract void recvWord(LoopFactory loopfactory_at_input_dock);
194 public final class DockInPort extends InPort {
198 public DockInPort(String name, Dock dock) { this(name, dock, 0); }
199 public DockInPort(String name, Dock dock, int count) { this(name, dock, count, new BitVector[] { null }); }
200 public DockInPort(String name, Dock dock, int count, BitVector[] pattern) {
204 this.pattern = pattern;
206 public void recvToken(LoopFactory lf) { lf.recvToken(); }
207 public void sendWord(LoopFactory lf) { lf.sendWord(dock.getDataDestination()); }
208 public void build(Context ctx) { build(ctx, new LoopFactory(ctx, dock, 1)); }
209 // number-in-flight is considered a property of the input dock in a pair
210 public int getInflight() { return 4; }
211 //public int getInflight() { return 1; }
212 public int getTokensToAbsorb() { return getInflight(); }
213 private boolean peerUsed() {
214 if (peer==null) return false;
215 for(int i=0; i<pattern.length; i++) if (pattern[i]==null) return true;
218 public void reset(Context ctx, int phase, Destination ackDestination) {
219 doReset(ctx, phase, dock, peer, ackDestination, peerUsed());
221 protected void build(Context ctx, LoopFactory lf) {
222 int inflight = (count != 0 && count < getInflight()) ? count : getInflight();
225 for(int i=0; i<inflight; i++) peer.sendToken(lf);
227 lf = lf.makeNext(count, true);
228 for(int i=0; i<pattern.length; i++) {
229 if (pattern[i]==null) {
231 lf.abortLoopIfTorpedoPresent();
236 lf.interruptibleNop();
239 lf.literal(pattern[i]);
240 lf.abortLoopIfTorpedoPresent();
246 // "torpedoable nop" to keep the dock in a receptive state
247 lf.abortLoopIfTorpedoPresent();
251 public BitVector getConstant(String constantName) {
252 return dock.getConstant(constantName);
256 public /*final*/ class DockOutPort extends OutPort {
257 public final Dock dock;
258 public final int count;
259 public DockOutPort(String name, Dock dock) { this(name, dock, 0); }
260 public DockOutPort(String name, Dock dock, int count) { super(name); this.dock = dock; this.count = count; }
261 public void sendToken(LoopFactory lf) { lf.sendToken(dock.getDataDestination()); }
262 public void recvWord(LoopFactory lf) { lf.recvWord(); }
263 public void build(Context ctx) { build(ctx, new LoopFactory(ctx, dock, 1)); }
264 protected void build(Context ctx, LoopFactory lf) {
265 if (peer==null) return;
266 lf = lf.makeNext(count);
267 lf.abortLoopIfTorpedoPresent();
272 public void reset(Context ctx, int phase, Destination ackDestination) {
273 doReset(ctx, phase, dock, peer, ackDestination, true);
278 private static BitVector bv(long l) { return new BitVector(/*FIXME fleet.getWordWidth()*/37).set(l); }
279 private static BitVector[] bv(long[] l) {
280 BitVector[] ret = new BitVector[l.length];
281 for(int i=0; i<ret.length; i++) ret[i] = bv(l[i]);
286 * Deliver the constant at out forever. Flow control in<->out is
287 * maintained, but out is not flow-controlled, so be sure
288 * that every datum sent there is consumed synchronously wiht
289 * data items sent to out.
291 public class ForeverModule extends Module {
292 private BitVector bv;
293 public final OutPort out = new OutPort("out") {
294 public void sendToken(LoopFactory lf) { }
295 public void recvWord(LoopFactory lf) { }
296 public void build(Context ctx) { }
297 public void reset(Context ctx, int phase, Destination ackDestination) { }
298 public void setPeer(InPort peer) {
300 DockInPort pip = ((DockInPort)peer);
301 for(int i=0; i<pip.pattern.length; i++) {
302 if (pip.pattern[i]==null)
307 public ForeverModule(long l) { this(new BitVector(fleet.getWordWidth()).set(l)); }
308 public ForeverModule(final BitVector bv) { this.bv = bv; }
311 public class OnceModule extends Module {
312 private BitVector bv;
313 public final OutPort out = new OutPort("out") {
314 public void sendToken(LoopFactory lf) { }
315 public void recvWord(LoopFactory lf) { }
316 public void build(Context ctx) { }
317 public void reset(Context ctx, int phase, Destination ackDestination) { }
318 public void setPeer(InPort peer) {
320 DockInPort pip = ((DockInPort)peer);
321 BitVector[] pip_pattern = pip.pattern;
322 BitVector[] temp = new BitVector[pip_pattern.length * 2];
325 boolean done = false;
326 // FIXME: if peer.count is already 1, this gets simpler and different
327 for(i=0; i<temp.length; i++) {
328 if (pip_pattern[j] != null) {
329 temp[i] = pip_pattern[j];
336 if (j >= pip_pattern.length) j = 0;
338 pip.pattern = new BitVector[i];
339 System.arraycopy(temp, 0, pip.pattern, 0, i);
343 public OnceModule(long l) { this(new BitVector(fleet.getWordWidth()).set(l)); }
344 public OnceModule(final BitVector bv) { this.bv = bv; }
347 public class DebugModule extends Module {
348 public final Ship ship = pool.allocateShip("Debug");
349 public final InPort in = new DockInPort("in", ship.getDock("in"));
350 // NOTE: shutdown needs to treat this specially
351 public DebugModule() { }
354 public class UnPunctuatorModule extends Module {
355 private final Ship ship = pool.allocateShip("Counter");
356 public final OutPort out = new DockOutPort("out", ship.getDock("out"));
357 public final InPort val = new DockInPort("in1", ship.getDock("in1"));
358 public final InPort count = new DockInPort("in2", ship.getDock("in2"), 0, new BitVector[] { null, bv(1) });
359 public final InPort op = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] {
360 ship.getDock("inOp").getConstant("PASS_C2_V1"),
361 ship.getDock("inOp").getConstant("DROP_C2_V1") } );
362 public UnPunctuatorModule() { }
365 public class PunctuatorModule extends Module {
366 private final long punc;
367 private final Ship ship = pool.allocateShip("Counter");
368 public final OutPort out = new DockOutPort("out", ship.getDock("out"));
369 public final InPort val = new DockInPort("in1", ship.getDock("in1"));
370 public final InPort op = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] {
371 ship.getDock("inOp").getConstant("PASS_C2_V1"),
372 ship.getDock("inOp").getConstant("PASS_C2_V2") } );
373 public final InPort count;
374 public PunctuatorModule(long punc) {
376 this.count = new DockInPort("in2", ship.getDock("in2"), 0, new BitVector[] { null, bv(1), bv(punc) });
380 public class AluModule extends Module {
381 public final Ship ship = pool.allocateShip("Alu");
382 public final InPort in1 = new DockInPort("in1", ship.getDock("in1"));
383 public final InPort in2 = new DockInPort("in2", ship.getDock("in2"));
384 public final InPort inOp = new DockInPort("inOp", ship.getDock("inOp"));
385 public final OutPort out = new DockOutPort("out", ship.getDock("out"));
386 public AluModule() { }
389 public class DownCounterModule extends Module {
390 public final Ship ship = pool.allocateShip("Counter");
391 public final InPort start = new DockInPort("in1", ship.getDock("in1"));
392 public final InPort incr = new DockInPort("in2", ship.getDock("in2"));
393 public final InPort inOp = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] {
394 ship.getDock("inOp").getConstant("COUNT") });
395 public final OutPort out = new DockOutPort("out", ship.getDock("out"));
396 public DownCounterModule() { }
399 public class RepeatModule extends Module {
400 public final Ship ship = pool.allocateShip("Counter");
401 public final InPort count = new DockInPort("in1", ship.getDock("in1"));
402 public final InPort val = new DockInPort("in2", ship.getDock("in2"));
403 public final InPort inOP = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] {
404 ship.getDock("inOp").getConstant("REPEAT_C1_V2") });
405 public final OutPort out = new DockOutPort("out", ship.getDock("out"));
406 public RepeatModule() { }
409 public class SortedMergeModule extends Module {
410 public final Ship ship = pool.allocateShip("Alu");
411 public final InPort in1 = new DockInPort("in1", ship.getDock("in1"));
412 public final InPort in2 = new DockInPort("in2", ship.getDock("in2"));
413 public final InPort inOp = new DockInPort("inOp", ship.getDock("inOp"), 0, new BitVector[] {
414 ship.getDock("inOp").getConstant("MAXMERGE") });
415 public final OutPort out = new DockOutPort("out", ship.getDock("out"));
416 public SortedMergeModule() { }
419 public class MemoryModule extends Module {
420 public final Ship ship;
421 public final InPort inCBD;
422 public final InPort inAddrRead1;
423 public final InPort inAddrRead2;
424 public final InPort inAddrWrite;
425 public final InPort inDataWrite;
426 public final OutPort outRead1;
427 public final OutPort outRead2;
428 public final OutPort outWrite;
429 public MemoryModule(Ship memoryShip) {
430 this.ship = memoryShip;
431 this.inCBD = ship.getType().equals("Memory") ? new DockInPort("inCBD", ship.getDock("inCBD")) : null;
432 this.inAddrWrite = new DockInPort("inAddrWrite", ship.getDock("inAddrWrite"));
433 this.inDataWrite = new DockInPort("inDataWrite", ship.getDock("inDataWrite"));
434 this.inAddrRead1 = new InPort("inAddrRead1") {
435 public void recvToken(LoopFactory lf) { lf.recvToken(); }
436 public void sendWord(LoopFactory lf) { lf.sendWord(ship.getDock("inAddrRead").getDataDestination(), new BitVector(1).set(0)); }
437 public void build(Context ctx) { }
438 public int getTokensToAbsorb() { return outRead1.peer.getTokensToAbsorb(); }
439 public void reset(Context ctx, int phase, Destination ackDestination) {
440 doReset(ctx, phase, ship.getDock("inAddrRead"), null, ackDestination, false);
443 this.inAddrRead2 = new InPort("inAddrRead2") {
444 public void recvToken(LoopFactory lf) { lf.recvToken(); }
445 public void sendWord(LoopFactory lf) { lf.sendWord(ship.getDock("inAddrRead").getDataDestination(), new BitVector(1).set(1)); }
446 public void build(Context ctx) { }
447 public int getTokensToAbsorb() { return outRead2.peer.getTokensToAbsorb(); }
448 public void reset(Context ctx, int phase, Destination ackDestination) { }
450 this.outRead1 = new OutPort("outRead1") {
451 public void sendToken(LoopFactory lf) { inAddrRead1.peer.sendToken(lf); }
452 public void recvWord(LoopFactory lf) { lf.recvWord(); }
453 public void build(Context ctx) { }
454 public void reset(Context ctx, int phase, Destination ackDestination) { }
456 this.outRead2 = new OutPort("outRead2") {
457 public void sendToken(LoopFactory lf) { inAddrRead2.peer.sendToken(lf); }
458 public void recvWord(LoopFactory lf) { lf.recvWord(); }
459 public void build(Context ctx) { }
460 public void reset(Context ctx, int phase, Destination ackDestination) { }
462 this.outWrite = new DockOutPort("out", ship.getDock("out")) {
463 protected void build(Context ctx, LoopFactory lf) {
465 lf.abortLoopIfTorpedoPresent();
468 lf.setFlags(FlagFunction.ZERO, FlagFunction.ZERO.add(FlagC));
469 if (this.peer != null) {
470 lf.setPredicate(Predicate.FlagB);
472 lf.abortLoopIfTorpedoPresent();
473 this.peer.recvToken(lf);
474 this.peer.sendWord(lf);
477 lf.setPredicate(Predicate.NotFlagB);
478 lf.abortLoopIfTorpedoPresent();
480 lf.setFlags(FlagFunction.ZERO.add(NotFlagC).add(FlagB), FlagFunction.ZERO.add(FlagC).add(FlagB));
481 if (outRead1.peer != null) {
482 lf.setPredicate(Predicate.NotFlagB);
483 outRead1.peer.sendWord(lf);
485 if (outRead2.peer != null) {
486 lf.setPredicate(Predicate.NotFlagA);
487 outRead2.peer.sendWord(lf);
489 lf.setPredicate(null);
493 public void build(Context ctx) {
497 lf = new LoopFactory(ctx, ship.getDock("inAddrRead"), 0);
498 lf.abortLoopIfTorpedoPresent();
500 lf.setFlags(FlagFunction.ZERO.add(FlagC), FlagFunction.ZERO);
501 lf.setPredicate(Predicate.NotFlagA);
502 lf.sendToken(ship.getDock("out").getDataDestination(), new BitVector(1).set(0));
503 lf.setPredicate(Predicate.FlagA);
504 lf.sendToken(ship.getDock("out").getDataDestination(), new BitVector(1).set(1));
505 lf.setPredicate(null);
510 public static void main(String[] s) throws Exception {
511 Fleet fleet = new Fpga();
512 //Fleet fleet = new Interpreter(false);
514 Random random = new Random(System.currentTimeMillis());
515 long[] vals = new long[256];
516 for(int i=0; i<vals.length; i++) {
517 vals[i] = Math.abs(random.nextInt());
520 Ship mem1 = fleet.getShip("Memory", 0);
521 Ship mem2 = fleet.getShip("Memory", 1);
522 //Ship mem2 = fleet.getShip("DDR2", 0);
528 fp = fleet.run(new Instruction[0]);
529 MemoryUtils.writeMem(fp, mem1, 0, bv(vals));
530 int vals_length = vals.length;
532 // Disable readback/writeback inside the loop
535 while(stride < vals_length) {
537 // reset the FleetProcess
538 //fp.terminate(); fp = null;
540 System.out.println("stride " + stride);
542 // if we reset the FleetProcess, restart it
543 if (fp==null) fp = fleet.run(new Instruction[0]);
546 vals = mergeSort(fp, fleet, vals, vals_length, stride, mem1, mem2);
548 // verify the cleanup
549 //CleanupUtils.verifyClean(fp);
551 Ship mem = mem1; mem1=mem2; mem2=mem;
554 System.out.println();
557 BitVector[] bvs = new BitVector[vals_length];
558 MemoryUtils.readMem(fp, mem1, 0, bvs);
559 System.out.println("results:");
560 for(int i=0; i<vals_length; i++)
561 System.out.println(bvs[i].toLong());
565 public static long[] mergeSort(FleetProcess fp, Fleet fleet,
566 long[] vals, int vals_length, int stride_length,
567 Ship memoryShip1, Ship memoryShip2) throws Exception {
570 BitVector[] mem = new BitVector[vals_length];
571 for(int i=0; i<mem.length; i++) mem[i] = new BitVector(fleet.getWordWidth()).set(vals[i]);
572 MemoryUtils.writeMem(fp, memoryShip1, 0, mem);
575 //////////////////////////////////////////////////////////////////////////////
577 Process proc = new Process(fleet);
578 DebugModule dm = proc.new DebugModule();
580 int end_of_data = vals_length;
581 int num_strides = end_of_data / (stride_length * 2);
583 MemoryModule mm = proc.new MemoryModule(memoryShip1);
584 SortedMergeModule sm = proc.new SortedMergeModule();
586 // So far: we have four spare Counter ships; one can be used for resetting
587 for(int i=0; i<2; i++) {
589 DownCounterModule c0 = proc.new DownCounterModule();
590 DownCounterModule c1 = proc.new DownCounterModule();
592 c0.start.connect(proc.new ForeverModule(stride_length).out);
593 c0.incr.connect(proc.new ForeverModule(1).out);
595 c1.start.connect(proc.new OnceModule(end_of_data + i*stride_length).out);
596 c1.incr.connect(proc.new OnceModule(stride_length*2).out);
598 RepeatModule r1 = proc.new RepeatModule();
599 r1.val.connect(c1.out);
600 r1.count.connect(proc.new ForeverModule(stride_length).out);
602 AluModule alu = proc.new AluModule();
603 alu.in1.connect(r1.out);
604 alu.in2.connect(c0.out);
605 alu.inOp.connect(proc.new ForeverModule(((Module.DockInPort)alu.inOp).getConstant("ADD")).out);
606 alu.out.connect(i==0 ? mm.inAddrRead1 : mm.inAddrRead2);
608 PunctuatorModule punc = proc.new PunctuatorModule(-1);
609 punc.count.connect(proc.new ForeverModule(stride_length).out);
610 punc.val.connect(i==0 ? mm.outRead1 : mm.outRead2);
611 punc.out.connect(i==0 ? sm.in1 : sm.in2);
614 UnPunctuatorModule unpunc = proc.new UnPunctuatorModule();
615 unpunc.val.connect(sm.out);
616 unpunc.count.connect(proc.new ForeverModule(2*stride_length).out);
618 DownCounterModule cw = proc.new DownCounterModule();
619 cw.start.connect(proc.new OnceModule(end_of_data).out);
620 cw.incr.connect(proc.new OnceModule(1).out);
622 MemoryModule mm2 = proc.new MemoryModule(memoryShip2);
623 mm2.inAddrWrite.connect(cw.out);
624 mm2.inDataWrite.connect(unpunc.out);
625 mm2.outWrite.connect(dm.in);
627 //////////////////////////////////////////////////////////////////////////////
629 Context ctx = new Context(fp.getFleet());
630 ctx.setAutoflush(true);
632 ArrayList<Instruction> ai = new ArrayList<Instruction>();
635 for(Instruction ins : ai) {
636 //System.out.println(ins);
637 fp.sendInstruction(ins);
641 for(int i=0; i<vals_length; i++) {
642 System.out.print("\rreading back... " + i+"/"+vals_length+" ");
643 BitVector rec = fp.recvWord();
644 System.out.print(" (prev result: " + rec + " = " + rec.toLong() + ")");
646 System.out.println("\rdone. ");
648 //if (true) return ret;
650 Context ctx2 = new Context(fp.getFleet());
651 Dock debugIn = fleet.getShip("Debug",0).getDock("in");
653 fp.sendToken(debugIn.getInstructionDestination());
656 LoopFactory lf = new LoopFactory(ctx2, debugIn, 0);
658 lf.abortLoopIfTorpedoPresent();
667 Ship counter = proc.pool.allocateShip("Counter");
669 for(int phase=0; phase<=3; phase++) {
670 System.out.println("== phase "+phase+" ==================================================================");
671 ctx2 = new Context(fp.getFleet());
673 Destination ackDestination = counter.getDock("in2").getDataDestination();
674 proc.reset(ctx2, phase, ackDestination);
676 Context ctx3 = new Context(fp.getFleet());
677 lf = new LoopFactory(ctx3, counter.getDock("inOp"), 1);
678 lf.literal("DROP_C1_V2");
682 lf = new LoopFactory(ctx3, counter.getDock("in1"), 1);
683 lf.literal(reset_count-1);
687 lf = new LoopFactory(ctx3, counter.getDock("in2"), 0);
688 lf.abortLoopIfTorpedoPresent();
691 lf = new LoopFactory(ctx3, counter.getDock("out"), 1);
693 lf.sendToken(counter.getDock("in2").getInstructionDestination()); // HACK: we don't check to make sure this hits
694 lf.sendToken(debugIn.getDataDestination());
695 ctx3.dispatch(fp); // HACK: we don't check to make sure that this is "firmly in place"
697 for(Dock dock : torpedoes) fp.sendToken(dock.getInstructionDestination());
700 System.out.println("flushed");
703 System.out.println("phase done");
705 System.out.println();
708 fp.sendToken(debugIn.getInstructionDestination());
711 //System.out.println("verifying cleanup:");
712 //CleanupUtils.verifyClean(fp);
714 System.out.println("reading back:");
717 ret = new long[vals_length];
718 BitVector[] mem = new BitVector[vals_length];
719 MemoryUtils.readMem(fp, memoryShip2, 0, mem);
720 for(int i=0; i<ret.length; i++) ret[i] = mem[i].toLong();
725 private BitVector[] longsToBitVectors(long[] initialValues) {
726 BitVector[] bv = new BitVector[initialValues.length];
727 for(int i=0; i<initialValues.length; i++)
728 bv[i] = new BitVector(fleet.getWordWidth()).set(initialValues[i]);