small changes
[IRC.git] / Robust / src / Runtime / bamboo / multicoregarbage.h
index 6c0dd8c0ee1d882b683661dee58aba9a4b9a694d..7ac1d6ed118dda8ed4892850a8b6617ddf63dc0d 100644 (file)
@@ -6,6 +6,7 @@
 #include "multicorehelper.h"  // for mappings between core # and block #
 #include "structdefs.h"
 #include "multicoregcprofile.h"
+#include "gctypes.h"
 
 #ifdef GC_DEBUG
 #define GC_PRINTF tprintf
 #define GC_PRINTF if(0) tprintf
 #endif 
 
+#ifdef GC_DEBUG
 #define TR() tprintf("%u\n",__LINE__)
+#else
+#define TR()
+#endif
 
 // data structures for GC
 #define BAMBOO_SMEM_SIZE_L (BAMBOO_SMEM_SIZE * 2)
@@ -21,8 +26,6 @@
 // let each gc core to have one big block, this is very important
 // for the computation of NUMBLOCKS(s, n), DO NOT change this!
 
-typedef int block_t;
-
 typedef enum {
   INITPHASE = 0x0,         // 0x0
   MARKPHASE,               // 0x1
@@ -107,24 +110,12 @@ void ** gcmappingtbl;
 unsigned int bamboo_rmsp_size;
 
 //mark table....keep track of mark bits
-unsigned int * gcmarktbl;
+volatile unsigned int * gcmarktbl;
 
-void * gcbaseva; // base va for shared memory without reserved sblocks
+bool gc_checkCoreStatus();
 
-static bool gc_checkCoreStatus() {
-  for(int i = 0; i < NUMCORES4GC; i++) {
-    if(gccorestatus[i]) {
-      return false;
-    }
-  }  
-  return true;
-}
+void gc_resetCoreStatus();
 
-static void gc_resetCoreStatus() {
-  for(int i = 0; i < NUMCORES4GC; i++) {
-    gccorestatus[i] = 1;
-  }
-}
 
 
 /* Structure to keep track of free space in block */
@@ -153,16 +144,14 @@ struct allocrecord {
 struct allocrecord allocationinfo;
 
 #ifdef GC_CACHE_ADAPT
-void * gctopva; // top va for shared memory without reserved sblocks
-volatile bool gccachestage;
 // table recording the sampling data collected for cache adaption 
-int * gccachesamplingtbl;
-int * gccachesamplingtbl_local;
-unsigned int size_cachesamplingtbl_local;
-int * gccachesamplingtbl_r;
-int * gccachesamplingtbl_local_r;
-unsigned int size_cachesamplingtbl_local_r;
-int * gccachepolicytbl;
+unsigned int * gccachesamplingtbl;
+unsigned int * gccachesamplingtbl_local;// for zeroing memory only
+unsigned int size_cachesamplingtbl_local; // for zeroing memory only
+unsigned int * gccachesamplingtbl_r;
+unsigned int * gccachesamplingtbl_local_r; // for zeroing memory only
+unsigned int size_cachesamplingtbl_local_r; // for zeroing memory only
+unsigned int * gccachepolicytbl;
 unsigned int size_cachepolicytbl;
 #endif
 
@@ -171,10 +160,15 @@ unsigned int size_cachepolicytbl;
 #define GCNUMBLOCK (NUMCORES4GC+(BAMBOO_SHARED_MEM_SIZE-BAMBOO_LARGE_SMEM_BOUND)/BAMBOO_SMEM_SIZE)
 #define GCNUMLOCALBLOCK (GCNUMBLOCK/NUMCORES4GC)
 
+/* Leave the neighboring cores with at least two blocks */
+#define MAXNEIGHBORALLOC (GCNUMLOCALBLOCK-2)
+
 /* This macro defines the smallest memoy chunk the master will hand out to another core during compacting */
 
 #define MINMEMORYCHUNKSIZE 32768
 
+#define ISVALIDPTR(x) ((((unsigned INTPTR)x)>=((unsigned INTPTR)gcbaseva))&&(((unsigned INTPTR)x)<((unsigned INTPTR)(gcbaseva+BAMBOO_SHARED_MEM_SIZE))))
+
 /* This macro waits for the given gc phase */
 #define WAITFORGCPHASE(phase) while(gc_status_info.gcphase != phase) ;