From 5ad174b536d906769b638ec5cb2081a306ee07d5 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Wed, 20 Oct 2010 00:07:43 +0000 Subject: [PATCH] more work towards working version --- .../src/IR/Flat/RuntimeConflictResolver.java | 18 +++++----- Robust/src/Runtime/oooJava/hashStructure.c | 36 ++++++++++--------- Robust/src/Runtime/oooJava/hashStructure.h | 14 ++++---- 3 files changed, 35 insertions(+), 33 deletions(-) diff --git a/Robust/src/IR/Flat/RuntimeConflictResolver.java b/Robust/src/IR/Flat/RuntimeConflictResolver.java index aa1c5705..223f1bb5 100644 --- a/Robust/src/IR/Flat/RuntimeConflictResolver.java +++ b/Robust/src/IR/Flat/RuntimeConflictResolver.java @@ -320,7 +320,7 @@ public class RuntimeConflictResolver { Vector invars=fsen.getInVarsForDynamicCoarseConflictResolution(); for(int i=0;i"+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) { diff --git a/Robust/src/Runtime/oooJava/hashStructure.c b/Robust/src/Runtime/oooJava/hashStructure.c index 3d1e0303..fee25943 100644 --- a/Robust/src/Runtime/oooJava/hashStructure.c +++ b/Robust/src/Runtime/oooJava/hashStructure.c @@ -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<bitindexrd=td->bitindexwr=1<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<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<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<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<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<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;iindex;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; diff --git a/Robust/src/Runtime/oooJava/hashStructure.h b/Robust/src/Runtime/oooJava/hashStructure.h index a645502b..5df558ff 100644 --- a/Robust/src/Runtime/oooJava/hashStructure.h +++ b/Robust/src/Runtime/oooJava/hashStructure.h @@ -53,14 +53,14 @@ typedef struct Hashtable_rcr { //Todo this is a clone of REntry, remove data fields as necessary typedef struct Entry_rcr { SESEcommon * task; - bitv bitindex; + bitvt bitindex; } TraverserData; typedef struct WriteBinItem_rcr { BinItem_rcr item; SESEcommon * task; - bitv bitindexwr; - bitv bitindexrd; + bitvt bitindexwr; + bitvt bitindexrd; } WriteBinItem_rcr; typedef struct ReadBinItem_rcr { @@ -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 //to store in each entry. -int rcr_WRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, void *heaproot); -int rcr_READBINCASE(HashStructure *T, void *ptr, SESEcommon * task, void *heaproot); -int rcr_TAILREADCASE(HashStructure *T, void * ptr, BinItem_rcr *val, BinItem_rcr *bintail, int key, SESEcommon * task, void *heaproot); -void rcr_TAILWRITECASE(HashStructure *T, void *ptr, BinItem_rcr *val, BinItem_rcr *bintail, int key, SESEcommon * task, void *heaproot); +int rcr_WRITEBINCASE(HashStructure *T, void *ptr, SESEcommon *task, int index); +int rcr_READBINCASE(HashStructure *T, void *ptr, SESEcommon * task, int index); +int rcr_TAILREADCASE(HashStructure *T, void * ptr, BinItem_rcr *val, BinItem_rcr *bintail, int key, SESEcommon * task, int index); +void rcr_TAILWRITECASE(HashStructure *T, void *ptr, BinItem_rcr *val, BinItem_rcr *bintail, int key, SESEcommon * task, int index); #endif -- 2.34.1