code changes...fix all of the statistics collection...clean up collection code
authorbdemsky <bdemsky>
Wed, 13 Jul 2011 10:56:28 +0000 (10:56 +0000)
committerbdemsky <bdemsky>
Wed, 13 Jul 2011 10:56:28 +0000 (10:56 +0000)
Robust/src/Runtime/bamboo/multicorecache.c
Robust/src/Runtime/bamboo/multicorecache.h
Robust/src/Runtime/bamboo/multicoregarbage.c
Robust/src/Runtime/bamboo/multicoregccompact.c

index 377bc698a11271e5b41eecf1dd11a9972d1d9aeb..e5415f6959ee39be28b56c7fd2d7f55001ed490c 100644 (file)
@@ -3,9 +3,19 @@
 #include "multicoremsg.h"
 #include "multicoregcprofile.h"
 
+void cacheadapt_finish_compact(void *toptr) {
+  unsigned int dstpage=(toptr-gcbaseva)>>BAMBOO_PAGE_SIZE_BITS;
+  unsigned int * newtable=&gccachesamplingtbl_r[dstpage*NUMCORESACTIVE];
+
+  for(int core = 0; core < NUMCORESACTIVE; core++) {
+    (*newtable)=(*newtable)>>6;
+    newtable++;
+  }  
+}
+
 void cacheadapt_finish_src_page(void *srcptr, void *tostart, void *tofinish) {
   unsigned int srcpage=(srcptr-gcbaseva)>>BAMBOO_PAGE_SIZE_BITS;
-  unsigned int dstpage=(tostart-gcbase)>>BAMBOO_PAGE_SIZE_BITS;
+  unsigned int dstpage=(tostart-gcbaseva)>>BAMBOO_PAGE_SIZE_BITS;
   unsigned int numbytes=tofinish-tostart;
   
   unsigned int * oldtable=&gccachesamplingtbl[srcpage*NUMCORESACTIVE];
@@ -20,19 +30,22 @@ void cacheadapt_finish_src_page(void *srcptr, void *tostart, void *tofinish) {
   }  
 }
 
+/* Bytes needed equal to zero is a special case...  It means that we should finish the dst page */
+
 void cacheadapt_finish_dst_page(void *origptr, void *tostart, void *toptr, unsigned int bytesneeded) {
   unsigned int numbytes=toptr-tostart;
 
-  void *tobound=(tostart&~(BAMBOO_PAGE_SIZE-1))+BAMBOO_PAGE_SIZE;
-  void *origbound=(origstart&~(BAMBOO_PAGE_SIZE-1))+BAMBOO_PAGE_SIZE;
+  void *tobound=(void *)((((unsigned INTPTR)toptr-1)&~(BAMBOO_PAGE_SIZE-1))+BAMBOO_PAGE_SIZE);
+  void *origbound=(void *)((((unsigned INTPTR)origptr)&~(BAMBOO_PAGE_SIZE-1))+BAMBOO_PAGE_SIZE);
   
-  unsigned int topage=(tostart-gcbase)>>BAMBOO_PAGE_SIZE_BITS; 
+  unsigned int topage=(toptr-1-gcbaseva)>>BAMBOO_PAGE_SIZE_BITS; 
   unsigned int origpage=(origptr-gcbaseva)>>BAMBOO_PAGE_SIZE_BITS;
 
   unsigned int * totable=&gccachesamplingtbl_r[topage*NUMCORESACTIVE];
   unsigned int * origtable=&gccachesamplingtbl[origpage*NUMCORESACTIVE];
 
-  unsigned int remaintobytes=tobound-toptr;
+  //handler
+  unsigned int remaintobytes=(bytesneeded==0)?0:(tobound-toptr);
   unsigned int remainorigbytes=origbound-origptr;
 
   do {
@@ -56,7 +69,7 @@ void cacheadapt_finish_dst_page(void *origptr, void *tostart, void *toptr, unsig
       topage++;//to page is definitely done
       tobound+=BAMBOO_PAGE_SIZE;
       origpage=(origptr-gcbaseva)>>BAMBOO_PAGE_SIZE_BITS;//handle exact match case
-      origbound=(origptr&~(BAMBOO_PAGE_SIZE-1))+BAMBOO_PAGE_SIZE;
+      origbound=(void *) ((((unsigned INTPTR)origptr)&~(BAMBOO_PAGE_SIZE-1))+BAMBOO_PAGE_SIZE);
     } else {
       //Finishing off orig page
 
@@ -370,9 +383,9 @@ void gc_output_cache_sampling() {
       printf("%x,  %d,  %d,  ",(int)page_sva,page_index,coren);
       unsigned int * local_tbl = &gccachesamplingtbl[page_index*NUMCORESACTIVE];
       for(int i = 0; i < NUMCORESACTIVE; i++) {
-        int freq = *local_tbl;
+        unsigned int freq = *local_tbl;
         local_tbl++;
-        printf("%d,  ", freq);
+        printf("%u,  ", freq);
       }
       printf("\n");
     }
@@ -405,7 +418,7 @@ void gc_output_cache_sampling_r() {
     int accesscore = 0; // TODO
     unsigned int * local_tbl = &gccachesamplingtbl_r[page_index*NUMCORESACTIVE];
     for(int i = 0; i < NUMCORESACTIVE; i++) {
-      int freq = *local_tbl; 
+      unsigned int freq = *local_tbl; 
       //printf("%d,  ", freq);
       if(freq != 0) {
         accesscore++;// TODO
@@ -416,8 +429,8 @@ void gc_output_cache_sampling_r() {
       printf("%x,  %d,  %d,  ",(int)page_sva,page_index,coren);
       unsigned int * local_tbl = &gccachesamplingtbl_r[page_index*NUMCORESACTIVE];
       for(int i = 0; i < NUMCORESACTIVE; i++) {
-        int freq = *local_tbl;
-        printf("%d,  ", freq);
+        unsigned int freq = *local_tbl;
+        printf("%u,  ", freq);
         sumdata[accesscore-1][i]+=freq;
         local_tbl++;
       }
@@ -430,7 +443,7 @@ void gc_output_cache_sampling_r() {
   for(int i = 0; i < NUMCORESACTIVE; i++) {
     printf("%d  ", i);
     for(int j = 0; j < NUMCORESACTIVE; j++) {
-      printf(" %d  ", sumdata[j][i]);
+      printf(" %u  ", sumdata[j][i]);
     }
     printf("\n");
   }
index cf4db76d8f816b3885dc70f0f0da0cb879b2133b..1665df4f5e8807b27cf760a34950ed13b4f1fb7e 100644 (file)
@@ -40,6 +40,7 @@ typedef union
 #define BAMBOO_CACHE_MODE_NONE 3   // no caching
 #define BAMBOO_CACHE_MODE_COORDS 4 // cached on a specific core
 
+void cacheadapt_finish_compact(void *toptr);
 void cacheadapt_finish_src_page(void *srcptr, void *tostart, void *tofinish);
 void cacheadapt_finish_dst_page(void *origptr, void *tostart, void *toptr, unsigned int bytesneeded);
 void cacheAdapt_gc(bool isgccachestage);
@@ -73,6 +74,7 @@ void gc_output_cache_sampling_r();
 
 #define CACHEADAPT_FINISH_SRC_PAGE(a,b,c) cacheadapt_finish_src_page(a,b,c);
 #define CACHEADAPT_FINISH_DST_PAGE(a,b,c,d) cacheadapt_finish_dst_page(a,b,c,d);
+#define CACHEADAPT_FINISH_COMPACT(a) cacheadapt_finish_compact(a);
 
 #define CACHEADAPT_GC(b) cacheAdapt_gc(b)
 #define CACHEADAPT_MASTER() cacheAdapt_master()
@@ -108,6 +110,7 @@ void gc_output_cache_sampling_r();
 #define CACHEADAPT_SAMPING_RESET()
 #define CACHEADAPT_FINISH_SRC_PAGE(a,b,c)
 #define CACHEADAPT_FINISH_DST_PAGE(a,b,c,d)
+#define CACHEADAPT_FINISH_COMPACT(a)
 #define CACHEADAPT_GC(b)
 #define CACHEADAPT_MASTER()
 #define CACHEADAPT_PHASE_CLIENT() 
index 3a42576892a38f6d8cbd0a2f52f5cc265fa8bd56..3e79be1089914ec96a6dde54a39087eeb621632e 100644 (file)
@@ -481,7 +481,7 @@ void gc_master(struct garbagelist * stackptr) {
 
   master_finish();
 
-  tprintf("finish GC ! %d \n",gcflag);
+  //tprintf("finish GC ! %d \n",gcflag);
 } 
 
 void pregccheck() {
index ea3264cf192b7d4434cf1b0a54e5b8521dafdfcf..49fd3d9364d856c4098987fa5ff3d50e360e9c8f 100644 (file)
@@ -206,8 +206,10 @@ void compacthelper(struct moveHelper * orig,struct moveHelper * to) {
 #ifdef GC_CACHE_ADAPT
       orig->pagebound=orig->base+BAMBOO_PAGE_SIZE;
 #endif
-      if (orig->base >= gcbaseva+BAMBOO_SHARED_MEM_SIZE)
+      if (orig->base >= gcbaseva+BAMBOO_SHARED_MEM_SIZE) {
+       CACHEADAPT_FINISH_COMPACT(to->ptr);
        break;
+      }
     }
     if (minimumbytes!=0) {
       getSpace(to, minimumbytes);
@@ -392,7 +394,7 @@ unsigned int compactblockshelper(struct moveHelper * orig, struct moveHelper * t
        return minimumbytes;
       } else {
        CACHEADAPT_FINISH_DST_PAGE(orig->ptr, tmpto, to->ptr, minimumbytes);
-       to->pagebound=((endtoptr-1)&~(BAMBOO_PAGE_SIZE-1))+BAMBOO_PAGE_SIZE;
+       to->pagebound=((((unsigned INTPTR)endtoptr)-1)&~(BAMBOO_PAGE_SIZE-1))+BAMBOO_PAGE_SIZE;
        //update pointers to avoid double counting the stuff we already added in
        tmporig=orig->ptr+minimumbytes;
        tmpto=to->ptr+minimumbytes;
@@ -490,7 +492,6 @@ void compact() {
   struct moveHelper to;
   initOrig_Dst(&orig, &to);
 
-  CACHEADAPT_SAMPLING_DATA_REVISE_INIT(&orig, &to);
   compacthelper(&orig, &to);
 }