Fix a performance bug in the multicore gc version. In hvc files, should not reserve...
[IRC.git] / Robust / src / Runtime / multicoregarbage.h
index 765122102fa85b6287dff35b9a910b69ff00cdc0..93a1b252deafaa3e834c2581a2e046be28442bac 100644 (file)
 #ifdef GC_DEBUG
 #define BAMBOO_SMEM_SIZE_L (BAMBOO_SMEM_SIZE * 2)
 #else
-#define BAMBOO_SMEM_SIZE_L (2 * BAMBOO_SMEM_SIZE)
+#define BAMBOO_SMEM_SIZE_L (BAMBOO_SMEM_SIZE * 2)
 #endif
 #define BAMBOO_LARGE_SMEM_BOUND (BAMBOO_SMEM_SIZE_L*NUMCORES4GC)
 // let each gc core to have one big block, this is very important
 // for the computation of NUMBLOCKS(s, n), DO NOT change this!
 
+#ifdef GC_FLUSH_DTLB
+#define GC_NUM_FLUSH_DTLB 1
+int gc_num_flush_dtlb;
+#endif
+
 #define NUMPTRS 100
 
 // for GC profile
 #define GCINFOLENGTH 100
 
 typedef struct gc_info {
-  unsigned long long time[8];
+  unsigned long long time[15];
   int index;
 } GCInfo;
 
 GCInfo * gc_infoArray[GCINFOLENGTH];
 int gc_infoIndex;
 bool gc_infoOverflow;
+unsigned long long gc_num_livespace;
+unsigned long long gc_num_freespace;
+unsigned long long gc_num_lobjspace;
+unsigned int gc_num_lobj;
 
 // TODO
-unsigned long long flushstalltime;
+/*unsigned long long flushstalltime;
 unsigned long long flushstalltime_i;
-int num_mapinforequest_i;
-#endif
+int num_mapinforequest_i;*/
+//#ifdef GC_PROFILE_S
+unsigned int gc_num_liveobj;
+unsigned int gc_num_obj;
+unsigned int gc_num_forwardobj;
+int gc_num_profiles;
+//#endif // GC_PROFILE_S
+
+#endif // GC_PROFILE
 
 typedef enum {
   INIT = 0,           // 0
@@ -65,15 +81,22 @@ volatile bool gcflag;
 volatile bool gcprocessing;
 volatile GCPHASETYPE gcphase; // indicating GC phase
 
+volatile bool gcpreinform; // counter for stopped cores
+volatile bool gcprecheck; // indicates if there are updated pregc information
+
 int gccurr_heaptop;
 struct MGCHash * gcforwardobjtbl; // cache forwarded objs in mark phase
 // for mark phase termination
 volatile int gccorestatus[NUMCORESACTIVE]; // records status of each core
                                            // 1: running gc
                                            // 0: stall
-volatile int gcnumsendobjs[NUMCORESACTIVE]; //records how many objects sent out
-volatile int gcnumreceiveobjs[NUMCORESACTIVE]; //records how many objects
-                                              //received
+volatile int gcnumsendobjs[2][NUMCORESACTIVE]; // the # of objects sent out
+volatile int gcnumreceiveobjs[2][NUMCORESACTIVE]; // the # of objects received
+volatile int gcnumsrobjs_index;  // indicates which entry to record the info 
+                                        // received before phase 1 of the mark finish 
+                                                        // checking process
+                                                                // the info received in phase 2 must be 
+                                                                // recorded in the other entry
 volatile bool gcbusystatus;
 int gcself_numsendobjs;
 int gcself_numreceiveobjs;
@@ -115,7 +138,11 @@ void * gcmappingtbl[NUMCORESACTIVE][NUM_MAPPING];*/
 //                                  + NUMCORES4GC bamboo_rmsp
 // These three types of table are always reside at the bottom of the shared 
 // memory and will never be moved or garbage collected
-#define BAMBOO_RMSP_SIZE (BAMBOO_SMEM_SIZE * 45)
+#ifdef GC_SMALLPAGESIZE
+#define BAMBOO_RMSP_SIZE (1024 * 1024)
+#else
+#define BAMBOO_RMSP_SIZE (BAMBOO_SMEM_SIZE) // (45 * 16 * 1024)
+#endif
 mspace bamboo_rmsp;
 // shared pointer mapping tbl
 //volatile struct GCSharedHash * gcsharedptbl;
@@ -124,7 +151,11 @@ mgcsharedhashtbl_t * gcsharedptbl;
 //struct GCSharedHash * gcrpointertbls[NUMCORES4GC];
 mgcsharedhashtbl_t * gcrpointertbls[NUMCORES4GC];
 
-volatile struct RuntimeHash * gcpointertbl;
+#ifdef LOCALHASHTBL_TEST
+struct RuntimeHash * gcpointertbl;
+#else
+mgchashtable_t * gcpointertbl;
+#endif
 //struct MGCHash * gcpointertbl;
 int gcobj2map;
 int gcmappedobj;
@@ -207,7 +238,7 @@ int gcbaseva; // base va for shared memory without reserved sblocks
 // the next core in the top of the heap
 #define NEXTTOPCORE(b) (gc_block2core[((b)+1)%(NUMCORES4GC*2)])
 
-inline void gc(struct garbagelist * stackptr); // core coordinator routine
+inline bool gc(struct garbagelist * stackptr); // core coordinator routine
 inline void gc_collect(struct garbagelist* stackptr); //core collector routine
 inline void gc_nocollect(struct garbagelist* stackptr); //non-gc core collector routine
 inline void transferMarkResults_I();