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;");
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);");
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
}
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)) {
//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++;
}
#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
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);
}
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);
}
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);
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);