From: bdemsky Date: Sat, 9 Jul 2011 00:29:20 +0000 (+0000) Subject: version runs specJBB...finally... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7f82b1d870285c4be0a4c2ff2343b4bc7505db12;p=IRC.git version runs specJBB...finally... --- diff --git a/Robust/src/Runtime/bamboo/multicoreruntime.c b/Robust/src/Runtime/bamboo/multicoreruntime.c index 7ee0a50b..dbad8e8c 100644 --- a/Robust/src/Runtime/bamboo/multicoreruntime.c +++ b/Robust/src/Runtime/bamboo/multicoreruntime.c @@ -5,6 +5,8 @@ #include "multicoregarbage.h" #ifdef PMC_GC #include "multicoregcprofile.h" +#include "multicoregc.h" +#include "pmc_garbage.h" #endif #include "multicore_arch.h" #include diff --git a/Robust/src/Runtime/bamboo/multicoreruntime.h b/Robust/src/Runtime/bamboo/multicoreruntime.h index 7b107b6f..560fd9dd 100644 --- a/Robust/src/Runtime/bamboo/multicoreruntime.h +++ b/Robust/src/Runtime/bamboo/multicoreruntime.h @@ -8,6 +8,11 @@ #include "multicoretask.h" #include "multicoremgc.h" #include "multicorecache.h" +#ifdef PMC_GC +#include "multicoregc.h" +#include "pmc_garbage.h" +#endif + //Define the following line if the base object type has pointers //#define OBJECTHASPOINTERS diff --git a/Robust/src/Runtime/bamboo/pmc_forward.c b/Robust/src/Runtime/bamboo/pmc_forward.c index 83a01b42..14788db4 100644 --- a/Robust/src/Runtime/bamboo/pmc_forward.c +++ b/Robust/src/Runtime/bamboo/pmc_forward.c @@ -11,7 +11,7 @@ void pmc_count() { //got lock void *unitbase=(i==0)?gcbaseva:pmc_heapptr->units[i-1].endptr; void *unittop=pmc_heapptr->units[i].endptr; - tprintf("Cnt: %x - %x\n", unitbase, unittop); + //tprintf("Cnt: %x - %x\n", unitbase, unittop); pmc_countbytes(&pmc_heapptr->units[i], unitbase, unittop); } } @@ -49,8 +49,16 @@ void pmc_processunits() { int totalbytes=0; int numregions=0; + pmc_heapptr->regions[0].startptr=gcbaseva; + pmc_heapptr->regions[0].lowunit=0; + for(int i=0;i0&&(totalbytes+pmc_heapptr->units[i].numbytes)>livebytespercore) { + pmc_heapptr->regions[regionnum].highunit=i; + pmc_heapptr->regions[regionnum].endptr=pmc_heapptr->units[i-1].endptr; + + pmc_heapptr->regions[regionnum+1].startptr=pmc_heapptr->units[i-1].endptr; + pmc_heapptr->regions[regionnum+1].lowunit=i; regionnum++; totalbytes-=livebytespercore; numregions=0; @@ -60,6 +68,15 @@ void pmc_processunits() { tmc_spin_mutex_init(&pmc_heapptr->units[i].lock); totalbytes+=pmc_heapptr->units[i].numbytes; } + pmc_heapptr->regions[regionnum].highunit=NUMPMCUNITS; + pmc_heapptr->regions[regionnum].endptr=pmc_heapptr->units[NUMPMCUNITS-1].endptr; + regionnum++; + for(;regionnumregions[regionnum].highunit=NUMPMCUNITS; + pmc_heapptr->regions[regionnum].endptr=pmc_heapptr->units[NUMPMCUNITS-1].endptr; + pmc_heapptr->regions[regionnum+1].startptr=pmc_heapptr->units[NUMPMCUNITS-1].endptr; + pmc_heapptr->regions[regionnum+1].lowunit=NUMPMCUNITS; + } } void pmc_doforward() { @@ -67,30 +84,10 @@ void pmc_doforward() { int endregion=-1; unsigned int totalbytes=0; struct pmc_region * region=&pmc_heapptr->regions[BAMBOO_NUM_OF_CORE]; - for(int i=0;iunits[i].regionnum) { - startregion=i; - } - if (BAMBOO_NUM_OF_COREunits[i].regionnum) { - endregion=i; - break; - } - if (startregion!=-1) { - totalbytes+=pmc_heapptr->units[i].numbytes; - } - } - if (startregion==-1) { - //out of regions.... - region->lowunit=region->highunit=NUMPMCUNITS; - region->lastptr=region->startptr=region->endptr=pmc_heapptr->units[region->highunit-1].endptr; - return; + for(int index=region->lowunit; indexhighunit;index++) { + totalbytes+=pmc_heapptr->units[index].numbytes; } - if (endregion==-1) - endregion=NUMPMCUNITS; - region->lowunit=startregion; - region->highunit=endregion; - region->startptr=(startregion==0)?gcbaseva:pmc_heapptr->units[startregion-1].endptr; - region->endptr=pmc_heapptr->units[endregion-1].endptr; + if (BAMBOO_NUM_OF_CORE&1) { //upward in memory region->lastptr=region->endptr-totalbytes; @@ -109,22 +106,28 @@ void pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *botto struct ___Object___ *lastobj=NULL; unsigned int currunit=region->lowunit; void *endunit=pmc_unitend(currunit); + bool internal=!(BAMBOO_NUM_OF_CORE&1); + int highbound=internal?region->highunit:region->highunit-1; + if (!lower) { //We're resetting the boundaries of units at the low address end of the region... //Be sure not to reset the boundary of our last unit...it is shared with another region - while(endunit<=region->lastptr&&(currunit<(region->highunit-1))) { + + while(endunit<=region->lastptr&&(currunitunits[currunit].endptr=endunit; + //tprintf("Ch2: %u -> %x\n", currunit, endunit); currunit++; endunit=pmc_unitend(currunit); } } else { //We're resetting the boundaries of units at the high address end of the region... //Very top most unit defines boundary of region...we can't move that right now - unsigned int lastunit=region->highunit-2; + unsigned int lastunit=internal?region->highunit-1:region->highunit-2; void * lastunitend=pmc_unitend(lastunit); while(lastunitend>=region->lastptr) { pmc_heapptr->units[lastunit].endptr=lastunitend; + //tprintf("Ch3: %u -> %x\n", lastunit, lastunitend); lastunit--; lastunitend=pmc_unitend(lastunit); } @@ -146,8 +149,9 @@ void pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *botto void *newforwardptr=forwardptr+size; //Need to make sure that unit boundaries do not fall in the middle of an object... //Unless the unit boundary is at the end of the region...then just ignore it. - while(newforwardptr>=endunit&&currunit<(region->highunit-1)) { + while(newforwardptr>=endunit&&currunitunits[currunit].endptr=newforwardptr; + //tprintf("Ch4: %u -> %x\n", currunit, newforwardptr); currunit++; endunit=pmc_unitend(currunit); } @@ -160,6 +164,6 @@ void pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *botto } tmpptr+=size; } - tprintf("forwardptr=%x\n",forwardptr); + //tprintf("forwardptr=%x\n",forwardptr); region->lastobj=lastobj; } diff --git a/Robust/src/Runtime/bamboo/pmc_garbage.c b/Robust/src/Runtime/bamboo/pmc_garbage.c index 91547146..c0cde4ad 100644 --- a/Robust/src/Runtime/bamboo/pmc_garbage.c +++ b/Robust/src/Runtime/bamboo/pmc_garbage.c @@ -33,7 +33,7 @@ void pmc_onceInit() { tmc_spin_barrier_init(&pmc_heapptr->barrier, NUMCORES4GC); for(int i=0;iunits[i].endptr=pmc_unitend(i); - tprintf("%u endptr=%x\n", i, pmc_heapptr->units[i].endptr); + //tprintf("Ch5: %u-> %x\n", i, pmc_heapptr->units[i].endptr); } for(int i=0;iregions[i+1].lowunit=4*(i+1); pmc_heapptr->regions[i+1].highunit=4*(i+2); } - for(int i=0;iregions[i].lastptr); - } + //for(int i=0;iregions[i].lastptr); + //} } } @@ -62,7 +62,7 @@ void pmc_init() { struct pmc_region *region=&pmc_heapptr->regions[i]; unsigned int startindex=region->lowunit; unsigned int endindex=pmc_heapptr->regions[i+1].highunit; - tprintf("Free space in partition %u from %x to %x\n", i, startptr, finishptr); + //tprintf("Free space in partition %u from %x to %x\n", i, startptr, finishptr); for(unsigned int index=startindex;indexunits[index].endptr; if ((ptr>startptr)&&(ptr<=finishptr)) { @@ -77,54 +77,63 @@ void pmc_init() { } } if (bamboo_smem_size) { - tprintf("Left over alloc space from %x to %x\n", bamboo_cur_msp, bamboo_cur_msp+bamboo_smem_size); + //tprintf("Left over alloc space from %x to %x\n", bamboo_cur_msp, bamboo_cur_msp+bamboo_smem_size); padspace(bamboo_cur_msp, bamboo_smem_size); } tmc_spin_barrier_wait(&pmc_heapptr->barrier); } void gc(struct garbagelist *gl) { - tprintf("start GC\n"); + if (BAMBOO_NUM_OF_CORE==STARTUPCORE) + tprintf("start GC\n"); pmc_init(); //mark live objects - tprintf("mark\n"); + //tprintf("mark\n"); pmc_mark(gl); //count live objects per unit tmc_spin_barrier_wait(&pmc_heapptr->barrier); - tprintf("count\n"); + //tprintf("count\n"); pmc_count(); tmc_spin_barrier_wait(&pmc_heapptr->barrier); //divide up work - tprintf("divide\n"); + //tprintf("divide\n"); if (BAMBOO_NUM_OF_CORE==STARTUPCORE) { pmc_processunits(); } tmc_spin_barrier_wait(&pmc_heapptr->barrier); //set up forwarding pointers - tprintf("forward\n"); + //tprintf("forward\n"); pmc_doforward(); tmc_spin_barrier_wait(&pmc_heapptr->barrier); //update pointers - tprintf("updaterefs\n"); + //tprintf("updaterefs\n"); pmc_doreferenceupdate(gl); tmc_spin_barrier_wait(&pmc_heapptr->barrier); //compact data - tprintf("compact\n"); + //tprintf("compact\n"); pmc_docompact(); //reset memory allocation bamboo_cur_msp=NULL; bamboo_smem_size=0; - tprintf("done\n"); + //tprintf("done\n"); + + //if (BAMBOO_NUM_OF_CORE==STARTUPCORE) { + // for(int i=0;iregions[i].lastptr; + // void *finishptr=pmc_heapptr->regions[i+1].lastptr; + // tprintf("Partition %u from %x to %x\n", i, startptr, finishptr); + // tprintf("%x %x %x %x\n", pmc_heapptr->regions[i].startptr, pmc_heapptr->regions[i].endptr, pmc_heapptr->regions[i+1].startptr, pmc_heapptr->regions[i+1].endptr); + // } + // } gcflag=false; tmc_spin_barrier_wait(&pmc_heapptr->barrier); - tprintf("exit GC\n"); + //tprintf("exit GC\n"); } void padspace(void *ptr, unsigned int length) { //zero small blocks - tprintf("Padspace from %x to %x\n", ptr, ptr+length); if (lengthTOTALNUMCLASSANDARRAY) { - tprintf("ptr=%x type=%u\n", ptr, type); - } + // if (type>TOTALNUMCLASSANDARRAY) { + // tprintf("ptr=%x type=%u\n", ptr, type); + // } if(type < NUMCLASSES) { // a normal object diff --git a/Robust/src/Runtime/bamboo/pmc_garbage.h b/Robust/src/Runtime/bamboo/pmc_garbage.h index e6c26e54..857ff23e 100644 --- a/Robust/src/Runtime/bamboo/pmc_garbage.h +++ b/Robust/src/Runtime/bamboo/pmc_garbage.h @@ -4,8 +4,8 @@ #include "pmc_queue.h" #include "structdefs.h" -//#define PMC_MINALLOC 131072 -#define PMC_MINALLOC 2048 +#define PMC_MINALLOC 131072 +//#define PMC_MINALLOC 2048 #define NUMPMCUNITS (4*NUMCORES4GC) #define UNITSIZE (BAMBOO_SHARED_MEM_SIZE/NUMPMCUNITS) diff --git a/Robust/src/Runtime/bamboo/pmc_mem.c b/Robust/src/Runtime/bamboo/pmc_mem.c index 40d7f437..1b488741 100644 --- a/Robust/src/Runtime/bamboo/pmc_mem.c +++ b/Robust/src/Runtime/bamboo/pmc_mem.c @@ -28,9 +28,11 @@ void * pmc_alloc(unsigned int * numbytesallocated, unsigned int minimumbytes) { //update unit end points for(unsigned int index=startindex;index<(endindex-1);index++) { void *ptr=pmc_unitend(index); - if ((ptr>startptr)&&(ptrstartptr)&&(ptr<=newstartptr)) { + //tprintf("Ch: %u -> %x\n", index, newstartptr); pmc_heapptr->units[index].endptr=newstartptr; } + if (ptr>newstartptr) break; } @@ -38,6 +40,7 @@ void * pmc_alloc(unsigned int * numbytesallocated, unsigned int minimumbytes) { *numbytesallocated=(unsigned int)(newstartptr-startptr); tmc_spin_mutex_unlock(®ion->lock); + return startptr; } while(0); tmc_spin_mutex_unlock(®ion->lock); diff --git a/Robust/src/Runtime/bamboo/pmc_refupdate.c b/Robust/src/Runtime/bamboo/pmc_refupdate.c index 100cb9ed..93359c46 100644 --- a/Robust/src/Runtime/bamboo/pmc_refupdate.c +++ b/Robust/src/Runtime/bamboo/pmc_refupdate.c @@ -12,13 +12,15 @@ #define pmcupdateObj(objptr) ((void *)((struct ___Object___ *)objptr)->marked) -#define PMCUPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) {obj=pmcupdateObj(updatetmpptr);if (obj==NULL) {tprintf("BAD REF UPDATE %x->%x in %u\n",updatetmpptr,obj,__LINE__);}}} +#define PMCUPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) {obj=pmcupdateObj(updatetmpptr);}} +//if (obj==NULL) {tprintf("BAD REF UPDATE %x->%x in %u\n",updatetmpptr,obj,__LINE__);}}} -#define PMCUPDATEOBJNONNULL(obj) {void *updatetmpptr=obj; obj=pmcupdateObj(updatetmpptr);if (obj==NULL) {tprintf("BAD REF UPDATE in %x->%x %u\n",updatetmpptr,obj,__LINE__);}} +#define PMCUPDATEOBJNONNULL(obj) {void *updatetmpptr=obj; obj=pmcupdateObj(updatetmpptr);} +//if (obj==NULL) {tprintf("BAD REF UPDATE in %x->%x %u\n",updatetmpptr,obj,__LINE__);}} void pmc_updatePtrs(void *ptr, int type) { unsigned int * pointer=pointerarray[type]; - tprintf("Updating pointers in %x\n", ptr); + //tprintf("Updating pointers in %x\n", ptr); if (pointer==0) { /* Array of primitives */ } else if (((unsigned int)pointer)==1) { @@ -36,7 +38,7 @@ void pmc_updatePtrs(void *ptr, int type) { PMCUPDATEOBJ(*((void **)(((char *)ptr)+offset))); } } - tprintf("done\n"); + //tprintf("done\n"); } void pmc_updategarbagelist(struct garbagelist *listptr) { @@ -149,7 +151,7 @@ void pmc_doreferenceupdate(struct garbagelist *stackptr) { void pmc_referenceupdate(void *bottomptr, void *topptr) { void *tmpptr=bottomptr; - tprintf("%x -- %x\n", bottomptr, topptr); + //tprintf("%x -- %x\n", bottomptr, topptr); while(tmpptr