From 874ae9465e013729aac27827e1542dec7520547c Mon Sep 17 00:00:00 2001 From: bdemsky Date: Sat, 2 Jul 2011 00:29:12 +0000 Subject: [PATCH] lots of bug fixes...none of them the right one --- Robust/src/Runtime/bamboo/multicoregarbage.c | 8 ++++++- Robust/src/Runtime/bamboo/multicoregarbage.h | 2 ++ .../src/Runtime/bamboo/multicoregccompact.c | 8 ++++++- Robust/src/Runtime/bamboo/multicoregcflush.c | 22 ++++++++----------- Robust/src/Runtime/bamboo/multicoregcmark.c | 2 +- Robust/src/Runtime/bamboo/multicoremem.c | 11 +++++----- Robust/src/Runtime/bamboo/multicoremem.h | 2 +- .../src/Runtime/bamboo/multicoremem_helper.c | 3 +++ Robust/src/Runtime/bamboo/multicoremsg.c | 7 ------ Robust/src/Runtime/bamboo/multicoreruntime.c | 1 - 10 files changed, 36 insertions(+), 30 deletions(-) diff --git a/Robust/src/Runtime/bamboo/multicoregarbage.c b/Robust/src/Runtime/bamboo/multicoregarbage.c index c161539d..ef73a360 100644 --- a/Robust/src/Runtime/bamboo/multicoregarbage.c +++ b/Robust/src/Runtime/bamboo/multicoregarbage.c @@ -417,7 +417,7 @@ void master_finish() { } void gc_master(struct garbagelist * stackptr) { - tprintf("start GC!\n"); + //tprintf("start GC!\n"); gc_status_info.gcprocessing = true; gc_status_info.gcphase = INITPHASE; @@ -449,6 +449,12 @@ void gc_master(struct garbagelist * stackptr) { CACHEADAPT_PHASE_MASTER(); //tprintf("finish cachdapt phase\n"); // do finish up stuff +#ifdef GC_DEBUG + for(int i=0;iusedspace, record->freespace, record->corenum, record->status, gcbaseva+OFFSET2BASEVA(i), (gcbaseva+OFFSET2BASEVA(i)+record->usedspace)); + } +#endif master_finish(); //tprintf("finish GC ! %d \n",gcflag); diff --git a/Robust/src/Runtime/bamboo/multicoregarbage.h b/Robust/src/Runtime/bamboo/multicoregarbage.h index 6218cb0c..aac5bebd 100644 --- a/Robust/src/Runtime/bamboo/multicoregarbage.h +++ b/Robust/src/Runtime/bamboo/multicoregarbage.h @@ -182,6 +182,8 @@ unsigned int size_cachepolicytbl; #define MINMEMORYCHUNKSIZE 32768 +#define ISVALIDPTR(x) ((((unsigned INTPTR)x)>=((unsigned INTPTR)gcbaseva))&&(((unsigned INTPTR)x)<((unsigned INTPTR)(gcbaseva+BAMBOO_SHARED_MEM_SIZE)))) + /* This macro waits for the given gc phase */ #define WAITFORGCPHASE(phase) while(gc_status_info.gcphase != phase) ; diff --git a/Robust/src/Runtime/bamboo/multicoregccompact.c b/Robust/src/Runtime/bamboo/multicoregccompact.c index 8cda2b36..18e3bf8f 100644 --- a/Robust/src/Runtime/bamboo/multicoregccompact.c +++ b/Robust/src/Runtime/bamboo/multicoregccompact.c @@ -5,6 +5,7 @@ #include "multicoregarbage.h" #include "markbit.h" #include "multicoremem_helper.h" +#include "gcqueue.h" int gc_countRunningCores() { int count=0; @@ -58,6 +59,7 @@ void handleReturnMem_I(unsigned int cnum, void *heaptop) { } /* 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(;nextlocalblocknumptr==orig->bound) { //need more data to compact //increment the core @@ -272,6 +275,10 @@ void handleOneMemoryRequest(int core, unsigned int lowestblock) { if (block->status==BS_FREE) { if(firstfree==NOFREEBLOCK) firstfree=searchblock; + //don't take a block from another core that hasn't returned its memory yet + if (block->corenum!=core&&returnedmem[block->corenum]) + continue; + unsigned INTPTR freespace=block->freespace&~BAMBOO_CACHE_LINE_MASK; if (freespace>=memcheck) { //TODO: should check memory block at same level on our own core...if that works, use it to preserve locality @@ -427,7 +434,6 @@ void compact() { initOrig_Dst(&orig, &to); CACHEADAPT_SAMPLING_DATA_REVISE_INIT(&orig, &to); - compacthelper(&orig, &to); } diff --git a/Robust/src/Runtime/bamboo/multicoregcflush.c b/Robust/src/Runtime/bamboo/multicoregcflush.c index df4a978e..cd336e73 100644 --- a/Robust/src/Runtime/bamboo/multicoregcflush.c +++ b/Robust/src/Runtime/bamboo/multicoregcflush.c @@ -27,12 +27,9 @@ extern struct lockvector bamboo_threadlocks; // NOTE: the objptr should not be NULL and should not be non shared ptr #define updateObj(objptr) gcmappingtbl[OBJMAPPINGINDEX(objptr)] //#define UPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) obj=updateObj(updatetmpptr);if (obj %x, mark=%u, line=%u\n", updatetmpptr, obj, getMarkedLength(updatetmpptr),__LINE__);}} -//if (obj==NULL) tprintf("Mapping problem for object %x, mark=%u, line=%u\n", updatetmpptr, getMarkedLength(updatetmpptr),__LINE__);}} - -#define UPDATEOBJNONNULL(obj) {void *updatetmpptr=obj; obj=updateObj(updatetmpptr);} -//if (updatetmpptr!=NULL&&obj==NULL) tprintf("Mapping parameter for object %x, mark=%u, line=%u\n", updatetmpptr, getMarkedLength(updatetmpptr),__LINE__);} +#define UPDATEOBJNONNULL(obj) {void *updatetmpptr=obj; obj=updateObj(updatetmpptr); if (!ISVALIDPTR(obj)) tprintf("Mapping parameter for object %x -> %x, mark=%u, line=%u\n", updatetmpptr, obj, getMarkedLength(updatetmpptr),__LINE__);} INLINE void updategarbagelist(struct garbagelist *listptr) { for(;listptr!=NULL; listptr=listptr->next) { @@ -206,20 +203,20 @@ void * updateblocks(struct moveHelper * orig, struct moveHelper * to) { //Scan more carefully next objlength=getMarkedLength(origptr); - void *dstptr=gcmappingtbl[OBJMAPPINGINDEX(origptr)]; if (objlength!=NOTMARKED) { + void *dstptr=gcmappingtbl[OBJMAPPINGINDEX(origptr)]; unsigned int length=ALIGNSIZETOBYTES(objlength); void *endtoptr=dstptr+length; - if (endtoptr>tobound||endtoptrtobound||dstptrptr=origptr; return dstptr; } /* Move the object */ - if(origptr <= endtoptr) { + if(origptr >= endtoptr||dstptr >= origptr+length) { memmove(dstptr, origptr, length); } else if (origptr!=dstptr) { //no need to copy if the source & dest are equal.... @@ -227,19 +224,20 @@ void * updateblocks(struct moveHelper * orig, struct moveHelper * to) { } //tprintf("Moving object %x to %x with length %u\n", origptr, dstptr, length); - + /* Update the pointers in the object */ updatePtrsInObj(dstptr); - /* Clear the mark */ clearMark(origptr); - + //good to move objects and update pointers origptr+=length; } else origptr+=ALIGNMENTSIZE; } + orig->ptr=origptr; + return NULL; } void updateOrigPtr(void *currtop) { @@ -289,11 +287,9 @@ void updatehelper(struct moveHelper * orig,struct moveHelper * to) { //increment the core orig->localblocknum++; BASEPTR(orig->base,BAMBOO_NUM_OF_CORE, orig->localblocknum); - update_origblockptr=orig->base; orig->ptr=orig->base; orig->bound = orig->base + BLOCKSIZE(orig->localblocknum); if (orig->base >= gcbaseva+BAMBOO_SHARED_MEM_SIZE) { - //free our entire memory for others to use break; } } diff --git a/Robust/src/Runtime/bamboo/multicoregcmark.c b/Robust/src/Runtime/bamboo/multicoregcmark.c index b3407676..52694174 100644 --- a/Robust/src/Runtime/bamboo/multicoregcmark.c +++ b/Robust/src/Runtime/bamboo/multicoregcmark.c @@ -268,7 +268,7 @@ void mark(struct garbagelist * stackptr) { #endif if(islarge) { // ptr is a large object and not marked or enqueued - printf("NEED TO SUPPORT LARGE OBJECTS!\n"); + printf("NEED TO SUPPORT LARGE OBJECTS: ptr=%x type=%u size=%u!\n", ptr, type, size); } else { // ptr is an unmarked active object on this core unsigned int isize=iunits<=GCNUMBLOCK) + return NULL; struct blockrecord * block=&allocationinfo.blocktable[searchblock]; if (block->status==BS_FREE) { unsigned INTPTR freespace=block->freespace&~BAMBOO_CACHE_LINE_MASK; @@ -45,16 +47,17 @@ void * fixedmalloc_I(int coren, return mem; //failed try neighbors...in a round robin fashion - for(block_t lblock=0;lblock=GCNUMBLOCK) + return NULL; struct blockrecord * block=&allocationinfo.blocktable[globalblockindex]; if (block->status==BS_FREE) { unsigned INTPTR freespace=block->freespace&~BAMBOO_CACHE_LINE_MASK; - if (memcheck<=freespace) { + if (freespace>=memcheck) { //we have a block //mark block as used block->status=BS_USED; @@ -67,7 +70,6 @@ void * fixedmalloc_I(int coren, } } } - //no memory return NULL; } @@ -96,7 +98,6 @@ 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/multicoremem.h b/Robust/src/Runtime/bamboo/multicoremem.h index a307c24d..010c9e89 100644 --- a/Robust/src/Runtime/bamboo/multicoremem.h +++ b/Robust/src/Runtime/bamboo/multicoremem.h @@ -33,7 +33,7 @@ #ifdef GC_DEBUG #include "structdefs.h" -#define BAMBOO_NUM_BLOCKS (NUMCORES4GC*(2+1)+3) +#define BAMBOO_NUM_BLOCKS (NUMCORES4GC*(2+3)) #define BAMBOO_PAGE_SIZE (64 * 64) #define BAMBOO_SMEM_SIZE ((unsigned int)(BAMBOO_PAGE_SIZE)) #define BAMBOO_SHARED_MEM_SIZE ((unsigned int)((BAMBOO_SMEM_SIZE) *(BAMBOO_NUM_BLOCKS))) diff --git a/Robust/src/Runtime/bamboo/multicoremem_helper.c b/Robust/src/Runtime/bamboo/multicoremem_helper.c index 3f290757..16bc13b2 100644 --- a/Robust/src/Runtime/bamboo/multicoremem_helper.c +++ b/Robust/src/Runtime/bamboo/multicoremem_helper.c @@ -12,6 +12,9 @@ void buildCore2Test() { int index=0; for(int x=xcoord-1;x<=(xcoord+1);x++) { for(int y=ycoord-1;y<=(ycoord+1);y++) { + if (x==xcoord&&y==ycoord) + continue; + if ((x<0||x>7)||(y<0||y>7)) { //bad coordinate core2test[i][index]=-1; diff --git a/Robust/src/Runtime/bamboo/multicoremsg.c b/Robust/src/Runtime/bamboo/multicoremsg.c index 6fa4c224..8deb797b 100644 --- a/Robust/src/Runtime/bamboo/multicoremsg.c +++ b/Robust/src/Runtime/bamboo/multicoremsg.c @@ -413,13 +413,6 @@ void processmsg_memresponse_I() { void processmsg_gcstartpre_I() { // the first time to be informed to start gc gcflag = true; - // Zero out the remaining memory here because for the GC_CACHE_ADAPT - // version, we need to make sure during the gcinit phase the shared heap - // is not touched. Otherwise, there would be problem when adapt the cache - // strategy. - bamboo_smem_size = 0; - bamboo_cur_msp = NULL; - smemflag = true; } void processmsg_gcstartinit_I() { diff --git a/Robust/src/Runtime/bamboo/multicoreruntime.c b/Robust/src/Runtime/bamboo/multicoreruntime.c index 1ed250e8..8f4a025c 100644 --- a/Robust/src/Runtime/bamboo/multicoreruntime.c +++ b/Robust/src/Runtime/bamboo/multicoreruntime.c @@ -758,7 +758,6 @@ inline void run(int argc, char** argv) { // initialize runtime data structures initruntimedata(); initCommunication(); - if (BAMBOO_NUM_OF_CORE==STARTUPCORE) { numconfirm=NUMCORES-1; for(int i=0;i