output.println("BAMBOO_DEBUGPRINT(0xAAAA);");
output.println("BAMBOO_DEBUGPRINT_REG(tmpsum);");
} else {
- //output.println("BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();");
output.println("printf(\"(%x,%x) Process %x(%d): task %s\\n\", udn_tile_coord_x(), udn_tile_coord_y(), corenum, corenum, \"" + task.getSymbol() + "\");");
- //output.println("BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();");
}
- //output.println("BAMBOO_DEBUGPRINT(BAMBOO_GET_EXE_TIME());");
output.println("#endif");
output.println("#ifdef DEBUG");
if(this.state.RAW) {
output.println("BAMBOO_DEBUGPRINT(0xAAAA);");
output.println("BAMBOO_DEBUGPRINT_REG(tmpsum);");
} else {
- //output.println("BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();");
output.println("printf(\"(%x,%x) Process %x(%d): task %s\\n\", udn_tile_coord_x(), udn_tile_coord_y(), corenum, corenum, \"" + task.getSymbol() + "\");");
- //output.println("BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();");
}
output.println("#endif");
if(this.state.RAW) {
//output.println(" flushAll();");
output.println("#ifdef CACHEFLUSH");
output.println("BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();");
- output.println("#ifdef DEBUG");
output.println("BAMBOO_DEBUGPRINT(0xec00);");
- output.println("#endif");
output.println("BAMBOO_CACHE_FLUSH_ALL();");
- output.println("#ifdef DEBUG");
output.println("BAMBOO_DEBUGPRINT(0xecff);");
- output.println("#endif");
output.println("BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();");
output.println("#endif");
outputTransCode(output);
if(fm.getTask() != null) {
output.println("#ifdef CACHEFLUSH");
output.println("BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();");
- output.println("#ifdef DEBUG");
output.println("BAMBOO_DEBUGPRINT(0xec00);");
- output.println("#endif");
output.println("BAMBOO_CACHE_FLUSH_ALL();");
- output.println("#ifdef DEBUG");
output.println("BAMBOO_DEBUGPRINT(0xecff);");
- output.println("#endif");
output.println("BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();");
output.println("#endif");
outputTransCode(output);
}
struct ObjectHash * allocateObjectHash(int size) {
- struct ObjectHash *thisvar; //=(struct ObjectHash *)RUNMALLOC(sizeof(struct ObjectHash));
+ struct ObjectHash *thisvar;
if (size <= 0) {
#ifdef MULTICORE
- BAMBOO_EXIT(0xf001);
+ BAMBOO_EXIT();
#else
printf("Negative Hashtable size Exception\n");
exit(-1);
}
struct RuntimeHash * allocateRuntimeHash(int size) {
- struct RuntimeHash *thisvar; //=(struct RuntimeHash *)RUNMALLOC(sizeof(struct RuntimeHash));
+ struct RuntimeHash *thisvar;
if (size <= 0) {
#ifdef MULTICORE
- BAMBOO_EXIT(0xf101);
+ BAMBOO_EXIT();
#else
printf("Negative Hashtable size Exception\n");
exit(-1);
#ifdef MULTICORE
struct RuntimeHash * allocateRuntimeHash_I(int size) {
- struct RuntimeHash *thisvar; //=(struct RuntimeHash *)RUNMALLOC(sizeof(struct RuntimeHash));
+ struct RuntimeHash *thisvar;
if (size <= 0) {
#ifdef MULTICORE
- BAMBOO_EXIT(0xf101);
+ BAMBOO_EXIT();
#else
printf("Negative Hashtable size Exception\n");
exit(-1);
struct GCSharedHash *thisvar;
if (size <= 0) {
#ifdef MULTICORE
- BAMBOO_EXIT(0xf301);
+ BAMBOO_EXIT();
#else
printf("Negative Hashtable size Exception\n");
exit(-1);
struct GCSharedHash *thisvar;
if (size <= 0) {
#ifdef MULTICORE
- BAMBOO_EXIT(0xf302);
+ BAMBOO_EXIT();
#else
printf("Negative Hashtable size Exception\n");
exit(-1);
ctable = (mgcsharedhashtbl_t *)FREEMALLOC_NGC(sizeof(mgcsharedhashtbl_t));
if(ctable == NULL) {
- // TODO
- BAMBOO_EXIT(0xf303);
- return NULL;
+ // TODO
+ BAMBOO_EXIT();
+ return NULL;
}
// Allocate space for the hash table
ctable->table = (mgcsharedhashlistnode_t *)FREEMALLOC_NGC(
size*sizeof(mgcsharedhashlistnode_t));
if(ctable->table == NULL) {
- BAMBOO_EXIT(0xf304); // TODO
- return NULL;
+ BAMBOO_EXIT(); // TODO
+ return NULL;
}
ctable->size = size;
ctable->loadfactor = loadfactor;
ctable = (mgcsharedhashtbl_t *)FREEMALLOC_NGC_I(sizeof(mgcsharedhashtbl_t));
if(ctable == NULL) {
- // TODO
- BAMBOO_EXIT(0xf305);
- return NULL;
+ // TODO
+ BAMBOO_EXIT();
+ return NULL;
}
// Allocate space for the hash table
ctable->table = (mgcsharedhashlistnode_t *)FREEMALLOC_NGC_I(
size*sizeof(mgcsharedhashlistnode_t));
if(ctable->table == NULL) {
- BAMBOO_EXIT(0xf306); // TODO
- return NULL;
+ BAMBOO_EXIT(); // TODO
+ return NULL;
}
ctable->size = size;
ctable->loadfactor = loadfactor;
if (size <= 0) {
#ifdef MULTICORE
- BAMBOO_EXIT(0xf401);
+ BAMBOO_EXIT();
#else
printf("Negative Hashtable size Exception\n");
exit(-1);
// Allocate space for the hash table
ctable = (mgchashtable_t *)RUNMALLOC(sizeof(mgchashtable_t));
if(ctable == NULL) {
- // Run out of local memory
- BAMBOO_EXIT(0xf402);
+ // Run out of local memory
+ BAMBOO_EXIT();
}
ctable->table = (mgchashlistnode_t*)RUNMALLOC(size*sizeof(mgchashlistnode_t));
if(ctable->table == NULL) {
- // Run out of local memory
- BAMBOO_EXIT(0xf403);
+ // Run out of local memory
+ BAMBOO_EXIT();
}
ctable->loadfactor = loadfactor;
ctable->size = size;
if (size <= 0) {
#ifdef MULTICORE
- BAMBOO_EXIT(0xf404);
+ BAMBOO_EXIT();
#else
printf("Negative Hashtable size Exception\n");
exit(-1);
// Allocate space for the hash table
ctable = (mgchashtable_t*)RUNMALLOC_I(sizeof(mgchashtable_t));
if(ctable == NULL) {
- // Run out of local memory
- BAMBOO_EXIT(0xf405);
+ // Run out of local memory
+ BAMBOO_EXIT();
}
ctable->table=(mgchashlistnode_t*)RUNMALLOC_I(size*sizeof(mgchashlistnode_t));
if(ctable->table == NULL) {
- // Run out of local memory
- BAMBOO_EXIT(0xf406);
+ // Run out of local memory
+ BAMBOO_EXIT();
}
ctable->loadfactor = loadfactor;
ctable->size = size;
oldsize = tbl->size;
if((node = RUNMALLOC_I(newsize*sizeof(mgchashlistnode_t))) == NULL) {
- BAMBOO_EXIT(0xf407);
+ BAMBOO_EXIT();
printf("Calloc error %s %d\n", __FILE__, __LINE__);
return 1;
}
mgchashlistnode_t *tmp,*next;
if ((key=curr->key) == 0) {
- //Exit inner loop if there the first element is 0
- break;
- //key = val =0 for element if not present within the hash table
+ //Exit inner loop if there the first element is 0
+ break;
+ //key = val =0 for element if not present within the hash table
}
index = (((unsigned INTPTR)key) & mask) >> (GC_SHIFT_BITS);
tmp=&node[index];
next = curr->next;
// Insert into the new table
if(tmp->key == 0) {
- tmp->key = key;
- tmp->val = curr->val;
+ tmp->key = key;
+ tmp->val = curr->val;
} /*
NOTE: Add this case if you change this...
This case currently never happens because of the way things rehash....*/
else if (isfirst) {
- mgchashlistnode_t *newnode=RUNMALLOC_I(1*sizeof(mgchashlistnode_t));
- newnode->key = curr->key;
- newnode->val = curr->val;
- newnode->next = tmp->next;
- tmp->next=newnode;
+ mgchashlistnode_t *newnode=RUNMALLOC_I(1*sizeof(mgchashlistnode_t));
+ newnode->key = curr->key;
+ newnode->val = curr->val;
+ newnode->next = tmp->next;
+ tmp->next=newnode;
} else {
- curr->next=tmp->next;
- tmp->next=curr;
+ curr->next=tmp->next;
+ tmp->next=curr;
}
isfirst = 0;
struct MGCHash *thisvar;
if (size <= 0) {
#ifdef MULTICORE
- BAMBOO_EXIT(0xf408);
+ BAMBOO_EXIT();
#else
printf("Negative Hashtable size Exception\n");
exit(-1);
struct MGCHash *thisvar;
if (size <= 0) {
#ifdef MULTICORE
- BAMBOO_EXIT(0xf409);
+ BAMBOO_EXIT();
#else
printf("Negative Hashtable size Exception\n");
exit(-1);
while (ptr!=NULL) {
if (ptr->data == data) {
if(prev != NULL) {
- prev->next = NULL;
- ptr->next = thisvar->bucket[hashkey].next;
- thisvar->bucket[hashkey].next = ptr;
+ prev->next = NULL;
+ ptr->next = thisvar->bucket[hashkey].next;
+ thisvar->bucket[hashkey].next = ptr;
}
return 1; // success
#ifndef GCQUEUE_H
#define GCQUEUE_H
+#include "stdio.h"
+
#define NUMPTRS 120
struct pointerblock {
gclobjhead->next=gclobjhead->prev=NULL;
}
+////////////////////////////////////////////////////////////////////
+// functions that should be invoked with interrupts off
+////////////////////////////////////////////////////////////////////
static void gc_enqueue_I(unsigned int ptr) {
if (gcheadindex==NUMPTRS) {
struct pointerblock * tmp;
gcheadindex=0;
}
gchead->ptrs[gcheadindex++]=ptr;
-}
-
+}
// dequeue and destroy the queue
static unsigned int gc_dequeue_I() {
static int gc_lobjmoreItems4_I() {
return !((gclobjhead==gclobjtail2)&&(gclobjtailindex2==gclobjheadindex));
}
+
+////////////////////////////////////////////////////////////////////
+// functions that can be invoked in normal places
+////////////////////////////////////////////////////////////////////
+static void gc_enqueue(unsigned int ptr) {
+ BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
+ if (gcheadindex==NUMPTRS) {
+ struct pointerblock * tmp;
+ if (gcspare!=NULL) {
+ tmp=gcspare;
+ gcspare=NULL;
+ tmp->next = NULL;
+ } else {
+ tmp=RUNMALLOC_I(sizeof(struct pointerblock));
+ }
+ gchead->next=tmp;
+ gchead=tmp;
+ gcheadindex=0;
+ }
+ gchead->ptrs[gcheadindex++]=ptr;
+ BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+}
+
+static unsigned int gc_dequeue() {
+ BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
+ if (gctailindex==NUMPTRS) {
+ struct pointerblock *tmp=gctail;
+ gctail=gctail->next;
+ gctailindex=0;
+ if (gcspare!=NULL) {
+ RUNFREE_I(tmp);
+ } else {
+ gcspare=tmp;
+ gcspare->next = NULL;
+ }
+ }
+ unsigned int r = gctail->ptrs[gctailindex++];
+ BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ return r;
+}
+
+static int gc_moreItems() {
+ BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
+ int r = !((gchead==gctail)&&(gctailindex==gcheadindex));
+ BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ return r;
+}
+
+// dequeue and do not destroy the queue
+static unsigned int gc_dequeue2() {
+ BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
+ if (gctailindex2==NUMPTRS) {
+ struct pointerblock *tmp=gctail2;
+ gctail2=gctail2->next;
+ gctailindex2=0;
+ }
+ unsigned int r = gctail2->ptrs[gctailindex2++];
+ BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ return r;
+}
+
+static int gc_moreItems2() {
+ BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
+ int r = !((gchead==gctail2)&&(gctailindex2==gcheadindex));
+ BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ return r;
+}
+
+static void gc_lobjenqueue(unsigned int ptr,
+ unsigned int length,
+ unsigned int host) {
+ BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
+ if (gclobjheadindex==NUMLOBJPTRS) {
+ struct lobjpointerblock * tmp;
+ if (gclobjspare!=NULL) {
+ tmp=gclobjspare;
+ gclobjspare=NULL;
+ tmp->next = NULL;
+ tmp->prev = NULL;
+ } else {
+ tmp=RUNMALLOC_I(sizeof(struct lobjpointerblock));
+ }
+ gclobjhead->next=tmp;
+ tmp->prev = gclobjhead;
+ gclobjhead=tmp;
+ gclobjheadindex=0;
+ }
+ gclobjhead->lobjs[gclobjheadindex]=ptr;
+ gclobjhead->lengths[gclobjheadindex]=length;
+ gclobjhead->hosts[gclobjheadindex++]=host;
+ BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+}
#endif
void cacheAdapt_phase_master() {
GCPROFILEITEM();
gcphase = PREFINISHPHASE;
- gccorestatus[BAMBOO_NUM_OF_CORE] = 1;
- // Note: all cores should flush their runtime data including non-gc
- // cores
- for(i = 1; i < NUMCORESACTIVE; ++i) {
- // send start flush messages to all cores
- gccorestatus[i] = 1;
- send_msg_1(i, GCSTARTPREF, false);
- }
+ // Note: all cores should flush their runtime data including non-gc cores
+ GC_SEND_MSG_1_TO_CLIENT(GCSTARTPREF);
GC_PRINTF("Start prefinish phase \n");
// cache adapt phase
cacheAdapt_mutator();
CACHEADPAT_OUTPUT_CACHE_POLICY();
cacheAdapt_gc(false);
- gccorestatus[BAMBOO_NUM_OF_CORE] = 0;
- while(PREFINISHPHASE == gcphase) {
- // check the status of all cores
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
- if(gc_checkAllCoreStatus_I()) {
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
- break;
- }
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
- }
+ GC_CHECK_ALL_CORE_STATUS(PREFINISHPHASE == gcphase);
CACHEADAPT_SAMPING_RESET();
if(BAMBOO_NUM_OF_CORE < NUMCORESACTIVE) {
// zero out the gccachesamplingtbl
BAMBOO_MEMSET_WH(gccachesamplingtbl_local,0,size_cachesamplingtbl_local);
- BAMBOO_MEMSET_WH(gccachesamplingtbl_local_r,0,
- size_cachesamplingtbl_local_r);
+ BAMBOO_MEMSET_WH(gccachesamplingtbl_local_r,0,size_cachesamplingtbl_local_r);
BAMBOO_MEMSET_WH(gccachepolicytbl,0,size_cachepolicytbl);
}
}
-// BAMBOO_EXIT(0xb000);
// TODO: DO NOT support tag!!!
#ifdef MULTICORE_GC
#include "runtime.h"
#include "multicoregcflush.h"
#include "multicoreruntime.h"
#include "multicoregcprofile.h"
+#include "gcqueue.h"
#ifdef SMEMM
extern unsigned int gcmem_mixed_threshold;
gccurr_heaptop = 0;
gcdstcore = 0;
- gcqueue_init();
+ gc_queueinit();
freeMGCHash(gcforwardobjtbl);
gcforwardobjtbl = allocateMGCHash(20, 3);
GCPROFILE_INIT();
}
+bool gc_checkAllCoreStatus() {
+ BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
+ for(int i = 0; i < NUMCORESACTIVE; i++) {
+ if(gccorestatus[i] != 0) {
+ BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ return false;
+ }
+ }
+ BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ return true;
+}
+
+// NOTE: should be invoked with interrupts turned off
bool gc_checkAllCoreStatus_I() {
for(int i = 0; i < NUMCORESACTIVE; i++) {
if(gccorestatus[i] != 0) {
// the first time found all cores stall
// send out status confirm msg to all other cores
// reset the corestatus array too
- gccorestatus[BAMBOO_NUM_OF_CORE] = 1;
waitconfirm = true;
numconfirm = NUMCORESACTIVE - 1;
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
- for(int i = 1; i < NUMCORESACTIVE; i++) {
- gccorestatus[i] = 1;
- // send mark phase finish confirm request msg to core i
- send_msg_1(i, GCMARKCONFIRM, false);
- }
+ GC_SEND_MSG_1_TO_CLIENT(GCMARKCONFIRM);
} else {
// Phase 2
// check if the sum of send objs and receive obj are the same
}
gcloads[BAMBOO_NUM_OF_CORE] = gccurr_heaptop;
//spin until we have all responses
- while(numconfirm!=0)
- ;
+ while(numconfirm!=0) ;
// check the heaptop
if(gcheaptop < gcmarkedptrbound) {
GC_PRINTF("prepare to cache large objs \n");
// cache all large objs
- BAMBOO_ASSERTMSG(cacheLObjs(), "Not enough space to cache large objects\n", 0xb02e);
+ BAMBOO_ASSERTMSG(cacheLObjs(), "Not enough space to cache large objects\n");
}
void master_compact() {
RUNFREE(to);
}
-void master_updaterefs() {
+void master_updaterefs(struct garbagelist * stackptr) {
gcphase = FLUSHPHASE;
GC_SEND_MSG_1_TO_CLIENT(GCSTARTFLUSH);
GCPROFILE_ITEM();
master_compact();
// update the references
- master_updaterefs();
+ master_updaterefs(stackptr);
// do cache adaptation
CACHEADAPT_PHASE_MASTER();
tprintf("finish GC ! %d \n", gcflag);
}
-void pregccheck_I() {
+void pregccheck() {
while(true) {
+ BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
gcnumsendobjs[0][BAMBOO_NUM_OF_CORE] = self_numsendobjs;
gcnumreceiveobjs[0][BAMBOO_NUM_OF_CORE] = self_numreceiveobjs;
int sumsendobj = 0;
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
while(!gcprecheck) ;
-
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
} else {
+ BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
return;
}
}
if(0 == BAMBOO_NUM_OF_CORE) {
GC_PRINTF("Check if we can do gc or not\n");
gccorestatus[BAMBOO_NUM_OF_CORE] = 0;
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
- if(!gc_checkAllCoreStatus_I()) {
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ if(!gc_checkAllCoreStatus()) {
// some of the cores are still executing the mutator and did not reach
// some gc safe point, therefore it is not ready to do gc
gcflag = true;
return false;
} else {
GCPROFILE_START();
- pregccheck_I();
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ pregccheck();
}
GC_PRINTF("start gc! \n");
pregcprocessing();
{ \
gccorestatus[BAMBOO_NUM_OF_CORE] = 0; \
while(f) { \
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(); \
- if(gc_checkAllCoreStatus_I()) { \
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); \
+ if(gc_checkAllCoreStatus()) { \
break; \
} \
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(); \
} \
}
void initmulticoregcdata();
void dismulticoregcdata();
-bool gc_checkAllCoreStatus_I();
+bool gc_checkAllCoreStatus();
bool gc(struct garbagelist * stackptr); // core coordinator routine
void gc_collect(struct garbagelist* stackptr); //core collector routine
void gc_nocollect(struct garbagelist* stackptr); //non-gc core collector routine
extern int corenum;
-INLINE bool gc_checkCoreStatus_I() {
+INLINE bool gc_checkCoreStatus() {
+ BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
for(int i = 0; i < NUMCORES4GC; ++i) {
- if(gccorestatus[i] != 0)
+ if(gccorestatus[i] != 0) {
+ BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
return false;
+ }
}
+ BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
return true;
}
+INLINE void gc_resetCoreStatus() {
+ BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
+ for(int i = 0; i < NUMCORES4GC; ++i) {
+ gccorestatus[i] = 1;
+ }
+ BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+}
+
+// should be invoked with interrupt closed
+int assignSpareMem_I(unsigned int sourcecore,
+ unsigned int * requiredmem,
+ unsigned int * tomove,
+ unsigned int * startaddr) {
+ unsigned int b = 0;
+ BLOCKINDEX(gcloads[sourcecore], &b);
+ unsigned int boundptr = (b<NUMCORES4GC) ? ((b+1)*BAMBOO_SMEM_SIZE_L)
+ : (BAMBOO_LARGE_SMEM_BOUND+(b-NUMCORES4GC+1)*BAMBOO_SMEM_SIZE);
+ unsigned int remain = boundptr - gcloads[sourcecore];
+ unsigned int memneed = requiredmem + BAMBOO_CACHE_LINE_SIZE;
+ *startaddr = gcloads[sourcecore];
+ *tomove = gcfilledblocks[sourcecore] + 1;
+ if(memneed < remain) {
+ gcloads[sourcecore] += memneed;
+ return 0;
+ } else {
+ // next available block
+ gcfilledblocks[sourcecore] += 1;
+ unsigned int newbase = 0;
+ BASEPTR(sourcecore, gcfilledblocks[sourcecore], &newbase);
+ gcloads[sourcecore] = newbase;
+ return requiredmem-remain;
+ }
+}
+
+int assignSpareMem(unsigned int sourcecore,
+ unsigned int * requiredmem,
+ unsigned int * tomove,
+ unsigned int * startaddr) {
+ BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
+ unsigned int b = 0;
+ BLOCKINDEX(gcloads[sourcecore], &b);
+ unsigned int boundptr = (b<NUMCORES4GC) ? ((b+1)*BAMBOO_SMEM_SIZE_L)
+ : (BAMBOO_LARGE_SMEM_BOUND+(b-NUMCORES4GC+1)*BAMBOO_SMEM_SIZE);
+ unsigned int remain = boundptr - gcloads[sourcecore];
+ unsigned int memneed = requiredmem + BAMBOO_CACHE_LINE_SIZE;
+ *startaddr = gcloads[sourcecore];
+ *tomove = gcfilledblocks[sourcecore] + 1;
+ if(memneed < remain) {
+ gcloads[sourcecore] += memneed;
+ BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ return 0;
+ } else {
+ // next available block
+ gcfilledblocks[sourcecore] += 1;
+ unsigned int newbase = 0;
+ BASEPTR(sourcecore, gcfilledblocks[sourcecore], &newbase);
+ gcloads[sourcecore] = newbase;
+ BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ return requiredmem-remain;
+ }
+}
+
INLINE void compact2Heaptophelper_I(unsigned int coren,
unsigned int* p,
unsigned int* numblocks,
gcdstcore = gctopcore;
gcblock2fill = *numblocks + 1;
} else {
- send_msg_4(coren, GCMOVESTART, gctopcore, *p, (*numblocks) + 1, false);
+ if(BAMBOO_CHECK_SEND_MODE()) {
+ cache_msg_4(coren,GCMOVESTART,gctopcore,*p,(*numblocks)+1);
+ } else {
+ send_msg_4(coren, GCMOVESTART, gctopcore, *p, (*numblocks) + 1, true);
+ }
}
if(memneed < *remain) {
*p = *p + memneed;
// find match
unsigned int tomove = 0;
unsigned int startaddr = 0;
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
- gcrequiredmems[dstcore] = assignSpareMem_I(sourcecore,
- gcrequiredmems[dstcore],
- &tomove,
- &startaddr);
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ gcrequiredmems[dstcore] = assignSpareMem(sourcecore,
+ gcrequiredmems[dstcore],
+ &tomove,
+ &startaddr);
if(STARTUPCORE == dstcore) {
gcdstcore = sourcecore;
gctomove = true;
}
// should be invoked with interrupt closed
-INLINE int assignSpareMem_I(unsigned int sourcecore,
- unsigned int * requiredmem,
- unsigned int * tomove,
- unsigned int * startaddr) {
- unsigned int b = 0;
- BLOCKINDEX(gcloads[sourcecore], &b);
- unsigned int boundptr = (b<NUMCORES4GC) ? ((b+1)*BAMBOO_SMEM_SIZE_L)
- : (BAMBOO_LARGE_SMEM_BOUND+(b-NUMCORES4GC+1)*BAMBOO_SMEM_SIZE);
- unsigned int remain = boundptr - gcloads[sourcecore];
- unsigned int memneed = requiredmem + BAMBOO_CACHE_LINE_SIZE;
- *startaddr = gcloads[sourcecore];
- *tomove = gcfilledblocks[sourcecore] + 1;
- if(memneed < remain) {
- gcloads[sourcecore] += memneed;
- return 0;
- } else {
- // next available block
- gcfilledblocks[sourcecore] += 1;
- unsigned int newbase = 0;
- BASEPTR(sourcecore, gcfilledblocks[sourcecore], &newbase);
- gcloads[sourcecore] = newbase;
- return requiredmem-remain;
+bool gcfindSpareMem_I(unsigned int * startaddr,
+ unsigned int * tomove,
+ unsigned int * dstcore,
+ unsigned int requiredmem,
+ unsigned int requiredcore) {
+ for(int k = 0; k < NUMCORES4GC; k++) {
+ if((gccorestatus[k] == 0) && (gcfilledblocks[k] < gcstopblock[k])) {
+ // check if this stopped core has enough mem
+ assignSpareMem_I(k, requiredmem, tomove, startaddr);
+ *dstcore = k;
+ return true;
+ }
}
+ // if can not find spare mem right now, hold the request
+ gcrequiredmems[requiredcore] = requiredmem;
+ gcmovepending++;
+ return false;
}
-// should be invoked with interrupt closed
-INLINE bool gcfindSpareMem_I(unsigned int * startaddr,
- unsigned int * tomove,
- unsigned int * dstcore,
- unsigned int requiredmem,
- unsigned int requiredcore) {
+bool gcfindSpareMem(unsigned int * startaddr,
+ unsigned int * tomove,
+ unsigned int * dstcore,
+ unsigned int requiredmem,
+ unsigned int requiredcore) {
+ BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
for(int k = 0; k < NUMCORES4GC; k++) {
if((gccorestatus[k] == 0) && (gcfilledblocks[k] < gcstopblock[k])) {
// check if this stopped core has enough mem
assignSpareMem_I(k, requiredmem, tomove, startaddr);
*dstcore = k;
+ BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
return true;
}
}
// if can not find spare mem right now, hold the request
gcrequiredmems[requiredcore] = requiredmem;
gcmovepending++;
+ BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
return false;
-}
+}
INLINE bool compacthelper(struct moveHelper * orig,
struct moveHelper * to,
if((unsigned int)(orig->ptr) < (unsigned int)gcmarkedptrbound) {
// ask for more mem
gctomove = false;
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
- if(gcfindSpareMem_I(&gcmovestartaddr, &gcblock2fill, &gcdstcore,
+ if(gcfindSpareMem(&gcmovestartaddr, &gcblock2fill, &gcdstcore,
gccurr_heaptop, BAMBOO_NUM_OF_CORE)) {
gctomove = true;
} else {
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
return false;
}
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
} else {
gccorestatus[BAMBOO_NUM_OF_CORE] = 0;
gctomove = false;
if(orig->ptr < gcmarkedptrbound) {
// still have unpacked obj
- while(!gctomove)
- ;
+ while(!gctomove) ;
gctomove = false;
}
void compact() {
- BAMBOO_ASSERT(COMPACTPHASE == gcphase, 0xb025);
+ BAMBOO_ASSERT(COMPACTPHASE == gcphase);
// initialize pointers for comapcting
struct moveHelper * orig = (struct moveHelper *)RUNMALLOC(sizeof(struct moveHelper));
finishcompact = compacthelper(orig,to,&filledblocks,&heaptopptr,&localcompact);
}
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
- if(gc_checkCoreStatus_I()) {
- // all cores have finished compacting
- // restore the gcstatus of all cores
- for(int i = 0; i < NUMCORES4GC; ++i) {
- gccorestatus[i] = 1;
- }
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ if(gc_checkCoreStatus()) {
+ // all cores have finished compacting restore the gcstatus of all cores
+ gc_resetCoreStatus();
break;
} else {
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
// check if there are spare mem for pending move requires
if(COMPACTPHASE == gcphase) {
resolvePendingMoveRequest();
#define GC_BLOCK_REMAIN_SIZE(b, p) \
((b)<NUMCORES4GC)?((BAMBOO_SMEM_SIZE_L)-((p)%(BAMBOO_SMEM_SIZE_L))):((BAMBOO_SMEM_SIZE)-((p)%(BAMBOO_SMEM_SIZE)))
-INLINE bool gcfindSpareMem_I(unsigned int * startaddr,
- unsigned int * tomove,
- unsigned int * dstcore,
- unsigned int requiredmem,
- unsigned int requiredcore);
+bool gcfindSpareMem_I(unsigned int * startaddr,
+ unsigned int * tomove,
+ unsigned int * dstcore,
+ unsigned int requiredmem,
+ unsigned int requiredcore);
void compact();
void compact_master(struct moveHelper * orig, struct moveHelper * to);
#endif // MULTICORE_GC
#include "multicoreruntime.h"
#include "ObjectHash.h"
#include "GenericHashtable.h"
+#include "gcqueue.h"
/* Task specific includes */
}
// flush cached objs to be transferred
- for(struct QueueItem * item = getHead(totransobjqueue);item != NULL;item = getNextQueueItem(item);) {
+ for(struct QueueItem * item = getHead(totransobjqueue);item != NULL;item = getNextQueueItem(item)) {
struct transObjInfo * totransobj = (struct transObjInfo *)(item->objectptr);
// the obj can not be NULL
FLUSHOBJNONNULL(totransobj->objptr, 0);
BAMBOO_CACHE_MF();
flushRuntimeObj(stackptr);
- while(true) {
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
- if(!gc_moreItems_I()) {
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
- break;
- }
-
- unsigned int ptr = gc_dequeue_I();
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ while(gc_moreItems()) {
+ unsigned int ptr = gc_dequeue();
// should be a local shared obj and should have mapping info
FLUSHOBJNONNULL(ptr, 0);
- BAMBOO_ASSERT(ptr != NULL, 0xb02a);
+ BAMBOO_ASSERT(ptr != NULL);
if(((struct ___Object___ *)ptr)->marked == COMPACTED) {
flushPtrsInObj((void *)ptr);
while(gc_lobjmoreItems_I()) {
unsigned int ptr = gc_lobjdequeue_I(NULL, NULL);
FLUSHOBJ(ptr, 0);
- BAMBOO_ASSERT(ptr!=NULL, 0xb02d);
+ BAMBOO_ASSERT(ptr!=NULL);
if(((struct ___Object___ *)ptr)->marked == COMPACTED) {
flushPtrsInObj((void *)ptr);
unsigned int host = hostcore(objptr);
if(BAMBOO_NUM_OF_CORE == host) {
// on this core
-
- /*BD: I think it is probably okay to keep interrupts enabled
- * here... Reasoning is the following... Even if we enqueue an
- * object twice, the pointers in it will be marked only once
- * (we'll catch it in the mark phase), so correctness should not
- * be a concern... The chances of this actually happening are
- * pretty small, so efficiency should not be a concern
- */
-
if(((struct ___Object___ *)objptr)->marked == INIT) {
// this is the first time that this object is discovered,
// set the flag as DISCOVERED
((struct ___Object___ *)objptr)->marked = DISCOVERED;
BAMBOO_CACHE_FLUSH_LINE(objptr);
- gc_enqueue_I(objptr);
+ gc_enqueue(objptr);
}
} else {
// check if this obj has been forwarded
// enqueue root objs
INLINE void tomark(struct garbagelist * stackptr) {
- BAMBOO_ASSERT(MARKPHASE == gcphase, 0xb010);
+ BAMBOO_ASSERT(MARKPHASE == gcphase);
gcbusystatus = true;
gcnumlobjs = 0;
// mark phase
while(MARKPHASE == gcphase) {
int counter = 0;
- while(true) {
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
- if(!gc_moreItems2_I()) {
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
- break;
- }
+ while(gc_moreItems2()) {
sendStall = false;
gcbusystatus = true;
- unsigned int ptr = gc_dequeue2_I();
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
+ unsigned int ptr = gc_dequeue2();
unsigned int size = 0;
unsigned int isize = 0;
continue;
} else if(isLarge(ptr, &type, &size)) {
// ptr is a large object and not marked or enqueued
- BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
- gc_lobjenqueue_I(ptr, size, BAMBOO_NUM_OF_CORE);
+ gc_lobjenqueue(ptr, size, BAMBOO_NUM_OF_CORE);
gcnumlobjs++;
- BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
} else {
// ptr is an unmarked active object on this core
ALIGNSIZE(size, &isize);
gcloads[BAMBOO_NUM_OF_CORE] = gccurr_heaptop;
} else {
if(!sendStall) {
- send_msg_4(STARTUPCORE, GCFINISHMARK, BAMBOO_NUM_OF_CORE,
- gcself_numsendobjs, gcself_numreceiveobjs, false);
+ send_msg_4(STARTUPCORE, GCFINISHMARK, BAMBOO_NUM_OF_CORE,gcself_numsendobjs, gcself_numreceiveobjs, false);
sendStall = true;
}
}
case SMEMFIXED: {
#ifdef SMEMF
- mem = fixedmalloc_I(coren, isize, allocsize);
+ mem = fixedmalloc_I(coren, isize, allocsize);
#else
- // not supported yet
- BAMBOO_EXIT(0xe101);
+ // not supported yet
+ BAMBOO_EXIT();
#endif
break;
}
case SMEMMIXED: {
#ifdef SMEMM
- mem = mixedmalloc_I(coren, isize, allocsize);
+ mem = mixedmalloc_I(coren, isize, allocsize);
#else
- // not supported yet
- BAMBOO_EXIT(0xe102);
+ // not supported yet
+ BAMBOO_EXIT();
#endif
break;
}
if(mem == NULL) {
// no enough shared global memory
*allocsize = 0;
- BAMBOO_EXIT(0xe103);
+ BAMBOO_EXIT();
}
return mem;
}
#include "runtime.h"
#include "multicoreruntime.h"
#include "multicoretaskprofile.h"
+#include "gcqueue.h"
INLINE int checkMsgLength_I(int size) {
int type = msgdata[msgdataindex];
case GCSTARTPREF:
#endif
#endif
- msglength = 1;
+ return 1;
break;
#ifdef TASK
case GCFINISHPREF:
#endif
#endif
- msglength = 2;
+ return 2;
break;
case MEMREQUEST:
case MEMRESPONSE:
- msglength = 3;
+ return 3;
break;
case TRANSTALL:
case GCPROFILES:
#endif
#endif
- msglength = 4;
+ return 4;
break;
#ifdef TASK
case GCFINISHCOMPACT:
case GCMARKREPORT:
#endif
- msglength = 5;
+ return 5;
break;
#ifdef TASK
case REDIRECTLOCK:
- msglength = 6;
+ return 6;
break;
#endif
#endif
{ // nonfixed size
if(size > 1) {
- msglength = msgdata[(msgdataindex+1)&(BAMBOO_MSG_BUF_MASK)];
+ return msgdata[(msgdataindex+1)&(BAMBOO_MSG_BUF_MASK)];
} else {
return -1;
}
}
default:
- BAMBOO_EXIT(0xe001);
+ BAMBOO_EXIT();
break;
}
- return msglength;
+ return BAMBOO_OUT_BUF_LENGTH;
}
-INLINE void processmsg_transobj_I() {
+INLINE void processmsg_transobj_I(int msglength) {
MSG_INDEXINC_I();
struct transObjInfo * transObj=RUNMALLOC_I(sizeof(struct transObjInfo));
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE <= NUMCORESACTIVE - 1, 0xe201);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE <= NUMCORESACTIVE - 1);
// store the object and its corresponding queue info, enqueue it later
transObj->objptr = (void *)msgdata[msgdataindex];
} else {
// send a update pregc information msg to the master core
if(BAMBOO_CHECK_SEND_MODE()) {
- cache_msg_4(STARTUPCORE, GCFINISHPRE, BAMBOO_NUM_OF_CORE,
- self_numsendobjs, self_numreceiveobjs);
+ cache_msg_4(STARTUPCORE,GCFINISHPRE,BAMBOO_NUM_OF_CORE,self_numsendobjs,self_numreceiveobjs);
} else {
- send_msg_4(STARTUPCORE, GCFINISHPRE, BAMBOO_NUM_OF_CORE,
- self_numsendobjs, self_numreceiveobjs, true);
+ send_msg_4(STARTUPCORE,GCFINISHPRE,BAMBOO_NUM_OF_CORE,self_numsendobjs, self_numreceiveobjs,true);
}
}
}
}
INLINE void processmsg_transtall_I() {
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE,0xe002);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE);
int num_core = msgdata[msgdataindex];
MSG_INDEXINC_I();
INLINE void processmsg_lockgrount_I() {
MSG_INDEXINC_I();
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE <= NUMCORESACTIVE - 1, 0xe202);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE <= NUMCORESACTIVE - 1);
int data2 = msgdata[msgdataindex];
MSG_INDEXINC_I();
int data3 = msgdata[msgdataindex];
MSG_INDEXINC_I();
- BAMBOO_ASSERT((lockobj == data2) && (lock2require == data3), 0xe203);
+ BAMBOO_ASSERT((lockobj == data2) && (lock2require == data3));
lockresult = 1;
lockflag = true;
#ifndef INTERRUPT
MSG_INDEXINC_I();
int data3 = msgdata[msgdataindex];
MSG_INDEXINC_I();
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE <= NUMCORESACTIVE - 1, 0xe204);
- BAMBOO_ASSERT((lockobj == data2) && (lock2require == data3), 0xe205);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE <= NUMCORESACTIVE - 1);
+ BAMBOO_ASSERT((lockobj == data2) && (lock2require == data3));
lockresult = 0;
lockflag = true;
#ifndef INTERRUPT
MSG_INDEXINC_I(); // root request core
int data5 = msgdata[msgdataindex];
MSG_INDEXINC_I(); // request core
- int deny = processlockrequest(data1, data3, data2, data5, data4, true);
+ int deny = processlockrequest_I(data1, data3, data2, data5, data4, true);
if(deny != -1) {
// send response msg
// for 32 bit machine, the size is always 4 words, cache the msg first
if(BAMBOO_CHECK_SEND_MODE()) {
- cache_msg_4(data4, deny==1 ? REDIRECTDENY : REDIRECTGROUNT,
- data1, data2, data3);
+ cache_msg_4(data4,deny==1?REDIRECTDENY:REDIRECTGROUNT,data1,data2,data3);
} else {
- send_msg_4(data4, deny==1?REDIRECTDENY:REDIRECTGROUNT,
- data1, data2, data3, true);
+ send_msg_4(data4,deny==1?REDIRECTDENY:REDIRECTGROUNT,data1,data2,data3,true);
}
}
}
MSG_INDEXINC_I();
int data2 = msgdata[msgdataindex];
MSG_INDEXINC_I();
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE <= NUMCORESACTIVE - 1, 0xe206);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE <= NUMCORESACTIVE - 1);
BAMBOO_ASSERT(lockobj == data2, 0xe207);
int data3 = msgdata[msgdataindex];
MSG_INDEXINC_I();
MSG_INDEXINC_I();
int data3 = msgdata[msgdataindex];
MSG_INDEXINC_I();
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE <= NUMCORESACTIVE - 1, 0x2e08);
- BAMBOO_ASSERT(lockobj == data2, 0xe209);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE <= NUMCORESACTIVE - 1);
+ BAMBOO_ASSERT(lockobj == data2);
lockresult = 0;
lockflag = true;
#ifndef INTERRUPT
MSG_INDEXINC_I();
int data3 = msgdata[msgdataindex];
MSG_INDEXINC_I();
- processlockrelease(data1, data2, data3, true);
+ processlockrelease_I(data1, data2, data3, true);
}
#endif // #ifndef MULTICORE_GC
#ifdef PROFILE
INLINE void processmsg_profileoutput_I() {
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE != STARTUPCORE, 0xe20a);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE != STARTUPCORE);
stall = true;
totalexetime = msgdata[msgdataindex];
MSG_INDEXINC_I();
}
INLINE void processmsg_profilefinish_I() {
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE, 0xe20b);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE);
int data1 = msgdata[msgdataindex];
MSG_INDEXINC_I();
profilestatus[data1] = 0;
#endif // PROFILE
INLINE void processmsg_statusconfirm_I() {
- BAMBOO_ASSERT(((BAMBOO_NUM_OF_CORE != STARTUPCORE) && (BAMBOO_NUM_OF_CORE <= NUMCORESACTIVE - 1)), 0xe003);
+ BAMBOO_ASSERT(((BAMBOO_NUM_OF_CORE != STARTUPCORE) && (BAMBOO_NUM_OF_CORE <= NUMCORESACTIVE - 1)));
// send response msg
// cache the msg first
if(BAMBOO_CHECK_SEND_MODE()) {
- cache_msg_5(STARTUPCORE,STATUSREPORT,busystatus?1:0,BAMBOO_NUM_OF_CORE,
- self_numsendobjs, self_numreceiveobjs);
+ cache_msg_5(STARTUPCORE,STATUSREPORT,busystatus?1:0,BAMBOO_NUM_OF_CORE,self_numsendobjs,self_numreceiveobjs);
} else {
- send_msg_5(STARTUPCORE,STATUSREPORT,busystatus?1:0,BAMBOO_NUM_OF_CORE,
- self_numsendobjs,self_numreceiveobjs, true);
+ send_msg_5(STARTUPCORE,STATUSREPORT,busystatus?1:0,BAMBOO_NUM_OF_CORE,self_numsendobjs,self_numreceiveobjs,true);
}
}
int data4 = msgdata[msgdataindex];
MSG_INDEXINC_I();
// receive a status confirm info
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE, 0xe004);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE);
if(waitconfirm) {
numconfirm--;
}
int data2 = msgdata[msgdataindex];
MSG_INDEXINC_I();
// receive a shared memory request msg
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE, 0xe005);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE);
int allocsize = 0;
void * mem = NULL;
#ifdef MULTICORE_GC
if(mem != NULL) {
// send the start_va to request core, cache the msg first
if(BAMBOO_CHECK_SEND_MODE()) {
- cache_msg_3(data2, MEMRESPONSE, mem, allocsize);
+ cache_msg_3(data2, MEMRESPONSE, mem, allocsize);
} else {
- send_msg_3(data2, MEMRESPONSE, mem, allocsize, true);
+ send_msg_3(data2, MEMRESPONSE, mem, allocsize, true);
}
} //else if mem == NULL, the gcflag of the startup core has been set
// and all the other cores have been informed to start gc
int data3 = msgdata[msgdataindex];
MSG_INDEXINC_I();
// received a init phase finish msg
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE, 0xe006);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE);
// All cores should do init GC
gcprecheck = true;
int data1 = msgdata[msgdataindex];
MSG_INDEXINC_I();
// received a init phase finish msg
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE, 0xe007);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE);
// All cores should do init GC
if(data1 < NUMCORESACTIVE) {
int data3 = msgdata[msgdataindex];
MSG_INDEXINC_I();
// received a mark phase finish msg
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE, 0xe008);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE);
// all cores should do mark
if(data1 < NUMCORESACTIVE) {
}
INLINE void processmsg_gcfinishcompact_I() {
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE, 0xe009);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE);
int cnum = msgdata[msgdataindex];
MSG_INDEXINC_I();
int data1 = msgdata[msgdataindex];
MSG_INDEXINC_I();
// received a flush phase finish msg
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE, 0xe00a);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE);
// all cores should do flush
if(data1 < NUMCORESACTIVE) {
}
INLINE void processmsg_gcmarkconfirm_I() {
- BAMBOO_ASSERT(((BAMBOO_NUM_OF_CORE!=STARTUPCORE)&&(BAMBOO_NUM_OF_CORE<=NUMCORESACTIVE-1)), 0xe00b);
+ BAMBOO_ASSERT(((BAMBOO_NUM_OF_CORE!=STARTUPCORE)&&(BAMBOO_NUM_OF_CORE<=NUMCORESACTIVE-1)));
gcbusystatus = gc_moreItems2_I();
// send response msg, cahce the msg first
if(BAMBOO_CHECK_SEND_MODE()) {
- cache_msg_5(STARTUPCORE,GCMARKREPORT,BAMBOO_NUM_OF_CORE,gcbusystatus,
- gcself_numsendobjs,gcself_numreceiveobjs);
+ cache_msg_5(STARTUPCORE,GCMARKREPORT,BAMBOO_NUM_OF_CORE,gcbusystatus,gcself_numsendobjs,gcself_numreceiveobjs);
} else {
- send_msg_5(STARTUPCORE,GCMARKREPORT,BAMBOO_NUM_OF_CORE,gcbusystatus,
- gcself_numsendobjs,gcself_numreceiveobjs, true);
+ send_msg_5(STARTUPCORE,GCMARKREPORT,BAMBOO_NUM_OF_CORE,gcbusystatus,gcself_numsendobjs,gcself_numreceiveobjs, true);
}
}
int data4 = msgdata[msgdataindex];
MSG_INDEXINC_I();
// received a marked phase finish confirm response msg
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE, 0xe00c);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE);
int entry_index = 0;
- BAMBOO_ASSERT(waitconfirm, 0xe00d);
+ BAMBOO_ASSERT(waitconfirm);
// phase 2
numconfirm--;
INLINE void processmsg_gcmarkedobj_I() {
int data1 = msgdata[msgdataindex];
MSG_INDEXINC_I();
- BAMBOO_ASSERT(ISSHAREDOBJ(data1), 0xa0000000+(int)data1);
+ BAMBOO_ASSERT(ISSHAREDOBJ(data1));
// received a markedObj msg
if(((struct ___Object___ *)data1)->marked == INIT) {
MSG_INDEXINC_I();
int data2 = msgdata[msgdataindex];
MSG_INDEXINC_I();
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE <= NUMCORES4GC - 1, 0xe00e);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE <= NUMCORES4GC - 1);
// store the mark result info
int cnum = data2;
int data1 = msgdata[msgdataindex];
MSG_INDEXINC_I();
// received a flush phase finish msg
- BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE, 0xe00f);
+ BAMBOO_ASSERT(BAMBOO_NUM_OF_CORE == STARTUPCORE);
// all cores should do flush
if(data1 < NUMCORESACTIVE) {
processmsg:
// processing received msgs
int size = 0;
+ int msglength = 0;
MSG_REMAINSIZE_I(&size);
- if((size == 0) || (checkMsgLength_I(size) == -1)) {
+ if((size == 0) || ((msglength=checkMsgLength_I(size)) == -1)) {
// not a whole msg
// have new coming msg
if((BAMBOO_MSG_AVAIL() != 0) && !msgdatafull) {
#ifdef TASK
case TRANSOBJ: {
// receive a object transfer msg
- processmsg_transobj_I();
+ processmsg_transobj_I(msglength);
break;
}
#endif
default:
break;
}
- msglength = BAMBOO_MSG_BUF_LENGTH;
if((msgdataindex != msgdatalast) || (msgdatafull)) {
// still have available msg
volatile int msgdataindex;
volatile int msgdatalast;
//BAD! BAD! BAD! THIS SHOULD NOT BE A GLOBAL!!!!
-int msglength;
+//int msglength;
volatile bool msgdatafull;
int outmsgdata[BAMBOO_OUT_BUF_LENGTH];
int outmsgindex;
#define OUTMSG_LASTINDEXINC() \
outmsglast = (outmsglast + 1) & (BAMBOO_OUT_BUF_MASK); \
if(outmsglast == outmsgindex) { \
- BAMBOO_EXIT(0xd101); \
+ BAMBOO_EXIT(); \
}
#define OUTMSG_CACHE(n) \
} MSGTYPE;
// msg related functions
-INLINE void send_hanging_msg(bool isInterrupt);
-INLINE void send_msg_1(int targetcore,
- unsigned long n0,
- bool isInterrupt);
-INLINE void send_msg_2(int targetcore,
- unsigned long n0,
- unsigned long n1,
- bool isInterrupt);
-INLINE void send_msg_3(int targetcore,
- unsigned long n0,
- unsigned long n1,
- unsigned long n2,
- bool isInterrupt);
-INLINE void send_msg_4(int targetcore,
- unsigned long n0,
- unsigned long n1,
- unsigned long n2,
- unsigned long n3,
- bool isInterrupt);
-INLINE void send_msg_5(int targetcore,
- unsigned long n0,
- unsigned long n1,
- unsigned long n2,
- unsigned long n3,
- unsigned long n4,
- bool isInterrupt);
-INLINE void send_msg_6(int targetcore,
- unsigned long n0,
- unsigned long n1,
- unsigned long n2,
- unsigned long n3,
- unsigned long n4,
- unsigned long n5,
- bool isInterrupt);
-INLINE void cache_msg_1(int targetcore,
- unsigned long n0);
-INLINE void cache_msg_2(int targetcore,
- unsigned long n0,
- unsigned long n1);
-INLINE void cache_msg_3(int targetcore,
- unsigned long n0,
- unsigned long n1,
- unsigned long n2);
-INLINE void cache_msg_4(int targetcore,
- unsigned long n0,
- unsigned long n1,
- unsigned long n2,
- unsigned long n3);
-INLINE void cache_msg_5(int targetcore,
- unsigned long n0,
- unsigned long n1,
- unsigned long n2,
- unsigned long n3,
- unsigned long n4);
-INLINE void cache_msg_6(int targetcore,
- unsigned long n0,
- unsigned long n1,
- unsigned long n2,
- unsigned long n3,
- unsigned long n4,
- unsigned long n5);
-INLINE int receiveMsg(unsigned int send_port_pending);
+void send_hanging_msg(bool isInterrupt);
+void send_msg_1(int targetcore,unsigned long n0,bool isInterrupt);
+void send_msg_2(int targetcore,unsigned long n0,unsigned long n1,bool isInterrupt);
+void send_msg_3(int targetcore,unsigned long n0,unsigned long n1,unsigned long n2,bool isInterrupt);
+void send_msg_4(int targetcore,unsigned long n0,unsigned long n1,unsigned long n2,unsigned long n3,bool isInterrupt);
+void send_msg_5(int targetcore,unsigned long n0,unsigned long n1,unsigned long n2,unsigned long n3,unsigned long n4,bool isInterrupt);
+void send_msg_6(int targetcore,unsigned long n0,unsigned long n1,unsigned long n2,unsigned long n3,unsigned long n4,unsigned long n5,bool isInterrupt);
+void cache_msg_1(int targetcore,unsigned long n0);
+void cache_msg_2(int targetcore,unsigned long n0,unsigned long n1);
+void cache_msg_3(int targetcore,unsigned long n0,unsigned long n1,unsigned long n2);
+void cache_msg_4(int targetcore,unsigned long n0,unsigned long n1,unsigned long n2,unsigned long n3);
+void cache_msg_5(int targetcore,unsigned long n0,unsigned long n1,unsigned long n2,unsigned long n3,unsigned long n4);
+void cache_msg_6(int targetcore,unsigned long n0,unsigned long n1,unsigned long n2,unsigned long n3,unsigned long n4,unsigned long n5);
+int receiveMsg(unsigned int send_port_pending);
#ifdef TASK
-INLINE void transferObject(struct transObjInfo * transObj);
+void transferObject(struct transObjInfo * transObj);
#endif
#ifdef MULTICORE_GC
-INLINE void transferMarkResults();
+void transferMarkResults();
#endif
#endif // MULTICORE
// gc_profile mode, output gc prfiling data
#ifdef MULTICORE_GC
if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
- BAMBOO_PRINT(BAMBOO_GET_EXE_TIME());
- BAMBOO_PRINT(0xbbbbbbbb);
CACHEADAPT_DISABLE_TIMER();
GC_OUTPUT_PROFILE_DATA();
}
#endif
- BAMBOO_EXIT(___status___);
+ BAMBOO_EXIT_APP(___status___);
}
#ifdef D___Vector______removeElement_____AR_L___Object____I_I
#ifdef THREADS
threadexit();
#elif defined MGC
- BAMBOO_EXIT(0xa0000000 + num);
+ BAMBOO_EXIT();
#else
exit(-1);
#endif
printf("Array out of bounds\n");
longjmp(error_handler,2);
#else
- BAMBOO_EXIT(0xa0000000 + num);
+ BAMBOO_EXIT();
#endif
#endif
}
#ifdef THREADS
threadexit();
#elif defined MGC
- BAMBOO_EXIT(0xa001);
+ BAMBOO_EXIT();
#else
exit(-1);
#endif
printf("NULL ptr\n");
longjmp(error_handler,2);
#else
- BAMBOO_EXIT(0xa001);
+ BAMBOO_EXIT();
#endif
#endif
}
}
msgdataindex = 0;
msgdatalast = 0;
- msglength = BAMBOO_MSG_BUF_LENGTH;
+ //msglength = BAMBOO_MSG_BUF_LENGTH;
msgdatafull = false;
for(i = 0; i < BAMBOO_OUT_BUF_LENGTH; ++i) {
outmsgdata[i] = -1;
#endif // USEIO
}
-INLINE void getprofiledata() {
+INLINE void getprofiledata_I() {
//profile mode, send msgs to other cores to request pouring out progiling data
#ifdef PROFILE
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
// terminate; for profiling mode, send request to all
// other cores to pour out profiling data
recordtotalexetime();
- getprofiledata();
+ getprofiledata_I();
CACHEADAPT_DISABLE_TIMER();
GC_OUTPUT_PROFILE_DATA();
disruntimedata();
} else {
// send StallMsg to startup core
// send stall msg
- send_msg_4(STARTUPCORE, TRANSTALL, BAMBOO_NUM_OF_CORE,
- self_numsendobjs, self_numreceiveobjs, false);
+ send_msg_4(STARTUPCORE, TRANSTALL, BAMBOO_NUM_OF_CORE,self_numsendobjs, self_numreceiveobjs, false);
sendStall = true;
isfirst = true;
busystatus = false;
INLINE void terminatememprof(void);
#endif // BAMBOO_MEMPROF
-// Would probably be better to just have these print out line numbers...
-// But not going to do that without consultation
-
-//Macros for performance runs....to eliminate assertions if we don't need them
-//#define BAMBOO_ASSERT(x, y) ;
-//#define BAMBOO_ASSERTMSG(x, y, z) ;
-
-#define BAMBOO_ASSERT(x, y) if (!x) BAMBOO_EXIT(y);
-#define BAMBOO_ASSERTMSG(x, y, z) if (!x) {GC_PRINTF(y); BAMBOO_EXIT(z);}
-
///////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// BAMBOO_DEBUGPRINT(x): print out integer x //
// BAMBOO_DEBUGPRINT_REG(x): print out value of variable x //
// BAMBOO_EXIT_APP(x): exit the whole application //
-// BAMBOO_EXIT(x): error exit routine with error # //
+// BAMBOO_EXIT(x): error exit routine with file name and line # //
// BAMBOO_DIE(x): error exit routine with error msg //
+// BAMBOO_ASSERT(x) : check if condition x is met //
+// BAMBOO_ASSERTMSG(x.y): check if condition x is met or not, if not, print//
+// out msg y //
// BAMBOO_GET_EXE_TIME(): rountine to get current clock cycle number //
// BAMBOO_MSG_AVAIL(): checking if there are msgs coming in //
// BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(): change to runtime mode from //
while(!isEmpty(&objqueue)) {
void * obj = NULL;
BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
- BAMBOO_DEBUGPRINT(0xf001);
- BAMBOO_DEBUGPRINT(0xeee1);
rflag = true;
objInfo = (struct transObjInfo *)getItem(&objqueue);
obj = objInfo->objptr;
- BAMBOO_DEBUGPRINT_REG((int)obj);
// grab lock and flush the obj
grount = 0;
struct ___Object___ * tmpobj = (struct ___Object___ *)obj;
BAMBOO_WAITING_FOR_LOCK(0);
}
grount = lockresult;
- BAMBOO_DEBUGPRINT_REG(grount);
lockresult = 0;
lockobj = 0;
int paramindex = objInfo->queues[2 * k + 1];
struct parameterwrapper ** queues =
&(paramqueues[BAMBOO_NUM_OF_CORE][taskindex][paramindex]);
- BAMBOO_DEBUGPRINT_REG(taskindex);
- BAMBOO_DEBUGPRINT_REG(paramindex);
enqueueObject_I(obj, queues, 1);
- BAMBOO_DEBUGPRINT_REG(hashsize(activetasks));
}
releasewritelock_I(tmpobj);
RUNFREE_I(objInfo->queues);
addNewItem_I(&objqueue, objInfo);
objqueuebreak:
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
- BAMBOO_DEBUGPRINT(0xf000);
break;
}
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
- BAMBOO_DEBUGPRINT(0xf000);
}
#ifdef ACCURATEPROFILE
PROFILE_TASK_END();
#endif
- BAMBOO_DEBUGPRINT(0xee02);
return rflag;
}
int reallock = (int)lock;
targetcore = (reallock >> 5) % NUMCORES;
- BAMBOO_DEBUGPRINT(0xe671);
- BAMBOO_DEBUGPRINT_REG((int)lock);
- BAMBOO_DEBUGPRINT_REG(reallock);
- BAMBOO_DEBUGPRINT_REG(targetcore);
-
if(targetcore == BAMBOO_NUM_OF_CORE) {
BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
- BAMBOO_DEBUGPRINT(0xf001);
// reside on this core
if(!RuntimeHashcontainskey(locktbl, reallock)) {
// no locks for this object, something is wrong
- BAMBOO_EXIT(0xe20c);
+ BAMBOO_EXIT();
} else {
int rwlock_obj = 0;
struct LockValue * lockvalue = NULL;
- BAMBOO_DEBUGPRINT(0xe672);
RuntimeHashget(locktbl, reallock, &rwlock_obj);
lockvalue = (struct LockValue *)rwlock_obj;
- BAMBOO_DEBUGPRINT_REG(lockvalue->value);
lockvalue->value++;
lockvalue->redirectlock = (int)redirectlock;
- BAMBOO_DEBUGPRINT_REG(lockvalue->value);
}
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
- BAMBOO_DEBUGPRINT(0xf000);
return;
} else {
// send lock release with redirect info msg
// for 32 bit machine, the size is always 4 words
- send_msg_4(targetcore, REDIRECTRELEASE, 1, (int)lock,
- (int)redirectlock, false);
+ send_msg_4(targetcore,REDIRECTRELEASE,1,(int)lock,(int)redirectlock,false);
}
}
#endif
newtask:
while(hashsize(activetasks)>0) {
GCCHECK(NULL);
- BAMBOO_DEBUGPRINT(0xe990);
/* See if there are any active tasks */
int i;
}
} // for(i = 0; i < numparams; i++)
// grab these required locks
- BAMBOO_DEBUGPRINT(0xe991);
for(i = 0; i < runtime_locklen; i++) {
int * lock = (int *)(runtime_locks[i].value);
islock = true;
// require locks for this parameter if it is not a startup object
- BAMBOO_DEBUGPRINT_REG((int)lock);
- BAMBOO_DEBUGPRINT_REG((int)(runtime_locks[i].value));
getwritelock(lock);
BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
- BAMBOO_DEBUGPRINT(0xf001);
while(!lockflag) {
BAMBOO_WAITING_FOR_LOCK(0);
}
reside = false;
#endif
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
- BAMBOO_DEBUGPRINT(0xf000);
if(grount == 0) {
- BAMBOO_DEBUGPRINT(0xe992);
- BAMBOO_DEBUGPRINT_REG(lock);
// check if has the lock already
// can not get the lock, try later
// release all grabbed locks for previous parameters
}
} // line 2752: for(i = 0; i < runtime_locklen; i++)
- BAMBOO_DEBUGPRINT(0xe993);
/* Make sure that the parameters are still in the queues */
for(i=0; i<numparams; i++) {
void * parameter=currtpd->parameterArray[i];
/* Check that object is still in queue */
{
if (!ObjectHashcontainskey(pw->objectset, (int) parameter)) {
- BAMBOO_DEBUGPRINT(0xe994);
- BAMBOO_DEBUGPRINT_REG(parameter);
// release grabbed locks
for(j = 0; j < runtime_locklen; j++) {
int * lock = (int *)(runtime_locks[j].value);
int next;
int UNUSED, UNUSED2;
int * enterflags;
- BAMBOO_DEBUGPRINT(0xe995);
- BAMBOO_DEBUGPRINT_REG(parameter);
ObjectHashget(pw->objectset, (int) parameter, (int *) &next,
(int *) &enterflags, &UNUSED, &UNUSED2);
ObjectHashremove(pw->objectset, (int)parameter);
int slotid=pd->tagarray[2*j]+numparams;
struct ___TagDescriptor___ *tagd=currtpd->parameterArray[slotid];
if (!containstag(parameter, tagd)) {
- BAMBOO_DEBUGPRINT(0xe996);
// release grabbed locks
int tmpj = 0;
for(tmpj = 0; tmpj < runtime_locklen; tmpj++) {
#endif
PROFILE_TASK_START(currtpd->task->name);
- BAMBOO_DEBUGPRINT(0xe997);
((void (*)(void **))currtpd->task->taskptr)(taskpointerarray);
#ifdef ACCURATEPROFILE
// new a PostTaskInfo for the post-task execution
PROFILE_TASK_START("post task execution");
#endif
- BAMBOO_DEBUGPRINT(0xe998);
- BAMBOO_DEBUGPRINT_REG(islock);
if(islock) {
- BAMBOO_DEBUGPRINT(0xe999);
for(i = runtime_locklen; i>0; i--) {
void * ptr = (void *)(runtime_locks[i-1].redirectlock);
int * lock = (int *)(runtime_locks[i-1].value);
- BAMBOO_DEBUGPRINT_REG((int)ptr);
- BAMBOO_DEBUGPRINT_REG((int)lock);
- BAMBOO_DEBUGPRINT_REG(*((int*)lock+5));
#ifndef MULTICORE_GC
#ifndef TILERA_BME
if(RuntimeHashcontainskey(lockRedirectTbl, (int)lock)) {
RUNFREE(currtpd->parameterArray);
RUNFREE(currtpd);
currtpd = NULL;
- BAMBOO_DEBUGPRINT(0xe99a);
}
} // while(hashsize(activetasks)>0)
- BAMBOO_DEBUGPRINT(0xe99b);
}
/* This function processes an objects tags */
// if return -1: the lock request is redirected
// 0: the lock request is approved
// 1: the lock request is denied
-INLINE int processlockrequest(int locktype,
- int lock,
- int obj,
- int requestcore,
- int rootrequestcore,
- bool cache);
-INLINE void processlockrelease(int locktype,
- int lock,
- int redirectlock,
- bool redirect);
+INLINE int processlockrequest_I(int locktype,
+ int lock,
+ int obj,
+ int requestcore,
+ int rootrequestcore,
+ bool cache);
+INLINE void processlockrelease_I(int locktype,
+ int lock,
+ int redirectlock,
+ bool redirect);
INLINE void inittaskdata();
INLINE void distaskdata();
hasgc++;
} else {
// no more global shared memory
- BAMBOO_EXIT(0xc001);
+ BAMBOO_EXIT();
}
// try to malloc again
p = BAMBOO_SHARE_MEM_CALLOC_I(m, isize); // calloc(m, isize);
if(p == NULL) {
// no more global shared memory
- BAMBOO_EXIT(0xc002);
+ BAMBOO_EXIT();
}
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
return
}
#endif
printf("mycalloc %s %d \n", file, line);
- BAMBOO_EXIT(0xc003);
+ BAMBOO_EXIT();
}
BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
return p;
}
#endif
tprintf("mycalloc_i %s %d \n", file, line);
- BAMBOO_EXIT(0xc004);
+ BAMBOO_EXIT();
}
return p;
}