changes
authorbdemsky <bdemsky>
Tue, 9 Nov 2010 09:07:43 +0000 (09:07 +0000)
committerbdemsky <bdemsky>
Tue, 9 Nov 2010 09:07:43 +0000 (09:07 +0000)
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/mlp_runtime.c
Robust/src/Runtime/mlp_runtime.h

index 97e09ca02742577e4e91c06195580efbd0ddbf54..10f8e1bca78859bc88a735af7d56f2e44cf1a813 100644 (file)
@@ -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)) {
index ad1542b53954f11475436f832674e5b30bd4a5a0..b357c0cc75ffacaad46d0d703aa31e82910312e4 100644 (file)
@@ -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);
index 4e4e343eece92ef831c95834595baf701957b102..8573fe38fb9e3847bf15701b7aef920eb40cfcb4 100644 (file)
@@ -160,6 +160,7 @@ typedef struct REntry_t{
   INTPTR* pointer;
 #ifdef RCR
   INTPTR mask;
+  int index;
 #else
   psemaphore * parentStallSem;
   int tag;