bug fix
authorjzhou <jzhou>
Mon, 16 Nov 2009 02:30:42 +0000 (02:30 +0000)
committerjzhou <jzhou>
Mon, 16 Nov 2009 02:30:42 +0000 (02:30 +0000)
Robust/src/Analysis/Scheduling/MCImplSynthesis.java
Robust/src/Analysis/Scheduling/SchedulingUtil.java

index 93252182a46ccb8b7b885071ab3d37dfdd990287..b2aa32b4e31eb60659316b3e5dce74079fcfe28d 100644 (file)
@@ -1006,6 +1006,11 @@ public class MCImplSynthesis {
     // first clone the whole graph
     Vector<ScheduleNode> newscheduleGraph = 
       cloneScheduleGraph(scheduleGraph, lgid);
+    
+    if(newscheduleGraph.size() == 0) {
+      System.err.println("empty schedule graph!");
+      return optimizeschedulegraphs;
+    }
 
     // these nodes are root nodes
     Vector<ScheduleNode> roots = new Vector<ScheduleNode>();
@@ -1099,7 +1104,17 @@ public class MCImplSynthesis {
       }
     }
     cGen.clear();
+    for(int i = 0; i < rootNodes.size(); i++) {
+      if(rootNodes.elementAt(i) != null) {
+        rootNodes.elementAt(i).clear();
+      }
+    }
     rootNodes = null;
+    for(int i = 0; i < nodes2combine.size(); i++) {
+      if(nodes2combine.elementAt(i) != null) {
+        nodes2combine.elementAt(i).clear();
+      }
+    }
     nodes2combine = null;
     for(int j = 0; j < newscheduleGraph.size(); j++) {
       ScheduleNode snode = newscheduleGraph.elementAt(j);
index 3df8d8900312242ccce9ea419d12aa63b8ae7992..10e8c7ff2a9f8073240d4748952aa9cd980939ff 100644 (file)
@@ -177,11 +177,13 @@ public class SchedulingUtil {
           for(index = 0; index < sNodeVecs.size(); index++) {
             if(sNodeVecs.elementAt(index).elementAt(0).getCid() > tmpcid) {
               // find the place to insert
-              sNodeVecs.add(sNodeVecs.lastElement());
+              sNodeVecs.insertElementAt(new Vector<ScheduleNode>(), index);
+              /*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);
+              sNodeVecs.setElementAt(new Vector<ScheduleNode>(), index);*/
+              break;
             } else if(sNodeVecs.elementAt(index).elementAt(0).getCid() == tmpcid) {
               break;
             }
@@ -197,13 +199,16 @@ public class SchedulingUtil {
            if(sNodeVecs.elementAt(index) == null) {
                sNodeVecs.setElementAt(new Vector<ScheduleNode>(), index);
            }*/
-          sNodeVecs.elementAt(index).add(tmpn);
+          if(!sNodeVecs.elementAt(index).contains(tmpn)) {
+            sNodeVecs.elementAt(index).addElement(tmpn);
+          }
         }
 
         return sNodeVecs;
       } catch(Error e) {
-        System.err.println("Error in rangeScheduleNodes");
+        System.err.println("Error in rangeScheduleNodes: " + scheduleNodes.size());
         e.printStackTrace();
+        //System.exit(-1);
         return null;
       }
     }