bug fixes
authorbdemsky <bdemsky>
Thu, 9 Apr 2009 06:38:16 +0000 (06:38 +0000)
committerbdemsky <bdemsky>
Thu, 9 Apr 2009 06:38:16 +0000 (06:38 +0000)
Robust/src/Analysis/Locality/LocalityBinding.java
Robust/src/Analysis/Loops/LoopInvariant.java
Robust/src/Analysis/Loops/LoopOptimize.java
Robust/src/Benchmarks/SingleTM/RainForest/RainForest.java
Robust/src/Benchmarks/SingleTM/RainForest/makefile
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Flat/FlatBackEdge.java
Robust/src/IR/Flat/FlatNode.java
Robust/src/IR/Flat/TempObject.java
Robust/src/Runtime/garbage.c
Robust/src/Runtime/thread.c

index 132bdfb68a82a4ff74608634e48544f4235aa672..1a100c3bb5c116b71e56ff2a7953b559e24193e5 100644 (file)
@@ -84,7 +84,9 @@ public class LocalityBinding {
        st+="[conflict] ";
     }
     for(int i=0; i<isglobal.length; i++)
-      if (isglobal[i].equals(LocalityAnalysis.LOCAL))
+      if (isglobal[i]==null)
+       st+="NULL";
+      else if (isglobal[i].equals(LocalityAnalysis.LOCAL))
        st+="local ";
       else if (isglobal[i].equals(LocalityAnalysis.GLOBAL))
        st+="global ";
index e130c3a6f9fd5bda3e801e7c98d69d8441b00b7e..3dfef6b869bebdb31d49e264ada70413e0486bc9 100644 (file)
@@ -19,7 +19,7 @@ public class LoopInvariant {
   }
   GlobalFieldType gft;
   LoopFinder loops;
-  DomTree posttree;
+  DomTree domtree;
   Hashtable<FlatNode, Vector<FlatNode>> table;
   Set<FlatNode> hoisted;
   UseDef usedef;
@@ -33,7 +33,7 @@ public class LoopInvariant {
     table=new Hashtable<FlatNode, Vector<FlatNode>>();
     hoisted=new HashSet<FlatNode>();
     usedef=new UseDef(fm);
-    posttree=new DomTree(fm,true);
+    domtree=new DomTree(fm,false);
     tounroll=new HashSet();
     recurse(root);
   }
@@ -78,8 +78,9 @@ public class LoopInvariant {
            fields.addAll(f);
          if (t!=null)
            types.addAll(t);
-         if (gft.containsAtomic(md))
+         if (gft.containsAtomic(md)) {
            unsafe=true;
+         }
        } else if (fn.kind()==FKind.FlatSetFieldNode) {
          FlatSetFieldNode fsfn=(FlatSetFieldNode)fn;
          fields.add(fsfn.getField());
@@ -128,7 +129,7 @@ public class LoopInvariant {
            }
          }
          if (isLeaf)
-           tounroll.add(l);
+           tounroll.add(entrance);
          break;
 
        case FKind.FlatFieldNode:
@@ -139,7 +140,7 @@ public class LoopInvariant {
            continue nextfn;
          }
          if (isLeaf)
-           tounroll.add(l);
+           tounroll.add(entrance);
          break;
 
        default:
@@ -168,7 +169,7 @@ public class LoopInvariant {
        domset.add(incoming);
        FlatNode tmp=incoming;
        while(tmp!=entrance) {
-         tmp=posttree.idom(tmp);
+         tmp=domtree.idom(tmp);
          domset.add(tmp);
        }
        if (first) {
@@ -202,4 +203,4 @@ public class LoopInvariant {
     }
     return false;
   }
-}
\ No newline at end of file
+}
index 84eeffc1509e99f961be3407e4855ea9a6f19414..2d6f2e328619cf719026272290bb17b0ed7be445 100644 (file)
@@ -30,7 +30,10 @@ public class LoopOptimize {
     }
   }
   public void processLoop(Loops l) {
-    if (loopinv.tounroll.contains(l)) {
+    Set entrances=l.loopEntrances();
+    assert entrances.size()==1;
+    FlatNode entrance=(FlatNode)entrances.iterator().next();
+    if (loopinv.tounroll.contains(entrance)) {
       unrollLoop(l);
     } else {
       hoistOps(l);
@@ -124,6 +127,25 @@ public class LoopOptimize {
       copytable.put(fn, copy);
       copyendtable.put(fn, copyend);
     }
+    /* Splice header in */
+
+    FlatNode[] prevarray=new FlatNode[entrance.numPrev()];
+    FlatNode first=copytable.get(entrance);
+    for(int i=0;i<entrance.numPrev();i++) {
+      prevarray[i]=entrance.getPrev(i);
+    }
+    for(int i=0;i<prevarray.length;i++) {
+      FlatNode prev=prevarray[i];
+
+      if (!lelements.contains(prev)) {
+       //need to fix this edge
+       for(int j=0;j<prev.numNext();j++) {
+         if (prev.getNext(j)==entrance)
+           prev.setNext(j, first);
+       }
+      }
+    }
+
     /* Copy the edges */
     for(Iterator it=lelements.iterator();it.hasNext();) {
       FlatNode fn=(FlatNode)it.next();
@@ -132,24 +154,25 @@ public class LoopOptimize {
        FlatNode nnext=fn.getNext(i);
        if (nnext==entrance) {
          /* Back to loop header...point to old graph */
-         copyend.addNext(nnext);
+         copyend.setNewNext(i,nnext);
        } else if (lelements.contains(nnext)) {
          /* In graph...point to first graph */
-         copyend.addNext(copytable.get(nnext));
+         copyend.setNewNext(i,copytable.get(nnext));
        } else {
          /* Outside loop */
          /* Just goto same place as before */
-         copyend.addNext(nnext);
+         copyend.setNewNext(i,nnext);
        }
       }
     }
+
     /* Splice out loop invariant stuff */
     for(Iterator it=lelements.iterator();it.hasNext();) {
       FlatNode fn=(FlatNode)it.next();
       if (tohoist.contains(fn)) {
        TempDescriptor[] writes=fn.writesTemps();
        TempDescriptor tmp=writes[0];
-       FlatOpNode fon=new FlatOpNode(temptable.get(fn),tmp, null, new Operation(Operation.ASSIGN));
+       FlatOpNode fon=new FlatOpNode(tmp, temptable.get(fn), null, new Operation(Operation.ASSIGN));
        fn.replace(fon);
       }
     }
index f714d4e2d0c098c0f3b54078118c0438b7c139ee..2f3443604a750c53f703f30c68399cad89dcf7c2 100644 (file)
@@ -150,8 +150,10 @@ public class RainForest extends Thread {
     /* Barrier Server waits for messages */
     boolean waitforthreaddone = true;
     while(waitforthreaddone) {
-        if(mybarr.done)
-           waitforthreaddone = false;
+       atomic {
+           if(mybarr.done)
+               waitforthreaddone = false;
+       }
     }
 
     /* Start threads */
index 1c48c05b5609dccc0e58d76d93246fc16158a3fe..a8760f25200e2d0e5520061a772e4d658a4f7a9e 100644 (file)
@@ -10,7 +10,7 @@ SRC=tmp${MAINCLASS}.java \
        Node.java \
        AStarPathFinder.java 
 
-FLAGS=-singleTM -nooptimize -mainclass ${MAINCLASS} -debug -transstats -joptimize
+FLAGS=-singleTM -optimize -mainclass ${MAINCLASS} -debug -transstats -joptimize
 
 default:
        cpp ${MAINCLASS}.java > tmp1${MAINCLASS}.java
index 0a9c17bfd3954be19dd64ab0ff758394a6c191f9..0cc7d088a9c7f40a96880dedd472af0b1ee68f92 100644 (file)
@@ -309,6 +309,9 @@ public class BuildCode {
          outmethod.println("printf(\"nRemoteReadSend= %d\\n\", nRemoteSend);");
          outmethod.println("printf(\"bytesSent= %d\\n\", bytesSent);");
          outmethod.println("printf(\"bytesRecv= %d\\n\", bytesRecv);");
+      } else if (state.SINGLETM) {
+         outmethod.println("printf(\"nSoftAbortAbort= %d\\n\", nSoftAbortAbort);");
+         outmethod.println("printf(\"nSoftAbortCommit= %d\\n\", nSoftAbortCommit);");
       }
       outmethod.println("#endif\n");
     }
@@ -791,6 +794,9 @@ public class BuildCode {
        outclassdefs.print("extern int bytesSent;\n");
        outclassdefs.print("extern int bytesRecv;\n");
        outclassdefs.print("extern void handle();\n");
+    } else if (state.SINGLETM) {
+       outclassdefs.println("extern int nSoftAbortAbort;");
+       outclassdefs.println("extern int nSoftAbortCommit;");
     }
     outclassdefs.print("#endif\n");
     outclassdefs.print("int numprefetchsites = " + pa.prefetchsiteid + ";\n");
index e6905cfe9a2e9433e581521100c9af6052e8faa4..b300ff1ef41d9a616e462a6d86bf20af8d8c5d09 100644 (file)
@@ -11,6 +11,9 @@ public class FlatBackEdge extends FlatNode {
   public String toString() {
     return "backedge";
   }
+  public FlatNode clone(TempMap t) {
+    return new FlatBackEdge();  
+  }
 
   public int kind() {
     return FKind.FlatBackEdge;
index 7f82c2d70875764237585b72e1b63cb91d84da8c..bc3063c8a1b60f89a1dba4d15d11d9c7ac6db2b4 100644 (file)
@@ -41,6 +41,13 @@ public class FlatNode {
     n.addPrev(this);
   }
   /** This function modifies the graph */
+  public void setNewNext(int i, FlatNode n) {
+    if (next.size()<=i)
+       next.setSize(i+1);
+    next.set(i, n);
+    n.addPrev(this);
+  }
+  /** This function modifies the graph */
   public void setprev(int i, FlatNode n) {
     prev.set(i, n);
   }
@@ -61,7 +68,7 @@ public class FlatNode {
     return new TempDescriptor[0];
   }
   public FlatNode clone(TempMap t) {
-    throw new Error();
+    throw new Error("no clone method for"+this);
   }
 
   public void rewriteUse(TempMap t) {
index 015891585429079f19879e14be75a5876ceec92a..2da66d689eae88f0ae0535bc9c3f6473ccbb461e 100644 (file)
@@ -64,6 +64,8 @@ public class TempObject {
   public boolean isLocalPrim(TempDescriptor t) {
     if (!params.containsTemp(t)) {
       Position p=(Position)temptostore.get(t);
+      if (p==null)
+         System.out.println(t);
       return !p.inStruct;
     }
     return false;
index 875fa9de53d62b9d483de4bf3813aa9ca9378ebd..bb312b5e6351a99bc15f33942629d464c90d1915 100644 (file)
@@ -22,7 +22,7 @@
 
 #define NUMPTRS 100
 
-#define INITIALHEAPSIZE 16*1024*1024
+#define INITIALHEAPSIZE 64*1024*1024
 #define GCPOINT(x) ((int)((x)*0.95))
 /* This define takes in how full the heap is initially and returns a new heap size to use */
 #define HEAPSIZE(x,y) ((int)(x+y))*2
@@ -655,12 +655,20 @@ void * mygcmalloc(struct garbagelist * stackptr, int size) {
     if (curr_heapbase==0) {
       /* Need to allocate base heap */
       curr_heapbase=malloc(INITIALHEAPSIZE);
+      if (curr_heapbase==NULL) {
+       printf("malloc failed\n");
+       exit(-1);
+      }
       bzero(curr_heapbase, INITIALHEAPSIZE);
       curr_heaptop=curr_heapbase+INITIALHEAPSIZE;
       curr_heapgcpoint=((char *) curr_heapbase)+GCPOINT(INITIALHEAPSIZE);
       curr_heapptr=curr_heapbase+size;
 
       to_heapbase=malloc(INITIALHEAPSIZE);
+      if (to_heapbase==NULL) {
+       printf("malloc failed\n");
+       exit(-1);
+      }
       to_heaptop=to_heapbase+INITIALHEAPSIZE;
       to_heapptr=to_heapbase;
       ptr=curr_heapbase;
index 019554174b7547bbd378c5e2be62ac31c3be07a2..ca659d9d1d4b0dd55090d0bc5197ddbd0d18566d 100644 (file)
@@ -105,6 +105,9 @@ void initializethreads() {
   sigaction(SIGSEGV,&sig,0);
   sigaction(SIGFPE,&sig,0);
   signal(SIGPIPE, SIG_IGN);
+#ifdef STM
+  newobjs=calloc(1, sizeof(struct objlist));
+#endif
 }
 
 #if defined(THREADS)||defined(STM)