Make the statistic data for cache adaption irrelavent with the timer counter. Use...
authorjzhou <jzhou>
Thu, 16 Sep 2010 00:04:23 +0000 (00:04 +0000)
committerjzhou <jzhou>
Thu, 16 Sep 2010 00:04:23 +0000 (00:04 +0000)
Robust/src/Runtime/bamboo/multicorecache.h
Robust/src/Runtime/bamboo/multicoregarbage.c
Robust/src/Runtime/bamboo/multicoreruntime.h
Robust/src/Runtime/bamboo/multicoretask.c

index ee85342378e657c7f8b48a42e401e9c0861cb4ad..5d4af667e94e7a24291e8e1a90a24579548ac675 100644 (file)
@@ -3,8 +3,8 @@
 
 #ifdef MULTICORE_GC
 #ifdef GC_CACHE_ADAPT
-#define GC_TILE_TIMER_EVENT_SETTING 100000000 // should be consistent with 
-                                              // runtime_arch.h
+#define GC_CACHE_SAMPLING_UNIT 100000000
+#define GC_TILE_TIMER_EVENT_SETTING 100000000  
 #define GC_NUM_SAMPLING 24
 #define GC_CACHE_ADAPT_HOTPAGE_THRESHOLD 1000
 #define GC_CACHE_ADAPT_ACCESS_THRESHOLD  30
index 530a289e2df19968ad9e6b6f062412bd30a7d4fe..d9f67288f34a1c1328056d7aa030cd6194b4cbb7 100644 (file)
@@ -2877,6 +2877,56 @@ void cacheAdapt_gc(bool isgccachestage) {
 // the master core decides how to adapt cache strategy for the mutator 
 // according to collected statistic data
 extern int gc_num_sampling;
+
+bool cacheAdapt_policy_d(VA page_sva,
+                            bamboo_cache_policy_t* policy,
+                                                int page_num,
+                                                int page_index){
+  int hottestcore = 0;
+  int num_hotcore = 0;
+  int hotfreq = 0;
+       
+  for(int i = 0; i < NUMCORESACTIVE; i++) {
+       int * local_tbl = (int *)((void *)gccachesamplingtbl_r
+               +page_num*sizeof(float)*i);
+       int freq = local_tbl[page_index];
+       // TODO
+/*     if(page_sva == 0xd180000) {
+      tprintf("%x %d %d\n", (int)page_sva, i, (int)(freq*100000));
+       }*/
+       // TODO
+    // check the freqency, decide if this page is hot for the core
+       if(hotfreq < freq) {
+         hotfreq = freq;
+         hottestcore = i;
+       }
+       if(freq > GC_CACHE_ADAPT_HOTPAGE_THRESHOLD) {
+         num_hotcore++;
+       }
+  }
+  // TODO
+  // Decide the cache strategy for this page
+  // If decide to adapt a new cache strategy, write into the shared block of
+  // the gcsharedsamplingtbl. The mem recording information that has been 
+  // written is enough to hold the information.
+  // Format: page start va + cache strategy(hfh/(host core+[x,y]))
+  if(hotfreq == 0) {
+       // this page has not been accessed, do not change its cache policy
+       return false;
+  }
+  if(num_hotcore > GC_CACHE_ADAPT_ACCESS_THRESHOLD) {
+       // use hfh
+       policy->cache_mode = BAMBOO_CACHE_MODE_HASH;
+  } else {
+       // locally cache the page in the hottest core
+       // NOTE: (x,y) should be changed to (x+1, y+1)!!!
+       policy->cache_mode = BAMBOO_CACHE_MODE_COORDS;
+       policy->lotar_x = bamboo_cpu2coords[2*hottestcore]+1;
+       policy->lotar_y = bamboo_cpu2coords[2*hottestcore+1]+1;
+  }
+  return true;
+}
+
 void cacheAdapt_master() {
   // check the statistic data
   // for each page, decide the new cache strategy
@@ -2889,54 +2939,16 @@ void cacheAdapt_master() {
   int num_hotcore = 0;
   int hotfreq = 0;
   for(page_index = 0; page_index < page_num; page_index++) {
-       hottestcore = 0;
-       num_hotcore = 0;
-       hotfreq = 0;
        page_sva = gcbaseva + (BAMBOO_PAGE_SIZE) * page_index;
-       for(int i = 0; i < NUMCORESACTIVE; i++) {
-         int * local_tbl = (int *)((void *)gccachesamplingtbl_r
-                 +page_num*sizeof(float)*i);
-         int freq = local_tbl[page_index];
-         // TODO
-/*       if(page_sva == 0xd180000) {
-               tprintf("%x %d %d\n", (int)page_sva, i, (int)(freq*100000));
-         }*/
-         // TODO
-         // check the freqency, decide if this page is hot for the core
-         if(hotfreq < freq) {
-               hotfreq = freq;
-               hottestcore = i;
-         }
-         if(freq > GC_CACHE_ADAPT_HOTPAGE_THRESHOLD) {
-               num_hotcore++;
-         }
-       }
-       // TODO
-       // Decide the cache strategy for this page
-       // If decide to adapt a new cache strategy, write into the shared block of
-       // the gcsharedsamplingtbl. The mem recording information that has been 
-       // written is enough to hold the information.
-       // Format: page start va + cache strategy(hfh/(host core+[x,y]))
-       if(hotfreq == 0) {
-         // this page has not been accessed, do not change its cache strategy
-         continue;
-       }
        bamboo_cache_policy_t policy = {0};
-       if(num_hotcore > GC_CACHE_ADAPT_ACCESS_THRESHOLD) {
-         // use hfh
-         policy.cache_mode = BAMBOO_CACHE_MODE_HASH;
-       } else {
-         // locally cache the page in the hottest core
-         // NOTE: (x,y) should be changed to (x+1, y+1)!!!
-         policy.cache_mode = BAMBOO_CACHE_MODE_COORDS;
-         policy.lotar_x = bamboo_cpu2coords[2*hottestcore]+1;
-         policy.lotar_y = bamboo_cpu2coords[2*hottestcore+1]+1;
+       bool ischange=cacheAdapt_policy_d(page_sva, &policy, page_num, page_index);
+       if(ischange) {
+         *tmp_p = page_index;
+         tmp_p++;
+         *tmp_p = policy.word;
+         tmp_p++;
+         numchanged++;
        }
-       *tmp_p = page_index;
-       tmp_p++;
-       *tmp_p = policy.word;
-       tmp_p++;
-       numchanged++;
   }
   *gccachepolicytbl = numchanged;
 }
index 0b34c18feaf7e3d42d1e267b0151cafd7cc49900..b86a5c06880b2a1ecfeeb2b310fae9beb4a2e04d 100644 (file)
@@ -299,7 +299,25 @@ struct Queue * totransobjqueue; // queue to hold objs to be transferred
 #define BAMBOO_PAGE_SIZE (64 * 64)
 #define BAMBOO_SMEM_SIZE (64 * 64) // (BAMBOO_PAGE_SIZE)
 #define BAMBOO_SHARED_MEM_SIZE ((BAMBOO_PAGE_SIZE) *(BAMBOO_NUM_PAGES))
+
+#elif defined GC_CACHE_ADAPT
+#define BAMBOO_NUM_PAGES ((GC_BAMBOO_NUMCORES)*(2+14))
+#ifdef GC_LARGEPAGESIZE
+#define BAMBOO_PAGE_SIZE (1024 * 1024)  // (4096)
+#define BAMBOO_SMEM_SIZE (1024 * 1024)
+#elif defined GC_SMALLPAGESIZE
+#define BAMBOO_PAGE_SIZE (64 * 1024)  // (4096)
+#define BAMBOO_SMEM_SIZE (64 * 1024)
+#elif defined GC_SMALLPAGESIZE2
+#define BAMBOO_PAGE_SIZE (16 * 1024)  // (4096)
+#define BAMBOO_SMEM_SIZE (16 * 1024)
 #else
+#define BAMBOO_PAGE_SIZE (256 * 1024)  // (4096)
+#define BAMBOO_SMEM_SIZE (256 * 1024)
+#endif // GC_LARGEPAGESIZE
+#define BAMBOO_SHARED_MEM_SIZE ((BAMBOO_PAGE_SIZE) * (BAMBOO_NUM_PAGES))
+
+#else // GC_DEBUG
 #ifdef GC_LARGESHAREDHEAP
 #define BAMBOO_NUM_PAGES ((GC_BAMBOO_NUMCORES)*(2+2))
 #elif defined GC_LARGESHAREDHEAP2
index 647394bb0dda0618fadcfb42151a4e42c351e3b0..c2e55abea944d13de6b8ef202e584f53d5ffe528 100644 (file)
@@ -1954,8 +1954,8 @@ void * smemalloc_I(int coren,
        }
        return NULL;
 #else
-    BAMBOO_DEBUGPRINT(0xa001);
-    BAMBOO_EXIT(0xa001);
+    BAMBOO_DEBUGPRINT(0xe003);
+    BAMBOO_EXIT(0xe003);
 #endif
   }
   return mem;
@@ -2080,7 +2080,7 @@ INLINE int checkMsgLength_I(int size) {
     while(i-- > 0) {
       BAMBOO_DEBUGPRINT(msgdata[msgdataindex+i]);
     }
-    BAMBOO_EXIT(0xd005);
+    BAMBOO_EXIT(0xe004);
     break;
   }
   }
@@ -2118,7 +2118,7 @@ INLINE void processmsg_transobj_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(msgdata[msgdataindex] /*[2]*/);
 #endif
-    BAMBOO_EXIT(0xa002);
+    BAMBOO_EXIT(0xe005);
   }
   // store the object and its corresponding queue info, enqueue it later
   transObj->objptr = (void *)msgdata[msgdataindex];  //[2]
@@ -2200,7 +2200,7 @@ INLINE void processmsg_transtall_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(msgdata[msgdataindex] /*[1]*/);
 #endif
-    BAMBOO_EXIT(0xa003);
+    BAMBOO_EXIT(0xe006);
   }
   int num_core = msgdata[msgdataindex]; //[1]
   MSG_INDEXINC_I();
@@ -2253,7 +2253,7 @@ INLINE void processmsg_lockgrount_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(msgdata[msgdataindex] /*[2]*/);
 #endif
-    BAMBOO_EXIT(0xa004);
+    BAMBOO_EXIT(0xe007);
   }
   int data2 = msgdata[msgdataindex];
   MSG_INDEXINC_I();
@@ -2275,7 +2275,7 @@ INLINE void processmsg_lockgrount_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data2);
 #endif
-    BAMBOO_EXIT(0xa005);
+    BAMBOO_EXIT(0xe008);
   }
 }
 
@@ -2289,7 +2289,7 @@ INLINE void processmsg_lockdeny_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data2);
 #endif
-    BAMBOO_EXIT(0xa006);
+    BAMBOO_EXIT(0xe009);
   }
   if((lockobj == data2) && (lock2require == data3)) {
 #ifdef DEBUG
@@ -2307,7 +2307,7 @@ INLINE void processmsg_lockdeny_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data2);
 #endif
-    BAMBOO_EXIT(0xa007);
+    BAMBOO_EXIT(0xe00a);
   }
 }
 
@@ -2357,7 +2357,7 @@ INLINE void processmsg_redirectgrount_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data2);
 #endif
-    BAMBOO_EXIT(0xa00a);
+    BAMBOO_EXIT(0xe00b);
   }
   if(lockobj == data2) {
 #ifdef DEBUG
@@ -2378,7 +2378,7 @@ INLINE void processmsg_redirectgrount_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data2);
 #endif
-    BAMBOO_EXIT(0xa00b);
+    BAMBOO_EXIT(0xe00c);
   }
 }
 
@@ -2390,7 +2390,7 @@ INLINE void processmsg_redirectdeny_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data2);
 #endif
-    BAMBOO_EXIT(0xa00c);
+    BAMBOO_EXIT(0xe00d);
   }
   if(lockobj == data2) {
 #ifdef DEBUG
@@ -2408,7 +2408,7 @@ INLINE void processmsg_redirectdeny_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data2);
 #endif
-    BAMBOO_EXIT(0xa00d);
+    BAMBOO_EXIT(0xe00e);
   }
 }
 
@@ -2427,7 +2427,7 @@ INLINE void processmsg_redirectrelease_I() {
 INLINE void processmsg_profileoutput_I() {
   if(BAMBOO_NUM_OF_CORE == STARTUPCORE) {
     // startup core can not receive profile output finish msg
-    BAMBOO_EXIT(0xa008);
+    BAMBOO_EXIT(0xe00f);
   }
 #ifdef DEBUG
 #ifndef CLOSE_PRINT
@@ -2456,7 +2456,7 @@ INLINE void processmsg_profilefinish_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(msgdata[msgdataindex /*1*/]);
 #endif
-    BAMBOO_EXIT(0xa009);
+    BAMBOO_EXIT(0xe010);
   }
 #ifdef DEBUG
 #ifndef CLOSE_PRINT
@@ -2473,7 +2473,7 @@ INLINE void processmsg_statusconfirm_I() {
   if((BAMBOO_NUM_OF_CORE == STARTUPCORE)
      || (BAMBOO_NUM_OF_CORE > NUMCORESACTIVE - 1)) {
     // wrong core to receive such msg
-    BAMBOO_EXIT(0xa00e);
+    BAMBOO_EXIT(0xe011);
   } else {
     // send response msg
 #ifdef DEBUG
@@ -2509,7 +2509,7 @@ INLINE void processmsg_statusreport_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data2);
 #endif
-    BAMBOO_EXIT(0xa00f);
+    BAMBOO_EXIT(0xe012);
   } else {
 #ifdef DEBUG
 #ifndef CLOSE_PRINT
@@ -2559,7 +2559,7 @@ INLINE void processmsg_memrequest_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data2);
 #endif
-    BAMBOO_EXIT(0xa010);
+    BAMBOO_EXIT(0xe013);
   } else {
 #ifdef DEBUG
 #ifndef CLOSE_PRINT
@@ -2716,7 +2716,7 @@ INLINE void processmsg_gcfinishpre_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data1);
 #endif
-    BAMBOO_EXIT(0xb000);
+    BAMBOO_EXIT(0xe014);
   }
   // All cores should do init GC
   if(!gcprecheck) {
@@ -2736,7 +2736,7 @@ INLINE void processmsg_gcfinishinit_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data1);
 #endif
-    BAMBOO_EXIT(0xb001);
+    BAMBOO_EXIT(0xe015);
   }
 #ifdef DEBUG
   BAMBOO_DEBUGPRINT(0xe88c);
@@ -2761,7 +2761,7 @@ INLINE void processmsg_gcfinishmark_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data1);
 #endif
-    BAMBOO_EXIT(0xb002);
+    BAMBOO_EXIT(0xe016);
   }
   // all cores should do mark
   if(data1 < NUMCORESACTIVE) {
@@ -2786,7 +2786,7 @@ INLINE void processmsg_gcfinishcompact_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(msgdata[msgdataindex] /*[1]*/);
 #endif
-    BAMBOO_EXIT(0xb003);
+    BAMBOO_EXIT(0xe017);
   }
   int cnum = msgdata[msgdataindex];
   MSG_INDEXINC_I();       //msgdata[1];
@@ -2830,7 +2830,7 @@ INLINE void processmsg_gcfinishmapinfo_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data1);
 #endif
-    BAMBOO_EXIT(0xb004);
+    BAMBOO_EXIT(0xe018);
   }
   // all cores should do flush
   if(data1 < NUMCORES4GC) {
@@ -2848,7 +2848,7 @@ INLINE void processmsg_gcfinishflush_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data1);
 #endif
-    BAMBOO_EXIT(0xb005);
+    BAMBOO_EXIT(0xe019);
   }
   // all cores should do flush
   if(data1 < NUMCORESACTIVE) {
@@ -2860,7 +2860,7 @@ INLINE void processmsg_gcmarkconfirm_I() {
   if((BAMBOO_NUM_OF_CORE == STARTUPCORE)
      || (BAMBOO_NUM_OF_CORE > NUMCORESACTIVE - 1)) {
     // wrong core to receive such msg
-    BAMBOO_EXIT(0xb006);
+    BAMBOO_EXIT(0xe01a);
   } else {
     // send response msg, cahce the msg first
     if(BAMBOO_CHECK_SEND_MODE()) {
@@ -2890,7 +2890,7 @@ INLINE void processmsg_gcmarkreport_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data2);
 #endif
-    BAMBOO_EXIT(0xb007);
+    BAMBOO_EXIT(0xe01b);
   } else {
        int entry_index = 0;
     if(waitconfirm) {
@@ -2964,7 +2964,7 @@ INLINE void processmsg_gcmaprequest_I() {
     BAMBOO_DEBUGPRINT_REG(data1);
     BAMBOO_DEBUGPRINT_REG(data2);
 #endif
-    BAMBOO_EXIT(0xb008);
+    BAMBOO_EXIT(0xe01c);
     //assume that the object was not moved, use the original address
     /*if(isMsgSending) {
             cache_msg_3(msgdata[2], GCMAPINFO, msgdata[1], msgdata[1]);
@@ -3026,7 +3026,7 @@ INLINE void processmsg_gclobjinfo_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data2);
 #endif
-    BAMBOO_EXIT(0xb009);
+    BAMBOO_EXIT(0xe01d);
   }
   // store the mark result info
   int cnum = data2;
@@ -3091,7 +3091,7 @@ INLINE void processmsg_gcfinishpref_I() {
 #ifndef CLOSE_PRINT
     BAMBOO_DEBUGPRINT_REG(data1);
 #endif
-    BAMBOO_EXIT(0xb00a);
+    BAMBOO_EXIT(0xe01e);
   }
   // all cores should do flush
   if(data1 < NUMCORESACTIVE) {
@@ -3660,7 +3660,7 @@ void releasewritelock_r(void * lock, void * redirectlock) {
     // reside on this core
     if(!RuntimeHashcontainskey(locktbl, reallock)) {
       // no locks for this object, something is wrong
-      BAMBOO_EXIT(0xa00b);
+      BAMBOO_EXIT(0xe01f);
     } else {
       int rwlock_obj = 0;
       struct LockValue * lockvalue = NULL;