fix demos to work with new assertAllocated() lines in writeMem
[fleet.git] / src / edu / berkeley / fleet / dataflow / MergeSort.java
index b478462..876cf91 100644 (file)
@@ -318,7 +318,8 @@ public class MergeSort {
 
         MemoryUtils.writeMem(fp, pool, mem1, offset, bvs);
 
-        Program program = new Program(pool.allocateShip("Memory"));
+        Ship mem = pool.allocateShip("Memory");
+        Program program = new Program(mem);
         long ret = new MergeSort(fleet, program, pool, 2, mem1, mem1).main(fp, vals_length);
 
         //long ret = 0;
@@ -327,6 +328,7 @@ public class MergeSort {
         //MemoryUtils.readMem(fp, new ShipPool(fp.getFleet()), mem1, 0, bvs);
 
         BitVector[] bvx = new BitVector[1024];
+        pool.allocateShip(mem);
         MemoryUtils.readMem(fp, new ShipPool(fp.getFleet()), mem1, 0, bvx);
         for(int i=0; i<bvx.length; i++)
             System.out.println(bvx[i]);
@@ -391,8 +393,12 @@ public class MergeSort {
         lf.sendWord(program.getCBDDestination());
         cb.seal();
 
+        ShipPool pool = new ShipPool(fp.getFleet());
+        pool.allocateShip(program.memoryShip);
         // FIXME
-        return program.run(fp, cb, new ShipPool(fp.getFleet()));
+        long ret = program.run(fp, cb, pool);
+        pool.releaseShip(program.memoryShip);
+        return ret;
     }
 
     public static void randomizeMemory(FleetProcess fp, ShipPool pool_, Ship memory, long start, long length, boolean randomize) {