bug fixing in Scheduling analysis(combination stage)
authorjzhou <jzhou>
Mon, 11 Aug 2008 20:16:49 +0000 (20:16 +0000)
committerjzhou <jzhou>
Mon, 11 Aug 2008 20:16:49 +0000 (20:16 +0000)
Robust/src/Analysis/Scheduling/CombinationUtil.java
Robust/src/Analysis/Scheduling/ScheduleAnalysis.java
Robust/src/Analysis/TaskStateAnalysis/FlagState.java
Robust/src/Benchmarks/Scheduling/JGFSeries/JGFSeriesBench.java
Robust/src/ClassLibrary/Math.java
Robust/src/IR/Flat/BuildCodeMultiCore.java
Robust/src/Main/Main.java
Robust/src/Runtime/math.c
Robust/src/Runtime/multicoretask.c
Robust/src/Runtime/task.c

index 5ea3d89bbb569f2b6da9be3d8dca42022668d2f0..6c180a70ae073424ef2be9c70377257aec65c24e 100644 (file)
@@ -51,9 +51,12 @@ public class CombinationUtil {
                int next = 1;
                trial = trial(num2choose, next);
            } else {
                int next = 1;
                trial = trial(num2choose, next);
            } else {
+               if(this.rootNodes.size() == 1) {
+                   return false;
+               }
                int next = this.rootNodes.lastElement().elementAt(0).getCid() + 1;
                int num2choose = 0;
                int next = this.rootNodes.lastElement().elementAt(0).getCid() + 1;
                int num2choose = 0;
-               if(next == this.sNodeVecs.size()) {
+               while(next == this.sNodeVecs.size()) {
                    // backtrack
                    num2choose = this.rootNodes.lastElement().size();
                    this.rootNodes.removeElementAt(this.rootNodes.size() - 1);
                    // backtrack
                    num2choose = this.rootNodes.lastElement().size();
                    this.rootNodes.removeElementAt(this.rootNodes.size() - 1);
@@ -62,8 +65,7 @@ public class CombinationUtil {
                        return false;
                    }
                    next = this.rootNodes.lastElement().elementAt(0).getCid() + 1;
                        return false;
                    }
                    next = this.rootNodes.lastElement().elementAt(0).getCid() + 1;
-                   
-               } 
+               }
                num2choose++;
                // reduce one from the last one
                this.rootNodes.lastElement().removeElementAt(this.rootNodes.lastElement().size() - 1);
                num2choose++;
                // reduce one from the last one
                this.rootNodes.lastElement().removeElementAt(this.rootNodes.lastElement().size() - 1);
@@ -81,10 +83,14 @@ public class CombinationUtil {
                for(int i = 1; i < this.rootNodes.size(); i++) {
                    int tmp = this.rootNodes.elementAt(i).elementAt(0).getCid();
                    while(next < tmp) {
                for(int i = 1; i < this.rootNodes.size(); i++) {
                    int tmp = this.rootNodes.elementAt(i).elementAt(0).getCid();
                    while(next < tmp) {
-                       this.node2Combine.add(new Vector<ScheduleNode>());
                        Vector<ScheduleNode> toadd = this.sNodeVecs.elementAt(next);
                        Vector<ScheduleNode> toadd = this.sNodeVecs.elementAt(next);
-                       for(index = 0; index < toadd.size(); index++) {
-                           this.node2Combine.lastElement().add(toadd.elementAt(index));
+                       if(toadd != null) {
+                           this.node2Combine.add(new Vector<ScheduleNode>());
+                           for(index = 0; index < toadd.size(); index++) {
+                               this.node2Combine.lastElement().add(toadd.elementAt(index));
+                           }
+                       } else {
+                           this.node2Combine.add(null);
                        }
                        next++;
                    }
                        }
                        next++;
                    }
@@ -98,10 +104,14 @@ public class CombinationUtil {
                    next++;
                }
                while(next < this.sNodeVecs.size()) {
                    next++;
                }
                while(next < this.sNodeVecs.size()) {
-                   this.node2Combine.add(new Vector<ScheduleNode>());
                    Vector<ScheduleNode> toadd = this.sNodeVecs.elementAt(next);
                    Vector<ScheduleNode> toadd = this.sNodeVecs.elementAt(next);
-                   for(index = 0; index < toadd.size(); index++) {
-                       this.node2Combine.lastElement().add(toadd.elementAt(index));
+                   if(toadd != null) {
+                       this.node2Combine.add(new Vector<ScheduleNode>());
+                       for(index = 0; index < toadd.size(); index++) {
+                           this.node2Combine.lastElement().add(toadd.elementAt(index));
+                       }
+                   } else {
+                       this.node2Combine.add(null);
                    }
                    next++;
                }
                    }
                    next++;
                }
@@ -118,14 +128,21 @@ public class CombinationUtil {
                        // no more nodes available to add
                        return false;
                    }
                        // no more nodes available to add
                        return false;
                    }
-                   this.rootNodes.add(new Vector<ScheduleNode>());
-                   first = false;
                }
                }
-               this.rootNodes.lastElement().add(this.sNodeVecs.elementAt(next).elementAt(index));
-               num2choose--;
-               index++;
-               if(index == this.sNodeVecs.elementAt(next).size()) {
-                   index = 0;
+               if(this.sNodeVecs.elementAt(next) != null) {
+                   if(first) {
+                       this.rootNodes.add(new Vector<ScheduleNode>());
+                       first = false;
+                   }
+                   this.rootNodes.lastElement().add(this.sNodeVecs.elementAt(next).elementAt(index));
+                   num2choose--;
+                   index++;
+                   if(index == this.sNodeVecs.elementAt(next).size()) {
+                       index = 0;
+                       next++;
+                       first = true;
+                   }
+               } else {
                    next++;
                    first = true;
                }
                    next++;
                    first = true;
                }
@@ -177,9 +194,13 @@ public class CombinationUtil {
            }
            this.combine = new Vector<Vector<Combine>>();
            for(int i = 0; i < this.node2Combine.size(); i++) {
            }
            this.combine = new Vector<Vector<Combine>>();
            for(int i = 0; i < this.node2Combine.size(); i++) {
-               this.combine.add(new Vector<Combine>());
-               for(int j = 0; j < this.node2Combine.elementAt(i).size(); j++) {
-                   this.combine.elementAt(i).add(new Combine(this.node2Combine.elementAt(i).elementAt(j)));
+               if(this.node2Combine.elementAt(i) == null) {
+                   this.combine.add(null);
+               } else {
+                   this.combine.add(new Vector<Combine>());
+                   for(int j = 0; j < this.node2Combine.elementAt(i).size(); j++) {
+                       this.combine.elementAt(i).add(new Combine(this.node2Combine.elementAt(i).elementAt(j)));
+                   }
                }
            }
            this.lastchoices = null;
                }
            }
            this.lastchoices = null;
@@ -206,16 +227,24 @@ public class CombinationUtil {
                    // no more available combination under this choice
                    // choose another choice
                    int next = this.node2Combine.size() - 1;
                    // no more available combination under this choice
                    // choose another choice
                    int next = this.node2Combine.size() - 1;
-                   boolean iter = false;;
+                   boolean iter = false;
                    do{
                    do{
-                       this.lastchoices[next]++;
-                       if(this.lastchoices[next] > this.node2Combine.elementAt(next).elementAt(0).getCid()) {
-                           // break the rule that a node can only be combined to nodes with smaller colorid.
-                           // backtrack
+                       if(this.node2Combine.elementAt(next) != null) {
+                           this.lastchoices[next]++;
+                           if((this.lastchoices[next] == this.rootNodes.size() ||
+                                   (this.rootNodes.elementAt(this.lastchoices[next]).elementAt(0).getCid() > 
+                                   this.node2Combine.elementAt(next).elementAt(0).getCid()))){
+                               // break the rule that a node can only be combined to nodes with smaller colorid.
+                               // or no more buckets
+                               // backtrack
+                               next--;
+                               iter = true;
+                           } else {
+                               iter = false;
+                           }
+                       } else {
                            next--;
                            iter = true;
                            next--;
                            iter = true;
-                       } else {
-                           iter = false;
                        }
                    }while(iter && !(next < 0));
                    if(next < 0) {
                        }
                    }while(iter && !(next < 0));
                    if(next < 0) {
@@ -249,22 +278,24 @@ public class CombinationUtil {
            
        private boolean firstexpand(int next, boolean first) {
            for(int i = next; i < this.node2Combine.size(); i++) {
            
        private boolean firstexpand(int next, boolean first) {
            for(int i = next; i < this.node2Combine.size(); i++) {
-               int choice = this.lastchoices[i];
-               for(int j = 0; j < this.node2Combine.elementAt(i).size(); j++) {
-                   Combine tmp = this.combine.elementAt(i).elementAt(j);
-                   if(!first) {
-                       this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
-                   }
-                   tmp.root = choice;
-                   tmp.index = 0;
-                   if(!first) {
-                       this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
+               if(this.node2Combine.elementAt(i) != null) {
+                   int choice = this.lastchoices[i];
+                   for(int j = 0; j < this.node2Combine.elementAt(i).size(); j++) {
+                       Combine tmp = this.combine.elementAt(i).elementAt(j);
+                       if(!first) {
+                           this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
+                       }
+                       tmp.root = choice;
+                       tmp.index = 0;
+                       if(!first) {
+                           this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
+                       }
                    }
                    }
-               }
-               if(first) {
-                   this.rootNStates.elementAt(choice).elementAt(0)[i] = this.node2Combine.elementAt(i).size();
-                   for(int j = 1; j < this.rootNodes.elementAt(choice).size(); j++) {
-                       this.rootNStates.elementAt(choice).elementAt(j)[i] = 0;
+                   if(first) {
+                       this.rootNStates.elementAt(choice).elementAt(0)[i] = this.node2Combine.elementAt(i).size();
+                       for(int j = 1; j < this.rootNodes.elementAt(choice).size(); j++) {
+                           this.rootNStates.elementAt(choice).elementAt(j)[i] = 0;
+                       }
                    }
                }
            }
                    }
                }
            }
@@ -272,6 +303,16 @@ public class CombinationUtil {
        }
        
        private boolean innertrial(int next, int layer) {
        }
        
        private boolean innertrial(int next, int layer) {
+           if((this.combine.elementAt(next) == null) || 
+                   (this.combine.elementAt(next).size() < 2)) {
+               // skip over empty buckets and bucket with only one obj ( make sure
+               // at least one obj is existing in the chosen bucket)
+               if(next - 1 < 0) {
+                   return false;
+               } else {
+                   return innertrial(next - 1, ++layer);
+               }
+           }
            Combine tmp = this.combine.elementAt(next).lastElement();
            // try to move it backward
            int root = tmp.root;
            Combine tmp = this.combine.elementAt(next).lastElement();
            // try to move it backward
            int root = tmp.root;
@@ -310,15 +351,28 @@ public class CombinationUtil {
                            return innertrial(next - 1, ++layer);
                        }
                    } else if(tmp.root != root) {
                            return innertrial(next - 1, ++layer);
                        }
                    } else if(tmp.root != root) {
+                       if((tmp.root == this.lastchoices[next]) && 
+                               (this.rootNStates.elementAt(this.lastchoices[next]).elementAt(0)[next] == 1)) {
+                           // only 1 obj left in the chosen bucket
+                           // can not move this one
+                           // try the bucket in node2combine before
+                           if(next - 1 < 0) {
+                               return false;
+                           } else {
+                               return innertrial(next - 1, ++layer);
+                           }
+                       }
                        this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
                        this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
-                       tmp.root = root;
+                       //tmp.root = root;
+                       int newroot = tmp.root + 1;
+                       tmp.root = newroot;
                        tmp.index = 0;
                        this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
                        // make all left things in this color bucket reset
                        tmp.index = 0;
                        this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
                        // make all left things in this color bucket reset
-                       for(t += 1; t < this.combine.elementAt(next).size(); t++) {
+                       for(t++; t < this.combine.elementAt(next).size(); t++) {
                            tmp = this.combine.elementAt(next).elementAt(t);
                            this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
                            tmp = this.combine.elementAt(next).elementAt(t);
                            this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
-                           tmp.root = root;
+                           tmp.root = newroot;
                            tmp.index = 0;
                            this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
                        }
                            tmp.index = 0;
                            this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
                        }
@@ -346,9 +400,33 @@ public class CombinationUtil {
                            }
                        } else {
                            this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
                            }
                        } else {
                            this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
+                           int tmproot = tmp.root;
+                           int tmpindex = tmp.index;
                            tmp.root = root;
                            tmp.index = index;
                            this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
                            tmp.root = root;
                            tmp.index = index;
                            this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
+                           int desroot = tmp.root;
+                           int desindex = tmp.index;
+                           // make all left things in this color bucket reset
+                           t++;
+                           boolean first = true;
+                           while(t < this.combine.elementAt(next).size()) {
+                               int k = 0;
+                               if(first) {
+                                   k = 1;
+                                   first = false;
+                               }
+                               for(; (k < this.rootNStates.elementAt(tmproot).elementAt(tmpindex)[next]) && (t < this.combine.elementAt(next).size()); t++) {
+                                   tmp = this.combine.elementAt(next).elementAt(t);
+                                   this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
+                                   tmp.root = desroot;
+                                   tmp.index = desindex;
+                                   this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
+                               }
+                               if(k == this.rootNStates.elementAt(tmproot).elementAt(tmpindex)[next]) {
+                                   desindex++;
+                               }
+                           }
                            if(layer != 0) {
                                return firstexpand(next+1, this.first4choice);
                            }
                            if(layer != 0) {
                                return firstexpand(next+1, this.first4choice);
                            }
@@ -357,14 +435,25 @@ public class CombinationUtil {
                    }
                }
            } else {
                    }
                }
            } else {
-               this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
-               tmp.root = root;
-               tmp.index = index;
-               this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
-               if(layer != 0) {
-                   return firstexpand(next+1, this.first4choice);
+               if((tmp.root != this.lastchoices[next]) || 
+                       (this.rootNStates.elementAt(this.lastchoices[next]).elementAt(0)[next] > 1)) {
+                   this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
+                   tmp.root = root;
+                   tmp.index = index;
+                   this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
+                   if(layer != 0) {
+                       return firstexpand(next+1, this.first4choice);
+                   }
+                   return true;
+               } else {
+                   // only 1 obj with the color next exist on the chosen bucket this time,
+                   // can not move it, try objs in forward color bucket
+                   if(next - 1 < 0) {
+                       return false;
+                   } else {
+                       return innertrial(next - 1, ++layer);
+                   }
                }
                }
-               return true;
            }
        }
        
            }
        }
        
@@ -379,35 +468,37 @@ public class CombinationUtil {
            tmp.index = index;
            this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
            t += 2;
            tmp.index = index;
            this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
            t += 2;
+           Combine tmpt = null;
            if(this.rootNStates.elementAt(root).elementAt(index - 1)[next] < 
                this.rootNStates.elementAt(root).elementAt(index)[next]) {
                // need to continue propagate
                while(t < this.combine.elementAt(next).size()) {
            if(this.rootNStates.elementAt(root).elementAt(index - 1)[next] < 
                this.rootNStates.elementAt(root).elementAt(index)[next]) {
                // need to continue propagate
                while(t < this.combine.elementAt(next).size()) {
-                   tmp = this.combine.elementAt(next).elementAt(t);
-                   if ((tmp.root != root) || (tmp.index != index)) {
+                   tmpt = this.combine.elementAt(next).elementAt(t);
+                   if ((tmpt.root != root) || (tmpt.index != index)) {
                        break;
                    }
                    t++;
                }
                if(t == this.combine.elementAt(next).size()) {
                        break;
                    }
                    t++;
                }
                if(t == this.combine.elementAt(next).size()) {
+                   // last element of this color bucket
                    if(index + 1 < this.rootNodes.elementAt(root).size()) {
                        // there is available place inside the same color bucket
                        Combine tmpbk = this.combine.elementAt(next).elementAt(t - 1);
                        boolean suc = propagateOne(next, root, index + 1, t - 1, tmpbk);
                    if(index + 1 < this.rootNodes.elementAt(root).size()) {
                        // there is available place inside the same color bucket
                        Combine tmpbk = this.combine.elementAt(next).elementAt(t - 1);
                        boolean suc = propagateOne(next, root, index + 1, t - 1, tmpbk);
-                       if(!suc) {
+                       /*if(!suc) {
                            // fail, roll back
                            this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
                            tmp.root = rootbk;
                            tmp.index = indexbk;
                            this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
                            // fail, roll back
                            this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
                            tmp.root = rootbk;
                            tmp.index = indexbk;
                            this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
-                       }
+                       }*/
                        return suc;
                    } else if(root+1 < this.rootNodes.size()) { // check if there are another bucket
                        // yes
                        return suc;
                    } else if(root+1 < this.rootNodes.size()) { // check if there are another bucket
                        // yes
-                       this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
-                       tmp.root = root + 1;
-                       tmp.index = 0;
-                       this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
+                       this.rootNStates.elementAt(tmpt.root).elementAt(tmpt.index)[next]--;
+                       tmpt.root = root + 1;
+                       tmpt.index = 0;
+                       this.rootNStates.elementAt(tmpt.root).elementAt(tmpt.index)[next]++;
                        return firstexpand(next+1, this.first4choice);
                    } else {
                        // no, roll back        
                        return firstexpand(next+1, this.first4choice);
                    } else {
                        // no, roll back        
@@ -417,26 +508,26 @@ public class CombinationUtil {
                        this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
                        return false;
                    }
                        this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
                        return false;
                    }
-               } else if(tmp.root != root) {
+               } else if(tmpt.root != root) {
                    Combine tmpbk = this.combine.elementAt(next).elementAt(t - 1);
                    this.rootNStates.elementAt(tmpbk.root).elementAt(tmpbk.index)[next]--;
                    Combine tmpbk = this.combine.elementAt(next).elementAt(t - 1);
                    this.rootNStates.elementAt(tmpbk.root).elementAt(tmpbk.index)[next]--;
-                   tmpbk.root = tmp.root;
+                   tmpbk.root = tmpt.root;
                    tmpbk.index = 0;
                    tmpbk.index = 0;
-                   root = tmp.root;
                    this.rootNStates.elementAt(tmpbk.root).elementAt(tmpbk.index)[next]++;
                    this.rootNStates.elementAt(tmpbk.root).elementAt(tmpbk.index)[next]++;
-                   index = tmp.index;
+                   root = tmpt.root;
+                   index = tmpt.index;
                    // make all left things in this color bucket reset
                    for(t += 1; t < this.combine.elementAt(next).size(); t++) {
                    // make all left things in this color bucket reset
                    for(t += 1; t < this.combine.elementAt(next).size(); t++) {
-                       tmp = this.combine.elementAt(next).elementAt(t);
-                       this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
-                       tmp.root = root;
-                       tmp.index = 0;
-                       this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]++;
+                       tmpt = this.combine.elementAt(next).elementAt(t);
+                       this.rootNStates.elementAt(tmpt.root).elementAt(tmpt.index)[next]--;
+                       tmpt.root = root;
+                       tmpt.index = 0;
+                       this.rootNStates.elementAt(tmpt.root).elementAt(tmpt.index)[next]++;
                    }
                    return firstexpand(next+1, this.first4choice);
                    }
                    return firstexpand(next+1, this.first4choice);
-               } else if(tmp.index != index) {
+               } else if(tmpt.index != index) {
                    Combine tmpbk = this.combine.elementAt(next).elementAt(t - 1);
                    Combine tmpbk = this.combine.elementAt(next).elementAt(t - 1);
-                   boolean suc = propagateOne(next, root, tmp.index, t - 1, tmpbk);
+                   boolean suc = propagateOne(next, root, tmpt.index, t - 1, tmpbk);
                    if(!suc) {
                        // fail, roll back
                        this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
                    if(!suc) {
                        // fail, roll back
                        this.rootNStates.elementAt(tmp.root).elementAt(tmp.index)[next]--;
index d151b1b39e67b4978865b9311a50a580145b50c3..f65c08fe8aabf757d745477b36a324ee1af77276 100644 (file)
@@ -755,13 +755,13 @@ public class ScheduleAnalysis {
            
            CombinationUtil.RootsGenerator rGen = CombinationUtil.allocateRootsGenerator(sNodeVecs, this.coreNum);
            
            
            CombinationUtil.RootsGenerator rGen = CombinationUtil.allocateRootsGenerator(sNodeVecs, this.coreNum);
            
+           int gid = 1;
            while(rGen.nextGen()) {
                // first get the chosen rootNodes
                Vector<Vector<ScheduleNode>> rootNodes = rGen.getRootNodes();
                Vector<Vector<ScheduleNode>> nodes2combine = rGen.getNode2Combine();
                
                CombinationUtil.CombineGenerator cGen = CombinationUtil.allocateCombineGenerator(rootNodes, nodes2combine);
            while(rGen.nextGen()) {
                // first get the chosen rootNodes
                Vector<Vector<ScheduleNode>> rootNodes = rGen.getRootNodes();
                Vector<Vector<ScheduleNode>> nodes2combine = rGen.getNode2Combine();
                
                CombinationUtil.CombineGenerator cGen = CombinationUtil.allocateCombineGenerator(rootNodes, nodes2combine);
-               int gid = 1;
                while (cGen.nextGen()) {
                    Vector<Vector<CombinationUtil.Combine>> combine = cGen.getCombine();
                    Vector<ScheduleNode> sNodes = generateScheduling(rootNodes, combine, gid++);
                while (cGen.nextGen()) {
                    Vector<Vector<CombinationUtil.Combine>> combine = cGen.getCombine();
                    Vector<ScheduleNode> sNodes = generateScheduling(rootNodes, combine, gid++);
@@ -997,29 +997,31 @@ public class ScheduleAnalysis {
        
        // combine those nodes in combine with corresponding rootnodes
        for(int i = 0; i < combine.size(); i++) {
        
        // combine those nodes in combine with corresponding rootnodes
        for(int i = 0; i < combine.size(); i++) {
-           for(int j = 0; j < combine.elementAt(i).size(); j++) {
-               CombinationUtil.Combine tmpcombine = combine.elementAt(i).elementAt(j);
-               ScheduleNode tocombine = sn2sn.get(tmpcombine.node);
-               ScheduleNode root = sn2sn.get(rootnodes.elementAt(tmpcombine.root).elementAt(tmpcombine.index));
-               ScheduleEdge se = (ScheduleEdge)tocombine.inedges().next();
-               try{
-                   if(root.equals(((ScheduleNode)se.getSource()))) {
-                       root.mergeSEdge(se);
-                       if(ScheduleEdge.NEWEDGE == se.getType()) {
-                           // As se has been changed into an internal edge inside a ScheduleNode, 
-                           // change the source and target of se from original ScheduleNodes into ClassNodes.
-                           se.setTarget(se.getTargetCNode());
-                           se.setSource(se.getSourceCNode());
-                           se.getTargetCNode().addEdge(se);
+           if(combine.elementAt(i) != null) {
+               for(int j = 0; j < combine.elementAt(i).size(); j++) {
+                   CombinationUtil.Combine tmpcombine = combine.elementAt(i).elementAt(j);
+                   ScheduleNode tocombine = sn2sn.get(tmpcombine.node);
+                   ScheduleNode root = sn2sn.get(rootnodes.elementAt(tmpcombine.root).elementAt(tmpcombine.index));
+                   ScheduleEdge se = (ScheduleEdge)tocombine.inedges().next();
+                   try{
+                       if(root.equals(((ScheduleNode)se.getSource()))) {
+                           root.mergeSEdge(se);
+                           if(ScheduleEdge.NEWEDGE == se.getType()) {
+                               // As se has been changed into an internal edge inside a ScheduleNode, 
+                               // change the source and target of se from original ScheduleNodes into ClassNodes.
+                               se.setTarget(se.getTargetCNode());
+                               se.setSource(se.getSourceCNode());
+                               se.getTargetCNode().addEdge(se);
+                           }
+                       } else {
+                           root.mergeSNode(tocombine);
                        }
                        }
-                   } else {
-                       root.mergeSNode(tocombine);
+                   } catch(Exception e) {
+                       e.printStackTrace();
+                       System.exit(-1);
                    }
                    }
-               } catch(Exception e) {
-                   e.printStackTrace();
-                   System.exit(-1);
+                   result.removeElement(tocombine);
                }
                }
-               result.removeElement(tocombine);
            }
        }
        
            }
        }
        
index c9787e32f336b4ba2bce217d4072d78009a7a9de..4572dd5062e3a5506b3d6d1fd1508209bb5cdf89 100644 (file)
@@ -16,6 +16,7 @@ public class FlagState extends GraphNode implements Cloneable {
     public static final int ONETAG=1;
     public static final int NOTAGS=0;
     public static final int MULTITAGS=-1;
     public static final int ONETAG=1;
     public static final int NOTAGS=0;
     public static final int MULTITAGS=-1;
+    public static final int MAXTIME=10;
     
     private int uid;
     private static int nodeid=0;
     
     private int uid;
     private static int nodeid=0;
@@ -30,6 +31,7 @@ public class FlagState extends GraphNode implements Cloneable {
     // jzhou
     // for static scheduling
     private int executeTime;
     // jzhou
     // for static scheduling
     private int executeTime;
+    private int visited4time;
     private int invokeNum;
     // for building multicore codes
     private int andmask;
     private int invokeNum;
     // for building multicore codes
     private int andmask;
@@ -50,6 +52,7 @@ public class FlagState extends GraphNode implements Cloneable {
        this.uid=FlagState.nodeid++;
        this.issourcenode=false;
        this.executeTime = -1;
        this.uid=FlagState.nodeid++;
        this.issourcenode=false;
        this.executeTime = -1;
+       this.visited4time = -1;
        this.invokeNum = 0;
        this.andmask = 0;
        this.checkmask = 0;
        this.invokeNum = 0;
        this.andmask = 0;
        this.checkmask = 0;
@@ -72,6 +75,7 @@ public class FlagState extends GraphNode implements Cloneable {
        this.uid=FlagState.nodeid++;
        this.issourcenode=false;
        this.executeTime = -1;
        this.uid=FlagState.nodeid++;
        this.issourcenode=false;
        this.executeTime = -1;
+       this.visited4time = -1;
        this.invokeNum = 0;
     }
    
        this.invokeNum = 0;
     }
    
@@ -331,7 +335,15 @@ public class FlagState extends GraphNode implements Cloneable {
     public int getExeTime() {
        try {
            if(this.executeTime == -1) {
     public int getExeTime() {
        try {
            if(this.executeTime == -1) {
-               calExeTime();
+               if(this.visited4time == -1) {
+                   this.visited4time = 0;
+                   calExeTime();
+               } else {
+                   // visited, this node is in a loop
+                   // TODO
+                   // currently set 10 as the largest time
+                   this.executeTime = FlagState.MAXTIME;
+               }
            }
        } catch (Exception e) {
            e.printStackTrace();
            }
        } catch (Exception e) {
            e.printStackTrace();
index 1ebb878dd2419ffd0d7c5919b5ef40911516e811..adb5e0cec0f932ad312cc0fe2ebcd6f541223c8b 100644 (file)
@@ -1,4 +1,4 @@
-/** Bristlecone Version  **/
+/** Banboo Version  **/
 
 /**************************************************************************
 *                                                                         *
 
 /**************************************************************************
 *                                                                         *
index 247ce63ab71b0bcc52c02b80e4dc07887c3f9cf7..e9d790a8a965020550c9dbb0453d4a1a8a1fafb9 100644 (file)
@@ -29,5 +29,6 @@ public class Math {
     public static native float sinf(float a);
     public static native float cosf(float a);
     public static native float sqrtf(float a);
     public static native float sinf(float a);
     public static native float cosf(float a);
     public static native float sqrtf(float a);
+    public static native double logf(float a);
     public static native float powf(float a, float b);
 }
     public static native float powf(float a, float b);
 }
index f737624d0b832cea8285e221b2966f19787202b2..2b9691af40254b80bd89a73a949d66ec632ceb56 100644 (file)
@@ -648,7 +648,17 @@ public class BuildCodeMultiCore extends BuildCode {
                super.generateFlatNode(fm, lb, current_node, output);
                if (current_node.kind()!=FKind.FlatReturnNode) {
                    //output.println("   flushAll();");
                super.generateFlatNode(fm, lb, current_node, output);
                if (current_node.kind()!=FKind.FlatReturnNode) {
                    //output.println("   flushAll();");
+                   output.println("#ifdef RAW");
+                  output.println("raw_user_interrupts_off();");
+                   output.println("#ifdef RAWDEBUG");
+                   output.println("raw_test_pass(0xec00);");
+                   output.println("#endif");
                    output.println("raw_flush_entire_cache();");
                    output.println("raw_flush_entire_cache();");
+                   output.println("#ifdef RAWDEBUG");
+                  output.println("raw_test_pass(0xecff);");
+                   output.println("#endif");
+                   output.println("raw_user_interrupts_on();");
+                   output.println("#endif");
                    outputTransCode(output);
                    output.println("   return;");
                }
                    outputTransCode(output);
                    output.println("   return;");
                }
@@ -1225,7 +1235,17 @@ public class BuildCodeMultiCore extends BuildCode {
        } else {
            if(fm.getTask() != null) {
                //output.println("flushAll();");
        } else {
            if(fm.getTask() != null) {
                //output.println("flushAll();");
+               output.println("#ifdef RAW");
+               output.println("raw_user_interrupts_off();");
+               output.println("#ifdef RAWDEBUG");
+               output.println("raw_test_pass(0xec00);");
+               output.println("#endif");
                output.println("raw_flush_entire_cache();");
                output.println("raw_flush_entire_cache();");
+               output.println("#ifdef RAWDEBUG");
+               output.println("raw_test_pass(0xecff);");
+               output.println("#endif");
+               output.println("raw_user_interrupts_on();");
+               output.println("#endif");
                outputTransCode(output);
            }
            output.println("return;");
                outputTransCode(output);
            }
            output.println("return;");
index 11043b2c07fe57fbbc362234d505e38e091bef65..e218d333aa46ea1060175e2276071f4dc2c8ff54 100644 (file)
@@ -307,13 +307,14 @@ public class Main {
                                          //int newRate = (j+1)%2+1;
                                          int newRate = 1;
                                          String cdname = cd.getSymbol();
                                          //int newRate = (j+1)%2+1;
                                          int newRate = 1;
                                          String cdname = cd.getSymbol();
-                                         if(cdname.equals("SeriesRunner")) {
+                                         if((cdname.equals("SeriesRunner")) || 
+                                                 (cdname.equals("MDRunner"))) {
                                              newRate = 16;
                                              newRate = 16;
-                                         } else if(cdname.equals("MapWorker")) {
-                                             newRate = 6;
-                                         } else if(cdname.equals("ReduceWorker")) {
+                                         } else if(cdname.equals("SentenceParser")) {
+                                             newRate = 4;
+                                         } /*else if(cdname.equals("ReduceWorker")) {
                                              newRate = 3;
                                              newRate = 3;
-                                         }
+                                         }*/
                                          /*do {
                                              tint = r.nextInt()%100;
                                          } while(tint <= 0);
                                          /*do {
                                              tint = r.nextInt()%100;
                                          } while(tint <= 0);
index 3140f1c0a062eb375c84630f171747e2ba238da8..7a54d283cd66d1359fdd6fa50740525db7a17784 100644 (file)
@@ -54,6 +54,10 @@ float CALL11(___Math______sqrtf____F, float ___a___, float ___a___) {
   return sqrtf(___a___);
 }
 
   return sqrtf(___a___);
 }
 
+float CALL11(___Math______logf____F, float ___a___, float ___a___) {
+  return logf(___a___);
+}
+
 float CALL22(___Math______powf____F_F, float ___a___, float ___b___, float ___a___, float ___b___) {
   return powf(___a___,___b___);
 }
 float CALL22(___Math______powf____F_F, float ___a___, float ___b___, float ___a___, float ___b___) {
   return powf(___a___,___b___);
 }
index d5e180e626fdee14d4cebc38100c9c5865c7a192..01516953d3efdc2d0258e952ca1a91f292f9b616 100644 (file)
@@ -410,6 +410,9 @@ void run(void* arg) {
                          // and try to execute active tasks already enqueued first
                          removeItem(&objqueue, objitem);
                          addNewItem_I(&objqueue, objInfo);
                          // and try to execute active tasks already enqueued first
                          removeItem(&objqueue, objitem);
                          addNewItem_I(&objqueue, objInfo);
+#ifdef INTERRUPT
+                         raw_user_interrupts_on();
+#endif
                          break;
                  }
 #ifdef INTERRUPT
                          break;
                  }
 #ifdef INTERRUPT
@@ -2785,6 +2788,7 @@ void executetasks() {
        taskpointerarray[i+OFFSET]=parameter;
        goto execute;
        }
        taskpointerarray[i+OFFSET]=parameter;
        goto execute;
        }
+               lock = true;
        // require locks for this parameter if it is not a startup object
        getwritelock(parameter);
        grount = 0;
        // require locks for this parameter if it is not a startup object
        getwritelock(parameter);
        grount = 0;
@@ -2845,6 +2849,7 @@ void executetasks() {
        taskpointerarray[i+OFFSET]=parameter;
        goto execute;
        }
        taskpointerarray[i+OFFSET]=parameter;
        goto execute;
        }
+       lock = true;
        if(0 == tmpparam->isolate) {
                isolateflags[i] = 0;
                // shared object, need to flush with current value
        if(0 == tmpparam->isolate) {
                isolateflags[i] = 0;
                // shared object, need to flush with current value
@@ -3056,13 +3061,18 @@ execute:
          } else {
            ((void (*) (void **)) currtpd->task->taskptr)(taskpointerarray);
          }
          } else {
            ((void (*) (void **)) currtpd->task->taskptr)(taskpointerarray);
          }
+#ifdef RAWDEBUG
+         raw_test_pass(0xe998);
+                raw_test_pass_reg(lock);
+                 #endif
+
          if(lock) {
 #ifdef RAW
           for(i = 0; i < numparams; ++i) {
                  int j = 0;
                  struct ___Object___ * tmpparam = (struct ___Object___ *)taskpointerarray[i+OFFSET];
 #ifdef RAWDEBUG
          if(lock) {
 #ifdef RAW
           for(i = 0; i < numparams; ++i) {
                  int j = 0;
                  struct ___Object___ * tmpparam = (struct ___Object___ *)taskpointerarray[i+OFFSET];
 #ifdef RAWDEBUG
-                 raw_test_pass(0xe998);
+                 raw_test_pass(0xe999);
                raw_test_pass(0xdd100000 + tmpparam->flag);
 #endif
                  releasewritelock(tmpparam);
                raw_test_pass(0xdd100000 + tmpparam->flag);
 #endif
                  releasewritelock(tmpparam);
@@ -3093,6 +3103,11 @@ execute:
          reverse=NULL;
 #endif
 #endif
          reverse=NULL;
 #endif
 #endif
+#ifdef RAWDEBUG
+         raw_test_pass(0xe99a);
+                 raw_test_pass_reg(lock);
+                 #endif
+
        }
       }
     }
        }
       }
     }
index 142f076d263395e8c8d5f25f5750241c7a4be1df..57bcbf07f2c986383aa6278f6d13f89b261b9a7c 100644 (file)
@@ -903,8 +903,9 @@ int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *pr
   /* Find initial state */
   for(j=0;j<numiterators;j++) {
   backtrackinit:
   /* Find initial state */
   for(j=0;j<numiterators;j++) {
   backtrackinit:
-    if(toiHasNext(&parameter->iterators[j], taskpointerarray OPTARG(failed)))
+    if(toiHasNext(&parameter->iterators[j], taskpointerarray OPTARG(failed))){
       toiNext(&parameter->iterators[j], taskpointerarray OPTARG(failed));
       toiNext(&parameter->iterators[j], taskpointerarray OPTARG(failed));
+       }
     else if (j>0) {
       /* Need to backtrack */
       toiReset(&parameter->iterators[j]);
     else if (j>0) {
       /* Need to backtrack */
       toiReset(&parameter->iterators[j]);
@@ -946,15 +947,16 @@ int enqueuetasks(struct parameterwrapper *parameter, struct parameterwrapper *pr
 #endif
       RUNFREE(tpd);
     }
 #endif
       RUNFREE(tpd);
     }
-    
+
     /* This loop iterates to the next parameter combination */
     if (numiterators==0)
       return retval;
 
     for(j=numiterators-1; j<numiterators;j++) {
     backtrackinc:
     /* This loop iterates to the next parameter combination */
     if (numiterators==0)
       return retval;
 
     for(j=numiterators-1; j<numiterators;j++) {
     backtrackinc:
-      if(toiHasNext(&parameter->iterators[j], taskpointerarray OPTARG(failed)))
+      if(toiHasNext(&parameter->iterators[j], taskpointerarray OPTARG(failed))){
        toiNext(&parameter->iterators[j], taskpointerarray OPTARG(failed));
        toiNext(&parameter->iterators[j], taskpointerarray OPTARG(failed));
+         }
       else if (j>0) {
        /* Need to backtrack */
        toiReset(&parameter->iterators[j]);
       else if (j>0) {
        /* Need to backtrack */
        toiReset(&parameter->iterators[j]);
@@ -1647,7 +1649,8 @@ void toiNext(struct tagobjectiterator *it , void ** objectarray OPTARG(int * fai
     }
   } else {
     /* Iterate object */
     }
   } else {
     /* Iterate object */
-    objectarray[it->slot]=(void *)Objkey(&it->it);
+         void * tmpp = (void *) Objkey(&it->it);
+    objectarray[it->slot]=tmpp;
 #ifdef OPTIONAL
     failed[it->slot]=it->failedstate;
     if (it->failedstate==0) {
 #ifdef OPTIONAL
     failed[it->slot]=it->failedstate;
     if (it->failedstate==0) {