From: bdemsky Date: Sun, 19 Jun 2011 22:42:22 +0000 (+0000) Subject: more changes X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=0bcb641d48f33dcfb888c86ef772864739ef613f;p=IRC.git more changes --- diff --git a/Robust/src/Runtime/bamboo/multicoregarbage.c b/Robust/src/Runtime/bamboo/multicoregarbage.c index 667e7ec5..5478e09e 100644 --- a/Robust/src/Runtime/bamboo/multicoregarbage.c +++ b/Robust/src/Runtime/bamboo/multicoregarbage.c @@ -103,6 +103,16 @@ void initmulticoregcdata() { gccachestage = false; #endif + if(STARTUPCORE == BAMBOO_NUM_OF_CORE) { + allocationinfo.blocktable=RUNMALLOC(sizeof(struct blockrecord)*GCNUMBLOCK); + for(int i=0; i=gcbaseva)&&(((unsigned int)p)<(gcbaseva+(BAMBOO_SHARED_MEM_SIZE)))) +/* Total number of blocks in heap */ -#define MAXBLOCK 0x4fffffff //local block number that can never be reached... +#define GCNUMBLOCK (NUMCORES4GC+(BAMBOO_SHARED_MEM_SIZE-BAMBOO_LARGE_SMEM_BOUND)/BAMBOO_SMEM_SIZE) +/* This macro waits for the given gc phase */ +#define WAITFORGCPHASE(phase) while(gc_status_info.gcphase != phase) ; -/* Number of bits used for each alignment unit */ +/* Local block number that can never be reached...*/ +#define MAXBLOCK 0x4fffffff //Takes in pointer to heap object and converts to offset in alignment units #define OBJMAPPINGINDEX(p) ALIGNOBJSIZE((unsigned INTPTR)(p-gcbaseva)) @@ -145,7 +167,7 @@ unsigned int size_cachepolicytbl; } \ } -#define RESIDECORE(p, c) { \ +#define RESIDECORE(c, p) { \ if(1 == (NUMCORES4GC)) { \ c = 0; \ } else { \ @@ -157,8 +179,8 @@ unsigned int size_cachepolicytbl; INLINE static unsigned int hostcore(void * ptr) { // check the host core of ptr - unsigned int host = 0; - RESIDECORE(ptr, host); + unsigned int host; + RESIDECORE(host, ptr); return host; } diff --git a/Robust/src/Runtime/bamboo/multicoregccompact.c b/Robust/src/Runtime/bamboo/multicoregccompact.c index 8d9e62e5..bc583924 100644 --- a/Robust/src/Runtime/bamboo/multicoregccompact.c +++ b/Robust/src/Runtime/bamboo/multicoregccompact.c @@ -46,7 +46,7 @@ void getSpaceRemotely(struct moveHelper *to, unsigned int minimumbytes) { //set flag to wait for memory gctomove=false; //send request for memory - send_msg_4(STARTUPCORE,GCFINISHCOMPACT,BAMBOO_NUM_OF_CORE, to->ptr, minimumbytes); + send_msg_3(STARTUPCORE,GCFINISHCOMPACT,BAMBOO_NUM_OF_CORE, minimumbytes); //wait for flag to be set that we received message while(!gctomove) ; @@ -71,7 +71,15 @@ void getSpace(struct moveHelper *to, unsigned int minimumbytes) { } void compacthelper(struct moveHelper * orig,struct moveHelper * to) { + bool senttopmessage=false; while(true) { + if ((gcheaptop < ((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+gcheaptop); + //Only send the message once + senttopmessage=true; + } + unsigned int minimumbytes=compactblocks(orig, to); if (orig->ptr==orig->bound) { //need more data to compact @@ -87,8 +95,8 @@ void compacthelper(struct moveHelper * orig,struct moveHelper * to) { getSpace(to, minimumbytes); } } - - send_msg_4(STARTUPCORE,GCFINISHCOMPACT,BAMBOO_NUM_OF_CORE, to->ptr, 0); + + send_msg_3(STARTUPCORE,GCFINISHCOMPACT,BAMBOO_NUM_OF_CORE, 0); } /* Should be invoked with interrupt turned off. */ @@ -131,7 +139,8 @@ bool gcfindSpareMem(unsigned int requiredmem,unsigned int requiredcore) { /* This function is performance critical... spend more time optimizing it */ unsigned int compactblocks(struct moveHelper * orig, struct moveHelper * to) { - void *toptr=to->ptr; + void *toptrinit=to->ptr; + void *toptr=toptr; void *tobound=to->bound; void *origptr=orig->ptr; void *origbound=orig->bound; @@ -150,6 +159,7 @@ unsigned int compactblocks(struct moveHelper * orig, struct moveHelper * to) { origptr=origbound; to->ptr=toptr; orig->ptr=origptr; + gcheaptop-=(unsigned INTPTR)(toptr-toptrinit) return 0; } } while(!gcmarktbl[arrayoffset]); @@ -163,8 +173,8 @@ unsigned int compactblocks(struct moveHelper * orig, struct moveHelper * to) { unsigned int length=ALIGNSIZETOBYTES(objlength); void *endtoptr=toptr+length; if (endtoptr>tobound) { - toptr=tobound; - to->ptr=toptr; + gcheaptop-=(unsigned INTPTR)(toptr-toptrinit) + to->ptr=tobound; orig->ptr=origptr; return length; } diff --git a/Robust/src/Runtime/bamboo/multicoregcmark.c b/Robust/src/Runtime/bamboo/multicoregcmark.c index df1a692a..9d4d136e 100644 --- a/Robust/src/Runtime/bamboo/multicoregcmark.c +++ b/Robust/src/Runtime/bamboo/multicoregcmark.c @@ -266,7 +266,7 @@ void mark(bool isfirst, struct garbagelist * stackptr) { unsigned int type = 0; bool islarge=isLarge(ptr, &type, &size); unsigned int iunits = ALIGNUNITS(size); - + setLengthMarked(ptr,iunits); if(islarge) { diff --git a/Robust/src/Runtime/bamboo/multicoregcprofile.h b/Robust/src/Runtime/bamboo/multicoregcprofile.h index b2cbdf9d..9b6c906e 100644 --- a/Robust/src/Runtime/bamboo/multicoregcprofile.h +++ b/Robust/src/Runtime/bamboo/multicoregcprofile.h @@ -112,7 +112,7 @@ INLINE static void gc_profileEnd(void) { { \ if(gc_profile_flag) { \ gc_num_livespace = 0; \ - for(int tmpi = 0; tmpi < gcnumblock; tmpi++) { \ + for(int tmpi = 0; tmpi < GCNUMBLOCK; tmpi++) { \ gc_num_livespace += bamboo_smemtbl[tmpi]; \ } \ gc_num_freespace = (BAMBOO_SHARED_MEM_SIZE) - gc_num_livespace; \ @@ -152,7 +152,7 @@ INLINE static void gc_profileEnd(void) { #define GCPROFILE_RECORD_SPACE() \ { \ gc_num_livespace = 0; \ - for(int tmpi = 0; tmpi < gcnumblock; tmpi++) { \ + for(int tmpi = 0; tmpi < GCNUMBLOCK; tmpi++) { \ gc_num_livespace += bamboo_smemtbl[tmpi]; \ } \ gc_num_freespace = (BAMBOO_SHARED_MEM_SIZE) - gc_num_livespace; \ diff --git a/Robust/src/Runtime/bamboo/multicoremem.c b/Robust/src/Runtime/bamboo/multicoremem.c index 86590cba..7deab55c 100644 --- a/Robust/src/Runtime/bamboo/multicoremem.c +++ b/Robust/src/Runtime/bamboo/multicoremem.c @@ -75,7 +75,7 @@ void * fixedmalloc_I(int coren, continue; } tofindb=totest=gc_core2block[2*core2test[gccorenum][k]]; - mem=searchBlock4Mem(&tofindb,&totest,core2test[gccorenum][k],isize,allocsize,(k==0)?0:((gcnumblock/NUMCORES4GC)>>LOCALMEMRESERVATION)); + mem=searchBlock4Mem(&tofindb,&totest,core2test[gccorenum][k],isize,allocsize,(k==0)?0:((GCNUMBLOCK/NUMCORES4GC)>>LOCALMEMRESERVATION)); if(mem!=NULL) { return mem; } @@ -107,7 +107,7 @@ void * mixedmalloc_I(int coren, continue; } tofindb=totest=gc_core2block[2*core2test[gccorenum][k]]; - mem=searchBlock4Mem(&tofindb,&totest,core2test[gccorenum][k],isize,allocsize,(k==0)?0:((gcnumblock/NUMCORES4GC)>>LOCALMEMRESERVATION)); + mem=searchBlock4Mem(&tofindb,&totest,core2test[gccorenum][k],isize,allocsize,(k==0)?0:((GCNUMBLOCK/NUMCORES4GC)>>LOCALMEMRESERVATION)); if(mem!=NULL) { return mem; } diff --git a/Robust/src/Runtime/bamboo/multicoremsg.c b/Robust/src/Runtime/bamboo/multicoremsg.c index 7e17de1f..c1520c89 100644 --- a/Robust/src/Runtime/bamboo/multicoremsg.c +++ b/Robust/src/Runtime/bamboo/multicoremsg.c @@ -36,7 +36,8 @@ int msgsizearray[] = { 4, //GCFINISHPRE, // 0xE7 2, //GCFINISHINIT, // 0xE8 4, //GCFINISHMARK, // 0xE9 - 4, //GCFINISHCOMPACT, // 0xEa + 3, //GCFINISHCOMPACT, // 0xEa + 3, //GCRETURNMEM, 2, //GCFINISHUPDATE, // 0xEb 1, //GCFINISH, // 0xEc 1, //GCMARKCONFIRM, // 0xEd @@ -495,14 +496,25 @@ INLINE void processmsg_gcfinishmark_I() { gcnumreceiveobjs[entry_index][data1] = data3; } } + +void processmsg_returnmem_I() { + unsigned int cnum = msgdata[msgdataindex]; + MSG_INDEXINC_I(); + void * heaptop = (void *) msgdata[msgdataindex]; + MSG_INDEXINC_I(); + unsigned int blockindex; + BLOCKINDEX(blockindex, heaptop); + struct blockrecord * blockrecord=&allocationinfo.blocktable[blockindex]; + if (cnum==blockrecord) { + //this is our own memory...need to clear our lower blocks + } +} INLINE void processmsg_gcfinishcompact_I() { BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE); int cnum = msgdata[msgdataindex]; MSG_INDEXINC_I(); - void * heaptop = (void *) msgdata[msgdataindex]; - MSG_INDEXINC_I(); unsigned int bytesneeded = msgdata[msgdataindex]; MSG_INDEXINC_I(); @@ -881,6 +893,11 @@ processmsg: break; } + case GCRETURNMEM: { + processmsg_returnmem_I(); + break; + } + case GCFINISHCOMPACT: { // received a compact phase finish msg processmsg_gcfinishcompact_I(); diff --git a/Robust/src/Runtime/bamboo/multicoremsg.h b/Robust/src/Runtime/bamboo/multicoremsg.h index ea702bd7..b18708a7 100644 --- a/Robust/src/Runtime/bamboo/multicoremsg.h +++ b/Robust/src/Runtime/bamboo/multicoremsg.h @@ -180,6 +180,7 @@ typedef enum { GCFINISHINIT, // 0xE8 GCFINISHMARK, // 0xE9 GCFINISHCOMPACT, // 0xEa + GCRETURNMEM, GCFINISHUPDATE, // 0xEb GCFINISH, // 0xEc GCMARKCONFIRM, // 0xEd diff --git a/Robust/src/Runtime/mem.c b/Robust/src/Runtime/mem.c index 0ab608f1..972b96c1 100644 --- a/Robust/src/Runtime/mem.c +++ b/Robust/src/Runtime/mem.c @@ -50,29 +50,16 @@ void * mycalloc_share(int size) { } #endif -void * mycalloc(int size, - char * file, - int line) { - void * p = NULL; - int isize = size; +void * mycalloc(int size, char * file, int line) { BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); - p = BAMBOO_LOCAL_MEM_CALLOC(isize); - - if(p == NULL) { - printf("mycalloc %s %d \n", file, line); - BAMBOO_EXIT(); - } + void * p = mycalloc_i(size, file, line); BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); return p; } -void * mycalloc_i(int size, - char * file, - int line) { - void * p = NULL; - int isize = size; - p = BAMBOO_LOCAL_MEM_CALLOC(isize); +void * mycalloc_i(int size, char * file, int line) { + void * p = BAMBOO_LOCAL_MEM_CALLOC(size); if(p == NULL) { tprintf("mycalloc_i %s %d \n", file, line); BAMBOO_EXIT();