From: jzhou Date: Fri, 9 Jul 2010 00:15:16 +0000 (+0000) Subject: Fix the strategy for determination of when the gc mark phase is finished. In phase... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=c642761c5f58fc2d272ffbc65568c3bb0fec0556;p=IRC.git Fix the strategy for determination of when the gc mark phase is finished. In phase 2, check if the number of send-out objs and received objs have been changed compared to that in the phase 1. Also tuned the BAMBOO_SMEM_ZERO_UNIT_SIZE. Looks like 4KB is OK. --- diff --git a/Robust/src/Runtime/multicoregarbage.c b/Robust/src/Runtime/multicoregarbage.c index 5efb32a8..36be3a43 100644 --- a/Robust/src/Runtime/multicoregarbage.c +++ b/Robust/src/Runtime/multicoregarbage.c @@ -426,10 +426,18 @@ inline void checkMarkStatue() { #ifdef DEBUG BAMBOO_DEBUGPRINT(0xee02); #endif + int entry_index = 0; + if(waitconfirm) { + // phase 2 + entry_index = (gcnumsrobjs_index == 0) ? 1 : 0; + } else { + // phase 1 + entry_index = gcnumsrobjs_index; + } BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); gccorestatus[BAMBOO_NUM_OF_CORE] = 0; - gcnumsendobjs[BAMBOO_NUM_OF_CORE] = gcself_numsendobjs; - gcnumreceiveobjs[BAMBOO_NUM_OF_CORE] = gcself_numreceiveobjs; + gcnumsendobjs[entry_index][BAMBOO_NUM_OF_CORE] = gcself_numsendobjs; + gcnumreceiveobjs[entry_index][BAMBOO_NUM_OF_CORE] = gcself_numreceiveobjs; // check the status of all cores bool allStall = gc_checkAllCoreStatus_I(); #ifdef DEBUG @@ -455,49 +463,69 @@ inline void checkMarkStatue() { gccorestatus[i] = 1; // send mark phase finish confirm request msg to core i send_msg_1(i, GCMARKCONFIRM, false); - } // for(i = 1; i < NUMCORESACTIVE; ++i) + } // for(i = 1; i < NUMCORESACTIVE; ++i) } else { + // Phase 2 // check if the sum of send objs and receive obj are the same // yes->check if the info is the latest; no->go on executing int sumsendobj = 0; for(i = 0; i < NUMCORESACTIVE; ++i) { - sumsendobj += gcnumsendobjs[i]; - } // for(i = 0; i < NUMCORESACTIVE; ++i) + sumsendobj += gcnumsendobjs[gcnumsrobjs_index][i]; + } // for(i = 0; i < NUMCORESACTIVE; ++i) #ifdef DEBUG BAMBOO_DEBUGPRINT(0xee06); BAMBOO_DEBUGPRINT_REG(sumsendobj); #endif for(i = 0; i < NUMCORESACTIVE; ++i) { - sumsendobj -= gcnumreceiveobjs[i]; - } // for(i = 0; i < NUMCORESACTIVE; ++i) + sumsendobj -= gcnumreceiveobjs[gcnumsrobjs_index][i]; + } // for(i = 0; i < NUMCORESACTIVE; ++i) #ifdef DEBUG BAMBOO_DEBUGPRINT(0xee07); BAMBOO_DEBUGPRINT_REG(sumsendobj); #endif if(0 == sumsendobj) { + // Check if there are changes of the numsendobjs or numreceiveobjs on + // each core + bool ischanged = false; + for(i = 0; i < NUMCORESACTIVE; ++i) { + if((gcnumsendobjs[0][i] != gcnumsendobjs[1][i]) || + (gcnumreceiveobjs[0][i] != gcnumreceiveobjs[1][i]) ) { + ischanged = true; + break; + } + } // for(i = 0; i < NUMCORESACTIVE; ++i) #ifdef DEBUG BAMBOO_DEBUGPRINT(0xee08); + BAMBOO_DEBUGPRINT_REG(ischanged); #endif - // all the core status info are the latest - // stop mark phase - gcphase = COMPACTPHASE; - // restore the gcstatus for all cores - for(i = 0; i < NUMCORESACTIVE; ++i) { - gccorestatus[i] = 1; - } // for(i = 0; i < NUMCORESACTIVE; ++i) + if(!ischanged) { +#ifdef DEBUG + BAMBOO_DEBUGPRINT(0xee09); +#endif + // all the core status info are the latest + // stop mark phase + gcphase = COMPACTPHASE; + // restore the gcstatus for all cores + for(i = 0; i < NUMCORESACTIVE; ++i) { + gccorestatus[i] = 1; + } // for(i = 0; i < NUMCORESACTIVE; ++i) + } else { + waitconfirm = false; + gcnumsrobjs_index = (gcnumsrobjs_index == 0) ? 1 : 0; + } // if(!ischanged) } else { - // wait for a while and ask for confirm again - int h = 100; - while(h--) { - } + // There were changes between phase 1 and phase 2, can not decide + // whether the mark phase has been finished waitconfirm = false; - } // if(0 == sumsendobj) else ... + // As it fails in phase 2, flip the entries + gcnumsrobjs_index = (gcnumsrobjs_index == 0) ? 1 : 0; + } // if(0 == sumsendobj) else ... BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); - } // if(!gcwaitconfirm) else() + } // if(!gcwaitconfirm) else() } else { BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); - } // if(allStall) - } // if((!waitconfirm)... + } // if(allStall) + } // if((!waitconfirm)... #ifdef DEBUG BAMBOO_DEBUGPRINT(0xee0a); #endif @@ -582,8 +610,8 @@ inline void initGC() { if(STARTUPCORE == BAMBOO_NUM_OF_CORE) { for(i = 0; i < NUMCORES4GC; ++i) { gccorestatus[i] = 1; - gcnumsendobjs[i] = 0; - gcnumreceiveobjs[i] = 0; + gcnumsendobjs[0][i] = gcnumsendobjs[1][i] = 0; + gcnumreceiveobjs[0][i] = gcnumreceiveobjs[1][i] = 0; gcloads[i] = 0; gcrequiredmems[i] = 0; gcfilledblocks[i] = 0; @@ -591,8 +619,8 @@ inline void initGC() { } // for(i = 0; i < NUMCORES4GC; ++i) for(i = NUMCORES4GC; i < NUMCORESACTIVE; ++i) { gccorestatus[i] = 1; - gcnumsendobjs[i] = 0; - gcnumreceiveobjs[i] = 0; + gcnumsendobjs[0][i] = gcnumsendobjs[1][i] = 0; + gcnumreceiveobjs[0][i] = gcnumreceiveobjs[1][i] = 0; } gcheaptop = 0; gctopcore = 0; @@ -1454,8 +1482,9 @@ inline void mark(bool isfirst, BAMBOO_DEBUGPRINT(0xed08); #endif gccorestatus[BAMBOO_NUM_OF_CORE] = 0; - gcnumsendobjs[BAMBOO_NUM_OF_CORE] = gcself_numsendobjs; - gcnumreceiveobjs[BAMBOO_NUM_OF_CORE] = gcself_numreceiveobjs; + gcnumsendobjs[gcnumsrobjs_index][BAMBOO_NUM_OF_CORE]=gcself_numsendobjs; + gcnumreceiveobjs[gcnumsrobjs_index][BAMBOO_NUM_OF_CORE]= + gcself_numreceiveobjs; gcloads[BAMBOO_NUM_OF_CORE] = gccurr_heaptop; } else { if(!sendStall) { diff --git a/Robust/src/Runtime/multicoregarbage.h b/Robust/src/Runtime/multicoregarbage.h index 6d16cfbf..f36f2218 100644 --- a/Robust/src/Runtime/multicoregarbage.h +++ b/Robust/src/Runtime/multicoregarbage.h @@ -71,9 +71,13 @@ struct MGCHash * gcforwardobjtbl; // cache forwarded objs in mark phase 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; diff --git a/Robust/src/Runtime/multicoretask.c b/Robust/src/Runtime/multicoretask.c index 9c1cecaf..9162e038 100644 --- a/Robust/src/Runtime/multicoretask.c +++ b/Robust/src/Runtime/multicoretask.c @@ -87,7 +87,7 @@ int core2test[1][NUM_CORES2TEST] = { {0, -1, -1, -1, -1, -1, -1, -1, -1} }; #elif defined GC_56 -int core2test[56][5] = { +int core2test[56][NUM_CORES2TEST] = { { 0, -1, 7, -1, 1, -1, 14, -1, 2}, { 1, -1, 8, 0, 2, -1, 15, -1, 3}, { 2, -1, 9, 1, 3, -1, 16, 0, 4}, { 3, -1, 10, 2, 4, -1, 17, 1, 5}, { 4, -1, 11, 3, 5, -1, 18, 2, 6}, { 5, -1, 12, 4, 6, -1, 19, 3, -1}, @@ -118,7 +118,7 @@ int core2test[56][5] = { {54, 47, -1, 53, 55, 40, -1, 52, -1}, {55, 48, -1, 54, -1, 41, -1, 53, -1} }; #elif defined GC_62 -int core2test[62][5] = { +int core2test[62][NUM_CORES2TEST] = { { 0, -1, 6, -1, 1, -1, 14, -1, 2}, { 1, -1, 7, 0, 2, -1, 15, -1, 3}, { 2, -1, 8, 1, 3, -1, 16, 0, 4}, { 3, -1, 9, 2, 4, -1, 17, 1, 5}, { 4, -1, 10, 3, 5, -1, 18, 2, -1}, { 5, -1, 11, 4, -1, -1, 19, 3, -1}, @@ -202,8 +202,8 @@ void initruntimedata() { #endif #ifdef MULTICORE_GC gccorestatus[i] = 1; - gcnumsendobjs[i] = 0; - gcnumreceiveobjs[i] = 0; + gcnumsendobjs[0][i] = gcnumsendobjs[1][i] = 0; + gcnumreceiveobjs[0][i] = gcnumreceiveobjs[1][i] = 0; #endif } // for(i = 0; i < NUMCORESACTIVE; ++i) #ifdef MULTICORE_GC @@ -2584,8 +2584,16 @@ INLINE void processmsg_gcfinishmark_I() { // all cores should do mark if(data1 < NUMCORESACTIVE) { gccorestatus[data1] = 0; - gcnumsendobjs[data1] = data2; - gcnumreceiveobjs[data1] = data3; + int entry_index = 0; + if(waitconfirm) { + // phase 2 + entry_index = (gcnumsrobjs_index == 0) ? 1 : 0; + } else { + // phase 1 + entry_index = gcnumsrobjs_index; + } + gcnumsendobjs[entry_index][data1] = data2; + gcnumreceiveobjs[entry_index][data1] = data3; } } @@ -2704,12 +2712,19 @@ INLINE void processmsg_gcmarkreport_I() { #endif BAMBOO_EXIT(0xb007); } else { + int entry_index = 0; if(waitconfirm) { + // phse 2 numconfirm--; - } + entry_index = (gcnumsrobjs_index == 0) ? 1 : 0; + } else { + // can never reach here + // phase 1 + entry_index = gcnumsrobjs_index; + } gccorestatus[data1] = data2; - gcnumsendobjs[data1] = data3; - gcnumreceiveobjs[data1] = data4; + gcnumsendobjs[entry_index][data1] = data3; + gcnumreceiveobjs[entry_index][data1] = data4; } }