more core...fix traversers...
authorbdemsky <bdemsky>
Fri, 22 Oct 2010 21:02:40 +0000 (21:02 +0000)
committerbdemsky <bdemsky>
Fri, 22 Oct 2010 21:02:40 +0000 (21:02 +0000)
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Flat/RuntimeConflictResolver.java
Robust/src/Runtime/oooJava/hashStructure.c
Robust/src/Runtime/oooJava/rcr_runtime.h
Robust/src/Runtime/workschedule.c
Robust/src/Util/Tuple.java [new file with mode: 0644]

index ef1d21b4dd1d127ba171aa2647f5685407521413..bf81596be03aed0f1a66cce8609200d81b4b5b19 100644 (file)
@@ -3229,8 +3229,7 @@ public class BuildCode {
           Analysis.OoOJava.ConflictGraph graph = oooa.getConflictGraph(currentSESE);
           if(graph!=null){
             Set<Analysis.OoOJava.SESELock> seseLockSet = oooa.getLockMappings(graph);
-            Set<Analysis.OoOJava.WaitingElement> waitingElementSet =
-              graph.getStallSiteWaitingElementSet(fn, seseLockSet);
+            Set<Analysis.OoOJava.WaitingElement> waitingElementSet = graph.getStallSiteWaitingElementSet(fn, seseLockSet);
             
             if(waitingElementSet.size()>0){
               output.println("// stall on parent's stall sites ");
@@ -3255,9 +3254,11 @@ public class BuildCode {
                 }
                 if(state.RCR) {
                  //no need to enqueue parent effect if coarse grained conflict clears us
-                 output.println("   stallrecord.common.parentsStallSem=&rentry->parentStallSem;");
-                 output.println("   stallrecord.tag=rentry->tag;");
-                  output.println("   "+rcr.getTraverserInvocation(waitingElement.getTempDesc(), generateTemp(fm, waitingElement.getTempDesc(), null)+", &stallrecord", fn));
+                 output.println("       stallrecord.common.parentsStallSem=&rentry->parentStallSem;");
+                 output.println("       stallrecord.tag=rentry->tag;");
+                 output.println("       stallrecord.___obj___=(struct ___Object___ *)"+generateTemp(fm, waitingElement.getTempDesc(), null)+";");
+                 output.println("       stallrecord.common.classID=-"+rcr.getTraverserID(waitingElement.getTempDesc(), fn)+";");
+                 output.println("       enqueueTR(TRqueue, (void *)&stallrecord);");
                 }
                output.println("        psem_take( &(rentry->parentStallSem), (struct garbagelist *)&___locals___ );");
                 if( state.COREPROF ) {
index e2e6cec0f8cdb4260e0f3e48a9651fb77f62e301..b97486c60cb16e2e7d258d71858c07627b665933 100644 (file)
@@ -9,6 +9,7 @@ import java.util.Hashtable;
 import java.util.Iterator;
 import java.util.Set;
 import java.util.Vector;
+import Util.Tuple;
 import Analysis.Disjoint.*;
 import Analysis.MLP.CodePlan;
 import IR.Flat.*;
@@ -37,10 +38,13 @@ public class RuntimeConflictResolver {
   //This keeps track of taints we've traversed to prevent printing duplicate traverse functions
   //The Integer keeps track of the weakly connected group it's in (used in enumerateHeapRoots)
   private Hashtable<Taint, Integer> doneTaints;
+  private Hashtable<Tuple, Integer> idMap=new Hashtable<Tuple,Integer>();
   private Hashtable<Taint, Set<Effect>> globalEffects;
   private Hashtable<Taint, Set<Effect>> globalConflicts;
   private ArrayList<TraversalInfo> toTraverse;
 
+  public int currentID=1;
+
   // initializing variables can be found in printHeader()
   private static final String getAllocSiteInC = "->allocsite";
   private static final String queryVistedHashtable = "hashRCRInsert";
@@ -297,6 +301,15 @@ public class RuntimeConflictResolver {
     return "traverse___" + invar.getSafeSymbol() + 
     removeInvalidChars(flatname) + "___("+varString+");";
   }
+
+  public int getTraverserID(TempDescriptor invar, FlatNode fn) {
+    Tuple t=new Tuple(invar, fn);
+    if (idMap.containsKey(t))
+      return idMap.get(t).intValue();
+    int value=currentID++;
+    idMap.put(t, new Integer(value));
+    return value;
+  }
   
   public String removeInvalidChars(String in) {
     StringBuilder s = new StringBuilder(in);
@@ -390,6 +403,16 @@ public class RuntimeConflictResolver {
       cFile.println(    "    break;");
     }
     
+    for(Taint t: doneTaints.keySet()) {
+      if (t.isStallSiteTaint()){
+       cFile.println(    "    case -" + getTraverserID(t.getVar(), t.getStallSite())+ ": {");
+       cFile.println(    "      SESEstall * rec=(SESEstall*) record;");
+        cFile.println(    "      " + this.getTraverserInvocation(t.getVar(), "rec->___obj___, rec", t.getStallSite())+";");
+       cFile.println(    "    }");
+       cFile.println("    break;");
+      }
+    }
+
     cFile.println("    default:\n    printf(\"Invalid SESE ID was passed in.\\n\");\n    break;");
     
     cFile.println("  }");
@@ -803,7 +826,6 @@ public class RuntimeConflictResolver {
         //This is done with the assumption that an array of object stores pointers. 
         currCase.append("{\n  int i;\n");
         currCase.append("  for(i = 0; i<((struct ArrayObject *) " + prefix + " )->___length___; i++ ) {\n");
-       //XXXXXXXXX
         currCase.append("    struct ___Object___ * arrayElement =((struct ___Object___ **)(((char *) &(((struct ArrayObject *)"+ prefix+")->___length___))+sizeof(int)))[i];\n");
         currCase.append("    if( arrayElement != NULL && (");
         
index 18b6fbe4a7efc610fe8a404a1cae510d86f66964..24c17c864d9af68be06ae503cbbc1ed0211f4479 100644 (file)
@@ -399,7 +399,7 @@ void RESOLVE(SESEcommon *record, bitvt mask) {
     int shift=__builtin_ctzll(mask)+1;
     index+=shift;
     if (atomic_sub_and_test(1,&array[index].count)) {
-      if(unlikely(record->classID==STALLCLASSID)) {
+      if(unlikely(record->classID<0)) {
        //parent stall...clear it
        psem_give_tag(record->parentsStallSem, ((SESEstall *)record)->tag);
       } else {
index f6f58dbd5668fbb64207eb9817df239906bd44fb..4f5f9c2a6078d940634d9e25991b4837e06cb0e1 100644 (file)
@@ -16,12 +16,11 @@ struct rcrRecord {
   struct rcrRecord *next;
 };
 
-#define STALLCLASSID 1939921
-
 typedef struct SESEstall_t { 
   SESEcommon common;
   int size;
   void * next;
+  struct ___Object___* ___obj___;
   struct rcrRecord rcrRecords[1];
   int tag;
 } SESEstall;
index 8b0890699671a0d101ae2e42a8dab92e9fb0c3cb..26b5fb65ffdc813547ff33f1d3719be31f730de6 100644 (file)
@@ -103,8 +103,8 @@ void* workerMain( void* arg ) {
   pthread_attr_setdetachstate( &nattr, PTHREAD_CREATE_DETACHED );
 
   //set up the stall site SESErecord
-  stallrecord.common.classID=STALLCLASSID;
   stallrecord.common.offsetToParamRecords=(INTPTR) &((SESEstall *)0)->rcrRecords;
+  stallrecord.common.classID=-1;
 
   if( TRqueue == NULL ) {
     TRqueue = allocTR();
diff --git a/Robust/src/Util/Tuple.java b/Robust/src/Util/Tuple.java
new file mode 100644 (file)
index 0000000..2859717
--- /dev/null
@@ -0,0 +1,19 @@
+package Util;
+
+public class Tuple {
+  private Object a;
+  private Object b;
+  public Tuple(Object a, Object b) {
+    this.a=a;
+    this.b=b;
+  }
+  public int hashCode() {
+    return a.hashCode()*31+b.hashCode();
+  }
+  public boolean equals(Object o) {
+    if (!(o instanceof Tuple))
+      return false;
+    Tuple t=(Tuple)o;
+    return a.equals(t.a)&&b.equals(t.b);
+  }
+}
\ No newline at end of file