From 2610d3f0e73dbfed8e9e57bf41e6ea1f8c60137b Mon Sep 17 00:00:00 2001 From: jzhou Date: Mon, 21 Jun 2010 21:37:28 +0000 Subject: [PATCH] Capture the version with mapinfo phase --- Robust/src/Runtime/multicoregarbage.c | 226 ++++++++++++++++++++------ Robust/src/Runtime/multicoregarbage.h | 37 ++++- Robust/src/Runtime/multicoreruntime.h | 36 ++-- Robust/src/Runtime/multicoretask.c | 188 +++++++++++++++++++-- 4 files changed, 400 insertions(+), 87 deletions(-) diff --git a/Robust/src/Runtime/multicoregarbage.c b/Robust/src/Runtime/multicoregarbage.c index aa9a52b4..854bb3f1 100644 --- a/Robust/src/Runtime/multicoregarbage.c +++ b/Robust/src/Runtime/multicoregarbage.c @@ -582,7 +582,7 @@ inline void initGC() { gcrequiredmems[i] = 0; gcfilledblocks[i] = 0; gcstopblock[i] = 0; - } // for(i = 0; i < NUMCORES4GC; ++i) + } // for(i = 0; i < NUMCORES4GC; ++i) for(i = NUMCORES4GC; i < NUMCORESACTIVE; ++i) { gccorestatus[i] = 1; gcnumsendobjs[i] = 0; @@ -591,13 +591,13 @@ inline void initGC() { gcheaptop = 0; gctopcore = 0; gctopblock = 0; - } // if(STARTUPCORE == BAMBOO_NUM_OF_CORE) + } // if(STARTUPCORE == BAMBOO_NUM_OF_CORE) gcself_numsendobjs = 0; gcself_numreceiveobjs = 0; gcmarkedptrbound = 0; gcobj2map = 0; gcmappedobj = 0; - gcismapped = false; + //gcismapped = false; gcnumlobjs = 0; gcmovestartaddr = 0; gctomove = false; @@ -636,6 +636,11 @@ inline void initGC() { freeMGCHash(gcforwardobjtbl); gcforwardobjtbl = allocateMGCHash(20, 3); + // initialize the mapping info related structures + freeRuntimeHash(gcrcoretbl); + gcrcoretbl = allocateRuntimeHash(20); + BAMBOO_MEMSET_WH(gcmappingtbl, 0, + sizeof(void *)*NUMCORESACTIVE*NUM_MAPPING); #ifdef GC_PROFILE // TODO num_mapinforequest = 0; @@ -880,8 +885,8 @@ inline void moveLObjs() { tmpheaptop = gcbaseva; } else { tmpheaptop = gcbaseva+bamboo_smemtbl[i]+((iptr = tmpheaptop; //MGCHashadd_I(gcpointertbl, ptr, tmpheaptop); BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); //} @@ -1054,6 +1062,9 @@ inline void moveLObjs() { BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); //mgchashInsert_I(ptr, tmpheaptop); RuntimeHashadd_I(gcpointertbl, ptr, tmpheaptop); + //struct nodemappinginfo * nodeinfo = NULL; + //RuntimeHashget(gcpointertbl, ptr, &nodeinfo); + //nodeinfo->ptr = tmpheaptop; //MGCHashadd_I(gcpointertbl, ptr, tmpheaptop); BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); //} @@ -1127,7 +1138,13 @@ inline void markObj(void * objptr) { // set the flag as DISCOVERED ((int *)objptr)[6] = DISCOVERED; gc_enqueue_I(objptr); - } + // insert the obj and request core info into mapping hashtable + /*struct nodemappinginfo * nodeinfo = + (struct nodemappinginfo *)RUNMALLOC_I(sizeof(struct nodemappinginfo)); + nodeinfo->ptr = NULL; + nodeinfo->cores = NULL; + RuntimeHashadd_I(gcpointertbl, (int)objptr, (int)nodeinfo);*/ + } BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); } else { #ifdef DEBUG @@ -1138,13 +1155,15 @@ inline void markObj(void * objptr) { // check if this obj has been forwarded if(!MGCHashcontains(gcforwardobjtbl, (int)objptr)) { #ifdef GC_PROFILE - unsigned long long ttime = BAMBOO_GET_EXE_TIME(); + // TODO unsigned long long ttime = BAMBOO_GET_EXE_TIME(); #endif // send a msg to host informing that objptr is active - send_msg_2(host, GCMARKEDOBJ, objptr, false); + send_msg_3(host, GCMARKEDOBJ, objptr, BAMBOO_NUM_OF_CORE, false); #ifdef GC_PROFILE + // TODO + /* marktime += BAMBOO_GET_EXE_TIME() - ttime; - num_markrequest++; + num_markrequest++;*/ #endif gcself_numsendobjs++; MGCHashadd(gcforwardobjtbl, (int)objptr); @@ -1356,24 +1375,24 @@ inline void mark(bool isfirst, // ptr is not an active obj or has been marked checkfield = false; } // if(isLarge(ptr, &type, &size)) else ... - } /* can never reach here - else { - #ifdef DEBUG - if(BAMBOO_NUM_OF_CORE == 0) { - BAMBOO_DEBUGPRINT(0xbbbb); - BAMBOO_DEBUGPRINT_REG(host); - BAMBOO_DEBUGPRINT_REG(ptr); - } - #endif - // check if this obj has been forwarded - if(!MGCHashcontains(gcforwardobjtbl, (int)ptr)) { - // send a msg to host informing that ptr is active - send_msg_2(host, GCMARKEDOBJ, ptr); - gcself_numsendobjs++; - MGCHashadd(gcforwardobjtbl, (int)ptr); - } - checkfield = false; - }// if(isLocal(ptr)) else ...*/ + } /* can never reach here + else { +#ifdef DEBUG + if(BAMBOO_NUM_OF_CORE == 0) { + BAMBOO_DEBUGPRINT(0xbbbb); + BAMBOO_DEBUGPRINT_REG(host); + BAMBOO_DEBUGPRINT_REG(ptr); + } +#endif + // check if this obj has been forwarded + if(!MGCHashcontains(gcforwardobjtbl, (int)ptr)) { + // send a msg to host informing that ptr is active + send_msg_3(host, GCMARKEDOBJ, ptr, BAMBOO_NUM_OF_CORE, false); + gcself_numsendobjs++; + MGCHashadd(gcforwardobjtbl, (int)ptr); + } + checkfield = false; + }// if(isLocal(ptr)) else ...*/ } // if(ISSHAREDOBJ(ptr)) #ifdef DEBUG BAMBOO_DEBUGPRINT(0xed06); @@ -1904,8 +1923,8 @@ innermoveobj: return true; } // if(stopblock == to->numblocks) } // if(to->top + isize > to->bound) - // set the mark field to 2, indicating that this obj has been moved - // and need to be flushed + // set the mark field to 2, indicating that this obj has been moved + // and need to be flushed ((int *)(orig->ptr))[6] = COMPACTED; if(to->ptr != orig->ptr) { if((int)(orig->ptr) < (int)(to->ptr)+size) { @@ -1921,6 +1940,9 @@ innermoveobj: BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); //mgchashInsert_I(orig->ptr, to->ptr); RuntimeHashadd_I(gcpointertbl, orig->ptr, to->ptr); + /*struct nodemappinginfo * nodeinfo = NULL; + RuntimeHashget(gcpointertbl, orig->ptr, &nodeinfo); + nodeinfo->ptr = to->ptr;*/ //MGCHashadd_I(gcpointertbl, orig->ptr, to->ptr); BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); //} @@ -2207,18 +2229,33 @@ inline void * flushObj(void * objptr) { // a shared obj ptr, change to new address BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); #ifdef GC_PROFILE - unsigned long long ttime = BAMBOO_GET_EXE_TIME(); + // TODO unsigned long long ttime = BAMBOO_GET_EXE_TIME(); #endif //dstptr = mgchashSearch(objptr); RuntimeHashget(gcpointertbl, objptr, &dstptr); + /*struct nodemappinginfo * nodeinfo = NULL; + RuntimeHashget(gcpointertbl, objptr, &nodeinfo); + if(nodeinfo == NULL) { + // currenly the mapping info is not ready TODO + // busy waiting until we get the mapping info + while(true) { + BAMBOO_WAITING_FOR_LOCK(0); + RuntimeHashget(gcpointertbl, objptr, &nodeinfo); + if(nodeinfo != NULL) { + break; + } + } + } + dstptr = nodeinfo->ptr;*/ #ifdef GC_PROFILE - flushstalltime += BAMBOO_GET_EXE_TIME()-ttime; + // TODO flushstalltime += BAMBOO_GET_EXE_TIME()-ttime; #endif //MGCHashget(gcpointertbl, objptr, &dstptr); BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); #ifdef DEBUG BAMBOO_DEBUGPRINT_REG(dstptr); #endif + if(NULL == dstptr) { // no mapping info #ifdef DEBUG @@ -2239,11 +2276,11 @@ inline void * flushObj(void * objptr) { gcmappedobj = NULL; #ifdef GC_PROFILE // TODO - num_mapinforequest++; + //num_mapinforequest++; //unsigned long long ttime = BAMBOO_GET_EXE_TIME(); #endif #ifdef GC_PROFILE - unsigned long long ttimet = BAMBOO_GET_EXE_TIME(); + // TODO unsigned long long ttimet = BAMBOO_GET_EXE_TIME(); #endif // the first time require the mapping, send msg to the hostcore // for the mapping info @@ -2255,7 +2292,7 @@ inline void * flushObj(void * objptr) { } } #ifdef GC_PROFILE - flushstalltime_i += BAMBOO_GET_EXE_TIME()-ttimet; + // TODO flushstalltime_i += BAMBOO_GET_EXE_TIME()-ttimet; #endif #ifdef GC_PROFILE // TODO @@ -2264,13 +2301,16 @@ inline void * flushObj(void * objptr) { BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); //dstptr = mgchashSearch(objptr); RuntimeHashget(gcpointertbl, objptr, &dstptr); + /*struct nodemappinginfo * nodeinfo = NULL; + RuntimeHashget(gcpointertbl, objptr, &nodeinfo); + dstptr = nodeinfo->ptr;*/ //MGCHashget(gcpointertbl, objptr, &dstptr); BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); - } // if(hostcore(objptr) == BAMBOO_NUM_OF_CORE) else ... + } // if(hostcore(objptr) == BAMBOO_NUM_OF_CORE) else ... #ifdef DEBUG BAMBOO_DEBUGPRINT_REG(dstptr); #endif - } // if(NULL == dstptr) + } // if(NULL == dstptr) } // if(ISSHAREDOBJ(objptr)) // if not a shared obj, return NULL to indicate no need to flush #ifdef DEBUG @@ -2383,16 +2423,59 @@ inline void flushRuntimeObj(struct garbagelist * stackptr) { } // void flushRuntimeObj(struct garbagelist * stackptr) +inline void transmappinginfo() { + // inform the other cores the mapping info they need + /*struct RuntimeIterator* it_pointertbl = + RuntimeHashcreateiterator(gcpointertbl); + while(RunhasNext(it_pointertbl)) { + int obj = Runkey(it_pointertbl); + struct nodemappinginfo * info = + (struct nodemappinginfo *)Runnext(it_pointertbl); + int newptr = (int)info->ptr; + struct requestcoreinfo * coreinfo = info->cores; + info->cores = NULL; + // send the mapping info to all requested cores + while(coreinfo != NULL) { + struct requestcoreinfo * tmp = coreinfo; + coreinfo = coreinfo->next; + send_msg_3(tmp->core, GCMAPINFO, obj, newptr, false); + RUNFREE(tmp); // release the node + } + }*/ + int core = (BAMBOO_NUM_OF_CORE + 1) % NUMCORESACTIVE; + for(int i = 0; i < NUMCORESACTIVE - 1; i++) { + for(int j = 1; j < gcmappingtbl[core][0]+1; j++) { + int obj = gcmappingtbl[core][j]; + int newptr = 0; + RuntimeHashget(gcpointertbl, obj, &newptr); + send_msg_3(core, GCMAPINFO, obj, newptr, false); + // TODO + //tprintf("send mapping %x -> %x, %x \n", (int)obj, (int)newptr, i); + } + // TODO + //tprintf("send mapping to core %d \n", core); + core = (core + 1) % NUMCORESACTIVE; + } + + // TODO + //BAMBOO_DEBUGPRINT(0xeeee); + + if(STARTUPCORE != BAMBOO_NUM_OF_CORE) { + send_msg_2(STARTUPCORE, GCFINISHMAPINFO, BAMBOO_NUM_OF_CORE, false); + } +} + inline void flush(struct garbagelist * stackptr) { #ifdef GC_PROFILE - if(BAMBOO_NUM_OF_CORE == 0) { + /* TODO if(BAMBOO_NUM_OF_CORE == 0) { BAMBOO_DEBUGPRINT(0xcccc); BAMBOO_DEBUGPRINT_REG(BAMBOO_GET_EXE_TIME()); - } + }*/ #endif + flushRuntimeObj(stackptr); #ifdef GC_PROFILE - if(BAMBOO_NUM_OF_CORE == 0) BAMBOO_DEBUGPRINT_REG(BAMBOO_GET_EXE_TIME()); + // TODO if(BAMBOO_NUM_OF_CORE == 0) BAMBOO_DEBUGPRINT_REG(BAMBOO_GET_EXE_TIME()); #endif while(true) { @@ -2491,7 +2574,7 @@ inline void flush(struct garbagelist * stackptr) { BAMBOO_DEBUGPRINT(0xe308); #endif #ifdef GC_PROFILE - if(BAMBOO_NUM_OF_CORE == 0) BAMBOO_DEBUGPRINT_REG(BAMBOO_GET_EXE_TIME()); + // TODO if(BAMBOO_NUM_OF_CORE == 0) BAMBOO_DEBUGPRINT_REG(BAMBOO_GET_EXE_TIME()); #endif // TODO bug here: the startup core contains all lobjs' info, thus all the @@ -2580,7 +2663,7 @@ inline void flush(struct garbagelist * stackptr) { BAMBOO_DEBUGPRINT(0xe310); #endif #ifdef GC_PROFILE - if(BAMBOO_NUM_OF_CORE == 0) BAMBOO_DEBUGPRINT_REG(BAMBOO_GET_EXE_TIME()); + // TODO if(BAMBOO_NUM_OF_CORE == 0) BAMBOO_DEBUGPRINT_REG(BAMBOO_GET_EXE_TIME()); #endif // send flush finish message to core coordinator @@ -2590,13 +2673,14 @@ inline void flush(struct garbagelist * stackptr) { send_msg_2(STARTUPCORE, GCFINISHFLUSH, BAMBOO_NUM_OF_CORE, false); } #ifdef GC_PROFILE - if(BAMBOO_NUM_OF_CORE == 0) { + // TODO + /*if(BAMBOO_NUM_OF_CORE == 0) { BAMBOO_DEBUGPRINT(0xffff); //BAMBOO_DEBUGPRINT_REG(num_mapinforequest); - BAMBOO_DEBUGPRINT_REG(flushstalltime); + //BAMBOO_DEBUGPRINT_REG(flushstalltime); //BAMBOO_DEBUGPRINT_REG(num_mapinforequest_i); - BAMBOO_DEBUGPRINT_REG(flushstalltime_i); - } + //BAMBOO_DEBUGPRINT_REG(flushstalltime_i); + }*/ //BAMBOO_DEBUGPRINT_REG(flushstalltime); #endif #ifdef DEBUG @@ -2635,6 +2719,20 @@ inline void gc_collect(struct garbagelist * stackptr) { #ifdef RAWPATH // TODO GC_DEBUG printf("(%x,%x) Finish compact phase\n", udn_tile_coord_x(), udn_tile_coord_y()); +#endif + while(true) { + if(MAPPHASE == gcphase) { + break; + } + } +#ifdef RAWPATH // TODO GC_DEBUG + printf("(%x,%x) Start map phase\n", udn_tile_coord_x(), + udn_tile_coord_y()); +#endif + transmappinginfo(); +#ifdef RAWPATH // TODO GC_DEBUG + printf("(%x,%x) Finish map phase\n", udn_tile_coord_x(), + udn_tile_coord_y()); #endif while(true) { if(FLUSHPHASE == gcphase) { @@ -2816,11 +2914,11 @@ inline void gc(struct garbagelist * stackptr) { #ifdef GC_PROFILE gc_profileItem(); // TODO - if(BAMBOO_NUM_OF_CORE == 0) { + /*if(BAMBOO_NUM_OF_CORE == 0) { BAMBOO_DEBUGPRINT(0xeeee); BAMBOO_DEBUGPRINT_REG(num_markrequest); BAMBOO_DEBUGPRINT_REG(marktime); - } + }*/ #endif #ifdef RAWPATH // TODO GC_DEBUG printf("(%x,%x) prepare to cache large objs \n", udn_tile_coord_x(), @@ -2998,6 +3096,40 @@ inline void gc(struct garbagelist * stackptr) { RUNFREE(to); orig = to = NULL; + gcphase = MAPPHASE; + gccorestatus[BAMBOO_NUM_OF_CORE] = 1; + // Note: all cores should flush their runtime data including non-gc + // cores + for(i = 1; i < NUMCORES4GC; ++i) { + // send start flush messages to all cores + gccorestatus[i] = 1; + send_msg_1(i, GCSTARTMAPINFO, false); + } +#ifdef GC_PROFILE + gc_profileItem(); +#endif +#ifdef RAWPATH // TODO GC_DEBUG + printf("(%x,%x) Start map phase \n", udn_tile_coord_x(), + udn_tile_coord_y()); +#endif + // mapinto phase + transmappinginfo(); +#ifdef RAWPATH // TODO GC_DEBUG + printf("(%x,%x) Finish map phase \n", udn_tile_coord_x(), + udn_tile_coord_y()); +#endif + gccorestatus[BAMBOO_NUM_OF_CORE] = 0; + while(MAPPHASE == gcphase) { + // check the status of all cores + BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); + if(gc_checkCoreStatus_I()) { + // all cores have finished sending mapping info + BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); + break; + } + BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); + } // while(MAPPHASE == gcphase) + gcphase = FLUSHPHASE; gccorestatus[BAMBOO_NUM_OF_CORE] = 1; // Note: all cores should flush their runtime data including non-gc diff --git a/Robust/src/Runtime/multicoregarbage.h b/Robust/src/Runtime/multicoregarbage.h index 2e95097f..96685262 100644 --- a/Robust/src/Runtime/multicoregarbage.h +++ b/Robust/src/Runtime/multicoregarbage.h @@ -26,7 +26,7 @@ #define GCINFOLENGTH 100 typedef struct gc_info { - unsigned long long time[7]; + unsigned long long time[8]; int index; } GCInfo; @@ -54,8 +54,9 @@ typedef enum { MARKPHASE, // 0x1 COMPACTPHASE, // 0x2 SUBTLECOMPACTPHASE, // 0x3 - FLUSHPHASE, // 0x4 - FINISHPHASE // 0x5 + MAPPHASE, // 0x4 + FLUSHPHASE, // 0x5 + FINISHPHASE // 0x6 } GCPHASETYPE; volatile bool gcflag; @@ -95,7 +96,7 @@ volatile bool gctomove; int gcrequiredmems[NUMCORES4GC]; //record pending mem requests volatile int gcmovepending; -struct flushlist { +/*struct flushlist { void * key; struct flushnode * val; struct flushlist * next; @@ -104,16 +105,36 @@ struct flushlist { struct flushnode { void ** ptr; struct flushnode * next; -}; +};*/ +//volatile struct flushlist * gcflushlist; // list of (key, list of reference +// to be flushed) +//volatile int gcnumflush; + // mapping of old address to new address +/*struct requestcoreinfo { + int core; + struct requestcoreinfo * next; +}; + +struct nodemappinginfo { + void * ptr; + struct requestcoreinfo * cores; +};*/ +// data structures to record remote cores that transferred the marked +// objs in the mark phase +struct rcoreinfo{ + int high; + int low; +}; +struct RuntimeHash * gcrcoretbl; +#define NUM_MAPPING 40 +void * gcmappingtbl[NUMCORESACTIVE][NUM_MAPPING]; + volatile struct RuntimeHash * gcpointertbl; //struct MGCHash * gcpointertbl; int gcobj2map; int gcmappedobj; volatile bool gcismapped; -//volatile struct flushlist * gcflushlist; // list of (key, list of reference -// to be flushed) -//volatile int gcnumflush; // table recording the starting address of each small block // (size is BAMBOO_SMEM_SIZE) diff --git a/Robust/src/Runtime/multicoreruntime.h b/Robust/src/Runtime/multicoreruntime.h index c900617b..e806567e 100644 --- a/Robust/src/Runtime/multicoreruntime.h +++ b/Robust/src/Runtime/multicoreruntime.h @@ -158,8 +158,8 @@ volatile bool isMsgHanging; * 1b (size if always 1 * sizeof(int)) * 1c + size of msg + corenum + gcsendobjs + gcreceiveobjs * (size is always 5 * sizeof(int)) - * 1d + obj's address - * (size is always 2 * sizeof(int)) + * 1d + obj's address + request core + * (size is always 3 * sizeof(int)) * 1e + corenum + start addr + end addr * (size if always 4 * sizeof(int)) * 1f + obj's address + corenum @@ -195,21 +195,23 @@ typedef enum { GCSTARTINIT, // 0xE2 GCSTART, // 0xE3 GCSTARTCOMPACT, // 0xE4 - GCSTARTFLUSH, // 0xE5 - GCFINISHINIT, // 0xE6 - GCFINISHMARK, // 0xE7 - GCFINISHCOMPACT, // 0xE8 - GCFINISHFLUSH, // 0xE9 - GCFINISH, // 0xEa - GCMARKCONFIRM, // 0xEb - GCMARKREPORT, // 0xEc - GCMARKEDOBJ, // 0xEd - GCMOVESTART, // 0xEe - GCMAPREQUEST, // 0xEf - GCMAPINFO, // 0xF0 - GCLOBJREQUEST, // 0xF1 - GCLOBJINFO, // 0xF2 - GCLOBJMAPPING, // 0xF3 + GCSTARTMAPINFO, // 0xE5 + GCSTARTFLUSH, // 0xE6 + GCFINISHINIT, // 0xE7 + GCFINISHMARK, // 0xE8 + GCFINISHCOMPACT, // 0xE9 + GCFINISHMAPINFO, // 0xEa + GCFINISHFLUSH, // 0xEb + GCFINISH, // 0xEc + GCMARKCONFIRM, // 0xEd + GCMARKREPORT, // 0xEe + GCMARKEDOBJ, // 0xEf + GCMOVESTART, // 0xF0 + GCMAPREQUEST, // 0xF1 + GCMAPINFO, // 0xF2 + GCLOBJREQUEST, // 0xF3 + GCLOBJINFO, // 0xF4 + GCLOBJMAPPING, // 0xF5 #endif MSGEND } MSGTYPE; diff --git a/Robust/src/Runtime/multicoretask.c b/Robust/src/Runtime/multicoretask.c index b4a42b6d..b70095d0 100644 --- a/Robust/src/Runtime/multicoretask.c +++ b/Robust/src/Runtime/multicoretask.c @@ -121,7 +121,7 @@ void initruntimedata() { gcforwardobjtbl = allocateMGCHash_I(20, 3); gcobj2map = 0; gcmappedobj = 0; - gcismapped = false; + //gcismapped = false; gcnumlobjs = 0; gcheaptop = 0; gctopcore = 0; @@ -132,7 +132,11 @@ void initruntimedata() { gcblock2fill = 0; gcsbstarttbl = BAMBOO_BASE_VA; bamboo_smemtbl = (void *)gcsbstarttbl - + (BAMBOO_SHARED_MEM_SIZE/BAMBOO_SMEM_SIZE)*sizeof(INTPTR); + + (BAMBOO_SHARED_MEM_SIZE/BAMBOO_SMEM_SIZE)*sizeof(INTPTR); + // for mapping info structures + gcrcoretbl = allocateRuntimeHash_I(20); + BAMBOO_MEMSET_WH(gcmappingtbl, 0, + sizeof(void *)*NUMCORESACTIVE*NUM_MAPPING); #else // create the lock table, lockresult table and obj queue locktable.size = 20; @@ -184,6 +188,8 @@ void disruntimedata() { freeRuntimeHash(gcpointertbl); //freeMGCHash(gcpointertbl); freeMGCHash(gcforwardobjtbl); + // for mapping info structures + freeRuntimeHash(gcrcoretbl); #else freeRuntimeHash(lockRedirectTbl); freeRuntimeHash(objRedirectLockTbl); @@ -1488,6 +1494,7 @@ INLINE int checkMsgLength_I(int size) { #ifdef MULTICORE_GC case GCSTARTINIT: case GCSTART: + case GCSTARTMAPINFO: case GCSTARTFLUSH: case GCFINISH: case GCMARKCONFIRM: @@ -1503,8 +1510,8 @@ INLINE int checkMsgLength_I(int size) { #ifdef MULTICORE_GC case GCSTARTCOMPACT: case GCFINISHINIT: + case GCFINISHMAPINFO: case GCFINISHFLUSH: - case GCMARKEDOBJ: #endif { msglength = 2; @@ -1514,6 +1521,7 @@ INLINE int checkMsgLength_I(int size) { case MEMREQUEST: case MEMRESPONSE: #ifdef MULTICORE_GC + case GCMARKEDOBJ: case GCMAPREQUEST: case GCMAPINFO: case GCLOBJMAPPING: @@ -2131,6 +2139,10 @@ INLINE void processmsg_gcstartcompact_I() { gcphase = COMPACTPHASE; } +INLINE void processmsg_gcstartmapinfo_I() { + gcphase = MAPPHASE; +} + INLINE void processmsg_gcstartflush_I() { gcphase = FLUSHPHASE; } @@ -2221,6 +2233,25 @@ INLINE void processmsg_gcfinishcompact_I() { } // if(cnum < NUMCORES4GC) } +INLINE void processmsg_gcfinishmapinfo_I() { + int data1 = msgdata[msgdataindex]; + MSG_INDEXINC_I(); + // received a map phase finish msg + if(BAMBOO_NUM_OF_CORE != STARTUPCORE) { + // non startup core can not receive this msg + // return -1 +#ifndef CLOSE_PRINT + BAMBOO_DEBUGPRINT_REG(data1); +#endif + BAMBOO_EXIT(0xb004); + } + // all cores should do flush + if(data1 < NUMCORES4GC) { + gccorestatus[data1] = 0; + } +} + + INLINE void processmsg_gcfinishflush_I() { int data1 = msgdata[msgdataindex]; MSG_INDEXINC_I(); @@ -2231,7 +2262,7 @@ INLINE void processmsg_gcfinishflush_I() { #ifndef CLOSE_PRINT BAMBOO_DEBUGPRINT_REG(data1); #endif - BAMBOO_EXIT(0xb004); + BAMBOO_EXIT(0xb005); } // all cores should do flush if(data1 < NUMCORESACTIVE) { @@ -2243,7 +2274,7 @@ INLINE void processmsg_gcmarkconfirm_I() { if((BAMBOO_NUM_OF_CORE == STARTUPCORE) || (BAMBOO_NUM_OF_CORE > NUMCORESACTIVE - 1)) { // wrong core to receive such msg - BAMBOO_EXIT(0xb005); + BAMBOO_EXIT(0xb006); } else { // send response msg, cahce the msg first if(BAMBOO_CHECK_SEND_MODE()) { @@ -2273,7 +2304,7 @@ INLINE void processmsg_gcmarkreport_I() { #ifndef CLOSE_PRINT BAMBOO_DEBUGPRINT_REG(data2); #endif - BAMBOO_EXIT(0xb006); + BAMBOO_EXIT(0xb007); } else { if(waitconfirm) { numconfirm--; @@ -2287,12 +2318,112 @@ INLINE void processmsg_gcmarkreport_I() { INLINE void processmsg_gcmarkedobj_I() { int data1 = msgdata[msgdataindex]; MSG_INDEXINC_I(); + int data2 = msgdata[msgdataindex]; + MSG_INDEXINC_I(); // received a markedObj msg if(((int *)data1)[6] == INIT) { // this is the first time that this object is discovered, // set the flag as DISCOVERED ((int *)data1)[6] = DISCOVERED; gc_enqueue_I(data1); + // insert the obj and request core info into mapping hashtable + /*struct requestcoreinfo * coreinfo = + (struct requestcoreinfo *)RUNMALLOC_I(sizeof(struct requestcoreinfo)); + coreinfo->core = data2; + coreinfo->next = NULL; + struct nodemappinginfo * nodeinfo = + (struct nodemappinginfo *)RUNMALLOC_I(sizeof(struct nodemappinginfo)); + nodeinfo->ptr = NULL; + nodeinfo->cores = coreinfo; + RuntimeHashadd_I(gcpointertbl, data1, (int)nodeinfo);*/ + struct rcoreinfo * coreinfo = + (struct rcoreinfo *)RUNMALLOC_I(sizeof(struct rcoreinfo)); + coreinfo->high = coreinfo->low = 0; + if(data2 > 31) { + coreinfo->high |= 1<<(data2-32); + } else { + coreinfo->low |= 1<cores; + if(coreinfo == NULL) { + nodeinfo->cores = + (struct requestcoreinfo *)RUNMALLOC_I( + sizeof(struct requestcoreinfo)); + nodeinfo->cores->core = data2; + nodeinfo->cores->next = NULL; + } else { + while(true) { + if(coreinfo->core == data2) { + break; + } else if ((coreinfo->core > data2) || + (coreinfo->next == NULL)) { + // insert here + struct requestcoreinfo * toinsert = + (struct requestcoreinfo *)RUNMALLOC_I( + sizeof(struct requestcoreinfo)); + if(coreinfo->core > data2) { + toinsert->next = coreinfo->next; + toinsert->core = coreinfo->core; + coreinfo->core = data2; + } else { + toinsert->core = data2; + } + coreinfo->next = toinsert; + break; + } else { + coreinfo = coreinfo->next; + } + } + } + }*/ + struct rcoreinfo * coreinfo = NULL; + RuntimeHashget(gcrcoretbl, data1, &coreinfo); + if(coreinfo == NULL) { + coreinfo = + (struct rcoreinfo *)RUNMALLOC_I(sizeof(struct rcoreinfo)); + coreinfo->high = coreinfo->low = 0; + if(data2 > 31) { + coreinfo->high |= 1<<(data2-32); + } else { + coreinfo->low |= 1< 31) { + if((coreinfo->high)&(1<<(data2-32))==0) { + toadd = true; + coreinfo->high |= 1<<(data2-32); + } + } else { + if((coreinfo->low)&(1<low |= 1<ptr = (void *)gcmappedobj; + nodeinfo->cores = NULL; + RuntimeHashadd_I(gcpointertbl, data1, (int)nodeinfo);*/ //MGCHashadd_I(gcpointertbl, gcobj2map, gcmappedobj); +// } + if(data1 == gcobj2map) { + gcismapped = true; } - gcismapped = true; #ifdef GC_PROFILE //flushstalltime += BAMBOO_GET_EXE_TIME() - ttime; #endif @@ -2394,7 +2536,7 @@ INLINE void processmsg_gclobjinfo_I() { #ifndef CLOSE_PRINT BAMBOO_DEBUGPRINT_REG(data2); #endif - BAMBOO_EXIT(0xb009); + BAMBOO_EXIT(0xb00b); } // store the mark result info int cnum = data2; @@ -2423,6 +2565,11 @@ INLINE void processmsg_gclobjmapping_I() { MSG_INDEXINC_I(); //mgchashInsert_I(msgdata[1], msgdata[2]); RuntimeHashadd_I(gcpointertbl, data1, data2); + /*struct nodemappinginfo * nodeinfo = + (struct nodemappinginfo *)RUNMALLOC_I(sizeof(struct nodemappinginfo)); + nodeinfo->ptr = (void *)data2; + nodeinfo->cores = NULL; + RuntimeHashadd_I(gcpointertbl, data1, (int)nodeinfo);*/ //MGCHashadd_I(gcpointertbl, msgdata[1], msgdata[2]); } #endif // #ifdef MULTICORE_GC @@ -2597,6 +2744,12 @@ processmsg: break; } // case GCSTARTCOMPACT + case GCSTARTMAPINFO: { + // received a flush phase start msg + processmsg_gcstartmapinfo_I(); + break; + } // case GCSTARTFLUSH + case GCSTARTFLUSH: { // received a flush phase start msg processmsg_gcstartflush_I(); @@ -2619,6 +2772,11 @@ processmsg: break; } // case GCFINISHCOMPACT + case GCFINISHMAPINFO: { + processmsg_gcfinishmapinfo_I(); + break; + } // case GCFINISHMAPINFO + case GCFINISHFLUSH: { processmsg_gcfinishflush_I(); break; @@ -2933,7 +3091,7 @@ void releasewritelock_r(void * lock, void * redirectlock) { // reside on this core if(!RuntimeHashcontainskey(locktbl, reallock)) { // no locks for this object, something is wrong - BAMBOO_EXIT(0xa011); + BAMBOO_EXIT(0xa00b); } else { int rwlock_obj = 0; struct LockValue * lockvalue = NULL; -- 2.34.1