Bug fixes for multicore gc
authorjzhou <jzhou>
Thu, 21 Apr 2011 01:26:49 +0000 (01:26 +0000)
committerjzhou <jzhou>
Thu, 21 Apr 2011 01:26:49 +0000 (01:26 +0000)
Robust/src/Runtime/bamboo/multicoregarbage.c
Robust/src/Runtime/bamboo/multicoremem.c
Robust/src/Runtime/bamboo/multicoreruntime.c
Robust/src/Runtime/mem.c

index 7c01d1d53e2ae6d034d36597233e7144b308c6de..f3ae6cfbee674e96bf5caaf49c0b615faeceea73 100644 (file)
@@ -2075,7 +2075,7 @@ innermoveobj:
                  unsigned int tt_size=tt_pointer[0];
                  int tt_i;
                  for(tt_i=1; tt_i<=tt_size; tt_i++) {
-                       unsigned int tt_offset=tt_pointer[i];
+                       unsigned int tt_offset=tt_pointer[tt_i];
                        void * objptr=*((void **)(((char *)origptr)+tt_offset));
                        if((objptr!= 0) && 
                          ((gcmappingtbl[OBJMAPPINGINDEX((unsigned int)objptr)] == 0) || 
@@ -2140,7 +2140,7 @@ innermoveobj:
                if((objptr != 0) && 
                        (gcmappingtbl[OBJMAPPINGINDEX((unsigned int)objptr)] == 0)) {
                  tprintf("Error moveobj, missing live obj ++: %x, %x, %d, %d, %d, %d, %d, %d, %d, %d \n", 
-                         (int)origptr, (int)objptr, __LINE__, tt_i
+                         (int)origptr, (int)objptr, __LINE__, tt_j
                          ((int *)(origptr))[0], ((int *)(objptr))[0], 
                          ((int *)(objptr))[BAMBOOMARKBIT], 
                          gcmappingtbl[OBJMAPPINGINDEX((unsigned int)objptr)], 
@@ -2172,7 +2172,7 @@ innermoveobj:
                  unsigned int tt_size=tt_pointer[0];
                  int tt_i;
                  for(tt_i=1; tt_i<=tt_size; tt_i++) {
-                       unsigned int tt_offset=tt_pointer[i];
+                       unsigned int tt_offset=tt_pointer[tt_i];
                        void * objptr=*((void **)(((char *)origptr)+tt_offset));
                        if((objptr!= 0) && 
                          ((gcmappingtbl[OBJMAPPINGINDEX((unsigned int)objptr)] == 0) || 
@@ -2330,7 +2330,7 @@ innercompact:
     }
   }
 #ifdef GC_TBL_DEBUG
-  tprintf("finish mark %x \n", (int)gcmarkedptrbound);
+  //tprintf("finish mark %x \n", (int)gcmarkedptrbound);
 #endif
 #ifdef GC_CACHE_ADAPT
   // end of an to page, wrap up its information
@@ -2907,8 +2907,7 @@ inline void flush(struct garbagelist * stackptr) {
 #endif
     GC_BAMBOO_DEBUGPRINT(0xe30a);
     GC_BAMBOO_DEBUGPRINT_REG(ptr);
-    GC_BAMBOO_DEBUGPRINT_REG(tptr);
-    GC_BAMBOO_DEBUGPRINT_REG(((int *)(tptr))[0]);
+    GC_BAMBOO_DEBUGPRINT_REG(((int *)(ptr))[0]);
     if(ptr == NULL) {
       BAMBOO_EXIT(0xb02a);
     }
@@ -3622,6 +3621,7 @@ inline void gc_collect(struct garbagelist * stackptr) {
   bamboo_smem_size = 0;
   bamboo_smem_zero_top = NULL;
 
+  gcflag = false;
   while(true) {
     if(FINISHPHASE == gcphase) {
       break;
@@ -3729,6 +3729,7 @@ inline void gc_nocollect(struct garbagelist * stackptr) {
   bamboo_smem_size = 0;
   bamboo_smem_zero_top = NULL;
 
+  gcflag = false;
   while(true) {
     if(FINISHPHASE == gcphase) {
       break;
@@ -4130,6 +4131,7 @@ inline void gc_master(struct garbagelist * stackptr) {
        }
 #endif
 #endif
+  gcflag = false;
   gccorestatus[BAMBOO_NUM_OF_CORE] = 1;
   for(i = 1; i < NUMCORESACTIVE; ++i) {
        // send gc finish messages to all cores
@@ -4137,8 +4139,22 @@ inline void gc_master(struct garbagelist * stackptr) {
        gccorestatus[i] = 1;
   }
 
-  gcflag = false;
   gcprocessing = false;
+  if(gcflag) {
+       // inform other cores to stop and wait for gc
+       gcprecheck = true;
+       for(int i = 0; i < NUMCORESACTIVE; i++) {
+         // reuse the gcnumsendobjs & gcnumreceiveobjs
+         gccorestatus[i] = 1;
+         gcnumsendobjs[0][i] = 0;
+         gcnumreceiveobjs[0][i] = 0;
+       }
+       for(int i = 0; i < NUMCORESACTIVE; i++) {
+         if(i != BAMBOO_NUM_OF_CORE) {
+               send_msg_1(i, GCSTARTPRE, false);
+         }
+       }
+  }
 #ifdef RAWPATH // TODO GC_DEBUG
   printf("(%x,%x) gc finished   \n", udn_tile_coord_x(), 
                 udn_tile_coord_y());
index cf6c921afb251627ea098bdaa3b6465766f9dcf3..2ec5fda38692b962e547e4843091eca4e06ba0dc 100644 (file)
@@ -880,20 +880,22 @@ void * smemalloc_I(int coren,
 #ifdef MULTICORE_GC
        if(!gcflag) {
          gcflag = true;
-         // inform other cores to stop and wait for gc
-         gcprecheck = true;
-         for(int i = 0; i < NUMCORESACTIVE; i++) {
-               // reuse the gcnumsendobjs & gcnumreceiveobjs
-               gccorestatus[i] = 1;
-               gcnumsendobjs[0][i] = 0;
-               gcnumreceiveobjs[0][i] = 0;
-         }
-         for(int i = 0; i < NUMCORESACTIVE; i++) {
-               if(i != BAMBOO_NUM_OF_CORE) {
-                 if(BAMBOO_CHECK_SEND_MODE()) {
-                       cache_msg_1(i, GCSTARTPRE);
-                 } else {
-                       send_msg_1(i, GCSTARTPRE, true);
+         if(!gcprocessing) {
+               // inform other cores to stop and wait for gc
+               gcprecheck = true;
+               for(int i = 0; i < NUMCORESACTIVE; i++) {
+                 // reuse the gcnumsendobjs & gcnumreceiveobjs
+                 gccorestatus[i] = 1;
+                 gcnumsendobjs[0][i] = 0;
+                 gcnumreceiveobjs[0][i] = 0;
+               }
+               for(int i = 0; i < NUMCORESACTIVE; i++) {
+                 if(i != BAMBOO_NUM_OF_CORE) {
+                       if(BAMBOO_CHECK_SEND_MODE()) {
+                         cache_msg_1(i, GCSTARTPRE);
+                       } else {
+                         send_msg_1(i, GCSTARTPRE, true);
+                       }
                  }
                }
          }
index 95173598908761058796ed816a5939ef7a86d677..8594308da2749109d485a74dca6eeac24def0b09 100644 (file)
@@ -592,7 +592,7 @@ INLINE void initruntimedata() {
   outmsgleft = 0;
   isMsgHanging = false;
 
-  smemflag = true;
+  smemflag = false;
   bamboo_cur_msp = NULL;
   bamboo_smem_size = 0;
 
@@ -1186,26 +1186,12 @@ INLINE void processmsg_memrequest_I() {
     int allocsize = 0;
     void * mem = NULL;
 #ifdef MULTICORE_GC
-    if(gcprocessing) {
-      // is currently doing gc, dump this msg if at the beginning of the gc
-         // if at the end of the gc, send a msg with a block with size of -1
-         // to ask the request core to send the mem request again
-      if(FINISHPHASE == gcphase) {
-               // if still in the finishphase of gc, send a memresponse msg with 
-               // invalid block: addr 0, size -1
-               if(BAMBOO_CHECK_SEND_MODE()) {
-                 cache_msg_3(data2, MEMRESPONSE, 0, -1);
-               } else {
-                 send_msg_3(data2, MEMRESPONSE, 0, -1, true);
-               }
-      } else if(INITPHASE == gcphase) {
-               if(BAMBOO_CHECK_SEND_MODE()) {
-                 cache_msg_1(data2, GCSTARTINIT);
-               } else {
-                 send_msg_1(data2, GCSTARTINIT, true);
-               }
-         }
+    if(gcprocessing && gcflag) {
+         // is currently doing GC and the master core does not decide to stop GC 
+         // yet
     } else {
+         // either not doing GC or the master core has decided to stop GC but 
+         // still sending msgs to other cores to inform them to stop the GC
 #endif
     mem = smemalloc_I(data2, data1, &allocsize);
     if(mem != NULL) {
@@ -1243,9 +1229,6 @@ INLINE void processmsg_memresponse_I() {
 #ifdef MULTICORE_GC
        bamboo_smem_zero_top = 0;
 #endif
-  } else if(data2 == -1) {
-       bamboo_smem_size = data2;
-       bamboo_cur_msp = (void *)data1;
   } else {
 #ifdef MULTICORE_GC
     // fill header to store the size of this mem block
@@ -1261,13 +1244,13 @@ INLINE void processmsg_memresponse_I() {
   }
   smemflag = true;
 #ifdef MULTICORE_GC
-}
+  }
 #endif
 }
 
 #ifdef MULTICORE_GC
 INLINE void processmsg_gcstartpre_I() {
-  if(gcprocessing) {
+  if(gcprocessing && gcflag) {
        // already stall for gc
   } else {
        // the first time to be informed to start gc
@@ -1821,7 +1804,7 @@ processmsg:
     case GCFINISH: {
       // received a GC finish msg
       gcphase = FINISHPHASE;
-         gcflag = false;
+         smemflag = false; // TODO
          gcprocessing = false;
       break;
     }   // case GCFINISH
index 3ddecd00fbbc661787939c295bf5e885deba901c..e808fba6d6f3e726ff1c27cd106a98974bebfe1e 100644 (file)
@@ -15,7 +15,7 @@ void * mycalloc_share(struct garbagelist * stackptr,
   int hasgc = 0;
 memalloc:
   BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
-  if(gcflag) {
+  while(gcflag) {
        BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
        gc(stackptr);
        BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();