From ce3fc0b22f292f76f18b8d529726460a54f5a3da Mon Sep 17 00:00:00 2001 From: bdemsky Date: Tue, 9 Nov 2010 09:07:43 +0000 Subject: [PATCH] changes --- Robust/src/IR/Flat/BuildCode.java | 9 +++--- Robust/src/Runtime/mlp_runtime.c | 52 +++++++++++++++++++++---------- Robust/src/Runtime/mlp_runtime.h | 1 + 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 97e09ca0..10f8e1bc 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -3120,7 +3120,6 @@ public class BuildCode { output.println(" stallrecord->common.rcrstatus=1;"); output.println(" stallrecord->common.offsetToParamRecords=(INTPTR) & (((SESEstall *)0)->rcrRecords);"); output.println(" stallrecord->common.refCount = 10003;"); - output.println(" int refCount=10000;"); output.println(" int localCount=10000;"); output.println(" stallrecord->rcrRecords[0].index=0;"); output.println(" stallrecord->rcrRecords[0].flag=0;"); @@ -3144,7 +3143,6 @@ public class BuildCode { output.println(" if(ADDRENTRY(runningSESE->memoryQueueArray[" + waitingElement.getQueueID() + "],rentry)==NOTREADY) {"); output.println(" localCount--;"); - output.println(" refCount--;"); output.println(" }"); output.println("#if defined(RCR)&&!defined(OOO_DISABLE_TASKMEMPOOL)"); output.println(" else poolfreeinto(runningSESE->memoryQueueArray["+waitingElement.getQueueID()+"]->rentrypool, rentry);"); @@ -3190,7 +3188,7 @@ public class BuildCode { output.println(" }"); //release our reference to stall record output.println("#ifndef OOO_DISABLE_TASKMEMPOOL"); - output.println(" RELEASE_REFERENCES_TO((SESEcommon *)stallrecord, refCount);"); + output.println(" RELEASE_REFERENCE_TO((SESEcommon *)stallrecord);"); output.println("#endif"); output.println(" }");//exit block } @@ -4588,13 +4586,14 @@ public class BuildCode { output.println(" rentry->queue=runningSESE->memoryQueueArray[" + waitingElement.getQueueID()+"];"); output.println(" if(ADDRENTRY(runningSESE->memoryQueueArray["+ waitingElement.getQueueID()+ "],rentry)==READY) {"); - output.println(" refCount--;"); for(int j=0;mask!=0;j++) { if ((mask&1)==1) output.println(" dispCount"+j+"++;"); mask=mask>>1; } - output.println(" }"); + output.println(" } else "); + output.println(" refCount--;"); + } if (fsen.getDynamicInVarSet().contains(td)) { diff --git a/Robust/src/Runtime/mlp_runtime.c b/Robust/src/Runtime/mlp_runtime.c index ad1542b5..b357c0cc 100644 --- a/Robust/src/Runtime/mlp_runtime.c +++ b/Robust/src/Runtime/mlp_runtime.c @@ -534,6 +534,7 @@ int ADDVECTOR(MemoryQueue *Q, REntry *r) { //expose entry int index=V->index; V->array[index]=r; + r->index=index; //*****NEED memory barrier here to ensure compiler does not reorder writes to V.array and V.index BARRIER(); V->index++; @@ -598,7 +599,7 @@ void RETIRERENTRY(MemoryQueue* Q, REntry * r) { } #ifndef OOO_DISABLE_TASKMEMPOOL #ifdef RCR - if(atomic_sub_and_test(1, &r->count)) + if (atomic_sub_and_test(1, &r->count)) #endif poolfreeinto(Q->rentrypool, r); #endif @@ -607,6 +608,13 @@ void RETIRERENTRY(MemoryQueue* Q, REntry * r) { void RETIRESCC(MemoryQueue *Q, REntry *r) { SCC* s=(SCC *)r->qitem; s->item.total=0;//don't need atomicdec + void *flag=NULL; + flag=(void*)LOCKXCHG((unsigned INTPTR*)&(s->val), (unsigned INTPTR)flag); + if (flag!=NULL) { +#if defined(RCR)&&defined(OOO_DISABLE_TASKMEMPOOL) + RELEASE_REFERENCE_TO(((REntry*)flag)->seseRec); +#endif + } RESOLVECHAIN(Q); } @@ -697,6 +705,13 @@ void RETIREBIN(Hashtable *T, REntry *r, BinItem *b) { void RETIREVECTOR(MemoryQueue *Q, REntry *r) { Vector* V=(Vector *)r->qitem; atomic_dec(&V->item.total); +#ifdef RCR + REntry* val=NULL; + val=(REntry*)LOCKXCHG((unsigned INTPTR*)&(V->array[r->index]), (unsigned INTPTR)val); + if (val!=NULL) { + RELEASE_REFERENCE_TO( ((REntry*)val)->seseRec); + } +#endif if (V->item.next!=NULL && V->item.total==0) { //NOTE: ORDERING CRUCIAL HERE RESOLVECHAIN(Q); } @@ -705,24 +720,24 @@ void RETIREVECTOR(MemoryQueue *Q, REntry *r) { void RESOLVECHAIN(MemoryQueue *Q) { while(TRUE) { MemoryQueueItem* head=Q->head; - if (head->next==NULL||head->total!=0) { + if (head->next==NULL||head->total!=0) { //item is not finished - if (head->status!=READY) { - //need to update status - head->status=READY; - if (isHashtable(head)) { - RESOLVEHASHTABLE(Q, (Hashtable *) head); - } else if (isVector(head)) { - RESOLVEVECTOR(Q, (Vector *) head); - } else if (isSingleItem(head)) { - RESOLVESCC((SCC *)head); - } - if (head->next==NULL) - break; - if (head->total!=0) - break; + if (head->status!=READY) { + //need to update status + head->status=READY; + if (isHashtable(head)) { + RESOLVEHASHTABLE(Q, (Hashtable *) head); + } else if (isVector(head)) { + RESOLVEVECTOR(Q, (Vector *) head); + } else if (isSingleItem(head)) { + RESOLVESCC((SCC *)head); + } + if (head->next==NULL) + break; + if (head->total!=0) + break; } else - break; + break; } MemoryQueueItem* nextitem=head->next; CAS((unsigned INTPTR*)&(Q->head), (unsigned INTPTR)head, (unsigned INTPTR)nextitem); @@ -841,6 +856,9 @@ void resolveDependencies(REntry* rentry){ workScheduleSubmit((void *)seseCommon); } } +#ifndef OOO_DISABLE_TASKMEMPOOL + RELEASE_REFERENCE_TO(seseCommon); +#endif } else if (type==PARENTCOARSE) { if (atomic_sub_and_test(1, &(seseCommon->unresolvedDependencies))) { psem_give_tag(seseCommon->parentsStallSem, ((SESEstall *) seseCommon)->tag); diff --git a/Robust/src/Runtime/mlp_runtime.h b/Robust/src/Runtime/mlp_runtime.h index 4e4e343e..8573fe38 100644 --- a/Robust/src/Runtime/mlp_runtime.h +++ b/Robust/src/Runtime/mlp_runtime.h @@ -160,6 +160,7 @@ typedef struct REntry_t{ INTPTR* pointer; #ifdef RCR INTPTR mask; + int index; #else psemaphore * parentStallSem; int tag; -- 2.34.1