From: bdemsky Date: Mon, 18 Oct 2010 06:48:46 +0000 (+0000) Subject: more changes towards new version of oooJava X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=5ed53350a9d7c2fe40b32c068217b60b77ad650c;p=IRC.git more changes towards new version of oooJava --- diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 97f2eb30..7979db02 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -620,8 +620,10 @@ public class BuildCode { outmethod.println("#include \"mlp_runtime.h\""); outmethod.println("#include \"psemaphore.h\""); - if( state.RCR && rcr != null) { + if( state.RCR ) { + outmethod.println("#include \"trqueue.h\""); outmethod.println("#include \"RuntimeConflictResolver.h\""); + outmethod.println("#include \"rcr_runtime.h\""); } } @@ -2200,7 +2202,8 @@ public class BuildCode { } if (state.RCR) { - outputStructs.println("struct rcrRecord rcrRecords["+inset.size()+"];"); + if (inset.size()!=0) + outputStructs.println("struct rcrRecord rcrRecords["+inset.size()+"];"); } if( fsen.getFirstDepRecField() != null ) { @@ -3072,7 +3075,7 @@ public class BuildCode { for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) { Analysis.OoOJava.WaitingElement waitingElement = (Analysis.OoOJava.WaitingElement) iterator.next(); - if(state.RCR && rcr != null){ + if(state.RCR) { Analysis.OoOJava.ConflictGraph conflictGraph = graph; Hashtable> conflicts; ReachGraph rg = oooa.getDisjointAnalysis().getReachGraph(currentSESE.getmdEnclosing()); @@ -3108,7 +3111,7 @@ public class BuildCode { } output.println(" } "); - if(state.RCR && rcr != null) { + if(state.RCR) { output.println(" "+rcr.getTraverserInvocation(waitingElement.getTempDesc(), generateTemp(fm, waitingElement.getTempDesc(), null), fn)); } @@ -3769,7 +3772,7 @@ public class BuildCode { ); } - if (state.RCR) { + if (state.RCR&&fsen.getInVarsForDynamicCoarseConflictResolution().size()>0) { output.println(" seseToIssue->common.offsetToParamRecords=(INTPTR)sizeof("+fsen.getSESErecordName()+") - (INTPTR) & ((("+fsen.getSESErecordName()+"*)0)->rcrRecords);"); } @@ -4180,10 +4183,10 @@ public class BuildCode { output.println(" CP_LOGEVENT( CP_EVENTID_PREPAREMEMQ, CP_EVENTTYPE_END );"); output.println("#endif"); } - + // Enqueue Task Record if (state.RCR) { - output.println(" enqueueTR((void *)seseToIssue);"); + output.println(" enqueueTR(TRqueue, (void *)seseToIssue);"); } // if there were no outstanding dependencies, issue here diff --git a/Robust/src/IR/Flat/RuntimeConflictResolver.java b/Robust/src/IR/Flat/RuntimeConflictResolver.java index af403d97..e87b4377 100644 --- a/Robust/src/IR/Flat/RuntimeConflictResolver.java +++ b/Robust/src/IR/Flat/RuntimeConflictResolver.java @@ -78,6 +78,8 @@ public class RuntimeConflictResolver { cFile.println("#include \"" + hashAndQueueCFileDir + "hashRCR.h\"\n#include \"" + hashAndQueueCFileDir + "Queue_RCR.h\"\n#include "); cFile.println("#include \"classdefs.h\""); + cFile.println("#include \"structdefs.h\""); + cFile.println("#include \"mlp_runtime.h\""); cFile.println("#include \"RuntimeConflictResolver.h\""); cFile.println("#include \"hashStructure.h\""); @@ -252,6 +254,7 @@ public class RuntimeConflictResolver { //Prints out the master traverser Invocation that'll call all other traverser //based on traverserID printMasterTraverserInvocation(); + printResumeTraverserInvocation(); //TODO this is only temporary, remove when thread local vars implemented. createMasterHashTableArray(); @@ -305,8 +308,8 @@ public class RuntimeConflictResolver { } private void printMasterTraverserInvocation() { - headerFile.println("\nint traverse(SESECommon * record);"); - cFile.println("\nint traverse(SESECommon * record) {"); + headerFile.println("\nint tasktraverse(SESEcommon * record);"); + cFile.println("\nint tasktraverse(SESEcommon * record) {"); cFile.println(" switch(record->classID) {"); for(Iterator seseit=oooa.getAllSESEs().iterator();seseit.hasNext();) { @@ -332,7 +335,7 @@ public class RuntimeConflictResolver { //This will print the traverser invocation that takes in a traverserID and //starting ptr - private void printAltMasterTraverserInvocation() { + private void printResumeTraverserInvocation() { headerFile.println("\nint traverse(void * startingPtr, int traverserID);"); cFile.println("\nint traverse(void * startingPtr, int traverserID) {"); cFile.println(" switch(traverserID) {"); diff --git a/Robust/src/Runtime/oooJava/Queue_RCR.c b/Robust/src/Runtime/oooJava/Queue_RCR.c index f9449b0a..ae8f197c 100644 --- a/Robust/src/Runtime/oooJava/Queue_RCR.c +++ b/Robust/src/Runtime/oooJava/Queue_RCR.c @@ -34,7 +34,7 @@ void * dequeueRCRQueue() { tail++; if(tail & SIZE) tail = 0; - myRXRQueue.tail=tail; + myRCRQueue.tail=tail; return ptr; } diff --git a/Robust/src/Runtime/oooJava/hashStructure.c b/Robust/src/Runtime/oooJava/hashStructure.c index 91588c60..71348090 100644 --- a/Robust/src/Runtime/oooJava/hashStructure.c +++ b/Robust/src/Runtime/oooJava/hashStructure.c @@ -14,7 +14,7 @@ void rcr_createMasterHashTableArray(int maxSize){ HashStructure* rcr_createHashtable(int sizeofWaitingQueue){ int i=0; HashStructure* newTable=(HashStructure*)RUNMALLOC(sizeof(HashStructure)); - for(i=0;iarray[i].head=NULL; newTable->array[i].tail=NULL; } @@ -45,7 +45,7 @@ int rcr_isWriteBinItem(BinItem_rcr* b){ } inline int rcr_generateKey(void * ptr){ - return (((struct genericObjectStruct *) ptr)->oid)&H_MASK; + return (((struct genericObjectStruct *) ptr)->oid)&RH_MASK; } int rcr_WRITEBINCASE(HashStructure *T, void *ptr, int traverserID, SESEcommon *task, void *heaproot) { @@ -194,7 +194,7 @@ int rcr_TAILREADCASE(HashStructure *T, void * ptr, BinItem_rcr *val, BinItem_rcr retval=NOTREADY; } - if (readbintail->index==NUMREAD) { // create new read group + if (readbintail->index==RNUMREAD) { // create new read group ReadBinItem_rcr* rb=rcr_createReadBinItem(); td = &rb->array[rb->index++]; diff --git a/Robust/src/Runtime/oooJava/hashStructure.h b/Robust/src/Runtime/oooJava/hashStructure.h index 5b200e1f..67716af6 100644 --- a/Robust/src/Runtime/oooJava/hashStructure.h +++ b/Robust/src/Runtime/oooJava/hashStructure.h @@ -23,10 +23,10 @@ #define TRUE 1 #define FALSE 0 -#define NUMBINS 64 -#define NUMREAD 64 -#define NUMRENTRY 256 -#define H_MASK (NUMBINS<<4)-1 +#define RNUMBINS 64 +#define RNUMREAD 64 +#define RNUMRENTRY 256 +#define RH_MASK (RNUMBINS<<4)-1 //Note: put resolved things at the end and unresolved at the front. typedef struct BinItem_rcr { @@ -64,7 +64,7 @@ typedef struct BinElement_rcr { typedef struct Hashtable_rcr { - BinElement_rcr array[NUMBINS]; + BinElement_rcr array[RNUMBINS]; WaitingQueueBin * waitingQueue; } HashStructure; @@ -89,7 +89,7 @@ typedef struct WriteBinItem_rcr { typedef struct ReadBinItem_rcr { BinItem_rcr item; - TraverserData array[NUMREAD]; + TraverserData array[RNUMREAD]; //We don't need a head index since if the item before it was freed, then all these would be considered ready as well. int index; diff --git a/Robust/src/Runtime/oooJava/rcr_runtime.c b/Robust/src/Runtime/oooJava/rcr_runtime.c index cbf4e06b..fb98c848 100644 --- a/Robust/src/Runtime/oooJava/rcr_runtime.c +++ b/Robust/src/Runtime/oooJava/rcr_runtime.c @@ -1,12 +1,15 @@ +#include "trqueue.h" #include "rcr_runtime.h" #include "mlp_runtime.h" +__thread struct trQueue * TRqueue; + void workerTR(void *x) { struct trQueue * queue=(struct trQueue *)x; - while(true) { + while(1) { SESEcommon * tmp; do { - tmp=(SESEcommon *) dequeueTR(TRqueue); + tmp=(SESEcommon *) dequeueTR(queue); if (tmp!=NULL) break; sched_yield(); diff --git a/Robust/src/Runtime/oooJava/rcr_runtime.h b/Robust/src/Runtime/oooJava/rcr_runtime.h index fe5b4782..234440d3 100644 --- a/Robust/src/Runtime/oooJava/rcr_runtime.h +++ b/Robust/src/Runtime/oooJava/rcr_runtime.h @@ -1,7 +1,7 @@ #ifndef RCR_RUNTIME_H #define RCR_RUNTIME_H -extern __thread struct trqueue * TRqueue; +extern __thread struct trQueue * TRqueue; void workerTR(void *); diff --git a/Robust/src/Runtime/oooJava/trqueue.c b/Robust/src/Runtime/oooJava/trqueue.c index d58a33f1..852c48ae 100644 --- a/Robust/src/Runtime/oooJava/trqueue.c +++ b/Robust/src/Runtime/oooJava/trqueue.c @@ -1,12 +1,13 @@ #include "trqueue.h" #include "stdlib.h" #include "stdio.h" +#include "mlp_lock.h" //0 would mean sucess //1 would mean fail //since if we reach SIZE, we will stop operation, it doesn't matter //that we overwrite the element in the queue -void enqueueTR(trQueue *q, void * ptr) { +void enqueueTR(struct trQueue *q, void * ptr) { unsigned int head=q->head+1; if (head&TRSIZE) head=0; @@ -17,10 +18,9 @@ void enqueueTR(trQueue *q, void * ptr) { q->elements[head] = ptr; BARRIER(); q->head=head; - return 0; } -void * dequeueTR(trQueue *q) { +void * dequeueTR(struct trQueue *q) { unsigned int tail=q->tail; if(q->head==tail) return NULL; diff --git a/Robust/src/Runtime/oooJava/trqueue.h b/Robust/src/Runtime/oooJava/trqueue.h index c1f83c2e..28f97499 100644 --- a/Robust/src/Runtime/oooJava/trqueue.h +++ b/Robust/src/Runtime/oooJava/trqueue.h @@ -3,10 +3,10 @@ //NOTE: SIZE MUST BE A POWER OF TWO; //SIZE is used as mask to check overflow -#define SIZE 16384 +#define TRSIZE 16384 struct trQueue { - void * elements[SIZE]; + void * elements[TRSIZE]; volatile unsigned int head; char buffer[60];//buffer us to the next cache line volatile unsigned int tail;