From 229240713fcca223202ba9380c71a037f1b53b4b Mon Sep 17 00:00:00 2001 From: jzhou Date: Thu, 21 Apr 2011 01:26:49 +0000 Subject: [PATCH] Bug fixes for multicore gc --- Robust/src/Runtime/bamboo/multicoregarbage.c | 30 +++++++++++++---- Robust/src/Runtime/bamboo/multicoremem.c | 30 +++++++++-------- Robust/src/Runtime/bamboo/multicoreruntime.c | 35 +++++--------------- Robust/src/Runtime/mem.c | 2 +- 4 files changed, 49 insertions(+), 48 deletions(-) diff --git a/Robust/src/Runtime/bamboo/multicoregarbage.c b/Robust/src/Runtime/bamboo/multicoregarbage.c index 7c01d1d5..f3ae6cfb 100644 --- a/Robust/src/Runtime/bamboo/multicoregarbage.c +++ b/Robust/src/Runtime/bamboo/multicoregarbage.c @@ -2075,7 +2075,7 @@ innermoveobj: unsigned int tt_size=tt_pointer[0]; int tt_i; for(tt_i=1; tt_i<=tt_size; tt_i++) { - unsigned int tt_offset=tt_pointer[i]; + unsigned int tt_offset=tt_pointer[tt_i]; void * objptr=*((void **)(((char *)origptr)+tt_offset)); if((objptr!= 0) && ((gcmappingtbl[OBJMAPPINGINDEX((unsigned int)objptr)] == 0) || @@ -2140,7 +2140,7 @@ innermoveobj: if((objptr != 0) && (gcmappingtbl[OBJMAPPINGINDEX((unsigned int)objptr)] == 0)) { tprintf("Error moveobj, missing live obj ++: %x, %x, %d, %d, %d, %d, %d, %d, %d, %d \n", - (int)origptr, (int)objptr, __LINE__, tt_i, + (int)origptr, (int)objptr, __LINE__, tt_j, ((int *)(origptr))[0], ((int *)(objptr))[0], ((int *)(objptr))[BAMBOOMARKBIT], gcmappingtbl[OBJMAPPINGINDEX((unsigned int)objptr)], @@ -2172,7 +2172,7 @@ innermoveobj: unsigned int tt_size=tt_pointer[0]; int tt_i; for(tt_i=1; tt_i<=tt_size; tt_i++) { - unsigned int tt_offset=tt_pointer[i]; + unsigned int tt_offset=tt_pointer[tt_i]; void * objptr=*((void **)(((char *)origptr)+tt_offset)); if((objptr!= 0) && ((gcmappingtbl[OBJMAPPINGINDEX((unsigned int)objptr)] == 0) || @@ -2330,7 +2330,7 @@ innercompact: } } #ifdef GC_TBL_DEBUG - tprintf("finish mark %x \n", (int)gcmarkedptrbound); + //tprintf("finish mark %x \n", (int)gcmarkedptrbound); #endif #ifdef GC_CACHE_ADAPT // end of an to page, wrap up its information @@ -2907,8 +2907,7 @@ inline void flush(struct garbagelist * stackptr) { #endif GC_BAMBOO_DEBUGPRINT(0xe30a); GC_BAMBOO_DEBUGPRINT_REG(ptr); - GC_BAMBOO_DEBUGPRINT_REG(tptr); - GC_BAMBOO_DEBUGPRINT_REG(((int *)(tptr))[0]); + GC_BAMBOO_DEBUGPRINT_REG(((int *)(ptr))[0]); if(ptr == NULL) { BAMBOO_EXIT(0xb02a); } @@ -3622,6 +3621,7 @@ inline void gc_collect(struct garbagelist * stackptr) { bamboo_smem_size = 0; bamboo_smem_zero_top = NULL; + gcflag = false; while(true) { if(FINISHPHASE == gcphase) { break; @@ -3729,6 +3729,7 @@ inline void gc_nocollect(struct garbagelist * stackptr) { bamboo_smem_size = 0; bamboo_smem_zero_top = NULL; + gcflag = false; while(true) { if(FINISHPHASE == gcphase) { break; @@ -4130,6 +4131,7 @@ inline void gc_master(struct garbagelist * stackptr) { } #endif #endif + gcflag = false; gccorestatus[BAMBOO_NUM_OF_CORE] = 1; for(i = 1; i < NUMCORESACTIVE; ++i) { // send gc finish messages to all cores @@ -4137,8 +4139,22 @@ inline void gc_master(struct garbagelist * stackptr) { gccorestatus[i] = 1; } - gcflag = false; gcprocessing = false; + if(gcflag) { + // inform other cores to stop and wait for gc + gcprecheck = true; + for(int i = 0; i < NUMCORESACTIVE; i++) { + // reuse the gcnumsendobjs & gcnumreceiveobjs + gccorestatus[i] = 1; + gcnumsendobjs[0][i] = 0; + gcnumreceiveobjs[0][i] = 0; + } + for(int i = 0; i < NUMCORESACTIVE; i++) { + if(i != BAMBOO_NUM_OF_CORE) { + send_msg_1(i, GCSTARTPRE, false); + } + } + } #ifdef RAWPATH // TODO GC_DEBUG printf("(%x,%x) gc finished \n", udn_tile_coord_x(), udn_tile_coord_y()); diff --git a/Robust/src/Runtime/bamboo/multicoremem.c b/Robust/src/Runtime/bamboo/multicoremem.c index cf6c921a..2ec5fda3 100644 --- a/Robust/src/Runtime/bamboo/multicoremem.c +++ b/Robust/src/Runtime/bamboo/multicoremem.c @@ -880,20 +880,22 @@ void * smemalloc_I(int coren, #ifdef MULTICORE_GC if(!gcflag) { gcflag = true; - // inform other cores to stop and wait for gc - gcprecheck = true; - for(int i = 0; i < NUMCORESACTIVE; i++) { - // reuse the gcnumsendobjs & gcnumreceiveobjs - gccorestatus[i] = 1; - gcnumsendobjs[0][i] = 0; - gcnumreceiveobjs[0][i] = 0; - } - for(int i = 0; i < NUMCORESACTIVE; i++) { - if(i != BAMBOO_NUM_OF_CORE) { - if(BAMBOO_CHECK_SEND_MODE()) { - cache_msg_1(i, GCSTARTPRE); - } else { - send_msg_1(i, GCSTARTPRE, true); + if(!gcprocessing) { + // inform other cores to stop and wait for gc + gcprecheck = true; + for(int i = 0; i < NUMCORESACTIVE; i++) { + // reuse the gcnumsendobjs & gcnumreceiveobjs + gccorestatus[i] = 1; + gcnumsendobjs[0][i] = 0; + gcnumreceiveobjs[0][i] = 0; + } + for(int i = 0; i < NUMCORESACTIVE; i++) { + if(i != BAMBOO_NUM_OF_CORE) { + if(BAMBOO_CHECK_SEND_MODE()) { + cache_msg_1(i, GCSTARTPRE); + } else { + send_msg_1(i, GCSTARTPRE, true); + } } } } diff --git a/Robust/src/Runtime/bamboo/multicoreruntime.c b/Robust/src/Runtime/bamboo/multicoreruntime.c index 95173598..8594308d 100644 --- a/Robust/src/Runtime/bamboo/multicoreruntime.c +++ b/Robust/src/Runtime/bamboo/multicoreruntime.c @@ -592,7 +592,7 @@ INLINE void initruntimedata() { outmsgleft = 0; isMsgHanging = false; - smemflag = true; + smemflag = false; bamboo_cur_msp = NULL; bamboo_smem_size = 0; @@ -1186,26 +1186,12 @@ INLINE void processmsg_memrequest_I() { int allocsize = 0; void * mem = NULL; #ifdef MULTICORE_GC - if(gcprocessing) { - // is currently doing gc, dump this msg if at the beginning of the gc - // if at the end of the gc, send a msg with a block with size of -1 - // to ask the request core to send the mem request again - if(FINISHPHASE == gcphase) { - // if still in the finishphase of gc, send a memresponse msg with - // invalid block: addr 0, size -1 - if(BAMBOO_CHECK_SEND_MODE()) { - cache_msg_3(data2, MEMRESPONSE, 0, -1); - } else { - send_msg_3(data2, MEMRESPONSE, 0, -1, true); - } - } else if(INITPHASE == gcphase) { - if(BAMBOO_CHECK_SEND_MODE()) { - cache_msg_1(data2, GCSTARTINIT); - } else { - send_msg_1(data2, GCSTARTINIT, true); - } - } + if(gcprocessing && gcflag) { + // is currently doing GC and the master core does not decide to stop GC + // yet } else { + // either not doing GC or the master core has decided to stop GC but + // still sending msgs to other cores to inform them to stop the GC #endif mem = smemalloc_I(data2, data1, &allocsize); if(mem != NULL) { @@ -1243,9 +1229,6 @@ INLINE void processmsg_memresponse_I() { #ifdef MULTICORE_GC bamboo_smem_zero_top = 0; #endif - } else if(data2 == -1) { - bamboo_smem_size = data2; - bamboo_cur_msp = (void *)data1; } else { #ifdef MULTICORE_GC // fill header to store the size of this mem block @@ -1261,13 +1244,13 @@ INLINE void processmsg_memresponse_I() { } smemflag = true; #ifdef MULTICORE_GC -} + } #endif } #ifdef MULTICORE_GC INLINE void processmsg_gcstartpre_I() { - if(gcprocessing) { + if(gcprocessing && gcflag) { // already stall for gc } else { // the first time to be informed to start gc @@ -1821,7 +1804,7 @@ processmsg: case GCFINISH: { // received a GC finish msg gcphase = FINISHPHASE; - gcflag = false; + smemflag = false; // TODO gcprocessing = false; break; } // case GCFINISH diff --git a/Robust/src/Runtime/mem.c b/Robust/src/Runtime/mem.c index 3ddecd00..e808fba6 100644 --- a/Robust/src/Runtime/mem.c +++ b/Robust/src/Runtime/mem.c @@ -15,7 +15,7 @@ void * mycalloc_share(struct garbagelist * stackptr, int hasgc = 0; memalloc: BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); - if(gcflag) { + while(gcflag) { BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); gc(stackptr); BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); -- 2.34.1