more work towards working version
authorbdemsky <bdemsky>
Wed, 20 Oct 2010 00:07:43 +0000 (00:07 +0000)
committerbdemsky <bdemsky>
Wed, 20 Oct 2010 00:07:43 +0000 (00:07 +0000)
Robust/src/IR/Flat/RuntimeConflictResolver.java
Robust/src/Runtime/oooJava/hashStructure.c
Robust/src/Runtime/oooJava/hashStructure.h

index aa1c57054ccdf8c574b55bbe9db7fd4e32eee685..223f1bb5e3506c7d42272767d486d5d3f7c1f39b 100644 (file)
@@ -320,7 +320,7 @@ public class RuntimeConflictResolver {
       Vector<TempDescriptor> invars=fsen.getInVarsForDynamicCoarseConflictResolution();
       for(int i=0;i<invars.size();i++) {
        TempDescriptor tmp=invars.get(i);
-       cFile.println("      " + this.getTraverserInvocation(tmp, "rec->"+tmp, fsen));
+       cFile.println("      " + this.getTraverserInvocation(tmp, "rec->"+tmp+", record", fsen));
       }
       cFile.println(    "    }");
       cFile.println(    "    break;");
@@ -336,16 +336,16 @@ public class RuntimeConflictResolver {
   //This will print the traverser invocation that takes in a traverserID and 
   //starting ptr
   private void printResumeTraverserInvocation() {
-    headerFile.println("\nint traverse(void * startingPtr, int traverserID);");
-    cFile.println("\nint traverse(void * startingPtr, int traverserID) {");
+    headerFile.println("\nint traverse(void * startingPtr, SESEcommon * record, int traverserID);");
+    cFile.println("\nint traverse(void * startingPtr, SESEcommon *record, int traverserID) {");
     cFile.println(" switch(traverserID) {");
     
     for(Taint t: doneTaints.keySet()) {
       cFile.println("  case " + doneTaints.get(t)+ ":");
       if(t.isRBlockTaint()) {
-        cFile.println("    " + this.getTraverserInvocation(t.getVar(), "startingPtr", t.getSESE()));
+        cFile.println("    " + this.getTraverserInvocation(t.getVar(), "startingPtr, record", t.getSESE()));
       } else if (t.isStallSiteTaint()){
-        cFile.println("    " + this.getTraverserInvocation(t.getVar(), "startingPtr", t.getStallSite()));
+        cFile.println("    " + this.getTraverserInvocation(t.getVar(), "startingPtr, record", t.getStallSite()));
       } else {
         System.out.println("RuntimeConflictResolver encountered a taint that is neither SESE nor stallsite: " + t);
       }
@@ -591,7 +591,7 @@ public class RuntimeConflictResolver {
     }
     //IMPORTANT: remember to change getTraverserInvocation if you change the line below
     String methodName = "void traverse___" + removeInvalidChars(inVar) + 
-                        removeInvalidChars(rBlock) + "___(void * InVar)";
+                        removeInvalidChars(rBlock) + "___(void * InVar, SESEcommon *record)";
     
     cFile.println(methodName + " {");
     headerFile.println(methodName + ";");
@@ -608,7 +608,7 @@ public class RuntimeConflictResolver {
       cFile.println(clearQueue + ";\n" + resetVisitedHashTable + ";"); 
       
       //Casts the ptr to a genericObjectStruct so we can get to the ptr->allocsite field. 
-      cFile.println("struct genericObjectStruct * ptr = (struct genericObjectStruct *) InVar;\nif (InVar != NULL) {\n " + queryVistedHashtable
+      cFile.println("struct ___Object___ * ptr = (struct ___Object___ *) InVar;\nif (InVar != NULL) {\n " + queryVistedHashtable
           + "(ptr);\n do {");
       
       cFile.println("  switch(ptr->allocsite) {");
@@ -675,13 +675,13 @@ public class RuntimeConflictResolver {
       assert heaprootNum != -1;
       int allocSiteID = connectedHRHash.get(taint).getWaitingQueueBucketNum(node);
       int traverserID = doneTaints.get(taint);
-      currCase.append("    rcr_WRITEBINCASE(allHashStructures["+heaprootNum+"],"+prefix+","+traverserID+",NULL,NULL)");
+      currCase.append("    rcr_WRITEBINCASE(allHashStructures["+heaprootNum+"],"+prefix+", record, -1"+")");
     } else if (primConfRead||objConfRead) {
       int heaprootNum = connectedHRHash.get(taint).id;
       assert heaprootNum != -1;
       int allocSiteID = connectedHRHash.get(taint).getWaitingQueueBucketNum(node);
       int traverserID = doneTaints.get(taint);
-      currCase.append("    rcr_READBINCASE(allHashStructures["+heaprootNum+"],"+prefix+","+traverserID+",NULL,NULL)");
+      currCase.append("    rcr_READBINCASE(allHashStructures["+heaprootNum+"],"+prefix+", record, -1"+")");
     }
 
     if(objConfRead) {
index 3d1e03036e0d6d0e3d88071d25b717fa5bb8f249..fee2594383b740cf8ca5f85aa98d360a94d95980 100644 (file)
@@ -2,6 +2,7 @@
 //#include "WaitingQueue.h"
 #include "mlp_lock.h"
 #include "mem.h"
+#include "classdefs.h"
 
 //NOTE: this is only temporary (for testing) and will be removed in favor of thread local variables
 //It's basically an array of hashStructures so we can simulate what would happen in a many-threaded version
@@ -10,6 +11,8 @@ HashStructure ** allHashStructures;
 #define ISREADBIN(x) (!(x&BINMASK))
 //#define POPCOUNT(x) __builtin_popcountll(x)
 //__builtin_popcountll
+#define RESOLVE(x) 
+
 
 //NOTE: only temporary
 void rcr_createMasterHashTableArray(int maxSize){
@@ -58,13 +61,13 @@ int rcr_WRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index) {
 
   if (val==NULL) {
     BinItem_rcr * b=(BinItem_rcr*)rcr_createWriteBinItem();
-    TraverserData * td = &((WriteBinItem_rcr*)b)->val;
+    WriteBinItem_rcr * td = (WriteBinItem_rcr*)b;
     b->total=1;
     b->status=READY;
     
     //common to both types
     td->task=task;
-    td->bitindex=1<<index;
+    td->bitindexrd=td->bitindexwr=1<<index;
     be->tail=b;
     
     //release lock
@@ -73,7 +76,7 @@ int rcr_WRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index) {
   }
 
   BinItem_rcr *bintail=be->tail;
-  bitv rdmask=0,wrmask=0;
+  bitvt rdmask=0,wrmask=0;
   int status=NOTREADY;
 
   if (ISWRITEBIN(bintail->type)) {
@@ -81,7 +84,7 @@ int rcr_WRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index) {
     //last one is to check for SESE blocks in a while loop.
     if(unlikely(td->task == task)) {
       be->head=val;
-      bitv bit=1<<index;
+      bitvt bit=1<<index;
       if (!(bit & td->bitindexwr)) {
        td->bitindexwr|=bit;
        td->bitindexrd|=bit;
@@ -95,7 +98,7 @@ int rcr_WRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index) {
       //if it matches, then we remove it and the code below will upgrade it to a write.
       ((ReadBinItem_rcr *)bintail)->index--;
       atomic_dec(&bintail->total);
-      rdmask=tr->bitindex;
+      rdmask=td->bitindex;
       if (bintail->status!=READY)
        wrmask=rdmask;
       status=SPECNOTREADY;
@@ -106,7 +109,7 @@ int rcr_WRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index) {
   b->item.total=1;
   b->task=task;
 
-  bitv bit=1<<index;
+  bitvt bit=1<<index;
   if (wrmask&bit) {
     //count already includes this
     status=READY;
@@ -120,7 +123,7 @@ int rcr_WRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index) {
   if (bintail->status==READY&&bintail->total==0) {
     //we may have to set write as ready
     while(val->total==0) {
-      if (val==b) {
+      if (val==((BinItem_rcr *)b)) {
        b->item.status=READY;
        be->head=val;
        return READY;
@@ -168,16 +171,16 @@ int rcr_READBINCASE(HashStructure *T, void *ptr, SESEcommon * task, int index) {
 
   //check if already added item or not.
   if (ISWRITEBIN(bintail->type)) {
-    WriteBinItem_rcr td = (WriteBinItem_rcr *)bintail;
+    WriteBinItem_rcr td = (WriteBinItem_rcr *)bintail;
     if(unlikely(td->task==task)) {
       //RELEASE LOCK
-      bitv bit=1<<index;
+      bitvt bit=1<<index;
       int status=bintail->status;
       if (!(td->bitindexrd & bit)) {
        td->bitindexrd|=bit;
        td->bitindexwr|=bit;
        if (status==NOTREADY)
-         status=SNOTREADY;
+         status=SPECNOTREADY;
       } else 
        status=READY;
       be->head=val;
@@ -187,12 +190,12 @@ int rcr_READBINCASE(HashStructure *T, void *ptr, SESEcommon * task, int index) {
     TraverserData * td = &((ReadBinItem_rcr *)bintail)->array[((ReadBinItem_rcr *)bintail)->index - 1];
     if (unlikely(td->task==task)) {
       //RELEASE LOCK
-      bitv bit=1<<index;
+      bitvt bit=1<<index;
       int status=bintail->status;
       if (!(td->bitindex & bit)) {
        td->bitindex|=bit;
        if (status==NOTREADY)
-         status=SNOTREADY;
+         status=SPECNOTREADY;
       } else 
        status=READY;
       be->head=val;
@@ -247,7 +250,6 @@ void rcr_TAILWRITECASE(HashStructure *T, void *ptr, BinItem_rcr *val, BinItem_rc
   rb->item.total=1;
   rb->item.status=NOTREADY;
 
-  td->binitem = (BinItem_rcr *) rb;
   td->task=task;
   td->bitindex=1<<index;
 
@@ -256,8 +258,8 @@ void rcr_TAILWRITECASE(HashStructure *T, void *ptr, BinItem_rcr *val, BinItem_rc
   T->array[key].head=val;//released lock
 }
 
-RETIREHASHTABLE(HashStructure *T, SESECommon *task, int key) {
-  BinElement_rcr * be = &(T->array[key]);  
+rcr_RETIREHASHTABLE(HashStructure *T, SESEcommon *task, int key) {
+  BinElement_rcr * be = &(T->array[key]);
   BinItem_rcr *b=be->head;
 
   if(ISREADBIN(READBIN)) {
@@ -285,7 +287,7 @@ RETIREHASHTABLE(HashStructure *T, SESECommon *task, int key) {
          ReadBinItem_rcr* rptr=(ReadBinItem_rcr*)ptr;
          for (i=0;i<rptr->index;i++) {
            RESOLVE(rptr->array[i]);
-            if (((INTPTR)rptr->array[i]->task)&PARENTBIN) {
+            if (((INTPTR)rptr->array[i].task)&PARENTBIN) {
               //parents go immediately
               atomic_dec(&rptr->item.total);
             }
@@ -306,7 +308,7 @@ RETIREHASHTABLE(HashStructure *T, SESECommon *task, int key) {
           break;
        if(ptr->status==NOTREADY) {
          WriteBinItem_rcr* wptr=(WriteBinItem_rcr*)ptr;
-         RESOLVE(wptr->val);
+         RESOLVE(wptr);
          ptr->status=READY;
          if(((INTPTR)wptr->task)&PARENTBIN) {
            val=val->next;
index a645502bd5886aaa02cfd61eca12876f6b9fdd34..5df558ffd8dc39069007046725f07406da05a15b 100644 (file)
@@ -53,14 +53,14 @@ typedef struct Hashtable_rcr {
 //Todo this is a clone of REntry, remove data fields as necessary\r
 typedef struct Entry_rcr {\r
   SESEcommon * task;\r
-  bitv bitindex;\r
+  bitvt bitindex;\r
 } TraverserData;\r
 \r
 typedef struct WriteBinItem_rcr {\r
   BinItem_rcr item;\r
   SESEcommon * task;\r
-  bitv bitindexwr;\r
-  bitv bitindexrd;\r
+  bitvt bitindexwr;\r
+  bitvt bitindexrd;\r
 } WriteBinItem_rcr;\r
 \r
 typedef struct ReadBinItem_rcr {\r
@@ -83,9 +83,9 @@ inline int rcr_generateKey(void * ptr);
 //Method signatures are not in their final form since I have still not decided what is the optimum amount of data\r
 //to store in each entry.\r
 \r
-int rcr_WRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, void *heaproot);\r
-int rcr_READBINCASE(HashStructure *T, void *ptr, SESEcommon * task, void *heaproot);\r
-int rcr_TAILREADCASE(HashStructure *T, void * ptr, BinItem_rcr *val, BinItem_rcr *bintail, int key, SESEcommon * task, void *heaproot);\r
-void rcr_TAILWRITECASE(HashStructure *T, void *ptr, BinItem_rcr *val, BinItem_rcr *bintail, int key, SESEcommon * task, void *heaproot);\r
+int rcr_WRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index);\r
+int rcr_READBINCASE(HashStructure *T, void *ptr, SESEcommon * task, int index);\r
+int rcr_TAILREADCASE(HashStructure *T, void * ptr, BinItem_rcr *val, BinItem_rcr *bintail, int key, SESEcommon * task, int index);\r
+void rcr_TAILWRITECASE(HashStructure *T, void *ptr, BinItem_rcr *val, BinItem_rcr *bintail, int key, SESEcommon * task, int index);\r
 \r
 #endif\r