Bug fix for cache adaption
authorjzhou <jzhou>
Tue, 21 Jun 2011 00:43:52 +0000 (00:43 +0000)
committerjzhou <jzhou>
Tue, 21 Jun 2011 00:43:52 +0000 (00:43 +0000)
Robust/src/Runtime/bamboo/multicorecache.c
Robust/src/Runtime/bamboo/multicorecache.h

index 3e78638a22830636b89f49744e57b69057a0bb30..f25d4813d13e13c80e7b77dd04b28394f8b868b6 100644 (file)
@@ -29,7 +29,7 @@ void cacheAdapt_gc(bool isgccachestage) {
     int *local_tbl=&gccachesamplingtbl_r[page_index]; \
     for(int i = 0; i < NUMCORESACTIVE; i++) { \
       int freq = *local_tbl; \
-      local_tbl=(int *)(((char *)local_tbl)+size_cachesamplingtbl_local_r); \
+      local_tbl=(int *)(((void *)local_tbl)+size_cachesamplingtbl_local_r); \
       if(hotfreq < freq) { \
         hotfreq = freq; \
         hottestcore = i; \
@@ -43,7 +43,7 @@ void cacheAdapt_gc(bool isgccachestage) {
     int *local_tbl=&gccachesamplingtbl_r[page_index]; \
     for(int i = 0; i < NUMCORESACTIVE; i++) { \
       int freq = *local_tbl; \
-      local_tbl=(int *)(((char *)local_tbl)+size_cachesamplingtbl_local_r); \
+      local_tbl=(int *)(((void *)local_tbl)+size_cachesamplingtbl_local_r); \
       totalfreq += freq; \
       if(hotfreq < freq) { \
         hotfreq = freq; \
@@ -127,7 +127,7 @@ void cacheAdapt_policy_hottest(int coren){
   }
 } 
 
-#define GC_CACHE_ADAPT_DOMINATE_THRESHOLD  64
+#define GC_CACHE_ADAPT_DOMINATE_THRESHOLD  1
 // cache the page on the core that accesses it the most if that core accesses 
 // it more than (GC_CACHE_ADAPT_DOMINATE_THRESHOLD)% of the total.  Otherwise,
 // h4h the page.
@@ -141,7 +141,7 @@ void cacheAdapt_policy_dominate(int coren){
   for(; page_index < page_index_end; page_index++) {
     bamboo_cache_policy_t policy = {0};
     unsigned int hottestcore = 0;
-    unsigned long long totalfreq = 0;
+    unsigned int totalfreq = 0;
     unsigned int hotfreq = 0;
     CACHEADAPT_FIND_HOTTEST_CORE_W_TOTALFREQ(page_index,hottestcore,hotfreq,totalfreq);
     // Decide the cache strategy for this page
@@ -149,10 +149,14 @@ void cacheAdapt_policy_dominate(int coren){
     // the gcpolicytbl 
     // Format: page start va + cache policy
     if(hotfreq != 0) {
-      totalfreq=(totalfreq*GC_CACHE_ADAPT_DOMINATE_THRESHOLD)>>7;
-      if(hotfreq < totalfreq) {
+      totalfreq=totalfreq>>GC_CACHE_ADAPT_DOMINATE_THRESHOLD;
+      if((unsigned int)hotfreq < (unsigned int)totalfreq) {
         // use hfh
-        policy.cache_mode = BAMBOO_CACHE_MODE_HASH;
+        //policy.cache_mode = BAMBOO_CACHE_MODE_HASH;
+        unsigned int block = 0;
+        BLOCKINDEX(page_sva, &block);
+        unsigned int coren = gc_block2core[block%(NUMCORES4GC*2)];
+        CACHEADAPT_POLICY_SET_HOST_CORE(policy, coren);
       } else {
         // locally cache the page in the hottest core
         CACHEADAPT_POLICY_SET_HOST_CORE(policy, hottestcore);
@@ -458,6 +462,8 @@ void cacheAdapt_phase_master() {
 }
 
 void gc_output_cache_sampling() {
+  //extern volatile bool gc_profile_flag;
+  //if(!gc_profile_flag) return;
   unsigned int page_index = 0;
   VA page_sva = 0;
   unsigned int page_num = (BAMBOO_SHARED_MEM_SIZE) / (BAMBOO_PAGE_SIZE);
@@ -480,6 +486,8 @@ void gc_output_cache_sampling() {
 } 
 
 void gc_output_cache_sampling_r() {
+  //extern volatile bool gc_profile_flag;
+  //if(!gc_profile_flag) return;
   // TODO summary data
   unsigned int sumdata[NUMCORESACTIVE][NUMCORESACTIVE];
   for(int i = 0; i < NUMCORESACTIVE; i++) {
index 8c30d4ee60275a3b8f29f2f10b94098c34586d1f..f5dc3d60d5b35225c3135af11a0dafb3a8997d0b 100644 (file)
@@ -7,8 +7,8 @@
 #include "multicoregarbage.h"
 
 #ifdef GC_CACHE_ADAPT
-#define GC_CACHE_SAMPLING_UNIT 100000000
-#define GC_TILE_TIMER_EVENT_SETTING 10000000 //0  
+#define GC_CACHE_SAMPLING_UNIT 0x40000 //100000 //000
+#define GC_TILE_TIMER_EVENT_SETTING (GC_CACHE_SAMPLING_UNIT) //100000 //000  
 
 // should be consistent with multicoreruntime.h
 typedef union