From: jzhou Date: Sat, 7 May 2011 00:52:52 +0000 (+0000) Subject: bug fix in multicore code X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=69c8ff2d8d864e0bf13344706374ae62ae55be8b;p=IRC.git bug fix in multicore code --- diff --git a/Robust/src/Benchmarks/Scheduling/GC/tsp/TSPBench.java b/Robust/src/Benchmarks/Scheduling/GC/tsp/TSPBench.java index 1d305a83..d1f50674 100644 --- a/Robust/src/Benchmarks/Scheduling/GC/tsp/TSPBench.java +++ b/Robust/src/Benchmarks/Scheduling/GC/tsp/TSPBench.java @@ -8,7 +8,7 @@ task t1(StartupObject s{initialstate}) { //System.printString("task t1\n"); int threadnum = 62; // 56; - int ncities = 4080; + int ncities = 4080*2; for(int i = 0; i < threadnum; ++i) { TestRunner tr = newflag TestRunner(ncities){run}; } diff --git a/Robust/src/Runtime/bamboo/multicoregarbage.c b/Robust/src/Runtime/bamboo/multicoregarbage.c index f228ca76..5ae1dab9 100644 --- a/Robust/src/Runtime/bamboo/multicoregarbage.c +++ b/Robust/src/Runtime/bamboo/multicoregarbage.c @@ -203,22 +203,23 @@ INLINE void initGC() { gcheadindex=gctailindex=gctailindex2 = 0; gchead=gctail=gctail2=RUNMALLOC(sizeof(struct pointerblock)); } else { - gctailindex = gctailindex2 = gcheadindex = 0; - gctail = gctail2 = gchead; + gctailindex=gctailindex2=gcheadindex=0; + gctail=gctail2=gchead; } + gchead->next=NULL; // initialize the large obj queues if (gclobjhead==NULL) { gclobjheadindex=0; gclobjtailindex=0; - gclobjtailindex2 = 0; + gclobjtailindex2=0; gclobjhead=gclobjtail=gclobjtail2= - RUNMALLOC(sizeof(struct lobjpointerblock)); + RUNMALLOC(sizeof(struct lobjpointerblock)); } else { - gclobjtailindex = gclobjtailindex2 = gclobjheadindex = 0; - gclobjtail = gclobjtail2 = gclobjhead; + gclobjtailindex=gclobjtailindex2=gclobjheadindex=0; + gclobjtail=gclobjtail2=gclobjhead; } - gclobjhead->next = gclobjhead->prev = NULL; + gclobjhead->next=gclobjhead->prev=NULL; freeMGCHash(gcforwardobjtbl); gcforwardobjtbl = allocateMGCHash(20, 3); @@ -253,8 +254,7 @@ INLINE void checkMarkStatue() { 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(); - if(allStall) { + if(gc_checkAllCoreStatus_I()) { // ask for confirm if(!waitconfirm) { // the first time found all cores stall @@ -677,7 +677,6 @@ INLINE void moveLObjs() { INLINE void gc_collect(struct garbagelist * stackptr) { gcprocessing = true; - tprintf("gc \n"); // inform the master that this core is at a gc safe point and is ready to // do gc send_msg_4(STARTUPCORE, GCFINISHPRE, BAMBOO_NUM_OF_CORE, self_numsendobjs, @@ -735,7 +734,6 @@ INLINE void gc_collect(struct garbagelist * stackptr) { INLINE void gc_nocollect(struct garbagelist * stackptr) { gcprocessing = true; - tprintf("gc \n"); // inform the master that this core is at a gc safe point and is ready to // do gc send_msg_4(STARTUPCORE, GCFINISHPRE, BAMBOO_NUM_OF_CORE, self_numsendobjs, @@ -804,7 +802,7 @@ INLINE void gc_master(struct garbagelist * stackptr) { GCPROFILE_ITEM(); CACHEADAPT_OUTPUT_CACHE_SAMPLING(); - GC_PRINTF("(%x,%x) Start mark phase \n"); + GC_PRINTF("Start mark phase \n"); GC_SEND_MSG_1_TO_CLIENT(GCSTART); gcphase = MARKPHASE; // mark phase @@ -814,7 +812,7 @@ INLINE void gc_master(struct garbagelist * stackptr) { if(isfirst) { isfirst = false; } - + // check gcstatus checkMarkStatue(); } diff --git a/Robust/src/Runtime/bamboo/multicoregarbage.h b/Robust/src/Runtime/bamboo/multicoregarbage.h index 97ee59ab..59f96c53 100644 --- a/Robust/src/Runtime/bamboo/multicoregarbage.h +++ b/Robust/src/Runtime/bamboo/multicoregarbage.h @@ -217,14 +217,14 @@ unsigned int size_cachepolicytbl; } \ } -// send a 1-word msg to all client +// send a 1-word msg to all clients #define GC_SEND_MSG_1_TO_CLIENT(m) \ { \ for(int i = 0; i < NUMCORESACTIVE; ++i) { \ + gccorestatus[i] = 1; \ if(BAMBOO_NUM_OF_CORE != i) { \ send_msg_1(i, (m), false); \ } \ - gccorestatus[i] = 1; \ } \ } diff --git a/Robust/src/Runtime/bamboo/multicoregcmark.c b/Robust/src/Runtime/bamboo/multicoregcmark.c index 9752f5f6..264186e7 100644 --- a/Robust/src/Runtime/bamboo/multicoregcmark.c +++ b/Robust/src/Runtime/bamboo/multicoregcmark.c @@ -73,7 +73,6 @@ INLINE unsigned int gc_dequeue_I() { gcspare->next = NULL; } } - int loopiter = 0; return gctail->ptrs[gctailindex++]; } @@ -84,7 +83,6 @@ INLINE unsigned int gc_dequeue2_I() { gctail2=gctail2->next; gctailindex2=0; } - int loopiter = 0; return gctail2->ptrs[gctailindex2++]; } @@ -411,7 +409,7 @@ INLINE void scanPtrsInObj(void * ptr, /* Array of primitives */ pointer=pointerarray[OBJECTTYPE]; //handle object class - unsigned int size=pointer[0]; + int size=pointer[0]; int i; for(i=1; i<=size; i++) { unsigned int offset=pointer[i]; @@ -434,7 +432,7 @@ INLINE void scanPtrsInObj(void * ptr, { pointer=pointerarray[OBJECTTYPE]; //handle object class - unsigned int size=pointer[0]; + int size=pointer[0]; int i; for(i=1; i<=size; i++) { unsigned int offset=pointer[i]; @@ -445,7 +443,7 @@ INLINE void scanPtrsInObj(void * ptr, } } } else { - unsigned int size=pointer[0]; + int size=pointer[0]; int i; for(i=1; i<=size; i++) { unsigned int offset=pointer[i]; @@ -470,6 +468,7 @@ INLINE void mark(bool isfirst, bool sendStall = false; // mark phase while(MARKPHASE == gcphase) { + int counter = 0; while(true) { BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); if(!gc_moreItems2_I()) { diff --git a/Robust/src/Runtime/bamboo/multicoremem.c b/Robust/src/Runtime/bamboo/multicoremem.c index e55e9090..8befb794 100644 --- a/Robust/src/Runtime/bamboo/multicoremem.c +++ b/Robust/src/Runtime/bamboo/multicoremem.c @@ -709,20 +709,20 @@ void * smemalloc_I(int coren, if(mem == NULL) { // no enough shared global memory *allocsize = 0; - if(!gcflag) { - gcflag = 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 - gcnumsendobjs[0][i] = 0; - gcnumreceiveobjs[0][i] = 0; + if(!gcflag) { + gcflag = 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 + gcnumsendobjs[0][i] = 0; + gcnumreceiveobjs[0][i] = 0; + } + GC_SEND_MSG_1_TO_CLIENT(GCSTARTPRE); } - GC_SEND_MSG_1_TO_CLIENT(GCSTARTPRE); - } - } - return NULL; + } + return NULL; } return mem; } diff --git a/Robust/src/Runtime/bamboo/multicoremem.h b/Robust/src/Runtime/bamboo/multicoremem.h index 4bd0c80d..0b29f7c9 100644 --- a/Robust/src/Runtime/bamboo/multicoremem.h +++ b/Robust/src/Runtime/bamboo/multicoremem.h @@ -82,7 +82,7 @@ #define BAMBOO_PAGE_SIZE ((unsigned int)(256 * 1024)) // (4096) #define BAMBOO_SMEM_SIZE ((unsigned int)(BAMBOO_PAGE_SIZE)) #elif defined GC_SMALLPAGESIZE2 -#define BAMBOO_PAGE_SIZE ((unsigned int)(64 * 1024)) // (4096) +#define BAMBOO_PAGE_SIZE ((unsigned int)(256 * 1024)) // (4096) 64 #define BAMBOO_SMEM_SIZE ((unsigned int)(BAMBOO_PAGE_SIZE)) #else #define BAMBOO_PAGE_SIZE ((unsigned int)(1024 * 1024)) // (4096) diff --git a/Robust/src/Runtime/bamboo/multicoremsg.c b/Robust/src/Runtime/bamboo/multicoremsg.c index 1e8d85a6..9876acc7 100644 --- a/Robust/src/Runtime/bamboo/multicoremsg.c +++ b/Robust/src/Runtime/bamboo/multicoremsg.c @@ -521,8 +521,7 @@ INLINE void processmsg_memresponse_I() { #ifdef MULTICORE_GC INLINE void processmsg_gcstartpre_I() { - // the first time to be informed to start gc - tprintf("pre msg \n"); + // the first time to be informed to start gc gcflag = true; if(!smemflag) { // Zero out the remaining memory here because for the GC_CACHE_ADAPT @@ -844,6 +843,10 @@ msg: if(receiveMsg(send_port_pending) == -1) { return -1; } + if(BAMBOO_CHECK_SEND_MODE()) { + // during send, don't process the msg now + return -3; + } processmsg: // processing received msgs int size = 0; diff --git a/Robust/src/Runtime/bamboo/multicoreruntime.c b/Robust/src/Runtime/bamboo/multicoreruntime.c index 6c4b5f01..de05e9cc 100644 --- a/Robust/src/Runtime/bamboo/multicoreruntime.c +++ b/Robust/src/Runtime/bamboo/multicoreruntime.c @@ -676,7 +676,6 @@ INLINE void getprofiledata() { } INLINE void checkCoreStatus() { - bool allStall = false; int i = 0; int sumsendobj = 0; if((!waitconfirm) || @@ -686,14 +685,12 @@ INLINE void checkCoreStatus() { numsendobjs[BAMBOO_NUM_OF_CORE] = self_numsendobjs; numreceiveobjs[BAMBOO_NUM_OF_CORE] = self_numreceiveobjs; // check the status of all cores - allStall = true; for(i = 0; i < NUMCORESACTIVE; ++i) { if(corestatus[i] != 0) { - allStall = false; break; } } - if(allStall) { + if(i == NUMCORESACTIVE) { // 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 sumsendobj = 0; @@ -716,7 +713,7 @@ INLINE void checkCoreStatus() { corestatus[i] = 1; // send status confirm msg to core i send_msg_1(i, STATUSCONFIRM, false); - } // for(i = 1; i < NUMCORESACTIVE; ++i) + } return; } else { // all the core status info are the latest @@ -729,20 +726,20 @@ INLINE void checkCoreStatus() { disruntimedata(); BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); terminate(); // All done. - } // if(!waitconfirm) + } } else { // still some objects on the fly on the network // reset the waitconfirm and numconfirm waitconfirm = false; numconfirm = 0; - } // if(0 == sumsendobj) + } } else { // not all cores are stall, keep on waiting waitconfirm = false; numconfirm = 0; - } // if(allStall) + } BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); - } // if((!waitconfirm) || + } } // main function for each core @@ -858,6 +855,6 @@ inline void run(int argc, char** argv) { } } } -} // run() +} #endif // MULTICORE