bug fix for my bug that Alokika found
authorbdemsky <bdemsky>
Mon, 17 Sep 2007 20:19:15 +0000 (20:19 +0000)
committerbdemsky <bdemsky>
Mon, 17 Sep 2007 20:19:15 +0000 (20:19 +0000)
Robust/src/Analysis/Locality/GenerateConversions.java
Robust/src/Analysis/Locality/TempNodePair.java
Robust/src/Analysis/TaskStateAnalysis/EGTaskNode.java
Robust/src/Analysis/TaskStateAnalysis/ExecutionGraph.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Flat/FlatMethod.java
Robust/src/IR/Flat/FlatNode.java

index f9c59f77aac557825e375b3a912b105c542e989a..9b987c99e2513df2883df59400563e358f8d3d43 100644 (file)
@@ -31,15 +31,14 @@ public class GenerateConversions {
     }
 
     /* At the end of an atomic block, we need to convert any global
-     * references that will be used again into OID's */
+     * references that will be used again into OID's. */
 
     private void converttoOid(LocalityBinding lb) {
        Hashtable<FlatNode, Integer> atomictab=locality.getAtomic(lb);
        Hashtable<FlatNode, Hashtable<TempDescriptor, Integer>> temptab=locality.getNodeTempInfo(lb);
        MethodDescriptor md=lb.getMethod();
        FlatMethod fm=state.getMethodFlat(md);
-               
-       Hashtable<FlatNode, Set<TempNodePair>> nodetotnpair=new Hashtable<FlatNode, Set<TempNodePair>>();       
+       Hashtable<FlatNode, Set<TempNodePair>> nodetotnpair=new Hashtable<FlatNode, Set<TempNodePair>>();
        Hashtable<FlatNode, Set<TempDescriptor>> nodetoconvs=new Hashtable<FlatNode, Set<TempDescriptor>>();
 
        Set<FlatNode> toprocess=fm.getNodeSet();
@@ -52,20 +51,27 @@ public class GenerateConversions {
            
            List<TempDescriptor> reads=Arrays.asList(fn.readsTemps());
            List<TempDescriptor> writes=Arrays.asList(fn.writesTemps());
-
+           
            if (!isatomic&&fn.kind()==FKind.FlatAtomicExitNode
                &&!nodetoconvs.containsKey(fn))
                nodetoconvs.put(fn, new HashSet<TempDescriptor>());
-
-
+           
            HashSet<TempNodePair> tempset=new HashSet<TempNodePair>();
+
            for(int i=0;i<fn.numPrev();i++) {
                FlatNode fnprev=fn.getPrev(i);
                if (!nodetotnpair.containsKey(fnprev))
                    continue;
+
                Set<TempNodePair> prevset=nodetotnpair.get(fnprev);
                for(Iterator<TempNodePair> it=prevset.iterator();it.hasNext();) {
                    TempNodePair tnp=it.next();
+                   if (fn.kind()==FKind.FlatGlobalConvNode&&
+                        ((FlatGlobalConvNode)fn).getLocality()!=lb) {
+                       //ignore this node
+                       tempset.add(tnp);
+                       continue;
+                   }
                    if (reads.contains(tnp.getTemp())&&tnp.getNode()!=null) {
                        //Value actually is read...
                        nodetoconvs.get(tnp.getNode()).add(tnp.getTemp());
@@ -85,7 +91,8 @@ public class GenerateConversions {
                }
            }
            if (isatomic) {
-               //if this is in an atomic block, record temps that are written to
+               /* If this is in an atomic block, record temps that
+                * are written to.*/
 
                /* NOTE: If this compiler is changed to maintain
                 * OID/Ptr's in variables, then we need to use all
@@ -93,8 +100,9 @@ public class GenerateConversions {
                 * ones converted by globalconvnode*/
 
                if (fn.kind()!=FKind.FlatGlobalConvNode||
-                   ((FlatGlobalConvNode)fn).getLocality()==lb)
-                   //If globalconvnode, make sure we have the right locality
+                   ((FlatGlobalConvNode)fn).getLocality()==lb) {
+                   /*If globalconvnode, make sure we have the right
+                    * locality. */
                    for(Iterator<TempDescriptor> writeit=writes.iterator();writeit.hasNext();) {
                        TempDescriptor wrtmp=writeit.next();
                        if (nodetemptab.get(wrtmp)==LocalityAnalysis.GLOBAL) {
@@ -102,6 +110,7 @@ public class GenerateConversions {
                            tempset.add(tnp);
                        }
                    }
+               }
            }
            if (!nodetotnpair.containsKey(fn)||!nodetotnpair.get(fn).equals(tempset)) {
                //changes to set, so enqueue next nodes
@@ -125,6 +134,7 @@ public class GenerateConversions {
                    FlatGlobalConvNode fgcn=new FlatGlobalConvNode(tempit.next(), lb, false);
                    atomictab.put(fgcn, atomictab.get(fn));
                    temptab.put(fgcn, (Hashtable<TempDescriptor, Integer>) temptab.get(fn).clone());
+
                    for(int i=0;i<fn.numPrev();i++) {
                        FlatNode fnprev=fn.getPrev(i);
                        for(int j=0;j<fnprev.numNext();j++) {
@@ -155,7 +165,7 @@ public class GenerateConversions {
        while(!toprocess.isEmpty()) {
            FlatNode fn=toprocess.iterator().next();
            toprocess.remove(fn);
-           
+
            if (atomictab.get(fn).intValue()>0) {
                //build set of transaction temps use by next nodes
                HashSet<TempDescriptor> transtemps=new HashSet<TempDescriptor>();
@@ -189,7 +199,7 @@ public class GenerateConversions {
                atomictab.get(fn.getPrev(0)).intValue()==0) {
                //sanity check
                assert(fn.kind()==FKind.FlatAtomicEnterNode);
-
+               
                //insert calls here...
                Set<TempDescriptor> tempset=nodetotranstemps.get(fn);
                for(Iterator<TempDescriptor> tempit=tempset.iterator();tempit.hasNext();) {
index ba3828a47878185d732909c7e4eb35d7a10ad5d3..b590d907dd300e8f594afab8df94d8585c3a7e32 100644 (file)
@@ -38,4 +38,11 @@ public class TempNodePair {
     public int hashCode() {
        return tmp.hashCode();
     }
+
+    public String toString() {
+       if (getNode()==null)
+           return "<null,"+getTemp()+">";
+       else
+           return "<"+getNode()+","+getTemp()+">";
+    }
 }
index eccb83d1c893a3c142f8bd3f094ac86422c542f3..e6c9ac32adaf4ec094ce87ac5c0853269a2df11a 100644 (file)
@@ -8,8 +8,6 @@ import Util.GraphNode;
 
 public class EGTaskNode extends TaskNode {
     private boolean source=false;
-    private int loopmarker=0;
-    private boolean tomention=true;
     private FlagState fs;
     private FlagState postfs;
     private TaskDescriptor td;
@@ -61,24 +59,6 @@ public class EGTaskNode extends TaskNode {
        return uid;
     }
 
-    public void doSelfLoopMarking(){
-       loopmarker=1;
-    }
-
-    public void doLoopMarking(){
-       loopmarker=2;
-    }
-           
-    public boolean isSelfLoop(){
-       if (loopmarker==1) return true;
-       else return false;
-    }
-
-    public boolean isLoop(){
-       if (loopmarker==2) return true;
-       else return false;
-    }
-
     public boolean isMultipleParams(){
        return getTD()!=null&&getTD().numParameters()>1;
     }
@@ -93,12 +73,4 @@ public class EGTaskNode extends TaskNode {
     public FlagState getFS(){
        return fs;
     }
-
-    public void dontMention(){
-       tomention = false;
-    }
-
-    public boolean toMention(){
-       return tomention;
-    }
 }
index f929641803af0d7aaf587f7e8b23f4456f4f85ed..ef6e25fc2cce25e849fa1c5684e580161f40ecae 100644 (file)
@@ -82,8 +82,6 @@ public class ExecutionGraph {
        if (map.containsKey(fedge))
            return map.get(fedge);
        EGTaskNode egnode=new EGTaskNode(fedge.getLabel(), (FlagState) fedge.getSource(), fedge.getTask(), fedge.getIndex(), (FlagState) fedge.getTarget());
-       if (fedge.getTarget()==fedge.getSource())
-           egnode.doSelfLoopMarking();
        map.put(fedge, egnode);
        nodes.add(egnode);
        return egnode;
@@ -133,7 +131,6 @@ public class ExecutionGraph {
        for(Iterator it1 = v.iterator(); it1.hasNext();){
            tn = (EGTaskNode)it1.next();
            output.println("\t"+tn.getLabel()+" [label=\""+tn.getTextLabel()+"\"");
-           if (tn.isSelfLoop()) output.println(", shape=box");
            if (tn.isMultipleParams()) output.println(", color=blue");
            output.println("];");
            
index 7b5ad1706288c66492b21bafa3a598ec070219ad..a3c003320b3945af1accd119a5125a6317ee946d 100644 (file)
@@ -1195,6 +1195,7 @@ public class BuildCode {
 
     private void generateFlatMethod(FlatMethod fm, LocalityBinding lb, PrintWriter output) {
        MethodDescriptor md=fm.getMethod();
+       
        TaskDescriptor task=fm.getTask();
 
                ClassDescriptor cn=md!=null?md.getClassDesc():null;
index 4f1e0c9f3aa7661f1148a6acffcf29508880d5a9..b48f718ec3add0365bcf4b7d1e75d1ec43e066e4 100644 (file)
@@ -90,10 +90,14 @@ public class FlatMethod extends FlatNode {
        return visited;
     }
     
+    public String printMethod() {
+       return printMethod(null);
+    }
+
     /** This method returns a string that is a human readable
      * representation of this method. */
 
-    public String printMethod() {
+    public String printMethod(Hashtable map) {
        String st=method+" {\n";
        HashSet tovisit=new HashSet();
        HashSet visited=new HashSet();
@@ -108,8 +112,6 @@ public class FlatMethod extends FlatNode {
            tovisit.remove(fn);
            visited.add(fn);
 
-//         System.out.println("Next : "+fn.numNext());
-
            for(int i=0;i<fn.numNext();i++) {
                FlatNode nn=fn.getNext(i);
                if(i>0) {
@@ -138,10 +140,16 @@ public class FlatMethod extends FlatNode {
            if (nodetolabel.containsKey(current_node))
                st+="L"+nodetolabel.get(current_node)+":\n";
            if (current_node.numNext()==0) {
-               st+="   "+current_node.toString()+"\n";
+               if (map==null)
+                   st+="   "+current_node.toString()+"\n";
+               else
+                   st+="   "+current_node.toString()+"["+map.get(current_node)+"]\n";
                current_node=null;
            } else if(current_node.numNext()==1) {
-               st+="   "+current_node.toString()+"\n";
+               if (map==null)
+                   st+="   "+current_node.toString()+"\n";
+               else
+                   st+="   "+current_node.toString()+"["+map.get(current_node)+"]\n";
                FlatNode nextnode=current_node.getNext(0);
                if (visited.contains(nextnode)) {
                    st+="goto L"+nodetolabel.get(nextnode)+"\n";
index b1780b100c83abca0445bf3f87dbf57f84fd71f9..714b894bfad3ba57e37519aab8c23afa324e2109 100644 (file)
@@ -37,6 +37,7 @@ public class FlatNode {
        FlatNode old=getNext(i);
        next.set(i, n);
        old.prev.remove(this);
+       n.addPrev(this);
     }
 
     protected void addPrev(FlatNode p) {