From: bdemsky Date: Wed, 22 Jun 2011 08:08:00 +0000 (+0000) Subject: changes X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=80db437ab6fc3bcdba79078fbd1213fb15962d07;p=IRC.git changes --- diff --git a/Robust/src/Runtime/bamboo/multicorecache.c b/Robust/src/Runtime/bamboo/multicorecache.c index f25d4813..10ee1be1 100644 --- a/Robust/src/Runtime/bamboo/multicorecache.c +++ b/Robust/src/Runtime/bamboo/multicorecache.c @@ -439,7 +439,7 @@ void cacheAdapt_phase_master() { GC_PRINTF("Start cachepolicy phase \n"); // cache adapt phase cacheAdapt_decision(BAMBOO_NUM_OF_CORE); - GC_CHECK_ALL_CORE_STATUS(CACHEPOLICYPHASE==gc_status_info.gcphase); + GC_CHECK_ALL_CORE_STATUS(); BAMBOO_CACHE_MF(); // let all cores to adopt new policies @@ -450,7 +450,7 @@ void cacheAdapt_phase_master() { // cache adapt phase cacheAdapt_mutator(); cacheAdapt_gc(false); - GC_CHECK_ALL_CORE_STATUS(PREFINISHPHASE==gc_status_info.gcphase); + GC_CHECK_ALL_CORE_STATUS(); CACHEADAPT_SAMPING_RESET(); if(BAMBOO_NUM_OF_CORE < NUMCORESACTIVE) { diff --git a/Robust/src/Runtime/bamboo/multicoregarbage.c b/Robust/src/Runtime/bamboo/multicoregarbage.c index 3f7d1fb0..dd0788f5 100644 --- a/Robust/src/Runtime/bamboo/multicoregarbage.c +++ b/Robust/src/Runtime/bamboo/multicoregarbage.c @@ -285,10 +285,10 @@ void gc_collect(struct garbagelist * stackptr) { WAITFORGCPHASE(UPDATEPHASE); - GC_PRINTF("Start flush phase\n"); + GC_PRINTF("Start update phase\n"); GCPROFILE_INFO_2_MASTER(); update(stackptr); - GC_PRINTF("Finish flush phase\n"); + GC_PRINTF("Finish update phase\n"); CACHEADAPT_PHASE_CLIENT(); @@ -321,15 +321,15 @@ void gc_nocollect(struct garbagelist * stackptr) { GC_PRINTF("Start mark phase\n"); mark(stackptr); - GC_PRINTF("Finish mark phase, wait for flush\n"); + GC_PRINTF("Finish mark phase, wait for update\n"); // non-gc core collector routine WAITFORGCPHASE(UPDATEPHASE); - GC_PRINTF("Start flush phase\n"); + GC_PRINTF("Start update phase\n"); GCPROFILE_INFO_2_MASTER(); update(stackptr); - GC_PRINTF("Finish flush phase\n"); + GC_PRINTF("Finish update phase\n"); CACHEADAPT_PHASE_CLIENT(); @@ -375,11 +375,11 @@ void master_updaterefs(struct garbagelist * stackptr) { gc_status_info.gcphase = UPDATEPHASE; GC_SEND_MSG_1_TO_CLIENT(GCSTARTUPDATE); GCPROFILE_ITEM(); - GC_PRINTF("Start flush phase \n"); - // flush phase + GC_PRINTF("Start update phase \n"); + // update phase update(stackptr); - GC_CHECK_ALL_CORE_STATUS(UPDATEPHASE==gc_status_info.gcphase); - GC_PRINTF("Finish flush phase \n"); + GC_CHECK_ALL_CORE_STATUS(); + GC_PRINTF("Finish update phase \n"); } void master_finish() { @@ -424,7 +424,7 @@ void gc_master(struct garbagelist * stackptr) { GC_SEND_MSG_1_TO_CLIENT(GCSTARTINIT); CACHEADAPT_GC(true); GC_PRINTF("Check core status \n"); - GC_CHECK_ALL_CORE_STATUS(true); + GC_CHECK_ALL_CORE_STATUS(); GCPROFILE_ITEM(); unsigned long long tmpt = BAMBOO_GET_EXE_TIME(); CACHEADAPT_OUTPUT_CACHE_SAMPLING(); @@ -441,7 +441,7 @@ void gc_master(struct garbagelist * stackptr) { // update the references master_updaterefs(stackptr); - + GC_PRINTF("gc master finished update \n"); // do cache adaptation CACHEADAPT_PHASE_MASTER(); diff --git a/Robust/src/Runtime/bamboo/multicoregarbage.h b/Robust/src/Runtime/bamboo/multicoregarbage.h index e8dd7a44..b50f91c0 100644 --- a/Robust/src/Runtime/bamboo/multicoregarbage.h +++ b/Robust/src/Runtime/bamboo/multicoregarbage.h @@ -112,7 +112,6 @@ void * gcbaseva; // base va for shared memory without reserved sblocks static bool gc_checkCoreStatus() { for(int i = 0; i < NUMCORES4GC; i++) { if(gccorestatus[i]) { - printf("CHECK\n"); return false; } } @@ -281,15 +280,8 @@ INLINE static unsigned int hostcore(void * ptr) { #define NEXTTOPCORE(b) (gc_block2core[((b)+1)%(NUMCORES4GC*2)]) // check if all cores are stall now -#define GC_CHECK_ALL_CORE_STATUS(f) \ - { \ - gccorestatus[BAMBOO_NUM_OF_CORE] = 0; \ - while(f) { \ - if(gc_checkCoreStatus()) { \ - break; \ - } \ - } \ - } +#define GC_CHECK_ALL_CORE_STATUS() gccorestatus[BAMBOO_NUM_OF_CORE] = 0; \ + while(!gc_checkCoreStatus()) ; // send a 1-word msg to all clients #define GC_SEND_MSG_1_TO_CLIENT(m) \ diff --git a/Robust/src/Runtime/bamboo/multicoregccompact.c b/Robust/src/Runtime/bamboo/multicoregccompact.c index b21410ba..51a255a2 100644 --- a/Robust/src/Runtime/bamboo/multicoregccompact.c +++ b/Robust/src/Runtime/bamboo/multicoregccompact.c @@ -37,14 +37,72 @@ void getSpaceLocally(struct moveHelper *to) { to->bound = to->base + BLOCKSIZE(to->localblocknum); } +//This function is called on the master core only...and typically by +//the message interrupt handler + +void handleReturnMem_I(unsigned int cnum, void *heaptop) { + unsigned int blockindex; + BLOCKINDEX(blockindex, heaptop); + unsigned INTPTR localblocknum=GLOBALBLOCK2LOCAL(blockindex); + + //this core is done as far as memory usage is concerned + returnedmem[cnum]=0; + + struct blockrecord * blockrecord=&allocationinfo.blocktable[blockindex]; + + blockrecord->status=BS_FREE; + blockrecord->usedspace=(unsigned INTPTR)(heaptop-OFFSET2BASEVA(blockindex)); + blockrecord->freespace=BLOCKSIZE(localblocknum)-blockrecord->usedspace; + /* Update the lowest free block */ + if (blockindex < allocationinfo.lowestfreeblock) { + blockindex=allocationinfo.lowestfreeblock; + } + + /* This is our own block...means we should mark other blocks above us as free*/ + if (cnum==blockrecord->corenum) { + unsigned INTPTR nextlocalblocknum=localblocknum+1; + for(;nextlocalblocknumstatus=BS_FREE; + nextblockrecord->usedspace=0; + //this is true because this cannot be the lowest block + nextblockrecord->freespace=BLOCKSIZE(1); + } + } +} + +void handleReturnMem(unsigned int cnum, void *heaptop) { + BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); + handleReturnMem_I(cnum, heaptop); + BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); +} + void getSpaceRemotely(struct moveHelper *to, unsigned int minimumbytes) { //need to get another block from elsewhere //set flag to wait for memory - gctomove=false; - //send request for memory - send_msg_4(STARTUPCORE,GCFINISHCOMPACT,BAMBOO_NUM_OF_CORE, minimumbytes, gccurr_heaptop); - //wait for flag to be set that we received message - while(!gctomove) ; + if (BAMBOO_NUM_OF_CORE==STARTUPCORE) { + printf("A: %d\n", BAMBOO_NUM_OF_CORE); + + gctomove=false; + BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); + void *startaddr=handlegcfinishcompact_I(BAMBOO_NUM_OF_CORE, minimumbytes, gccurr_heaptop); + BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); + if (startaddr) { + gcmovestartaddr=startaddr; + } else { + while(!gctomove) ; + } + printf("B: %d\n", BAMBOO_NUM_OF_CORE); + } else { + printf("C: %d\n", BAMBOO_NUM_OF_CORE); + gctomove=false; + //send request for memory + send_msg_4(STARTUPCORE,GCFINISHCOMPACT,BAMBOO_NUM_OF_CORE, minimumbytes, gccurr_heaptop); + //wait for flag to be set that we received message + while(!gctomove) ; + printf("D: %d\n", BAMBOO_NUM_OF_CORE); + } //store pointer to->ptr = gcmovestartaddr; @@ -71,11 +129,14 @@ void compacthelper(struct moveHelper * orig,struct moveHelper * to) { while(true) { if ((gccurr_heaptop < ((unsigned INTPTR)(to->bound-to->ptr)))&&!senttopmessage) { //This block is the last for this core...let the startup know - send_msg_3(STARTUPCORE, GCRETURNMEM, BAMBOO_NUM_OF_CORE, to->ptr+gccurr_heaptop); + if (BAMBOO_NUM_OF_CORE==STARTUPCORE) { + handleReturnMem(BAMBOO_NUM_OF_CORE, to->ptr+gccurr_heaptop); + } else { + send_msg_3(STARTUPCORE, GCRETURNMEM, BAMBOO_NUM_OF_CORE, to->ptr+gccurr_heaptop); + } //Only send the message once senttopmessage=true; } - unsigned int minimumbytes=compactblocks(orig, to); if (orig->ptr==orig->bound) { //need more data to compact @@ -91,8 +152,15 @@ void compacthelper(struct moveHelper * orig,struct moveHelper * to) { getSpace(to, minimumbytes); } } - - send_msg_4(STARTUPCORE,GCFINISHCOMPACT,BAMBOO_NUM_OF_CORE, 0, 0); + + if (BAMBOO_NUM_OF_CORE==STARTUPCORE) { + BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); + handlegcfinishcompact_I(BAMBOO_NUM_OF_CORE, 0, 0); + BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); + } else { + send_msg_4(STARTUPCORE,GCFINISHCOMPACT,BAMBOO_NUM_OF_CORE, 0, 0); + } + } void * checkNeighbors_I(int corenum, unsigned INTPTR requiredmem, unsigned INTPTR desiredmem) { @@ -233,7 +301,7 @@ void * gcfindSpareMem_I(unsigned INTPTR requiredmem, unsigned INTPTR desiredmem, unsigned int compactblocks(struct moveHelper * orig, struct moveHelper * to) { void *toptrinit=to->ptr; - void *toptr=toptr; + void *toptr=toptrinit; void *tobound=to->bound; void *origptr=orig->ptr; void *origbound=orig->bound; @@ -334,10 +402,12 @@ void master_compact() { // compact phase compact(); /* wait for all cores to finish compacting */ + tprintf("MASTER WAITING\n"); while(!gc_checkCoreStatus()) ; + tprintf("POST_WAIT\n"); GCPROFILE_ITEM(); //just in case we didn't get blocks back... diff --git a/Robust/src/Runtime/bamboo/multicoregcflush.c b/Robust/src/Runtime/bamboo/multicoregcflush.c index 1cf5d422..fc89108f 100644 --- a/Robust/src/Runtime/bamboo/multicoregcflush.c +++ b/Robust/src/Runtime/bamboo/multicoregcflush.c @@ -29,7 +29,7 @@ extern struct lockvector bamboo_threadlocks; #define UPDATEOBJ(obj, tt) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) obj=updateObj(updatetmpptr);} #define UPDATEOBJNONNULL(obj, tt) {void *updatetmpptr=obj; obj=updateObj(updatetmpptr);} - +#define dbpr() if (STARTUPCORE==BAMBOO_NUM_OF_CORE) tprintf("FL: %d\n", __LINE__); INLINE void updategarbagelist(struct garbagelist *listptr) { for(;listptr!=NULL; listptr=listptr->next) { @@ -212,6 +212,14 @@ void * updateblocks(struct moveHelper * orig, struct moveHelper * to) { if (endtoptr>tobound||endtoptrptr=origptr; + if (BAMBOO_NUM_OF_CORE==STARTUPCORE) { + tprintf("dstptr=%x\n",dstptr); + tprintf("endtoptrptr=%x\n",endtoptr); + tprintf("tobound=%x\n",tobound); + tprintf("tobase=%x\n",tobase); + tprintf("origptr=%x\n",origptr); + tprintf("length=%d\n",length); + } return dstptr; } @@ -255,9 +263,13 @@ void updateOrigPtr(void *currtop) { void updatehelper(struct moveHelper * orig,struct moveHelper * to) { while(true) { + dbpr(); void *dstptr=updateblocks(orig, to); + dbpr(); if (dstptr) { - //need more memory to compact into + dbpr(); + printf("M: %x\n", dstptr); + //need more memory to compact into block_t blockindex; BLOCKINDEX(blockindex, dstptr); unsigned int corenum; @@ -274,7 +286,9 @@ void updatehelper(struct moveHelper * orig,struct moveHelper * to) { ; } } + dbpr(); if (orig->ptr==orig->bound) { + dbpr(); //inform others that we are done with previous block updateOrigPtr(orig->bound); @@ -285,30 +299,32 @@ void updatehelper(struct moveHelper * orig,struct moveHelper * to) { update_origblockptr=orig->base; orig->ptr=orig->base; orig->bound = orig->base + BLOCKSIZE(orig->localblocknum); - if (orig->base >= gcbaseva+BAMBOO_SHARED_MEM_SIZE) + if (orig->base >= gcbaseva+BAMBOO_SHARED_MEM_SIZE) { + //free our entire memory for others to use break; + } } + dbpr(); } } void updateheap() { - BAMBOO_CACHE_MF(); - // initialize structs for compacting struct moveHelper orig={0,NULL,NULL,0,NULL,0,0,0,0}; struct moveHelper to={0,NULL,NULL,0,NULL,0,0,0,0}; + dbpr(); initOrig_Dst(&orig, &to); - + dbpr(); updatehelper(&orig, &to); + dbpr(); } void update(struct garbagelist * stackptr) { - BAMBOO_CACHE_MF(); - + dbpr(); updateRuntimePtrs(stackptr); - + dbpr(); updateheap(); - + dbpr(); // send update finish message to core coordinator if(STARTUPCORE == BAMBOO_NUM_OF_CORE) { gccorestatus[BAMBOO_NUM_OF_CORE] = 0; diff --git a/Robust/src/Runtime/bamboo/multicoremem.c b/Robust/src/Runtime/bamboo/multicoremem.c index 145398bb..f84ac450 100644 --- a/Robust/src/Runtime/bamboo/multicoremem.c +++ b/Robust/src/Runtime/bamboo/multicoremem.c @@ -57,6 +57,7 @@ void * mixedmalloc_I(int coren, void * globalmalloc_I(int coren, unsigned INTPTR memcheck, int * allocsize) { block_t firstfree=NOFREEBLOCK; block_t lowestblock=allocationinfo.lowestfreeblock; + for(block_t searchblock=lowestblock;searchblockstatus==BS_FREE) { diff --git a/Robust/src/Runtime/bamboo/multicoremsg.c b/Robust/src/Runtime/bamboo/multicoremsg.c index 1a6d596f..b2f1e869 100644 --- a/Robust/src/Runtime/bamboo/multicoremsg.c +++ b/Robust/src/Runtime/bamboo/multicoremsg.c @@ -527,57 +527,17 @@ void processmsg_returnmem_I() { MSG_INDEXINC_I(); void * heaptop = (void *) msgdata[msgdataindex]; MSG_INDEXINC_I(); - unsigned int blockindex; - BLOCKINDEX(blockindex, heaptop); - unsigned INTPTR localblocknum=GLOBALBLOCK2LOCAL(blockindex); - //this core is done as far as memory usage is concerned - returnedmem[cnum]=0; - - struct blockrecord * blockrecord=&allocationinfo.blocktable[blockindex]; - - blockrecord->status=BS_FREE; - blockrecord->usedspace=(unsigned INTPTR)(heaptop-OFFSET2BASEVA(blockindex)); - blockrecord->freespace=BLOCKSIZE(localblocknum)-blockrecord->usedspace; - /* Update the lowest free block */ - if (blockindex < allocationinfo.lowestfreeblock) { - blockindex=allocationinfo.lowestfreeblock; - } - - /* This is our own block...means we should mark other blocks above us as free*/ - if (cnum==blockrecord->corenum) { - unsigned INTPTR nextlocalblocknum=localblocknum+1; - for(;nextlocalblocknumstatus=BS_FREE; - nextblockrecord->usedspace=0; - //this is true because this cannot be the lowest block - nextblockrecord->freespace=BLOCKSIZE(1); - } - } + handleReturnMem_I(cnum, heaptop); } -INLINE void processmsg_gcfinishcompact_I() { - BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE); - - int cnum = msgdata[msgdataindex]; - MSG_INDEXINC_I(); - unsigned int bytesneeded = msgdata[msgdataindex]; - MSG_INDEXINC_I(); - unsigned int maxbytesneeded = msgdata[msgdataindex]; - MSG_INDEXINC_I(); - +void * handlegcfinishcompact_I(int cnum, unsigned int bytesneeded, unsigned int maxbytesneeded) { if(bytesneeded > 0) { // ask for more mem void * startaddr = gcfindSpareMem_I(bytesneeded, maxbytesneeded, cnum); if(startaddr) { // cache the msg first - if(BAMBOO_CHECK_SEND_MODE()) { - cache_msg_2_I(cnum,GCMOVESTART,startaddr); - } else { - send_msg_2_I(cnum,GCMOVESTART,startaddr); - } + return startaddr; } else { maxusefulmems[cnum]=maxbytesneeded; gcrequiredmems[cnum]=bytesneeded; @@ -586,6 +546,25 @@ INLINE void processmsg_gcfinishcompact_I() { //done with compacting gccorestatus[cnum] = 0; } + return NULL; +} + +void processmsg_gcfinishcompact_I() { + int cnum = msgdata[msgdataindex]; + MSG_INDEXINC_I(); + unsigned int bytesneeded = msgdata[msgdataindex]; + MSG_INDEXINC_I(); + unsigned int maxbytesneeded = msgdata[msgdataindex]; + MSG_INDEXINC_I(); + + void * startaddr=handlegcfinishcompact_I(cnum, bytesneeded, maxbytesneeded); + if (startaddr) { + if(BAMBOO_CHECK_SEND_MODE()) { + cache_msg_2_I(cnum,GCMOVESTART,startaddr); + } else { + send_msg_2_I(cnum,GCMOVESTART,startaddr); + } + } } INLINE void processmsg_gcfinishupdate_I() { diff --git a/Robust/src/Runtime/mem.c b/Robust/src/Runtime/mem.c index 972b96c1..bc5216fa 100644 --- a/Robust/src/Runtime/mem.c +++ b/Robust/src/Runtime/mem.c @@ -10,7 +10,6 @@ extern volatile bool gcflag; void * mycalloc_share(struct garbagelist * stackptr, int size) { void * p = NULL; - int isize = ((size-1)&(~(ALIGNMENTSIZE-1)))+ALIGNMENTSIZE; int hasgc = 0;