Fix bugs in cache adapt verion.
authorjzhou <jzhou>
Fri, 1 Oct 2010 23:34:35 +0000 (23:34 +0000)
committerjzhou <jzhou>
Fri, 1 Oct 2010 23:34:35 +0000 (23:34 +0000)
Robust/src/Runtime/bamboo/multicoregarbage.c
Robust/src/Runtime/bamboo/multicoretask.c

index d94e72f99a5e6a617df5cdf66cc4a2ea103a55ce..83967ec5a93061527aad4b0e1f0073a2bd091ee0 100644 (file)
@@ -3057,15 +3057,33 @@ inline void gc_collect(struct garbagelist * stackptr) {
   printf("(%x,%x) Finish prefinish phase\n", udn_tile_coord_x(),
             udn_tile_coord_y());
 #endif
+#ifdef GC_CACHE_SAMPLING
+  // reset the sampling arrays
+  bamboo_dtlb_sampling_reset();
+#endif // GC_CACHE_SAMPLING
+  if(BAMBOO_NUM_OF_CORE < NUMCORESACTIVE) {
+       // zero out the gccachesamplingtbl
+       BAMBOO_MEMSET_WH(gccachesamplingtbl_local,0,size_cachesamplingtbl_local);
+       BAMBOO_MEMSET_WH(gccachesamplingtbl_local_r,0,
+               size_cachesamplingtbl_local_r);
+  }
 #endif // GC_CACHE_ADAPT
 
+  // invalidate all shared mem pointers
+  bamboo_cur_msp = NULL;
+  bamboo_smem_size = 0;
+  bamboo_smem_zero_top = NULL;
+
   while(true) {
     if(FINISHPHASE == gcphase) {
       break;
     }
   }
+
+  gcflag = false;
+  gcprocessing = false;
 #ifdef RAWPATH // TODO GC_DEBUG
-  printf("(%x,%x) Finish gc!\n", udn_tile_coord_x(), udn_tile_coord_y());
+  printf("(%x,%x) Finish gc! \n", udn_tile_coord_x(), udn_tile_coord_y());
 #endif
 } // void gc_collect(struct garbagelist * stackptr)
 
@@ -3148,15 +3166,32 @@ inline void gc_nocollect(struct garbagelist * stackptr) {
   printf("(%x,%x) Finish prefinish phase\n", udn_tile_coord_x(),
             udn_tile_coord_y());
 #endif
+#ifdef GC_CACHE_SAMPLING
+  // reset the sampling arrays
+  bamboo_dtlb_sampling_reset();
+#endif // GC_CACHE_SAMPLING
+  if(BAMBOO_NUM_OF_CORE < NUMCORESACTIVE) {
+       // zero out the gccachesamplingtbl
+       BAMBOO_MEMSET_WH(gccachesamplingtbl_local,0,size_cachesamplingtbl_local);
+       BAMBOO_MEMSET_WH(gccachesamplingtbl_local_r,0,
+               size_cachesamplingtbl_local_r);
+  }
 #endif // GC_CACHE_ADAPT
 
+  // invalidate all shared mem pointers
+  bamboo_cur_msp = NULL;
+  bamboo_smem_size = 0;
+  bamboo_smem_zero_top = NULL;
+
   while(true) {
     if(FINISHPHASE == gcphase) {
       break;
     }
   }
+  gcflag = false;
+  gcprocessing = false;
 #ifdef RAWPATH // TODO GC_DEBUG
-  printf("(%x,%x) Finish gc!\n", udn_tile_coord_x(), udn_tile_coord_y());
+  printf("(%x,%x) Finish gc! \n", udn_tile_coord_x(), udn_tile_coord_y());
 #endif
 } // void gc_collect(struct garbagelist * stackptr)
 
@@ -3498,6 +3533,7 @@ inline void gc_master(struct garbagelist * stackptr) {
   bamboo_output_cache_policy();
 #endif
   cacheAdapt_gc(false);
+
   gccorestatus[BAMBOO_NUM_OF_CORE] = 0;
   while(PREFINISHPHASE == gcphase) {
        // check the status of all cores
@@ -3508,6 +3544,18 @@ inline void gc_master(struct garbagelist * stackptr) {
        }
        BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
   }  // while(PREFINISHPHASE == gcphase)
+
+#ifdef GC_CACHE_SAMPLING
+  // reset the sampling arrays
+  bamboo_dtlb_sampling_reset();
+#endif // GC_CACHE_SAMPLING
+  if(BAMBOO_NUM_OF_CORE < NUMCORESACTIVE) {
+       // zero out the gccachesamplingtbl
+       BAMBOO_MEMSET_WH(gccachesamplingtbl_local,0,size_cachesamplingtbl_local);
+       BAMBOO_MEMSET_WH(gccachesamplingtbl_local_r,0,
+               size_cachesamplingtbl_local_r);
+       BAMBOO_MEMSET_WH(gccachepolicytbl,0,size_cachepolicytbl);
+  }
 #endif // GC_CACHE_ADAPT
 
   gcphase = FINISHPHASE;
@@ -3519,8 +3567,6 @@ inline void gc_master(struct garbagelist * stackptr) {
   bamboo_cur_msp = NULL;
   bamboo_smem_size = 0;
   bamboo_smem_zero_top = NULL;
-  gcflag = false;
-  gcprocessing = false;
 
 #ifdef GC_PROFILE
   gc_profileEnd();
@@ -3531,8 +3577,11 @@ inline void gc_master(struct garbagelist * stackptr) {
        send_msg_1(i, GCFINISH, false);
        gccorestatus[i] = 1;
   }
+
+  gcflag = false;
+  gcprocessing = false;
 #ifdef RAWPATH // TODO GC_DEBUG
-  printf("(%x,%x) gc finished \n", udn_tile_coord_x(), 
+  printf("(%x,%x) gc finished   \n", udn_tile_coord_x(), 
                 udn_tile_coord_y());
 #endif
 } // void gc_master(struct garbagelist * stackptr)
@@ -3667,13 +3716,6 @@ pregccheck:
 #endif // GC_CACHE_ADAPT
     gcprocessing = true;
     gc_collect(stackptr);
-
-    // invalidate all shared mem pointers
-    bamboo_cur_msp = NULL;
-    bamboo_smem_size = 0;
-       bamboo_smem_zero_top = NULL;
-    gcflag = false;
-    gcprocessing = false;
   } else {
        // Zero out the remaining bamboo_cur_msp 
        // Only zero out the first 4 bytes of the remaining memory
@@ -3703,34 +3745,15 @@ pregccheck:
     // not a gc core, should wait for gcfinish msg
     gcprocessing = true;
     gc_nocollect(stackptr);
-
-    // invalidate all shared mem pointers
-    bamboo_cur_msp = NULL;
-    bamboo_smem_size = 0;
-    bamboo_smem_zero_top = NULL;
-       gcflag = false;
-    gcprocessing = false;
   }
 #ifdef GC_CACHE_ADAPT
-#ifdef GC_CACHE_SAMPLING
-  // reset the sampling arrays
-  bamboo_dtlb_sampling_reset();
-#endif // GC_CACHE_SAMPLING
-  if(BAMBOO_NUM_OF_CORE < NUMCORESACTIVE) {
-       // zero out the gccachesamplingtbl
-       BAMBOO_MEMSET_WH(gccachesamplingtbl_local,0,size_cachesamplingtbl_local);
-       BAMBOO_MEMSET_WH(gccachesamplingtbl_local_r,0,
-               size_cachesamplingtbl_local_r);
-       if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
-         BAMBOO_MEMSET_WH(gccachepolicytbl,0,size_cachepolicytbl);
-       }
-  }
 #ifdef GC_CACHE_SAMPLING
   // enable the timer interrupt
   bamboo_tile_timer_set_next_event(GC_TILE_TIMER_EVENT_SETTING); 
   bamboo_unmask_timer_intr();
 #endif // GC_CACHE_SAMPLING
 #endif // GC_CACHE_ADAPT
+
   return true;
 } // void gc(struct garbagelist * stackptr)
 
index f630da0ba99c353cc2a72e175080747dbf63fd95..2d0636031baa5cca28acac8291f45e2209547927 100644 (file)
@@ -2836,7 +2836,7 @@ INLINE void processmsg_gclobjinfo_I() {
     gcheaptop = data4;
   }
   // large obj info here
-  for(int k = 5; k < data1; ) {
+  for(int k = 5; k < data1; k+=2) {
     int lobj = msgdata[msgdataindex];
     MSG_INDEXINC_I();   //msgdata[k++];
     int length = msgdata[msgdataindex];