Fix bugs in scheduling simulator. Also add -robustroot setting in Tests/dotest script
authorjzhou <jzhou>
Tue, 18 Nov 2008 23:20:44 +0000 (23:20 +0000)
committerjzhou <jzhou>
Tue, 18 Nov 2008 23:20:44 +0000 (23:20 +0000)
12 files changed:
Robust/src/Analysis/Scheduling/CoreSimulator.java
Robust/src/Analysis/Scheduling/ScheduleAnalysis.java
Robust/src/Analysis/Scheduling/ScheduleSimulator.java
Robust/src/Analysis/Scheduling/TaskSimulator.java
Robust/src/Analysis/TaskStateAnalysis/FEdge.java
Robust/src/Analysis/TaskStateAnalysis/FlagState.java
Robust/src/Benchmarks/Scheduling/PSFluidAnimate/PSFADemo.java
Robust/src/IR/State.java
Robust/src/Main/Main.java
Robust/src/Runtime/multicoretask.c
Robust/src/Tests/dotest
Robust/src/buildscript

index 0bc4543b61d861d687ae010d2a4fab3ed0334a7a..38b3a0d104f300132e85fd6d68c3d9815afafde0 100644 (file)
@@ -166,6 +166,17 @@ public class CoreSimulator {
          }
          allycores = null;
        }
+       // check if need to transfer to other cores
+       Queue<Integer> targetcores = this.getTargetCores(obj.getCurrentFS());
+       if(targetcores != null) {
+           if(transObjs == null) {
+               transObjs = new Vector<ObjectSimulator>();
+           }
+           if(!transObjs.contains(obj)) {
+               transObjs.add(obj);
+           }
+           remove = true;
+       }
        for(int j = 0; j < this.tasks.size(); j++) {
          this.tasks.elementAt(j).refreshPara(obj, remove);
        }
index 94b887ec8b319cf6255499a09f4e5576b25cfee3..89e8f8272ff695eaf16df54ded7c125912f26c84 100644 (file)
@@ -213,7 +213,9 @@ public class ScheduleAnalysis {
     }
     toVisit = null;
 
-    SchedulingUtil.printScheduleGraph("scheduling_ori.dot", this.scheduleNodes);
+    if(this.state.PRINTSCHEDULING) {
+       SchedulingUtil.printScheduleGraph("scheduling_ori.dot", this.scheduleNodes);
+    }
   }
 
   public void scheduleAnalysis() {
@@ -384,7 +386,9 @@ public class ScheduleAnalysis {
     fe2ses = null;
     sn2fes = null;
 
-    SchedulingUtil.printScheduleGraph("scheduling_extend.dot", this.scheduleNodes);
+    if(this.state.PRINTSCHEDULING) {
+       SchedulingUtil.printScheduleGraph("scheduling_extend.dot", this.scheduleNodes);
+    }
   }
 
   private void handleScheduleEdge(ScheduleEdge se, boolean merge) {
@@ -746,8 +750,10 @@ public class ScheduleAnalysis {
       // Enough cores, no need to combine any ScheduleNode
       this.scheduleGraphs.addElement(this.scheduleNodes);
       int gid = 1;
-      String path = "scheduling_" + gid + ".dot";
-      SchedulingUtil.printScheduleGraph(path, this.scheduleNodes);
+      if(this.state.PRINTSCHEDULING) {
+         String path = "scheduling_" + gid + ".dot";
+         SchedulingUtil.printScheduleGraph(path, this.scheduleNodes);
+      }
     } else {
       // Go through all the Scheudle Nodes, organize them in order of their cid
       Vector<Vector<ScheduleNode>> sNodeVecs = new Vector<Vector<ScheduleNode>>();
@@ -1052,8 +1058,10 @@ public class ScheduleAnalysis {
     sn2hash = null;
     sn2sn = null;
 
-    String path = "scheduling_" + gid + ".dot";
-    SchedulingUtil.printScheduleGraph(path, result);
+    if(this.state.PRINTSCHEDULING) {
+       String path = "scheduling_" + gid + ".dot";
+       SchedulingUtil.printScheduleGraph(path, result);
+    }
 
     return result;
   }
index 49c063dfe306c2fae2a1bc0bdc5ef8702d091a91..d5db4149f53e23212f69daf43593fa4c955ca550 100644 (file)
@@ -303,7 +303,7 @@ public class ScheduleSimulator {
                  // this obj will reside on this core
                  cs.addObject(tobj);
                } else {
-                 Integer targetCore = cores.peek();
+                 Integer targetCore = cores.poll();
                  if(targetCore == coreNum) {
                    // this obj will reside on this core
                    cs.addObject(tobj);
@@ -315,8 +315,9 @@ public class ScheduleSimulator {
                    tmpqueue.add(new ObjectInfo(tobj));
                    tmpqueue = null;
                  }
-                 cores = null;
+                 cores.add(targetCore);
                }
+               cores = null;
                // check if this object becoming shared or not
                Vector<Integer> allycores = cs.getAllyCores(tobj.getCurrentFS());
                if(allycores != null) {
@@ -380,8 +381,10 @@ public class ScheduleSimulator {
       finishTasks = null;
     }
 
-    SchedulingUtil.printSimulationResult("SimulatorResult_" + this.invoketime + ".dot", this.processTime,
-                                         this.coreNum, this.checkpoints);
+    if(this.state.PRINTSCHEDULESIM) {
+       SchedulingUtil.printSimulationResult("SimulatorResult_" + this.invoketime + ".dot", this.processTime,
+               this.coreNum, this.checkpoints);
+    }
     System.out.println("Simulate scheduling #" + this.invoketime + ": ");
     System.out.println("\tTotal execution time is: " + this.processTime);
     System.out.println("\tUtility of cores: ");
index 6e5c6eb470bec8f82d8a14bcf9b9235090cfbb04..f8dfc92752bae73cadec7149c6f72a6210f5b7ae 100644 (file)
@@ -213,11 +213,26 @@ public class TaskSimulator {
       if(tpara.isShared()) {
        if(tpara.isHold()) {
          // shared object held by other tasks
-         finishTime = 800;           // TODO currenly assume the effort on requesting locks are only 1
-         this.currentRun.setFinishTime(finishTime);
+         finishTime = 800;           // TODO currenly assume the effort on requesting locks are only 800
+         /*this.currentRun.setFinishTime(finishTime);
          this.currentRun.setExetype(1);
          paraQueues.elementAt(i).poll();
          paraQueues.elementAt(i).add(tpara);
+         for(int j = 0; j < i; ++j) {
+           tpara = this.paraQueues.elementAt(j).poll();
+           if(tpara.isShared() && tpara.isHold()) {
+             tpara.setHold(false);
+           }
+           this.paraQueues.elementAt(j).add(tpara);
+         }*/
+         // remove it instead
+         this.currentRun.setFinishTime(finishTime);
+         this.currentRun.setExetype(2);
+         paraQueues.elementAt(i).poll();
+         // remove this object from the remaining parameter queues
+         for(int j = i + 1; j < paraQueues.size(); j++) {
+           paraQueues.elementAt(j).remove(tpara);
+         }
          for(int j = 0; j < i; ++j) {
            tpara = this.paraQueues.elementAt(j).poll();
            if(tpara.isShared() && tpara.isHold()) {
@@ -228,7 +243,7 @@ public class TaskSimulator {
          return;
        } else if (tpara.getVersion() != this.objVersionTbl.get(tpara)) {
          // shared object has been updated and no longer fitted to this task
-         finishTime = 800;           // TODO currenly assume the effort on requesting locks are only 1
+         finishTime = 800;           // TODO currenly assume the effort on requesting locks are only 800
          this.currentRun.setFinishTime(finishTime);
          this.currentRun.setExetype(2);
          paraQueues.elementAt(i).poll();
index c998d70ceda2e157fcd52a65d62111bf0f01797d..c81d8546e228432d33cf13de6711c77fe94eae57 100644 (file)
@@ -206,6 +206,10 @@ public class FEdge extends Edge {
   public int getInvokeNumGap() {
     return this.expInvokeNum - this.invokeNum;
   }
+  
+  public int getInvokeNumGapByObj(int byObj) {
+      return this.expInvokeNum - (this.invokeNum/byObj);
+  }
 
   public void setExpInvokeNum(int expInvokeNum) {
     this.expInvokeNum = expInvokeNum;
index 2fb5b671d0cd614976e9e6d6c417a5e8ceac8b5a..58bd822f478f7c59049db61c18091f8baabe9d03 100644 (file)
@@ -33,6 +33,7 @@ public class FlagState extends GraphNode implements Cloneable {
   private int executeTime;
   private int visited4time;
   private int invokeNum;
+  private int byObj;
   // for building multicore codes
   private int andmask;
   private int checkmask;
@@ -54,6 +55,7 @@ public class FlagState extends GraphNode implements Cloneable {
     this.executeTime = -1;
     this.visited4time = -1;
     this.invokeNum = 0;
+    this.byObj = 0;
     this.andmask = 0;
     this.checkmask = 0;
     this.setmask = false;
@@ -283,13 +285,16 @@ public class FlagState extends GraphNode implements Cloneable {
       FlagState fs=(FlagState)o;
       if (fs.cd!=cd)
        return false;
+      if(fs.byObj != this.byObj) {
+         return false;
+      }
       return (fs.flagstate.equals(flagstate) & fs.tags.equals(tags));
     }
     return false;
   }
 
   public int hashCode() {
-    return cd.hashCode()^flagstate.hashCode()^tags.hashCode();
+    return cd.hashCode()^flagstate.hashCode()^tags.hashCode()^byObj;
   }
 
   public String getLabel() {
@@ -422,6 +427,7 @@ public class FlagState extends GraphNode implements Cloneable {
     for(int i = 0; i < this.inedges.size(); i++) {
       o.inedges.addElement(this.inedges.elementAt(i));
     }
+    o.byObj = this.byObj;
     return o;
   }
 
@@ -435,7 +441,11 @@ public class FlagState extends GraphNode implements Cloneable {
     // refresh all the expInvokeNum of each edge
     for(int i = 0; i < this.edges.size(); i++) {
       next = (FEdge) this.edges.elementAt(i);
-      next.setExpInvokeNum((int)(Math.ceil(this.invokeNum * next.getProbability() / 100)));
+      if(this.byObj == 0) {
+         next.setExpInvokeNum((int)(Math.ceil(this.invokeNum * next.getProbability() / 100)));
+      } else {
+         next.setExpInvokeNum((int)(Math.ceil(((this.invokeNum - 1) / this.byObj + 1) * next.getProbability() / 100)));
+      }
     }
 
     // find the one with the biggest gap between its actual invoke time and the expected invoke time
@@ -446,7 +456,7 @@ public class FlagState extends GraphNode implements Cloneable {
     boolean isbackedge = true;
     for(int i = 0; i < this.edges.size(); i++) {
       next = ((FEdge) this.edges.elementAt(i));
-      int temp = next.getInvokeNumGap();
+      int temp = (this.byObj == 0) ? next.getInvokeNumGap() : next.getInvokeNumGapByObj(this.byObj);
       boolean exchange = false;
       if((temp > gap) && (next.getTask().equals(td))) {
        exchange = true;
@@ -473,6 +483,14 @@ public class FlagState extends GraphNode implements Cloneable {
     return next;
   }
 
+  public int getByObj() {
+      return byObj;
+  }
+
+  public void setByObj(int byObj) {
+      this.byObj = byObj;
+  }
+
   /*public Vector<ScheduleEdge> getAllys() {
       return allys;
      }
index fdc07bc54743cff32d1dc4bd67bf56db6ae17662..7c923d0581edd78f9a534b950cc34ac1ab634444 100644 (file)
@@ -88,26 +88,28 @@ public class PSFADemo {
                Cell toadd = (Cell)(g.m_neighCells.get(key));
                int toaddnp = toadd.m_numPars;
                for(int j = 0; j < toaddnp; ++j) {
-                   if(cell.m_p[np] == null) {
-                       cell.m_p[np] = new Vec3();
-                       cell.m_hv[np] = new Vec3();
-                       cell.m_v[np] = new Vec3();
-                       cell.m_a[np] = new Vec3();
+                   if(np < cell.m_p.length) {
+                       if(cell.m_p[np] == null) {
+                           cell.m_p[np] = new Vec3();
+                           cell.m_hv[np] = new Vec3();
+                           cell.m_v[np] = new Vec3();
+                           cell.m_a[np] = new Vec3();
+                       }
+                       cell.m_p[np].m_x = toadd.m_p[j].m_x;
+                       cell.m_p[np].m_y = toadd.m_p[j].m_y;
+                       cell.m_p[np].m_z = toadd.m_p[j].m_z;
+                       cell.m_hv[np].m_x = toadd.m_hv[j].m_x;
+                       cell.m_hv[np].m_y = toadd.m_hv[j].m_y;
+                       cell.m_hv[np].m_z = toadd.m_hv[j].m_z;
+                       cell.m_v[np].m_x = toadd.m_v[j].m_x;
+                       cell.m_v[np].m_y = toadd.m_v[j].m_y;
+                       cell.m_v[np].m_z = toadd.m_v[j].m_z;
+                       cell.m_a[np].m_x = toadd.m_a[j].m_x;
+                       cell.m_a[np].m_y = toadd.m_a[j].m_y;
+                       cell.m_a[np].m_z = toadd.m_a[j].m_z;
+                       cell.m_density[np] = toadd.m_density[j];
+                       np++;
                    }
-                   cell.m_p[np].m_x = toadd.m_p[j].m_x;
-                   cell.m_p[np].m_y = toadd.m_p[j].m_y;
-                   cell.m_p[np].m_z = toadd.m_p[j].m_z;
-                   cell.m_hv[np].m_x = toadd.m_hv[j].m_x;
-                   cell.m_hv[np].m_y = toadd.m_hv[j].m_y;
-                   cell.m_hv[np].m_z = toadd.m_hv[j].m_z;
-                   cell.m_v[np].m_x = toadd.m_v[j].m_x;
-                   cell.m_v[np].m_y = toadd.m_v[j].m_y;
-                   cell.m_v[np].m_z = toadd.m_v[j].m_z;
-                   cell.m_a[np].m_x = toadd.m_a[j].m_x;
-                   cell.m_a[np].m_y = toadd.m_a[j].m_y;
-                   cell.m_a[np].m_z = toadd.m_a[j].m_z;
-                   cell.m_density[np] = toadd.m_density[j];
-                   np++;
                }
                cell.m_numPars += toaddnp;
                visited.put(key, key);
@@ -126,26 +128,28 @@ public class PSFADemo {
                        Cell toadd = g.m_cells[ix][iy][iz];
                        int toaddnp = toadd.m_numPars;
                        for(int j = 0; j < toaddnp; ++j) {
-                           if(cell.m_p[np] == null) {
-                               cell.m_p[np] = new Vec3();
-                               cell.m_hv[np] = new Vec3();
-                               cell.m_v[np] = new Vec3();
-                               cell.m_a[np] = new Vec3();
+                           if(np < cell.m_p.length) {
+                               if(cell.m_p[np] == null) {
+                                   cell.m_p[np] = new Vec3();
+                                   cell.m_hv[np] = new Vec3();
+                                   cell.m_v[np] = new Vec3();
+                                   cell.m_a[np] = new Vec3();
+                               }
+                               cell.m_p[np].m_x = toadd.m_p[j].m_x;
+                               cell.m_p[np].m_y = toadd.m_p[j].m_y;
+                               cell.m_p[np].m_z = toadd.m_p[j].m_z;
+                               cell.m_hv[np].m_x = toadd.m_hv[j].m_x;
+                               cell.m_hv[np].m_y = toadd.m_hv[j].m_y;
+                               cell.m_hv[np].m_z = toadd.m_hv[j].m_z;
+                               cell.m_v[np].m_x = toadd.m_v[j].m_x;
+                               cell.m_v[np].m_y = toadd.m_v[j].m_y;
+                               cell.m_v[np].m_z = toadd.m_v[j].m_z;
+                               cell.m_a[np].m_x = toadd.m_a[j].m_x;
+                               cell.m_a[np].m_y = toadd.m_a[j].m_y;
+                               cell.m_a[np].m_z = toadd.m_a[j].m_z;
+                               cell.m_density[np] = toadd.m_density[j];
+                               np++;
                            }
-                           cell.m_p[np].m_x = toadd.m_p[j].m_x;
-                           cell.m_p[np].m_y = toadd.m_p[j].m_y;
-                           cell.m_p[np].m_z = toadd.m_p[j].m_z;
-                           cell.m_hv[np].m_x = toadd.m_hv[j].m_x;
-                           cell.m_hv[np].m_y = toadd.m_hv[j].m_y;
-                           cell.m_hv[np].m_z = toadd.m_hv[j].m_z;
-                           cell.m_v[np].m_x = toadd.m_v[j].m_x;
-                           cell.m_v[np].m_y = toadd.m_v[j].m_y;
-                           cell.m_v[np].m_z = toadd.m_v[j].m_z;
-                           cell.m_a[np].m_x = toadd.m_a[j].m_x;
-                           cell.m_a[np].m_y = toadd.m_a[j].m_y;
-                           cell.m_a[np].m_z = toadd.m_a[j].m_z;
-                           cell.m_density[np] = toadd.m_density[j];
-                           np++;
                        }
                        cell.m_numPars += toaddnp;
                        visited.put(index, index);
@@ -171,26 +175,28 @@ public class PSFADemo {
                        Cell toadd = g.m_cells[ix][iy][iz];
                        int toaddnp = toadd.m_numPars;
                        for(int j = 0; j < toaddnp; ++j) {
-                           if(cell.m_p[np] == null) {
-                               cell.m_p[np] = new Vec3();
-                               cell.m_hv[np] = new Vec3();
-                               cell.m_v[np] = new Vec3();
-                               cell.m_a[np] = new Vec3();
+                           if(np < cell.m_p.length) {
+                               if(cell.m_p[np] == null) {
+                                   cell.m_p[np] = new Vec3();
+                                   cell.m_hv[np] = new Vec3();
+                                   cell.m_v[np] = new Vec3();
+                                   cell.m_a[np] = new Vec3();
+                               }
+                               cell.m_p[np].m_x = toadd.m_p[j].m_x;
+                               cell.m_p[np].m_y = toadd.m_p[j].m_y;
+                               cell.m_p[np].m_z = toadd.m_p[j].m_z;
+                               cell.m_hv[np].m_x = toadd.m_hv[j].m_x;
+                               cell.m_hv[np].m_y = toadd.m_hv[j].m_y;
+                               cell.m_hv[np].m_z = toadd.m_hv[j].m_z;
+                               cell.m_v[np].m_x = toadd.m_v[j].m_x;
+                               cell.m_v[np].m_y = toadd.m_v[j].m_y;
+                               cell.m_v[np].m_z = toadd.m_v[j].m_z;
+                               cell.m_a[np].m_x = toadd.m_a[j].m_x;
+                               cell.m_a[np].m_y = toadd.m_a[j].m_y;
+                               cell.m_a[np].m_z = toadd.m_a[j].m_z;
+                               cell.m_density[np] = toadd.m_density[j];
+                               np++;
                            }
-                           cell.m_p[np].m_x = toadd.m_p[j].m_x;
-                           cell.m_p[np].m_y = toadd.m_p[j].m_y;
-                           cell.m_p[np].m_z = toadd.m_p[j].m_z;
-                           cell.m_hv[np].m_x = toadd.m_hv[j].m_x;
-                           cell.m_hv[np].m_y = toadd.m_hv[j].m_y;
-                           cell.m_hv[np].m_z = toadd.m_hv[j].m_z;
-                           cell.m_v[np].m_x = toadd.m_v[j].m_x;
-                           cell.m_v[np].m_y = toadd.m_v[j].m_y;
-                           cell.m_v[np].m_z = toadd.m_v[j].m_z;
-                           cell.m_a[np].m_x = toadd.m_a[j].m_x;
-                           cell.m_a[np].m_y = toadd.m_a[j].m_y;
-                           cell.m_a[np].m_z = toadd.m_a[j].m_z;
-                           cell.m_density[np] = toadd.m_density[j];
-                           np++;
                        }
                        cell.m_numPars += toaddnp;
                        visited.put(index, index);
@@ -218,26 +224,28 @@ public class PSFADemo {
                cell.m_numPars = 0;
                int np = 0;
                for(int j = 0; j < toflushnp; ++j) {
-                   if(cell.m_p[np] == null) {
-                       cell.m_p[np] = new Vec3();
-                       cell.m_hv[np] = new Vec3();
-                       cell.m_v[np] = new Vec3();
-                       cell.m_a[np] = new Vec3();
+                   if(np < cell.m_p.length) {
+                       if(cell.m_p[np] == null) {
+                           cell.m_p[np] = new Vec3();
+                           cell.m_hv[np] = new Vec3();
+                           cell.m_v[np] = new Vec3();
+                           cell.m_a[np] = new Vec3();
+                       }
+                       cell.m_p[np].m_x = toflush.m_p[j].m_x;
+                       cell.m_p[np].m_y = toflush.m_p[j].m_y;
+                       cell.m_p[np].m_z = toflush.m_p[j].m_z;
+                       cell.m_hv[np].m_x = toflush.m_hv[j].m_x;
+                       cell.m_hv[np].m_y = toflush.m_hv[j].m_y;
+                       cell.m_hv[np].m_z = toflush.m_hv[j].m_z;
+                       cell.m_v[np].m_x = toflush.m_v[j].m_x;
+                       cell.m_v[np].m_y = toflush.m_v[j].m_y;
+                       cell.m_v[np].m_z = toflush.m_v[j].m_z;
+                       cell.m_a[np].m_x = toflush.m_a[j].m_x;
+                       cell.m_a[np].m_y = toflush.m_a[j].m_y;
+                       cell.m_a[np].m_z = toflush.m_a[j].m_z;
+                       cell.m_density[np] = toflush.m_density[j];
+                       np++;
                    }
-                   cell.m_p[np].m_x = toflush.m_p[j].m_x;
-                   cell.m_p[np].m_y = toflush.m_p[j].m_y;
-                   cell.m_p[np].m_z = toflush.m_p[j].m_z;
-                   cell.m_hv[np].m_x = toflush.m_hv[j].m_x;
-                   cell.m_hv[np].m_y = toflush.m_hv[j].m_y;
-                   cell.m_hv[np].m_z = toflush.m_hv[j].m_z;
-                   cell.m_v[np].m_x = toflush.m_v[j].m_x;
-                   cell.m_v[np].m_y = toflush.m_v[j].m_y;
-                   cell.m_v[np].m_z = toflush.m_v[j].m_z;
-                   cell.m_a[np].m_x = toflush.m_a[j].m_x;
-                   cell.m_a[np].m_y = toflush.m_a[j].m_y;
-                   cell.m_a[np].m_z = toflush.m_a[j].m_z;
-                   cell.m_density[np] = toflush.m_density[j];
-                   np++;
                }
                cell.m_numPars += toflushnp;
                visited.put(key, key);
@@ -258,26 +266,28 @@ public class PSFADemo {
                        cell.m_numPars = 0;
                        int np = 0;
                        for(int j = 0; j < toflushnp; ++j) {
-                           if(cell.m_p[np] == null) {
-                               cell.m_p[np] = new Vec3();
-                               cell.m_hv[np] = new Vec3();
-                               cell.m_v[np] = new Vec3();
-                               cell.m_a[np] = new Vec3();
+                           if(np < cell.m_p.length) {
+                               if(cell.m_p[np] == null) {
+                                   cell.m_p[np] = new Vec3();
+                                   cell.m_hv[np] = new Vec3();
+                                   cell.m_v[np] = new Vec3();
+                                   cell.m_a[np] = new Vec3();
+                               }
+                               cell.m_p[np].m_x = toflush.m_p[j].m_x;
+                               cell.m_p[np].m_y = toflush.m_p[j].m_y;
+                               cell.m_p[np].m_z = toflush.m_p[j].m_z;
+                               cell.m_hv[np].m_x = toflush.m_hv[j].m_x;
+                               cell.m_hv[np].m_y = toflush.m_hv[j].m_y;
+                               cell.m_hv[np].m_z = toflush.m_hv[j].m_z;
+                               cell.m_v[np].m_x = toflush.m_v[j].m_x;
+                               cell.m_v[np].m_y = toflush.m_v[j].m_y;
+                               cell.m_v[np].m_z = toflush.m_v[j].m_z;
+                               cell.m_a[np].m_x = toflush.m_a[j].m_x;
+                               cell.m_a[np].m_y = toflush.m_a[j].m_y;
+                               cell.m_a[np].m_z = toflush.m_a[j].m_z;
+                               cell.m_density[np] = toflush.m_density[j];
+                               np++;
                            }
-                           cell.m_p[np].m_x = toflush.m_p[j].m_x;
-                           cell.m_p[np].m_y = toflush.m_p[j].m_y;
-                           cell.m_p[np].m_z = toflush.m_p[j].m_z;
-                           cell.m_hv[np].m_x = toflush.m_hv[j].m_x;
-                           cell.m_hv[np].m_y = toflush.m_hv[j].m_y;
-                           cell.m_hv[np].m_z = toflush.m_hv[j].m_z;
-                           cell.m_v[np].m_x = toflush.m_v[j].m_x;
-                           cell.m_v[np].m_y = toflush.m_v[j].m_y;
-                           cell.m_v[np].m_z = toflush.m_v[j].m_z;
-                           cell.m_a[np].m_x = toflush.m_a[j].m_x;
-                           cell.m_a[np].m_y = toflush.m_a[j].m_y;
-                           cell.m_a[np].m_z = toflush.m_a[j].m_z;
-                           cell.m_density[np] = toflush.m_density[j];
-                           np++;
                        }
                        cell.m_numPars += toflushnp;
                        visited.put(index, index);
@@ -304,26 +314,28 @@ public class PSFADemo {
                        cell.m_numPars = 0;
                        int np = 0;
                        for(int j = 0; j < toflushnp; ++j) {
-                           if(cell.m_p[np] == null) {
-                               cell.m_p[np] = new Vec3();
-                               cell.m_hv[np] = new Vec3();
-                               cell.m_v[np] = new Vec3();
-                               cell.m_a[np] = new Vec3();
+                           if(np < cell.m_p.length) {
+                               if(cell.m_p[np] == null) {
+                                   cell.m_p[np] = new Vec3();
+                                   cell.m_hv[np] = new Vec3();
+                                   cell.m_v[np] = new Vec3();
+                                   cell.m_a[np] = new Vec3();
+                               }
+                               cell.m_p[np].m_x = toflush.m_p[j].m_x;
+                               cell.m_p[np].m_y = toflush.m_p[j].m_y;
+                               cell.m_p[np].m_z = toflush.m_p[j].m_z;
+                               cell.m_hv[np].m_x = toflush.m_hv[j].m_x;
+                               cell.m_hv[np].m_y = toflush.m_hv[j].m_y;
+                               cell.m_hv[np].m_z = toflush.m_hv[j].m_z;
+                               cell.m_v[np].m_x = toflush.m_v[j].m_x;
+                               cell.m_v[np].m_y = toflush.m_v[j].m_y;
+                               cell.m_v[np].m_z = toflush.m_v[j].m_z;
+                               cell.m_a[np].m_x = toflush.m_a[j].m_x;
+                               cell.m_a[np].m_y = toflush.m_a[j].m_y;
+                               cell.m_a[np].m_z = toflush.m_a[j].m_z;
+                               cell.m_density[np] = toflush.m_density[j];
+                               np++;
                            }
-                           cell.m_p[np].m_x = toflush.m_p[j].m_x;
-                           cell.m_p[np].m_y = toflush.m_p[j].m_y;
-                           cell.m_p[np].m_z = toflush.m_p[j].m_z;
-                           cell.m_hv[np].m_x = toflush.m_hv[j].m_x;
-                           cell.m_hv[np].m_y = toflush.m_hv[j].m_y;
-                           cell.m_hv[np].m_z = toflush.m_hv[j].m_z;
-                           cell.m_v[np].m_x = toflush.m_v[j].m_x;
-                           cell.m_v[np].m_y = toflush.m_v[j].m_y;
-                           cell.m_v[np].m_z = toflush.m_v[j].m_z;
-                           cell.m_a[np].m_x = toflush.m_a[j].m_x;
-                           cell.m_a[np].m_y = toflush.m_a[j].m_y;
-                           cell.m_a[np].m_z = toflush.m_a[j].m_z;
-                           cell.m_density[np] = toflush.m_density[j];
-                           np++;
                        }
                        cell.m_numPars += toflushnp;
                        visited.put(index, index);
@@ -546,12 +558,6 @@ public class PSFADemo {
                int np = cell.m_numPars;
                Cell toadd = (Cell)(g.m_neighCells.get(key));
                for(int j = 0; j < np; ++j) {
-                   if(cell.m_p[np] == null) {
-                       cell.m_p[np] = new Vec3();
-                       cell.m_hv[np] = new Vec3();
-                       cell.m_v[np] = new Vec3();
-                       cell.m_a[np] = new Vec3();
-                   }
                    cell.m_v[j].m_x += toadd.m_v[j].m_x - cell.m_a[j].m_x;
                    cell.m_v[j].m_y += toadd.m_v[j].m_y - cell.m_a[j].m_y;
                    cell.m_v[j].m_z += toadd.m_v[j].m_z - cell.m_a[j].m_z;
@@ -571,12 +577,6 @@ public class PSFADemo {
                        int np = cell.m_numPars;
                        Cell toadd = g.m_cells[ix][iy][iz];
                        for(int j = 0; j < np; ++j) {
-                           if(cell.m_p[np] == null) {
-                               cell.m_p[np] = new Vec3();
-                               cell.m_hv[np] = new Vec3();
-                               cell.m_v[np] = new Vec3();
-                               cell.m_a[np] = new Vec3();
-                           }
                            cell.m_v[j].m_x = toadd.m_v[j].m_x - 
                                               cell.m_a[j].m_x;
                            cell.m_v[j].m_y = toadd.m_v[j].m_y - 
@@ -606,12 +606,6 @@ public class PSFADemo {
                        int np = cell.m_numPars;
                        Cell toadd = g.m_cells[ix][iy][iz];
                        for(int j = 0; j < np; ++j) {
-                           if(cell.m_p[np] == null) {
-                               cell.m_p[np] = new Vec3();
-                               cell.m_hv[np] = new Vec3();
-                               cell.m_v[np] = new Vec3();
-                               cell.m_a[np] = new Vec3();
-                           }
                            cell.m_v[j].m_x = toadd.m_v[j].m_x - 
                                              cell.m_a[j].m_x;
                            cell.m_v[j].m_y = toadd.m_v[j].m_y - 
@@ -636,12 +630,6 @@ public class PSFADemo {
                Cell cell = (Cell)it_values.next();
                int np = cell.m_numPars;
                for(int j = 0; j < np; ++j) {
-                   if(cell.m_p[np] == null) {
-                       cell.m_p[np] = new Vec3();
-                       cell.m_hv[np] = new Vec3();
-                       cell.m_v[np] = new Vec3();
-                       cell.m_a[np] = new Vec3();
-                   }
                    cell.m_a[j].m_x += cell.m_v[j].m_x;
                    cell.m_a[j].m_y += cell.m_v[j].m_y;
                    cell.m_a[j].m_z += cell.m_v[j].m_z;
@@ -661,12 +649,6 @@ public class PSFADemo {
                Cell cell = (Cell)(g.m_neighCells.get(key));
                int np = cell.m_numPars;
                for(int j = 0; j < np; ++j) {
-                   if(cell.m_p[np] == null) {
-                       cell.m_p[np] = new Vec3();
-                       cell.m_hv[np] = new Vec3();
-                       cell.m_v[np] = new Vec3();
-                       cell.m_a[np] = new Vec3();
-                   }
                    cell.m_a[j].m_x = toflush.m_a[j].m_x;
                    cell.m_a[j].m_y = toflush.m_a[j].m_y;
                    cell.m_a[j].m_z = toflush.m_a[j].m_z;
@@ -687,12 +669,6 @@ public class PSFADemo {
                        Cell cell = g.m_cells[ix][iy][iz];
                        int np = cell.m_numPars;
                        for(int j = 0; j < np; ++j) {
-                           if(cell.m_p[np] == null) {
-                               cell.m_p[np] = new Vec3();
-                               cell.m_hv[np] = new Vec3();
-                               cell.m_v[np] = new Vec3();
-                               cell.m_a[np] = new Vec3();
-                           }
                            cell.m_a[j].m_x = toflush.m_a[j].m_x;
                            cell.m_a[j].m_y = toflush.m_a[j].m_y;
                            cell.m_a[j].m_z = toflush.m_a[j].m_z;
@@ -719,12 +695,6 @@ public class PSFADemo {
                        Cell cell = g.m_cells[ix][iy][iz];
                        int np = cell.m_numPars;
                        for(int j = 0; j < np; ++j) {
-                           if(cell.m_p[np] == null) {
-                               cell.m_p[np] = new Vec3();
-                               cell.m_hv[np] = new Vec3();
-                               cell.m_v[np] = new Vec3();
-                               cell.m_a[np] = new Vec3();
-                           }
                            cell.m_a[j].m_x = toflush.m_a[j].m_x;
                            cell.m_a[j].m_y = toflush.m_a[j].m_y;
                            cell.m_a[j].m_z = toflush.m_a[j].m_z;
index 157fe003bbd0320390468832120bea0d01c5348d..893224929cbb821a8f634401ea1c47de070e60e2 100644 (file)
@@ -67,6 +67,8 @@ public class State {
   public boolean INSTRUCTIONFAILURE=false;
   public static double TRUEPROB=0.8;
   public static boolean PRINTFLAT=false;
+  public static boolean PRINTSCHEDULING=false;
+  public static boolean PRINTSCHEDULESIM=false;
   public int CORENUM = 1;
   public String structfile;
   public String main;
index 01ed2f6b508fc40aab9a9262663908f3a479d55d..c63ed8dfc54b0f9fec4f8e750dcd43aec9030ba5 100644 (file)
@@ -75,6 +75,10 @@ public class Main {
        state.TRUEPROB=Double.parseDouble(args[++i]);
       } else if (option.equals("-printflat"))
        State.PRINTFLAT=true;
+      else if (option.equals("-printscheduling"))
+               State.PRINTSCHEDULING=true;
+      else if (option.equals("-printschedulesim"))
+               State.PRINTSCHEDULESIM=true;
       else if (option.equals("-struct"))
        state.structfile=args[++i];
       else if (option.equals("-conscheck"))
@@ -147,6 +151,18 @@ public class Main {
        System.out.println("-ownwritedots <all/final> -- write ownership graphs; can be all results or just final results");
        System.out.println("-ownaliasfile <filename> -- write a text file showing all detected aliases in program tasks");
        System.out.println("-optional -- enable optional arguments");
+       System.out.println("-scheduling do task scheduling" );
+       System.out.println("-multicore generate multi-core version binary");
+       System.out.println("-numcore set the number of cores (should be used together with -multicore), defaultly set as 1");
+       System.out.println("-raw generate raw version binary (should be used together with -multicore)");
+       System.out.println("-interrupt generate raw version binary with interruption (should be used togethere with -raw)");
+       System.out.println("-rawconfig config raw simulator as 4xn (should be used together with -raw)");
+       System.out.println("-rawpath print out execute path information for raw version (should be used together with -raw)");
+       System.out.println("-useprofile use profiling data for scheduling (should be used together with -raw)");
+       System.out.println("-threadsimulate generate multi-thread simulate version binary");
+       System.out.println("-rawuseio use standard io to output profiling data (should be used together with -raw and -profile), it only works with single core version");
+       System.out.println("-printscheduling -- print out scheduling graphs");
+       System.out.println("-printschedulesim -- print out scheduling simulation result graphs");
        System.out.println("-webinterface -- enable web interface");
        System.out.println("-help -- print out help");
        System.exit(0);
@@ -312,10 +328,22 @@ public class Main {
            while(inint.startsWith(" ")) {
              inint = inint.substring(1);
            }
-           tmpinindex = inint.indexOf(';');
+           tmpinindex = inint.indexOf(',');
+           if(tmpinindex == -1) {
+             break;
+           }
            int numofexits = Integer.parseInt(inint.substring(0, tmpinindex));
            TaskInfo tinfo = new TaskInfo(numofexits);
            inint = inint.substring(tmpinindex + 1);
+           while(inint.startsWith(" ")) {
+             inint = inint.substring(1);
+           }
+           tmpinindex = inint.indexOf(';');
+           int byObj = Integer.parseInt(inint.substring(0, tmpinindex));
+           if(byObj != -1) {
+               tinfo.m_byObj = byObj;
+           }
+           inint = inint.substring(tmpinindex + 1);
            while(inint.startsWith(" ")) {
                inint = inint.substring(1);
            }
@@ -403,16 +431,20 @@ public class Main {
                      int total = 100;
                      for(int j = 0; j < numEdges; j++) {
                        FEdge pfe = fev.elementAt(j);
-                       tint = taskinfos.get(td.getSymbol()).m_exetime[pfe.getTaskExitIndex()];
+                       TaskInfo taskinfo = taskinfos.get(td.getSymbol());
+                       tint = taskinfo.m_exetime[pfe.getTaskExitIndex()];
                        pfe.setExeTime(tint);
-                       double idouble = taskinfos.get(td.getSymbol()).m_probability[pfe.getTaskExitIndex()];
+                       double idouble = taskinfo.m_probability[pfe.getTaskExitIndex()];
                        pfe.setProbability(idouble);
                        int newRate = 0;
-                       if((taskinfos.get(td.getSymbol()).m_newobjinfo.elementAt(pfe.getTaskExitIndex()) != null)
-                               && (taskinfos.get(td.getSymbol()).m_newobjinfo.elementAt(pfe.getTaskExitIndex()).containsKey(cd.getSymbol()))) {
-                           newRate = taskinfos.get(td.getSymbol()).m_newobjinfo.elementAt(pfe.getTaskExitIndex()).get(cd.getSymbol());
+                       if((taskinfo.m_newobjinfo.elementAt(pfe.getTaskExitIndex()) != null)
+                               && (taskinfo.m_newobjinfo.elementAt(pfe.getTaskExitIndex()).containsKey(cd.getSymbol()))) {
+                           newRate = taskinfo.m_newobjinfo.elementAt(pfe.getTaskExitIndex()).get(cd.getSymbol());
                        }
                        pfe.addNewObjInfo(cd, newRate, idouble);
+                       if(taskinfo.m_byObj != -1) {
+                           ((FlagState)pfe.getSource()).setByObj(taskinfo.m_byObj);
+                       }
                      }
                      fev = null;
                    }
@@ -426,10 +458,14 @@ public class Main {
                int total = 100;
                while(it_edges.hasNext()) {
                  FEdge edge = (FEdge)it_edges.next();
-                 tint = taskinfos.get(edge.getTask().getSymbol()).m_exetime[edge.getTaskExitIndex()];
+                 TaskInfo taskinfo = taskinfos.get(edge.getTask().getSymbol());
+                 tint = taskinfo.m_exetime[edge.getTaskExitIndex()];
                  edge.setExeTime(tint);
-                 double idouble = taskinfos.get(edge.getTask().getSymbol()).m_probability[edge.getTaskExitIndex()];
+                 double idouble = taskinfo.m_probability[edge.getTaskExitIndex()];
                  edge.setProbability(idouble);
+                 if(taskinfo.m_byObj != -1) {
+                     ((FlagState)edge.getSource()).setByObj(taskinfo.m_byObj);
+                 }
                }
              }
            }
@@ -478,7 +514,8 @@ public class Main {
                           (cdname.equals("MDRunner")) ||
                           (cdname.equals("Stage")) ||
                           (cdname.equals("AppDemoRunner")) ||
-                          (cdname.equals("FilterBankAtom"))) {
+                          (cdname.equals("FilterBankAtom")) ||
+                          (cdname.equals("Grid"))) {
                          newRate = 16;
                        } else if(cdname.equals("SentenceParser")) {
                          newRate = 4;
@@ -554,7 +591,7 @@ public class Main {
        // Create a new output stream for the standard output.
        PrintStream stdout  = null;
        try {
-         stdout = new PrintStream(new FileOutputStream("SimulatorResult.out"));
+         stdout = new PrintStream(new FileOutputStream("/scratch/SimulatorResult.out"));
        } catch (Exception e) {
          // Sigh.  Couldn't open the file.
          System.out.println("Redirect:  Unable to open output file!");
@@ -590,63 +627,55 @@ public class Main {
 
        //simulate these schedulings
        ScheduleSimulator scheduleSimulator = new ScheduleSimulator(scheduleAnalysis.getCoreNum(), state, ta);
-       Iterator it_scheduling = scheduleAnalysis.getSchedulingsIter();
-       int index = 0;
+       Vector<Vector<Schedule>> schedulings = scheduleAnalysis.getSchedulings();
        Vector<Integer> selectedScheduling = new Vector<Integer>();
        int processTime = Integer.MAX_VALUE;
-       while(it_scheduling.hasNext()) {
-         Vector<Schedule> scheduling = (Vector<Schedule>)it_scheduling.next();
-         scheduleSimulator.setScheduling(scheduling);
-         int tmpTime = scheduleSimulator.process();
-         if(tmpTime < processTime) {
-           selectedScheduling.clear();
-           selectedScheduling.add(index);
-           processTime = tmpTime;
-         } else if(tmpTime == processTime) {
-           selectedScheduling.add(index);
-         }
-         scheduling = null;
-         index++;
+       if(schedulings.size() > 1500) {
+           int index = 0;
+           int upperbound = schedulings.size();
+           long seed = 0;
+           java.util.Random r = new java.util.Random(seed);
+           for(int ii = 0; ii < 1500; ii++) {
+               index = (int)((Math.abs((double)r.nextInt() / (double)Integer.MAX_VALUE)) * upperbound);
+               System.out.println("Scheduling index:" + index);
+               //System.err.println("Scheduling index:" + index);
+               Vector<Schedule> scheduling = schedulings.elementAt(index);
+               scheduleSimulator.setScheduling(scheduling);
+               int tmpTime = scheduleSimulator.process();
+               if(tmpTime < processTime) {
+                   selectedScheduling.clear();
+                   selectedScheduling.add(index);
+                   processTime = tmpTime;
+               } else if(tmpTime == processTime) {
+                   selectedScheduling.add(index);
+               }
+               scheduling = null;
+           }
+       } else {
+           Iterator it_scheduling = scheduleAnalysis.getSchedulingsIter();
+           int index = 0;
+           while(it_scheduling.hasNext()) {
+               Vector<Schedule> scheduling = (Vector<Schedule>)it_scheduling.next();
+               scheduleSimulator.setScheduling(scheduling);
+               int tmpTime = scheduleSimulator.process();
+               if(tmpTime < processTime) {
+                   selectedScheduling.clear();
+                   selectedScheduling.add(index);
+                   processTime = tmpTime;
+               } else if(tmpTime == processTime) {
+                   selectedScheduling.add(index);
+               }
+               scheduling = null;
+               index++;
+           }
        }
+
        System.out.print("Selected schedulings with least exectution time " + processTime + ": \n\t");
        for(int i = 0; i < selectedScheduling.size(); i++) {
          System.out.print((selectedScheduling.elementAt(i) + 1) + ", ");
        }
        System.out.println();
 
-       /*ScheduleSimulator scheduleSimulator = new ScheduleSimulator(4, state, ta);
-          Vector<Schedule> scheduling = new Vector<Schedule>();
-          for(int i = 0; i < 4; i++) {
-           Schedule schedule = new Schedule(i);
-           scheduling.add(schedule);
-          }
-          Iterator it_tasks = state.getTaskSymbolTable().getAllDescriptorsIterator();
-          while(it_tasks.hasNext()) {
-           TaskDescriptor td = (TaskDescriptor)it_tasks.next();
-           if(td.getSymbol().equals("t10")) {
-               scheduling.elementAt(1).addTask(td);
-           } else {
-               scheduling.elementAt(0).addTask(td);
-           }
-          }
-          ClassDescriptor cd = (ClassDescriptor)state.getClassSymbolTable().get("E");
-          scheduling.elementAt(0).addTargetCore(cd, 1);
-          scheduleSimulator.setScheduling(scheduling);
-          scheduleSimulator.process();
-
-          Vector<Schedule> scheduling1 = new Vector<Schedule>();
-          for(int i = 0; i < 4; i++) {
-           Schedule schedule = new Schedule(i);
-           scheduling1.add(schedule);
-          }
-          Iterator it_tasks1 = state.getTaskSymbolTable().getAllDescriptorsIterator();
-          while(it_tasks1.hasNext()) {
-           TaskDescriptor td = (TaskDescriptor)it_tasks1.next();
-           scheduling1.elementAt(0).addTask(td);
-          }
-          scheduleSimulator.setScheduling(scheduling1);
-          scheduleSimulator.process();*/
-
        // Close the streams.
        try {
          stdout.close();
@@ -736,6 +765,7 @@ public class Main {
       public int[] m_exetime;
       public double[] m_probability;
       public Vector<Hashtable<String, Integer>> m_newobjinfo;
+      public int m_byObj;
       
       public TaskInfo(int numofexits) {
          this.m_numofexits = numofexits;
@@ -745,6 +775,7 @@ public class Main {
          for(int i = 0; i < this.m_numofexits; i++) {
              this.m_newobjinfo.add(null);
          }
+         this.m_byObj = -1;
       }
   }
 }
index aef2a45a45588b862d50af5ad0975742d574737e..237a1eb810fcf23742e8c0c0d707b4fe6b5de8a9 100644 (file)
@@ -3985,6 +3985,7 @@ parameterpresent:
 #ifdef RAWDEBUG
          raw_test_pass_reg(x);
 #endif
+         raw_test_pass_reg(x);
          raw_test_done(0xa009);
 #else
          exit(-1);
index 3681a9204effbb1e813ff8ba6e1eaa4fbb84b989..20ed204c69d20dc380d3ce8f5cbb7d3e9a760f13 100755 (executable)
@@ -4,8 +4,10 @@ ARG2=$2
 shift
 shift
 
+dir=`pwd`
+
 echo Doing Test $ARG1
-../buildscript -mainclass $ARG1 $ARG2 -o $ARG1 &>/dev/null
+../buildscript -robustroot ${dir}/../ -mainclass $ARG1 $ARG2 -o $ARG1 &>/dev/null
 $ARG1.bin $@ &> output/$ARG1.output
 diff output/$ARG1.output output/$ARG1.output.goal
 rm $ARG1.bin
index 332b24d563fce86f5d8112430e8a523912b7804f..c5b34f546e645f464c2c17698f6d76156d2806df 100755 (executable)
@@ -24,6 +24,8 @@ echo "-rawconfig config raw simulator as 4xn (should be used together with -raw)
 echo "-rawpath print out execute path information for raw version (should be used together with -raw)"
 echo "-useprofile use profiling data for scheduling (should be used together with -raw)"
 echo -threadsimulate generate multi-thread simulate version binary
+echo -printscheduling print out scheduling graphs
+echo -printschedulesim print out scheduling simulator result graphs
 echo -optional enable optional
 echo -debug generate debug symbols
 echo -prefetch do prefetch analysis