bug fix in scheduling
authorjzhou <jzhou>
Sun, 15 Nov 2009 02:53:36 +0000 (02:53 +0000)
committerjzhou <jzhou>
Sun, 15 Nov 2009 02:53:36 +0000 (02:53 +0000)
13 files changed:
Robust/src/Analysis/Scheduling/MCImplSynthesis.java
Robust/src/Analysis/Scheduling/ScheduleAnalysis.java
Robust/src/Analysis/Scheduling/ScheduleNode.java
Robust/src/Analysis/Scheduling/ScheduleSimulator.java
Robust/src/Analysis/Scheduling/SchedulingUtil.java
Robust/src/Analysis/Scheduling/SimExecutionEdge.java
Robust/src/Analysis/Scheduling/TaskSimulator.java
Robust/src/Analysis/TaskStateAnalysis/FEdge.java
Robust/src/Analysis/TaskStateAnalysis/FlagState.java
Robust/src/Runtime/multicoreruntime.h
Robust/src/Runtime/multicoretask.c
Robust/src/Runtime/socket.c
Robust/src/buildscript

index 544f29cd5570b64c1953110f33659746168f4412..93252182a46ccb8b7b885071ab3d37dfdd990287 100644 (file)
@@ -140,6 +140,7 @@ public class MCImplSynthesis {
     if(this.generateThreshold > 5) {
       this.generateThreshold = 5;
     }
+    this.scheduleSimulator.init();
 
     Vector<Vector<ScheduleNode>> scheduleGraphs = null;
     Vector<Vector<ScheduleNode>> newscheduleGraphs = 
@@ -150,10 +151,12 @@ public class MCImplSynthesis {
     Vector<Integer> selectedSchedulings = new Vector<Integer>();
     Vector<SimExecutionNode> selectedSimExeGraphs = 
       new Vector<SimExecutionNode>();
+    SimExecutionNode selectedSimExeGraph_bk = null;
 
     int tryindex = 1;
     long bestexetime = Long.MAX_VALUE;
     Random rand = new Random();
+    int threshold = this.scheduleThreshold;
     // simulate the generated schedulings and try to optimize it
     do {
       System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n");
@@ -204,35 +207,79 @@ public class MCImplSynthesis {
             snode.getClassNodes().clear();
           }
           schedulinggraph.clear();
+          selectedSimExeGraph_bk = null;
         }
         scheduling = schedulings.elementAt(selectedSchedulings.elementAt(0));
         schedulinggraph = scheduleGraphs.elementAt(
             selectedSchedulings.elementAt(0));
+        selectedSimExeGraph_bk = selectedSimExeGraphs.elementAt(0);
+        
         System.out.print("end of: #" + tryindex + " (bestexetime: " 
             + bestexetime + ")\n");
         System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n");
         tryindex++;
+        threshold = this.scheduleThreshold;
       } else if(tmpexetime == bestexetime) {
         System.out.print("end of: #" + tryindex + " (bestexetime: " 
             + bestexetime + ")\n");
         System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n");
         tryindex++;
+        threshold = this.scheduleThreshold;
         if((Math.abs(rand.nextInt()) % 100) < this.probThreshold) {
           break;
         }
       } else {
-        break;
+        System.out.print("end of: #" + tryindex + " (bestexetime: " 
+            + bestexetime + ")\n");
+        System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+        tryindex++;
+        if(threshold == this.scheduleThreshold) {
+          if(scheduleGraphs != null) {
+            scheduleGraphs.clear();
+          }
+          scheduleGraphs.addElement(schedulinggraph);
+          if(selectedSchedulings != null) {
+            selectedSchedulings.clear();
+          }
+          selectedSchedulings.addElement(Integer.valueOf(0));
+          if(selectedSimExeGraphs != null) {
+            selectedSimExeGraphs.clear();
+          }
+          selectedSimExeGraphs.addElement(selectedSimExeGraph_bk);
+        }
+        threshold += 10;
+        if((Math.abs(rand.nextInt()) % 100) < this.probThreshold + 1) {
+          break;
+        }
+        //break;
       }
 
       //if(tooptimize) {
       // try to optimize the best one scheduling
+      //do {
       newscheduleGraphs = optimizeScheduling(scheduleGraphs, 
           selectedSchedulings, 
           selectedSimExeGraphs,
           gid,
-          this.scheduleThreshold);
+          threshold);
+      /*if(newscheduleGraphs != null) {
+        if(this.generateThreshold < 30) {
+          this.generateThreshold = 30;
+        }
+        break;
+      } else {
+        threshold += 10;
+        if(this.generateThreshold > 0) {
+          this.generateThreshold -= 3;
+        }
+        if((Math.abs(rand.nextInt()) % 10000) < this.probThreshold + 1) {
+          break;
+        }
+      }
+      }while(true);*/
       if(remove) {
         scheduleGraphs.removeElementAt(selectedSchedulings.elementAt(0));
+        selectedSimExeGraphs.removeElementAt(0);
       }
       /*} else {
         break;
@@ -330,6 +377,7 @@ public class MCImplSynthesis {
       // Generate all possible schedulings
       this.scheduleAnalysis.setScheduleThreshold(Integer.MAX_VALUE);
       this.scheduleAnalysis.schedule(-1, multiparamtds);
+      this.scheduleSimulator.init();
 
       Vector<Vector<ScheduleNode>> totestscheduleGraphs = 
         this.scheduleAnalysis.getScheduleGraphs();
@@ -600,6 +648,10 @@ public class MCImplSynthesis {
           selectedScheduleGraphs.elementAt(i));
       SimExecutionNode startnode = selectedSimExeGraphs.elementAt(i);
       Vector<SimExecutionEdge> criticalPath = analyzeCriticalPath(startnode); 
+      // for Test
+      if(this.state.PRINTCRITICALPATH) {
+        System.err.println("gid: " + lgid + " endpoint: " + startnode.getTimepoint());
+      }
       Vector<Vector<ScheduleNode>> tmposchedulegraphs = 
         optimizeCriticalPath(schedulegraph, 
                              criticalPath,
@@ -618,7 +670,7 @@ public class MCImplSynthesis {
           tmposchedulegraphs = null;
           break;
         }
-      }
+      } 
       schedulegraph = null;
       criticalPath = null;
       tmposchedulegraphs = null;
@@ -651,7 +703,7 @@ public class MCImplSynthesis {
         (Iterator<SimExecutionEdge>)snode.inedges();
       while(it_iedges.hasNext()) {
         SimExecutionEdge sedge = it_iedges.next();
-        if(sedge.getWeight() != 0) {    
+        //if(sedge.getWeight() != 0) {    
           SimExecutionNode tsnode = (SimExecutionNode)(sedge.getSource());
           if(tsnode.getTimepoint() + sedge.getWeight() == snode.getTimepoint()) {
             nsnode = tsnode;
@@ -659,7 +711,7 @@ public class MCImplSynthesis {
             sum += sedge.getWeight();
             break;
           }
-        }
+        //}
       }
       it_iedges = null;
       snode = nsnode;
@@ -731,14 +783,17 @@ public class MCImplSynthesis {
     for(int i = 0; i < criticalPath.size(); i++) {
       SimExecutionEdge seedge = criticalPath.elementAt(i);
       long starttime = seedge.getBestStartPoint();
-      if(starttime < ((SimExecutionNode)seedge.getSource()).getTimepoint()) {
+      if((starttime < ((SimExecutionNode)seedge.getSource()).getTimepoint()) 
+          && (seedge.getTd() != null)){
+        // Note: must be a task related edge, can not be an object transfer edge
         // no restrictions due to data dependencies
         // have potential to be parallelled and start execution earlier
         seedge.setFixedTime(false);
         // consider to optimize it only when its predicates can NOT 
         // be optimized, otherwise first considering optimize its predicates
-        SimExecutionEdge lastpredicateedge = seedge.getLastpredicateEdge();
-        if(lastpredicateedge.isFixedTime()) {                  
+        //SimExecutionEdge lastpredicateedge = seedge.getLastpredicateEdge();
+        // TODO
+        //if(lastpredicateedge.isFixedTime()) {                        
           int corenum = seedge.getCoreNum();
           if(!toselects.containsKey(starttime)) {
             toselects.put(starttime, 
@@ -749,7 +804,7 @@ public class MCImplSynthesis {
                 new Vector<SimExecutionEdge>());
           }
           toselects.get(starttime).get(corenum).add(seedge);
-        }
+        //}
       }
     }
 
@@ -985,8 +1040,9 @@ public class MCImplSynthesis {
             }
           }
           it_cnodes = null;
+
           // split the node
-          ScheduleNode splitnode = snode.spliteClassNode(tosplit);
+          ScheduleNode splitnode = snode.spliteClassNode(tosplit);          
           newscheduleGraph.add(splitnode);
           tocombines.add(splitnode);
           tosplit = null;
@@ -1011,8 +1067,14 @@ public class MCImplSynthesis {
 
     Vector<Vector<ScheduleNode>> rootNodes =  
       SchedulingUtil.rangeScheduleNodes(roots);
+    if(rootNodes == null) {
+      return optimizeschedulegraphs;
+    }
     Vector<Vector<ScheduleNode>> nodes2combine = 
       SchedulingUtil.rangeScheduleNodes(tocombines);
+    if(nodes2combine == null) {
+      return optimizeschedulegraphs;
+    }
 
     CombinationUtil.CombineGenerator cGen = 
       CombinationUtil.allocateCombineGenerator(rootNodes, nodes2combine);
@@ -1039,6 +1101,13 @@ public class MCImplSynthesis {
     cGen.clear();
     rootNodes = null;
     nodes2combine = null;
+    for(int j = 0; j < newscheduleGraph.size(); j++) {
+      ScheduleNode snode = newscheduleGraph.elementAt(j);
+      snode.getEdgeVector().clear();
+      snode.getInedgeVector().clear();
+      snode.getScheduleEdges().clear();
+      snode.getClassNodes().clear();
+    }
     newscheduleGraph = null;
     scheduleEdges.clear();
     scheduleEdges = null;
index 181296f39ddbfe7c3d33317e131714d40e68b0ee..0a4e6cc54bcd99e6d9204316a417158a4199aa47 100644 (file)
@@ -44,7 +44,7 @@ public class ScheduleAnalysis {
     this.scheduleGraphs = null;
     this.td2maincd = null;
   }
-
+  
   public void setTransThreshold(int tt) {
     this.transThreshold = tt;
   }
@@ -158,6 +158,11 @@ public class ScheduleAnalysis {
                     if(taskinfo.m_byObj != -1) {
                       ((FlagState)pfe.getSource()).setByObj(taskinfo.m_byObj);
                     }
+                    // TODO for test
+                    /*System.err.println("task " + td.getSymbol() + " exit# " + 
+                        pfe.getTaskExitIndex() + " exetime: " + pfe.getExeTime() 
+                        + " prob: " + pfe.getProbability() + "% newobj: "
+                         + pfe.getNewObjInfoHashtable().size());*/
                   }
                   fev = null;
                 }
@@ -184,6 +189,10 @@ public class ScheduleAnalysis {
               if(taskinfo.m_byObj != -1) {
                 ((FlagState)edge.getSource()).setByObj(taskinfo.m_byObj);
               }
+              // TODO for test
+              /*System.err.println("task " + edge.getTask().getSymbol() + " exit# " + 
+                  edge.getTaskExitIndex() + " exetime: " + edge.getExeTime() 
+                  + " prob: " + edge.getProbability());*/
             }
             it_edges = null;
           }
@@ -659,20 +668,23 @@ public class ScheduleAnalysis {
     }
   }
   
-  private void handleDescenSEs(Vector<ScheduleEdge> ses) {
-    ScheduleEdge tempse = ses.elementAt(0);
-    long temptime = tempse.getListExeTime();
-    // find out the ScheduleEdge with least exeTime
-    for(int k = 1; k < ses.size(); k++) {
-      long ttemp = ses.elementAt(k).getListExeTime();
-      if(ttemp < temptime) {
-        tempse = ses.elementAt(k);
-        temptime = ttemp;
-      } // if(ttemp < temptime)
-    } // for(int k = 1; k < ses.size(); k++)
-    // handle the tempse
-    handleScheduleEdge(tempse, true);
-    ses.removeElement(tempse);
+  private void handleDescenSEs(Vector<ScheduleEdge> ses,
+                               boolean isflag) {
+    if(isflag) {
+      ScheduleEdge tempse = ses.elementAt(0);
+      long temptime = tempse.getListExeTime();
+      // find out the ScheduleEdge with least exeTime
+      for(int k = 1; k < ses.size(); k++) {
+        long ttemp = ses.elementAt(k).getListExeTime();
+        if(ttemp < temptime) {
+          tempse = ses.elementAt(k);
+          temptime = ttemp;
+        } // if(ttemp < temptime)
+      } // for(int k = 1; k < ses.size(); k++)
+      // handle the tempse
+      handleScheduleEdge(tempse, true);
+      ses.removeElement(tempse);
+    }
     // handle other ScheduleEdges
     for(int k = 0; k < ses.size(); k++) {
       handleScheduleEdge(ses.elementAt(k), false);
@@ -751,7 +763,8 @@ public class ScheduleAnalysis {
                 for(int j = 0; j < fes.size(); j++) {
                   FEdge tempfe = fes.elementAt(j);
                   Vector<ScheduleEdge> ses = fe2ses.get(tempfe);
-                  this.handleDescenSEs(ses);
+                  boolean isflag = !(preSNode.edges().hasNext());
+                  this.handleDescenSEs(ses, isflag);
                   ses = null;
                   fe2ses.remove(tempfe);
                 } // for(int j = 0; j < fes.size(); j++)
@@ -796,7 +809,8 @@ public class ScheduleAnalysis {
       while(it_keys.hasNext()) {
         FEdge tempfe = (FEdge)it_keys.next();
         Vector<ScheduleEdge> ses = fe2ses.get(tempfe);
-        this.handleDescenSEs(ses);
+        boolean isflag = !(tempfe.getTarget().edges().hasNext());
+        this.handleDescenSEs(ses, isflag);
         ses = null;
       }
       keys = null;
index 060d7da1bb8f1dad75ed2920420343e9f59f3349..031e74ede7a3cb3bdb3b9895366060cd65a0caeb 100644 (file)
@@ -440,6 +440,9 @@ public class ScheduleNode extends GraphNode implements Cloneable {
   
   public ScheduleNode spliteClassNode(ClassNode cd) {
       ScheduleNode sNode = new ScheduleNode(cd, this.gid);
+      // clean all inedges and edges
+      sNode.edges.clear();
+      sNode.inedges.clear();
       
       this.classNodes.remove(cd);
       cd.setScheduleNode(sNode);
@@ -449,7 +452,7 @@ public class ScheduleNode extends GraphNode implements Cloneable {
          e.printStackTrace();
       }
       
-      // redirct all corresponding internal ScheduleEdge to the new snode
+      // redirect all corresponding internal ScheduleEdge to the new snode
       Iterator it_innersEdges = this.scheduleEdges.iterator();
       Vector<ScheduleEdge> toremove = new Vector<ScheduleEdge>();
       if(it_innersEdges != null) {
@@ -476,15 +479,22 @@ public class ScheduleNode extends GraphNode implements Cloneable {
          }
       }
       toremove.clear();
+      
       // redirect external ScheudleEdges out of this cd to the new ScheduleNode
       Iterator it_exsEdges = this.edges();
       while(it_exsEdges.hasNext()) {
          ScheduleEdge tse = (ScheduleEdge)it_exsEdges.next();
          if(tse.getSourceCNode().equals(cd)) {
-             this.removeEdge(tse);
-             sNode.addEdge(tse);
+        toremove.add(tse);
+             //this.removeEdge(tse);
+             //sNode.addEdge(tse);
+        tse.setSource(sNode);
+        sNode.edges.addElement(tse);
          }
       }
+      this.edges.removeAll(toremove);
+      toremove.clear();
+      
       it_exsEdges = null;
       // redirect inedges whose target is this Classnode to new ScheduleNode
       Iterator it_insEdges = this.inedges();
@@ -493,6 +503,7 @@ public class ScheduleNode extends GraphNode implements Cloneable {
          if(tse.getTargetCNode().equals(cd)) {
              toremove.add(tse);
              tse.setTarget(sNode);
+          sNode.inedges.addElement(tse);
          }
       }
       it_insEdges = null;
index 48b82a0996aa19c3464d2179ccd0ac5214d724b4..2459b5f53a241d03981f01baca4a4c868b5408d7 100644 (file)
@@ -6,9 +6,11 @@ import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.Queue;
+import java.util.Set;
 import java.util.Vector;
 import java.util.Map.Entry;
 
+import Analysis.TaskStateAnalysis.FEdge;
 import Analysis.TaskStateAnalysis.FlagState;
 import Analysis.TaskStateAnalysis.TaskAnalysis;
 import IR.ClassDescriptor;
@@ -23,6 +25,9 @@ public class ScheduleSimulator {
   private Vector<TaskSimulator> tasks;
   private long processTime;
   private int invoketime;
+  
+  private Vector<FlagState> fstates;
+  private Vector<FEdge> fedges;
 
   State state;
   TaskAnalysis taskanalysis;
@@ -38,6 +43,8 @@ public class ScheduleSimulator {
     this.invoketime = 0;
     this.state = state;
     this.taskanalysis = taskanalysis;
+    this.fstates = new Vector<FlagState>();
+    this.fedges = new Vector<FEdge>();    
   }
 
   public ScheduleSimulator(int corenum, 
@@ -56,9 +63,34 @@ public class ScheduleSimulator {
     this.invoketime = 0;
     this.state = state;
     this.taskanalysis = taskanalysis;
+    this.fstates = new Vector<FlagState>();
+    this.fedges = new Vector<FEdge>();
     applyScheduling();
   }
   
+  public void init() {
+    // gather all the flag states and fedges together
+    Iterator it_classes = this.state.getClassSymbolTable().getDescriptorsIterator();
+    while(it_classes.hasNext()) {
+      ClassDescriptor cd = (ClassDescriptor) it_classes.next();
+      Iterator<FlagState> it_fStates = this.taskanalysis.getFlagStates(cd).iterator();
+      
+      while(it_fStates.hasNext()) {
+        FlagState fs = it_fStates.next();
+        if(!this.fstates.contains(fs)) {
+          this.fstates.addElement(fs);
+        }
+        Iterator<FEdge> it_fe = (Iterator<FEdge>)fs.edges();
+        while(it_fe.hasNext()) {
+          FEdge next = it_fe.next();
+          if(!this.fedges.contains(next)) {
+            this.fedges.addElement(next);
+          }
+        }
+      }
+    }
+  }
+  
   public long simulate(Vector<Vector<Schedule>> schedulings,
                      Vector<Integer> selectedScheduling,
                      Vector<SimExecutionNode> selectedSimExeGraphs) {      
@@ -206,6 +238,18 @@ public class ScheduleSimulator {
   public Vector<TaskSimulator> getTasks() {
     return tasks;
   }
+  
+  private void init4Simulation() {
+//  TODO for test
+    /*System.err.println("======Init for Sim # " 
+        + this.scheduling.elementAt(0).getGid() + "======");*/
+    for(int i = 0; i < this.fstates.size(); i++) {
+      this.fstates.elementAt(i).init4Simulate();
+    }
+    for(int i = 0; i < this.fedges.size(); i++) {
+      this.fedges.elementAt(i).init4Simulate();
+    }
+  }
 
   public long process(Vector<CheckPoint> checkpoints,
                      Vector<SimExecutionNode> simexegraph) {
@@ -214,6 +258,9 @@ public class ScheduleSimulator {
     this.invoketime++;
     this.processTime = 0;
     
+    // initialization
+    this.init4Simulation();
+    
     // helper structures for building SimExecutionGraph
     Hashtable<SimExecutionNode, Action> senode2action = 
            new Hashtable<SimExecutionNode, Action>();
@@ -427,7 +474,7 @@ public class ScheduleSimulator {
 
     int gid = this.scheduling.elementAt(0).getGid();
     if(this.state.PRINTSCHEDULESIM) {
-       SchedulingUtil.printSimulationResult(this.state.outputdir + "SimulatorResult_" + gid + ".dot", 
+       SchedulingUtil.printSimulationResult(this.state.outputdir + "SimGraph/" + "SimulatorResult_" + gid + ".dot", 
                                             this.processTime,
                                             this.coreNum, 
                                             checkpoints);
index a20dc7483767e73f1cbbc592266a475329b812c6..3df8d8900312242ccce9ea419d12aa63b8ae7992 100644 (file)
@@ -165,40 +165,47 @@ public class SchedulingUtil {
     }
     
     //  Organize the scheduleNodes in order of their cid
-    public static Vector<Vector<ScheduleNode>> rangeScheduleNodes(Vector<ScheduleNode> scheduleNodes) {
-       Vector<Vector<ScheduleNode>> sNodeVecs = new Vector<Vector<ScheduleNode>>();
-       
-       for(int i = 0; i < scheduleNodes.size(); i++) {
-           ScheduleNode tmpn = scheduleNodes.elementAt(i);
-           int tmpcid = tmpn.getCid();
-           int index = 0;
-           for(index = 0; index < sNodeVecs.size(); index++) {
-               if(sNodeVecs.elementAt(index).elementAt(0).getCid() > tmpcid) {
-                   // find the place to insert
-                   sNodeVecs.add(sNodeVecs.lastElement());
-                   for(int j = sNodeVecs.size() - 2; j > index; j--) {
-                       sNodeVecs.setElementAt(sNodeVecs.elementAt(j - 1), j);
-                   }
-                   sNodeVecs.setElementAt(new Vector<ScheduleNode>(), index);
-               } else if(sNodeVecs.elementAt(index).elementAt(0).getCid() == tmpcid) {
-                   break;
-               }
-           }
-           if(index == sNodeVecs.size()) {
-               sNodeVecs.add(new Vector<ScheduleNode>());
-           }
-           
-           /*int index = tmpcid;
+    public static Vector<Vector<ScheduleNode>> 
+    rangeScheduleNodes(Vector<ScheduleNode> scheduleNodes) {
+      try{  
+        Vector<Vector<ScheduleNode>> sNodeVecs = new Vector<Vector<ScheduleNode>>();
+
+        for(int i = 0; i < scheduleNodes.size(); i++) {
+          ScheduleNode tmpn = scheduleNodes.elementAt(i);
+          int tmpcid = tmpn.getCid();
+          int index = 0;
+          for(index = 0; index < sNodeVecs.size(); index++) {
+            if(sNodeVecs.elementAt(index).elementAt(0).getCid() > tmpcid) {
+              // find the place to insert
+              sNodeVecs.add(sNodeVecs.lastElement());
+              for(int j = sNodeVecs.size() - 2; j > index; j--) {
+                sNodeVecs.setElementAt(sNodeVecs.elementAt(j - 1), j);
+              }
+              sNodeVecs.setElementAt(new Vector<ScheduleNode>(), index);
+            } else if(sNodeVecs.elementAt(index).elementAt(0).getCid() == tmpcid) {
+              break;
+            }
+          }
+          if(index == sNodeVecs.size()) {
+            sNodeVecs.add(new Vector<ScheduleNode>());
+          }
+
+          /*int index = tmpcid;
            while(sNodeVecs.size() <= index) {
                sNodeVecs.add(null);
            }
            if(sNodeVecs.elementAt(index) == null) {
                sNodeVecs.setElementAt(new Vector<ScheduleNode>(), index);
            }*/
-           sNodeVecs.elementAt(index).add(tmpn);
-       }
-       
-       return sNodeVecs;
+          sNodeVecs.elementAt(index).add(tmpn);
+        }
+
+        return sNodeVecs;
+      } catch(Error e) {
+        System.err.println("Error in rangeScheduleNodes");
+        e.printStackTrace();
+        return null;
+      }
     }
 
   /*public static int maxDivisor(int l, int r) {
@@ -839,17 +846,20 @@ public class SchedulingUtil {
                  label = startnode.getCoreNum() + ":" + startnode.getTimepoint();
                  output.println("\t" + startnode.getLabel() + " [label=\"" 
                                 + label + "\" ];");
+          nodes.addElement(startnode);
              }
              if(!nodes.contains(endnode)) {
                  label = endnode.getCoreNum() + ":" + endnode.getTimepoint();
                  output.println("\t" + endnode.getLabel() + " [label=\"" 
                                 + label + "\" ];");
+          nodes.addElement(endnode);
              }
              output.println("\t" + startnode.getLabel() + " -> " + endnode.getLabel() 
                             + " [" + "label=\"" + seedge.getLabel() + "\"];");
          }
          output.println("}");
          output.close();
+      nodes.clear();
          nodes = null;
       } catch (Exception e) {
          e.printStackTrace();
index a8edc42bc8d729120949c23d3b880ed13d805c87..8d070015d73001b8d6efd6849f282fab6701ad05 100644 (file)
@@ -41,7 +41,7 @@ public class SimExecutionEdge extends Edge {
     
     public long getBestStartPoint() {
        if(this.bestStartPoint == -1) {
-           if(this.predicates.size() > 0) {
+           if((this.predicates != null) && (this.predicates.size() > 0)) {
                // have predicates
                long starttime = 0;
                // check the latest finish time of all the predicates
index 9e1044f8d0e8f3f093476da6063a9c82f8c0329e..943476412b4f322df64d2e0a334cbdb9cd74794f 100644 (file)
@@ -287,12 +287,23 @@ public class TaskSimulator {
        paraQueues.elementAt(j).remove(tpara);
       }
     }
+    long ftime = 0;
     for(int i = 0; i < paraQueues.size(); i++) {
       ObjectSimulator tpara = paraQueues.elementAt(i).peek();
 
       FlagState tfstate = tpara.getCurrentFS();
       FEdge toexecute = tfstate.process(td);
       finishTime += toexecute.getExeTime();
+      // TODO for test
+      if(ftime == 0) {
+        ftime = toexecute.getExeTime();
+      } else if(ftime != toexecute.getExeTime()) {
+        //System.err.println("error for simulation: " + td.getSymbol());
+      }
+      // TODO for test
+      /*if(td.getSymbol().equals("addIYLM")) {
+        System.err.println("# " + i + " time: " + toexecute.getExeTime());
+      }*/
       if((toexecute.getNewObjInfoHashtable() != null) 
              && (toexecute.getNewObjInfoHashtable().size() > 0)) {
        // have new objects
@@ -314,6 +325,11 @@ public class TaskSimulator {
       tpara.increaseVersion();
     }
     finishTime /= paraQueues.size();
+//  TODO for test
+    /*if(td.getSymbol().equals("addIYLM")) {
+      System.err.println("total time: " + finishTime);
+      System.err.println("=====");
+    }*/
     this.currentRun.setFinishTime(finishTime);
     this.currentRun.setExetype(0);
   }
index 751574c7b44beee697236f241e6d62184455c8d5..71d4a45ba308c2938edfcb412d8f9be019e58498 100644 (file)
@@ -155,7 +155,9 @@ public class FEdge extends Edge {
           e.source.equals(source) &&
           e.td==td&&
           e.parameterindex==parameterindex &&
-          e.executeTime == executeTime) {
+          e.executeTime == executeTime &&
+          e.m_taskexitindex == m_taskexitindex &&
+          e.m_isbackedge == m_isbackedge) {
        if(this.newObjInfos != null) {
          if(e.newObjInfos == null) {
            return false;
@@ -194,6 +196,17 @@ public class FEdge extends Edge {
     }
     this.newObjInfos.put(cd, new NewObjInfo(newRate, probability));
   }
+  
+  public void init4Simulate() {
+    this.invokeNum = 0;
+    this.expInvokeNum = 0;
+    if(this.newObjInfos != null) {
+      Iterator<NewObjInfo> it_nobjs = this.newObjInfos.values().iterator();
+      while(it_nobjs.hasNext()) {
+        it_nobjs.next().invokeNum = 0;
+      }
+    }
+  }
 
   public void process() {
     this.invokeNum++;
index 0270fd5e5c43e38044d8d8c0e6d8ad2c37e96996..80353b03ec6dd46bd8340357dd9989c1d2b2d567 100644 (file)
@@ -438,6 +438,9 @@ public class FlagState extends GraphNode implements Cloneable {
   public FEdge process(TaskDescriptor td) {
     FEdge next = null;
     this.invokeNum++;
+    if(td.getSymbol().equals("addIYLM")) {
+      next = null;
+    }
     // refresh all the expInvokeNum of each edge
     for(int i = 0; i < this.edges.size(); i++) {
       next = (FEdge) this.edges.elementAt(i);
@@ -448,8 +451,8 @@ public class FlagState extends GraphNode implements Cloneable {
       }
     }
 
-    // find the one with the biggest gap between its actual invoke time and the expected invoke time
-    // and associated with task td
+    // find the one with the biggest gap between its actual invoke time and 
+    // the expected invoke time and associated with task td
     int index = 0;
     int gap = 0;
     double prob = 0;
index 7610b5192d8c3f9eedf52a1ee751184350ea9dcc..220b6d8ae8b3c4fe29289ecbb0ba314cc9487d35 100644 (file)
@@ -221,7 +221,7 @@ struct Queue * totransobjqueue; // queue to hold objs to be transferred
 #define BAMBOO_PAGE_SIZE (64 * 64)
 #define BAMBOO_SMEM_SIZE (BAMBOO_PAGE_SIZE)
 #else
-#define BAMBOO_NUM_PAGES (1024 * 512 * 4)
+#define BAMBOO_NUM_PAGES (1024 * 1024 * 3.5)
 #define BAMBOO_PAGE_SIZE (4096)
 #define BAMBOO_SMEM_SIZE (16 * BAMBOO_PAGE_SIZE)
 #endif
index 6447caf5b356cc0370c4427dee22a6c8ddfc5523..75a5f47cdf8d815dc18ba76aff064075f724b077 100644 (file)
@@ -1342,10 +1342,9 @@ void * smemalloc(int coren,
                             int size, 
                             int * allocsize) {
        void * mem = NULL;
-       int isize = size+(BAMBOO_CACHE_LINE_SIZE);
-       int toallocate = ((size+(BAMBOO_CACHE_LINE_SIZE))>(BAMBOO_SMEM_SIZE)) ? 
-                                    (size+(BAMBOO_CACHE_LINE_SIZE)):(BAMBOO_SMEM_SIZE);
 #ifdef MULTICORE_GC
+       int isize = size+(BAMBOO_CACHE_LINE_SIZE);
+       int toallocate = (isize>(BAMBOO_SMEM_SIZE)) ? (isize):(BAMBOO_SMEM_SIZE);
        // go through free mem list for suitable chunks
        int tofindb = 0;
        struct freeMemItem * freemem = findFreeMemChunk(coren, isize, &tofindb);
@@ -1387,8 +1386,9 @@ void * smemalloc(int coren,
                }
        } else {
 #else
-       mem = mspace_calloc(bamboo_free_msp, 1, isize);
-       *allocsize = isize;
+       int toallocate = (size>(BAMBOO_SMEM_SIZE)) ? (size):(BAMBOO_SMEM_SIZE);
+       mem = mspace_calloc(bamboo_free_msp, 1, toallocate);
+       *allocsize = toallocate;
        if(mem == NULL) {
 #endif
                // no enough shared global memory
@@ -1856,16 +1856,14 @@ msg:
                  bamboo_smem_size = 0;
                  bamboo_cur_msp = 0;
          } else {
+#ifdef MULTICORE_GC
                        // fill header to store the size of this mem block
                        (*((int*)msgdata[1])) = msgdata[2];
                  bamboo_smem_size = msgdata[2] - BAMBOO_CACHE_LINE_SIZE;
-#ifdef MULTICORE_GC
                        bamboo_cur_msp = msgdata[1] + BAMBOO_CACHE_LINE_SIZE;
 #else
-                 bamboo_cur_msp = 
-                               create_mspace_with_base((void*)(msgdata[1]+BAMBOO_CACHE_LINE_SIZE),
-                                                        msgdata[2]-BAMBOO_CACHE_LINE_SIZE, 
-                                                                                                                                0);
+                 bamboo_smem_size = msgdata[2];
+                 bamboo_cur_msp =(void*)(msgdata[1]);
 #endif
          }
          smemflag = true;
index 7c079ac095d87e1abb93c0b2662ac1f71aba380c..e9e73d45ec9efdfdd85611d15602356962af091a 100644 (file)
@@ -180,10 +180,10 @@ struct ArrayObject * CALL01(___InetAddress______getHostByName_____AR_B, struct A
   }
 
   return arraybytearray;
-#endif
-       }
-       else
+       } else {
                return NULL;
+       }
+#endif
 }
 
 
index 7526510feeeb198ba92c533292977d6fe17d17cf..8b15dd915c322c9d4519dce8ddeecbe45d5595de 100755 (executable)
@@ -487,7 +487,7 @@ fi
 
 if $MULTICOREFLAG
 then
-if ! ${ROBUSTROOT}/ourjava -Xms50m -Xmx2500m $JAVAFORWARDOPTS -classpath $ROBUSTROOT/../cup/:$ROBUSTROOT Main.Main -classlibrary \
+if ! ${ROBUSTROOT}/ourjava -Xms50m -Xmx1500m $JAVAFORWARDOPTS -classpath $ROBUSTROOT/../cup/:$ROBUSTROOT Main.Main -classlibrary \
 $ROBUSTROOT/ClassLibrary/ -classlibrary $ROBUSTROOT/ClassLibrary/gnu/ \
 -dir $BUILDDIR $JAVAOPTS $SRCFILES
 then exit $?
@@ -626,7 +626,7 @@ cd $TILERADIR
 make clean
 rm ./*
 
-export TILERACFLAGS="-DTASK -DMULTICORE -DCLOSE_PRINT"
+export TILERACFLAGS="-DTASK -DMULTICORE -DCLOSE_PRINT -DTILERA"
 
 if $CACHEFLUSHFLAG
 then # print path