int block = 0;
int sblock = 0;
unsigned int j = 0;
- void * i = 0;
+ unsigned int i = 0;
int coren = 0;
int x = 0;
int y = 0;
// reserved blocks for sblocktbl
printf("(%x,%x) ++++ reserved sblocks ++++ \n", udn_tile_coord_x(),
udn_tile_coord_y());
- for(i=BAMBOO_BASE_VA; (unsinged int)i<(unsigned int)gcbaseva; i+= 4*16) {
+ for(i=BAMBOO_BASE_VA; i<gcbaseva; i+= 4*16) {
printf("(%x,%x) 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x \n",
udn_tile_coord_x(), udn_tile_coord_y(),
*((int *)(i)), *((int *)(i + 4)),
buildCore2Test();
}
+ //initialize update structures
+ origarraycount=0;
+ for(int i=0;i<NUMCORES4GC;i++) {
+ origblockarray[i]=NULL;
+ }
+
INIT_MULTICORE_GCPROFILE_DATA();
}
gcblock2fill = 0;
gcmovepending = 0;
gccurr_heaptop = 0;
-
+ update_origblockptr=NULL;
gc_queueinit();
MGCHashreset(gcforwardobjtbl);
#include "structdefs.h"
#include "multicoregcprofile.h"
-#ifdef GC_DEBUG
+//#ifdef GC_DEBUG
#define GC_PRINTF tprintf
-#else
-#define GC_PRINTF if(0) tprintf
-#endif
+//#else
+//#define GC_PRINTF if(0) tprintf
+//#endif
// data structures for GC
#define BAMBOO_SMEM_SIZE_L (BAMBOO_SMEM_SIZE * 2)
volatile unsigned int gcrequiredmems[NUMCORES4GC]; //record pending mem requests
volatile unsigned int gcmovepending;
+//keep track of current base block pointer for orig block
+volatile void * update_origblockptr;
+volatile void * origblockarray[NUMCORES4GC];
+volatile int origarraycount;
+volatile bool blockgranted;
+
+
// shared memory pointer for pointer mapping tbls
// In GC version, this block of memory is located at the bottom of the
// shared memory, right on the top of the smem tbl.
} \
}
+#define BLOCK2CORE(c, b) { \
+ if(1 == (NUMCORES4GC)) { \
+ c = 0; \
+ } else { \
+ c = gc_block2core[(b%(NUMCORES4GC*2))]; \
+ } \
+ }
+
INLINE static unsigned int hostcore(void * ptr) {
// check the host core of ptr
unsigned int host;
//finished with block...
origptr=origbound;
orig->ptr=origptr;
- return 0;
+ return NULL;
}
} while(!gcmarktbl[arrayoffset]);
origptr=CONVERTTABLEINDEXTOPTR(arrayoffset);
if (endtoptr>tobound||endtoptr<tobase) {
//get use the next block of memory
- to->ptr=tobound;
orig->ptr=origptr;
return dstptr;
}
}
}
+void updateOrigPtr(void *currtop) {
+ //Ordering is important...
+ //Update heap top first...
+ update_origblockptr=currtop;
+
+ //Then check for waiting cores
+ if (origarraycount>0) {
+ for(int i=0;i<NUMCORES4GC;i++) {
+ void *ptr=origblockarray[i];
+ if (ptr!=NULL&&ptr<currtop) {
+ origarraycount--;
+ origblockarray[i]=NULL;
+ send_msg_1(i,GCGRANTBLOCK);
+ }
+ }
+ }
+}
+
void updatehelper(struct moveHelper * orig,struct moveHelper * to) {
while(true) {
- unsigned int minimumbytes=updateblocks(orig, to);
+ void *dstptr=updateblocks(orig, to);
+ if (dstptr) {
+ //need more memory to compact into
+ block_t blockindex;
+ BLOCKINDEX(blockindex, dstptr);
+ unsigned int corenum;
+ BLOCK2CORE(corenum, blockindex);
+ to->base=OFFSET2BASEVA(blockindex)+gcbaseva;
+ to->bound=BOUNDPTR(blockindex)+gcbaseva;
+ if (corenum!=BAMBOO_NUM_OF_CORE) {
+ //we have someone elses memory...need to ask to use it
+ //first set flag to false
+ blockgranted=false;
+ send_msg_3(corenum,GCREQBLOCK, BAMBOO_NUM_OF_CORE, to->bound);
+ //wait for permission
+ while(!blockgranted)
+ ;
+ }
+ }
if (orig->ptr==orig->bound) {
+ //inform others that we are done with previous block
+ updateOrigPtr(orig->bound);
+
//need more data to compact
//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)
break;
}
- if (minimumbytes!=0) {
- getSpace(to, minimumbytes);
- }
}
}
return (*tsize) > blocksize;
}
-INLINE unsigned int hostcore(void * ptr) {
- // check the host core of ptr
- unsigned int host = 0;
- if(1 == (NUMCORES4GC)) {
- host = 0;
- } else {
- unsigned int t = (unsigned int)ptr - (unsigned int)gcbaseva;
- unsigned int b = (t < BAMBOO_LARGE_SMEM_BOUND) ? t / (BAMBOO_SMEM_SIZE_L) : NUMCORES4GC+((t-(BAMBOO_LARGE_SMEM_BOUND))/(BAMBOO_SMEM_SIZE));
- host = gc_block2core[(b%(NUMCORES4GC*2))];
- }
- return host;
-}
-
//push the null check into the mark macro
//#define MARKOBJ(objptr, ii) {void * marktmpptr=objptr; if (marktmpptr!=NULL) markObj(marktmpptr, __LINE__, ii);}
//#define MARKOBJNONNULL(objptr, ii) {markObj(objptr, __LINE__, ii);}
INLINE void gettype_size(void * ptr, int * ttype, unsigned int * tsize);
INLINE bool isLarge(void * ptr, int * ttype, unsigned int * tsize);
-INLINE unsigned int hostcore(void * ptr);
INLINE void markgarbagelist(struct garbagelist * listptr);
INLINE void tomark(struct garbagelist * stackptr);
INLINE void scanPtrsInObj(void * ptr, int type);
5, //GCMARKREPORT, // 0xEe
2, //GCMARKEDOBJ, // 0xEf
2, //GCMOVESTART, // 0xF0
- 1, //GCLOBJREQUEST, // 0xF1
- -1, //GCLOBJINFO, // 0xF2
+ 1, //GCLOBJREQUEST, // 0xF1
+ 3, //GCREQBLOCK,
+ 1, //GCGRANTBLOCK,
+ -1, //GCLOBJINFO, // 0xF2
#ifdef GC_PROFILE
4, //GCPROFILES, // 0xF3
#endif // GC_PROFILE
}
}
+INLINE void processmsg_reqblock_I() {
+ int cnum=msgdata[msgdataindex];
+ MSG_INDEXINC_I();
+ void * topptr=msgdata[msgdataindex];
+ MSG_INDEXINC_I();
+ if (topptr<=update_origblockptr) {
+ //send message
+ if(BAMBOO_CHECK_SEND_MODE()) {
+ cache_msg_1_I(cnum,GCGRANTBLOCK);
+ } else {
+ send_msg_1_I(cnum,GCGRANTBLOCK);
+ }
+ } else {
+ //store message
+ origblockarray[cnum]=topptr;
+ origarraycount++;
+ }
+}
+
+INLINE void processmsg_grantblock_I() {
+ blockgranted=true;
+}
+
+
INLINE void processmsg_gcfinishmark_I() {
int data1 = msgdata[msgdataindex];
MSG_INDEXINC_I();
break;
}
+ case GCREQBLOCK: {
+ processmsg_reqblock_I();
+ break;
+ }
+
+ case GCGRANTBLOCK: {
+ processmsg_grantblock_I();
+ break;
+ }
+
case GCLOBJINFO: {
// received a large objs info response msg
processmsg_gclobjinfo_I(msglength);
GCMARKEDOBJ, // 0xEf
GCMOVESTART, // 0xF0
GCLOBJREQUEST, // 0xF1
+ GCREQBLOCK,
+ GCGRANTBLOCK,
GCLOBJINFO, // 0xF2
#ifdef GC_PROFILE
GCPROFILES, // 0xF3