From: bdemsky Date: Wed, 6 Jul 2011 10:16:18 +0000 (+0000) Subject: code to compute unit boundaries and allocation function X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ae4cfa63fd9727f22cd89285caeef22f4101f818;p=IRC.git code to compute unit boundaries and allocation function --- diff --git a/Robust/src/Runtime/bamboo/pmc_forward.c b/Robust/src/Runtime/bamboo/pmc_forward.c index a7d14fcc..bb5bd7e2 100644 --- a/Robust/src/Runtime/bamboo/pmc_forward.c +++ b/Robust/src/Runtime/bamboo/pmc_forward.c @@ -76,8 +76,10 @@ void pmc_doforward() { return; if (endregion==-1) endregion=NUMPMCUNITS; - region->startptr=(i==0)?gcbaseva:pmc_heapptr->units[i-1].endptr; - region->endptr=pmc_heapptr->units[i].endptr; + region->lowunit=startregion; + region->highunit=endregion; + region->startptr=(startregion==0)?gcbaseva:pmc_heapptr->units[startregion-1].endptr; + region->endptr=pmc_heapptr->units[endregion].endptr; if (BAMBOO_NUM_OF_CORE&1) { //backward direction @@ -95,6 +97,26 @@ void pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *botto void *tmpptr=bottomptr; void *forwardptr=fwddirection?bottomptr:(topptr-totalbytes); struct ___Object___ *lastobj=NULL; + unsigned int currunit=region->lowunit; + void *endunit=pmc_unitend(currunit); + + if (!fwddirection) { + //reset boundaries of beginning units + while(endunitunits[currunit].endptr=endunit; + currunit++; + endunit=pmc_unitend(currunit); + } + } else { + //reset boundaries of end units + unsigned int lastunit=region->highunit-1; + void * lastunitend=pmc_unitend(lastunit); + while(lastunitend>forwardptr) { + pmc_heapptr->units[currunit].endptr=lastunitend; + lastunit--; + lastunitend=pmc_unitend(lastunit); + } + } while(tmpptr>topptr) { unsigned int type; @@ -108,7 +130,14 @@ void pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *botto if (((struct ___Object___ *)tmpptr)->mark) { ((struct ___Object___ *)tmpptr)->mark=forwardptr; - forwardptr+=size; + void *newforwardptr=forwardptr+size; + while(newforwardptr>endunit) { + pmc_heapptr->region[currunit].endptr=newforwardptr; + currunit++; + endunit=pmc_unitend(currunit); + } + + forwardptr=newforwardptr; if (lastobj&&!fwddirection) { tmpptr->backward=lastobj; lastobj=(struct ___Object___ *)tmpptr; diff --git a/Robust/src/Runtime/bamboo/pmc_garbage.c b/Robust/src/Runtime/bamboo/pmc_garbage.c index 4d0d7472..0b8301a9 100644 --- a/Robust/src/Runtime/bamboo/pmc_garbage.c +++ b/Robust/src/Runtime/bamboo/pmc_garbage.c @@ -14,10 +14,17 @@ void decrementthreads() { tmc_spin_mutex_unlock(&pmc_heapptr->lock); } +void * pmc_unitend(unsigned int index) { + return gcbaseva+(index+1)*NUMPMCUNITS; +} + void pmc_onceInit() { pmc_localqueue=&pmc_heapptr->regions[BAMBOO_NUM_OF_THREADS].markqueue; pmc_queueinit(pmc_localqueue); tmc_spin_barrier_init(&pmc_heapptr->barrier, NUMCORES4GC); + for(int i=0;iunits[i].endptr=pmc_unitend(i); + } } void pmc_init() { diff --git a/Robust/src/Runtime/bamboo/pmc_garbage.h b/Robust/src/Runtime/bamboo/pmc_garbage.h index 2be0312e..9f565252 100644 --- a/Robust/src/Runtime/bamboo/pmc_garbage.h +++ b/Robust/src/Runtime/bamboo/pmc_garbage.h @@ -2,6 +2,7 @@ #define PMC_GARBAGE_H #include +#define PMC_MINALLOC 131072 #define NUMPMCUNITS (4*NUMCORES4GC) #define UNITSIZE (BAMBOO_SHARED_MEM_SIZE/NUMPMCUNITS) @@ -17,6 +18,8 @@ struct pmc_region { void * lastptr; void * startptr; void * endptr; + unsigned int lowunit; + unsigned int highunit; tmc_spin_mutex_t lock; struct ___Object___ * lastobj; struct pmc_queue markqueue; @@ -32,6 +35,7 @@ struct pmc_heap { extern struct pmc_heap * pmc_heapptr; extern struct pmc_queue * pmc_localqueue; +void * pmc_unitend(unsigned int index); void incrementthreads(); void decrementthreads(); void pmc_onceInit(); diff --git a/Robust/src/Runtime/bamboo/pmc_mem.c b/Robust/src/Runtime/bamboo/pmc_mem.c index e69de29b..a939bf30 100644 --- a/Robust/src/Runtime/bamboo/pmc_mem.c +++ b/Robust/src/Runtime/bamboo/pmc_mem.c @@ -0,0 +1,41 @@ +#include "pmc_mem.h" + +void * pmc_alloc(unsigned int * numbytesallocated, unsigned int minimumbytes) { + unsigned int memcheck=minimumbytes>PMC_MINALLOC?minimumbytes:PMC_MINALLOC; + + for(int i=0;iregions[i].lastptr; + void *finishptr=pmc_heapptr->regions[i+1].lastptr; + + if ((finishptr-startptr)>memcheck) { + struct pmc_region *region=&pmc_heapptr->regions[i]; + tmc_spin_mutex_lock(®ion->lock); + startptr=region->lastptr; + do { + //double check that we have the space + if ((finishptr-startptr)lowunit; + unsigned int endindex=pmc_heapptr->regions[i+1]->highunit; + void * newstartptr=startptr+memcheck; + + //update unit end points + for(unsigned int index=startindex;indexstartptr)&&(ptrunits[index].endptr=newstartptr; + } + if (ptr>newstartptr) + break; + } + region->lastptr=newstartptr; + + *numbytesallocated=(unsigned int)(newstartptr-startptr); + tmc_spin_mutex_unlock(®ion->lock); + return startptr; + } while(0); + tmc_spin_mutex_unlock(®ion->lock); + } + } + return NULL; +} diff --git a/Robust/src/Runtime/bamboo/pmc_mem.h b/Robust/src/Runtime/bamboo/pmc_mem.h index caad0d0b..3f1fbb3e 100644 --- a/Robust/src/Runtime/bamboo/pmc_mem.h +++ b/Robust/src/Runtime/bamboo/pmc_mem.h @@ -1,14 +1,6 @@ #ifndef PMC_MEM_H #define PMC_MEM_H -void * pmc_alloc(unsigned int * numbytesallocated, unsigned int minimumbytes) { - for(int i=0;iregions[i].lastptr; - void *finishptr=pmc_heapptr->regions[i+1].lastptr; - if ((finishptr-startptr)>minimumbytes) { - - } - } -} +void * pmc_alloc(unsigned int * numbytesallocated, unsigned int minimumbytes); #endif