private Vector<Schedule> scheduling;
int coreNum;
int tcoreNum;
+ int gcoreNum;
Schedule currentSchedule;
Hashtable[] fsate2qnames;
String objqarrayprefix= "objqueuearray4class";
SafetyAnalysis sa,
Vector<Schedule> scheduling,
int coreNum,
+ int gcoreNum,
PrefetchAnalysis pa) {
super(st, temptovar, typeutil, sa, pa);
this.scheduling = scheduling;
- this.coreNum = coreNum;
- this.tcoreNum = coreNum;
+ this.coreNum = coreNum; // # of the active cores
+ this.tcoreNum = coreNum; // # of the cores setup by users
+ this.gcoreNum = gcoreNum; // # of the cores for gc if any
this.currentSchedule = null;
this.fsate2qnames = null;
this.startupcorenum = 0;
/* Record number of total cores */
outstructs.println("#define NUMCORES "+this.tcoreNum);
/* Record number of active cores */
- outstructs.println("#define NUMCORESACTIVE "+this.coreNum);
+ outstructs.println("#define NUMCORESACTIVE "+this.coreNum); // this.coreNum
+ // can be reset by the scheduling analysis
+ /* Record number of garbage collection cores */
+ outtask.println("#ifdef MULTICORE_GC");
+ outstructs.println("#define NUMCORES4GC "+this.gcoreNum);
+ outtask.println("#endif");
/* Record number of core containing startup task */
outstructs.println("#define STARTUPCORE "+this.startupcorenum);
} //else if (state.main!=null) {
public boolean HYBRID=false;
//Other options
public int CORENUM = 1;
+ public int CORENUM4GC = 0;
public String structfile;
public String main;
public String outputdir = "/scratch/";
} else if(option.equals("-numcore")) {
++i;
state.CORENUM = Integer.parseInt(args[i]);
+ } else if(option.equals("-numcore4gc")) {
+ ++i;
+ state.CORENUM4GC = Integer.parseInt(args[i]);
} else if (option.equals("-mainclass"))
state.main=args[++i];
else if (option.equals("-trueprob")) {
sa,
scheduling,
mcImplSynthesis.getCoreNum(),
+ state.CORENUM4GC,
pa);
bcm.setOwnershipAnalysis(oa);
bcm.buildCode();
}
// compute core #
if(advanceblock) {
- coren = gc_block2core[block%(NUMCORES*2)];
+ coren = gc_block2core[block%(NUMCORES4GC*2)];
}
// compute core coordinate
- int tmpcore = coren;
- if((NUMCORES==62) && (tmpcore > 5)) {
+ /*int tmpcore = coren;
+ if((NUMCORES4GC==62) && (tmpcore > 5)) {
tmpcore+=2;
}
x = tmpcore/bamboo_width;
- y = tmpcore%bamboo_width;
+ y = tmpcore%bamboo_width;*/
+ x = bamboo_cpu2coords[coren*2];
+ y = bamboo_cpu2coords[coren*2+1];
tprintf("==== %d, %d : core (%d,%d), saddr %x====\n",
block, sblock++, x, y,
(sblock-1)*(BAMBOO_SMEM_SIZE)+BAMBOO_BASE_VA);
inline bool gc_checkCoreStatus() {
bool allStall = true;
- for(int i = 0; i < NUMCORES; ++i) {
+ for(int i = 0; i < NUMCORES4GC; ++i) {
if(gccorestatus[i] != 0) {
allStall = false;
break;
} // if(gccorestatus[i] != 0)
- } // for(i = 0; i < NUMCORES; ++i)
+ } // for(i = 0; i < NUMCORES4GC; ++i)
return allStall;
}
// check if the sum of send objs and receive obj are the same
// yes->check if the info is the latest; no->go on executing
int sumsendobj = 0;
- for(i = 0; i < NUMCORES; ++i) {
+ for(i = 0; i < NUMCORES4GC; ++i) {
sumsendobj += gcnumsendobjs[i];
- } // for(i = 0; i < NUMCORES; ++i)
+ } // for(i = 0; i < NUMCORES4GC; ++i)
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xee05);
BAMBOO_DEBUGPRINT_REG(sumsendobj);
#endif
- for(i = 0; i < NUMCORES; ++i) {
+ for(i = 0; i < NUMCORES4GC; ++i) {
sumsendobj -= gcnumreceiveobjs[i];
- } // for(i = 0; i < NUMCORES; ++i)
+ } // for(i = 0; i < NUMCORES4GC; ++i)
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xee06);
BAMBOO_DEBUGPRINT_REG(sumsendobj);
// reset the corestatus array too
gccorestatus[BAMBOO_NUM_OF_CORE] = 1;
waitconfirm = true;
- numconfirm = NUMCORES - 1;
- for(i = 1; i < NUMCORES; ++i) {
+ numconfirm = NUMCORES4GC - 1;
+ for(i = 1; i < NUMCORES4GC; ++i) {
gccorestatus[i] = 1;
// send mark phase finish confirm request msg to core i
send_msg_1(i, GCMARKCONFIRM);
- } // for(i = 1; i < NUMCORES; ++i)
+ } // for(i = 1; i < NUMCORES4GC; ++i)
} else {
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xee09);
// stop mark phase
gcphase = COMPACTPHASE;
// restore the gcstatus for all cores
- for(i = 0; i < NUMCORES; ++i) {
+ for(i = 0; i < NUMCORES4GC; ++i) {
gccorestatus[i] = 1;
- } // for(i = 0; i < NUMCORES; ++i)
+ } // for(i = 0; i < NUMCORES4GC; ++i)
} // if(!gcwautconfirm) else()
} // if(0 == sumsendobj)
} // if(allStall)
inline void initGC() {
int i;
if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
- for(i = 0; i < NUMCORES; ++i) {
+ for(i = 0; i < NUMCORES4GC; ++i) {
gccorestatus[i] = 1;
gcnumsendobjs[i] = 0;
gcnumreceiveobjs[i] = 0;
gcrequiredmems[i] = 0;
gcfilledblocks[i] = 0;
gcstopblock[i] = 0;
- } // for(i = 0; i < NUMCORES; ++i)
+ } // for(i = 0; i < NUMCORES4GC; ++i)
gcheaptop = 0;
gctopcore = 0;
gctopblock = 0;
// get the total loads
int tloads = gcloads[STARTUPCORE];
- for(i = 1; i < NUMCORES; i++) {
+ for(i = 1; i < NUMCORES4GC; i++) {
tloads += gcloads[i];
}
int heaptop = gcbaseva + tloads;
#endif
int b = 0;
BLOCKINDEX(heaptop, &b);
- int numbpc = b / NUMCORES; // num of blocks per core
+ int numbpc = b / NUMCORES4GC; // num of blocks per core
#ifdef DEBUG
BAMBOO_DEBUGPRINT_REG(b);
BAMBOO_DEBUGPRINT_REG(numbpc);
int j = 0;
int toset = 0;
do{
- toset = gc_core2block[2*coren+i]+(NUMCORES*2)*j;
+ toset = gc_core2block[2*coren+i]+(NUMCORES4GC*2)*j;
if(toset < ltopcore) {
- gcsmemtbl[toset]=(toset<NUMCORES)?BAMBOO_SMEM_SIZE_L:BAMBOO_SMEM_SIZE;
+ gcsmemtbl[toset]=(toset<NUMCORES4GC)?BAMBOO_SMEM_SIZE_L:BAMBOO_SMEM_SIZE;
} else if(toset == ltopcore) {
gcsmemtbl[toset] = load;
break;
BAMBOO_DEBUGPRINT_REG(gcloads[0]);
BAMBOO_DEBUGPRINT_REG(gcsmemtbl[0]);
#endif
- for(int i = 1; i < NUMCORES; i++) {
+ for(int i = 1; i < NUMCORES4GC; i++) {
int tmptop = 0;
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xf000+i);
#ifdef DEBUG
BAMBOO_DEBUGPRINT_REG(gcloads[i]);
#endif
- } // for(int i = 1; i < NUMCORES; i++) {
+ } // for(int i = 1; i < NUMCORES4GC; i++) {
// find current heap top
// TODO
if(i == -1) {
tmpheaptop = gcbaseva;
} else {
- tmpheaptop = gcbaseva+gcsmemtbl[i]+((i<NUMCORES)?(BAMBOO_SMEM_SIZE_L*i):
- (BAMBOO_SMEM_SIZE*(i-NUMCORES)+BAMBOO_LARGE_SMEM_BOUND));
+ tmpheaptop = gcbaseva+gcsmemtbl[i]+((i<NUMCORES4GC)?
+ (BAMBOO_SMEM_SIZE_L*i):
+ (BAMBOO_SMEM_SIZE*(i-NUMCORES4GC)+BAMBOO_LARGE_SMEM_BOUND));
}
// move large objs from gcheaptop to tmpheaptop
// write the header first
gcsbstarttbl[sb+k] = (INTPTR)(-1);
}
sb += tmpsbs;
- bound = (b<NUMCORES)?BAMBOO_SMEM_SIZE_L:BAMBOO_SMEM_SIZE;
+ bound = (b<NUMCORES4GC)?BAMBOO_SMEM_SIZE_L:BAMBOO_SMEM_SIZE;
BLOCKINDEX(tmpheaptop-1, &tmpsbs);
for(; b < tmpsbs; b++) {
gcsmemtbl[b] = bound;
- if(b==NUMCORES-1) {
+ if(b==NUMCORES4GC-1) {
bound = BAMBOO_SMEM_SIZE;
}
}
// blank one
if(startptr == 0) {
// a start of a new free mem chunk
- startptr = gcbaseva+((i<NUMCORES)?(i*BAMBOO_SMEM_SIZE_L)
- :(BAMBOO_LARGE_SMEM_BOUND+(i-NUMCORES)*BAMBOO_SMEM_SIZE));
+ startptr = gcbaseva+((i<NUMCORES4GC)?(i*BAMBOO_SMEM_SIZE_L)
+ :(BAMBOO_LARGE_SMEM_BOUND+(i-NUMCORES4GC)*BAMBOO_SMEM_SIZE));
} // if(startptr == 0)
size += bound;
} else {
//size = 0;
}
// start of a new free mem chunk
- startptr = gcbaseva+((i<NUMCORES)?(i*BAMBOO_SMEM_SIZE_L)
- :((BAMBOO_LARGE_SMEM_BOUND+(i-NUMCORES)*BAMBOO_SMEM_SIZE)))
- +gcsmemtbl[i];
+ startptr = gcbaseva+((i<NUMCORES4GC)?(i*BAMBOO_SMEM_SIZE_L)
+ :((BAMBOO_LARGE_SMEM_BOUND+(i-NUMCORES4GC)*BAMBOO_SMEM_SIZE)))
+ +gcsmemtbl[i];
size = bound-gcsmemtbl[i];
} // if(gcsmemtbl[i] == 0) else
} else {
size = 0;
} // if(startptr != 0) {
} // if(gcsmemtbl[i] < bound) else
- if(i == NUMCORES-1) {
+ if(i == NUMCORES4GC-1) {
bound = BAMBOO_SMEM_SIZE;
}
} // for(i = 0; i < gcnumblock; i++) {
*numblocks = gcstopblock[gctopcore];
*p = gcloads[gctopcore];
BLOCKINDEX(*p, &b);
- *remain=(b<NUMCORES)?((BAMBOO_SMEM_SIZE_L)-((*p)%(BAMBOO_SMEM_SIZE_L)))
- :((BAMBOO_SMEM_SIZE)-((*p)%(BAMBOO_SMEM_SIZE)));
+ *remain=(b<NUMCORES4GC)?
+ ((BAMBOO_SMEM_SIZE_L)-((*p)%(BAMBOO_SMEM_SIZE_L)))
+ :((BAMBOO_SMEM_SIZE)-((*p)%(BAMBOO_SMEM_SIZE)));
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xd106);
BAMBOO_DEBUGPRINT_REG(gctopcore);
p = gcloads[gctopcore];
int b;
BLOCKINDEX(p, &b);
- int remain = (b<NUMCORES)?((BAMBOO_SMEM_SIZE_L)-(p%(BAMBOO_SMEM_SIZE_L)))
- :((BAMBOO_SMEM_SIZE)-(p%(BAMBOO_SMEM_SIZE)));
+ int remain = (b<NUMCORES4GC)?
+ ((BAMBOO_SMEM_SIZE_L)-(p%(BAMBOO_SMEM_SIZE_L)))
+ :((BAMBOO_SMEM_SIZE)-(p%(BAMBOO_SMEM_SIZE)));
// check if the top core finishes
if(gccorestatus[gctopcore] != 0) {
#ifdef DEBUG
remain -= gcreservedsb*BAMBOO_SMEM_SIZE;
p += gcreservedsb*BAMBOO_SMEM_SIZE;
}*/
- for(int i = 0; i < NUMCORES; i++) {
+ for(int i = 0; i < NUMCORES4GC; i++) {
BAMBOO_START_CRITICAL_SECTION();
if((gccorestatus[i] != 0) && (gcrequiredmems[i] > 0)) {
#ifdef DEBUG
}
} // if((gccorestatus[i] != 0) && (gcrequiredmems[i] > 0))
BAMBOO_CLOSE_CRITICAL_SECTION();
- } // for(i = 0; i < NUMCORES; i++)
+ } // for(i = 0; i < NUMCORES4GC; i++)
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xd106);
#endif
#endif
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xeeee);
- for(int k = 0; k < NUMCORES; k++) {
+ for(int k = 0; k < NUMCORES4GC; k++) {
BAMBOO_DEBUGPRINT(0xf000+k);
BAMBOO_DEBUGPRINT_REG(gccorestatus[k]);
BAMBOO_DEBUGPRINT_REG(gcloads[k]);
bool noblock = false;
int dstcore = 0; // the core who need spare mem
int sourcecore = 0; // the core who has spare mem
- for(i = j = 0; (i < NUMCORES) && (j < NUMCORES);) {
+ for(i = j = 0; (i < NUMCORES4GC) && (j < NUMCORES4GC);) {
if(nosparemem) {
// check if there are cores with spare mem
if(gccorestatus[i] == 0) {
haspending = false;
noblock = true;
}
- } // for(i = 0; i < NUMCORES; i++)
+ } // for(i = 0; i < NUMCORES4GC; i++)
#ifdef DEBUG
BAMBOO_DEBUGPRINT(0xcccc);
BAMBOO_DEBUGPRINT_REG(hasrunning);
int * startaddr) {
int b = 0;
BLOCKINDEX(gcloads[sourcecore], &b);
- int boundptr = (b<NUMCORES)?((b+1)*BAMBOO_SMEM_SIZE_L)
- :(BAMBOO_LARGE_SMEM_BOUND+(b-NUMCORES+1)*BAMBOO_SMEM_SIZE);
+ int boundptr = (b<NUMCORES4GC)?((b+1)*BAMBOO_SMEM_SIZE_L)
+ :(BAMBOO_LARGE_SMEM_BOUND+(b-NUMCORES4GC+1)*BAMBOO_SMEM_SIZE);
int remain = boundptr - gcloads[sourcecore];
int memneed = requiredmem + BAMBOO_CACHE_LINE_SIZE;
*startaddr = gcloads[sourcecore];
int * dstcore,
int requiredmem,
int requiredcore) {
- for(int k = 0; k < NUMCORES; k++) {
+ 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);
waitconfirm = false;
waitconfirm = 0;
gcphase = INITPHASE;
- for(i = 1; i < NUMCORES; i++) {
+ for(i = 1; i < NUMCORES4GC; i++) {
// send GC init messages to all cores
send_msg_1(i, GCSTARTINIT);
}
// all cores have finished compacting
// restore the gcstatus of all cores
gccorestatus[BAMBOO_NUM_OF_CORE] = 1;
- for(i = 1; i < NUMCORES; ++i) {
+ for(i = 1; i < NUMCORES4GC; ++i) {
gccorestatus[i] = 1;
// send GC start messages to all cores
send_msg_1(i, GCSTART);
checkMarkStatue();
} // while(MARKPHASE == gcphase)
// send msgs to all cores requiring large objs info
- numconfirm = NUMCORES - 1;
- for(i = 1; i < NUMCORES; ++i) {
+ numconfirm = NUMCORES4GC - 1;
+ for(i = 1; i < NUMCORES4GC; ++i) {
send_msg_1(i, GCLOBJREQUEST);
}
gcloads[BAMBOO_NUM_OF_CORE] = gccurr_heaptop;
BAMBOO_DEBUGPRINT(0xabab);
BAMBOO_DEBUGPRINT_REG(tmptopptr);
#endif
- for(i = 0; i < NUMCORES; ++i) {
+ for(i = 0; i < NUMCORES4GC; ++i) {
int tmpcoreptr = 0;
BASEPTR(i, 0, &tmpcoreptr);
//send start compact messages to all cores
if(gc_checkCoreStatus()) {
// all cores have finished compacting
// restore the gcstatus of all cores
- for(i = 0; i < NUMCORES; ++i) {
+ for(i = 0; i < NUMCORES4GC; ++i) {
gccorestatus[i] = 1;
}
break;
gcphase = FLUSHPHASE;
gccorestatus[BAMBOO_NUM_OF_CORE] = 1;
- for(i = 1; i < NUMCORES; ++i) {
+ for(i = 1; i < NUMCORES4GC; ++i) {
// send start flush messages to all cores
gccorestatus[i] = 1;
send_msg_1(i, GCSTARTFLUSH);
gcphase = FINISHPHASE;
gccorestatus[BAMBOO_NUM_OF_CORE] = 1;
- for(i = 1; i < NUMCORES; ++i) {
+ for(i = 1; i < NUMCORES4GC; ++i) {
// send gc finish messages to all cores
send_msg_1(i, GCFINISH);
gccorestatus[i] = 1;
#else
#define BAMBOO_SMEM_SIZE_L (32 * BAMBOO_SMEM_SIZE)
#endif
-#define BAMBOO_LARGE_SMEM_BOUND (BAMBOO_SMEM_SIZE_L*NUMCORES) // NUMCORES=62
+#define BAMBOO_LARGE_SMEM_BOUND (BAMBOO_SMEM_SIZE_L*NUMCORES4GC) // NUMCORES=62
#define NUMPTRS 100
int gccurr_heaptop;
// for mark phase termination
-int gccorestatus[NUMCORES]; // records status of each core
+int gccorestatus[NUMCORES4GC]; // records status of each core
// 1: running gc
// 0: stall
-int gcnumsendobjs[NUMCORES]; // records how many objects sent out
-int gcnumreceiveobjs[NUMCORES]; // records how many objects received
+int gcnumsendobjs[NUMCORES4GC]; // records how many objects sent out
+int gcnumreceiveobjs[NUMCORES4GC]; // records how many objects received
bool gcbusystatus;
int gcself_numsendobjs;
int gcself_numreceiveobjs;
// for load balancing
INTPTR gcheaptop;
-int gcloads[NUMCORES];
+int gcloads[NUMCORES4GC];
int gctopcore; // the core host the top of the heap
int gctopblock; // the number of current top block
// compact instruction
INTPTR gcmarkedptrbound;
int gcblock2fill;
-int gcstopblock[NUMCORES]; // indicate when to stop compact phase
-int gcfilledblocks[NUMCORES]; //indicate how many blocks have been fulfilled
+int gcstopblock[NUMCORES4GC]; // indicate when to stop compact phase
+int gcfilledblocks[NUMCORES4GC]; //indicate how many blocks have been fulfilled
// move instruction;
INTPTR gcmovestartaddr;
int gcdstcore;
volatile bool gctomove;
-int gcrequiredmems[NUMCORES]; //record pending mem requests
+int gcrequiredmems[NUMCORES4GC]; //record pending mem requests
volatile int gcmovepending;
// mapping of old address to new address
if(t < (BAMBOO_LARGE_SMEM_BOUND)) { \
(*((int*)b)) = t / (BAMBOO_SMEM_SIZE_L); \
} else { \
- (*((int*)b)) = NUMCORES+((t-(BAMBOO_LARGE_SMEM_BOUND))/(BAMBOO_SMEM_SIZE));\
+ (*((int*)b)) = NUMCORES4GC+((t-(BAMBOO_LARGE_SMEM_BOUND))/(BAMBOO_SMEM_SIZE));\
} \
}
// mapping of pointer to core #
#define RESIDECORE(p, c) \
{ \
- if(1 == (NUMCORES)) { \
+ if(1 == (NUMCORES4GC)) { \
(*((int*)c)) = 0; \
} else {\
int b; \
BLOCKINDEX((p), &b); \
- (*((int*)c)) = gc_block2core[(b%(NUMCORES*2))]; \
+ (*((int*)c)) = gc_block2core[(b%(NUMCORES4GC*2))]; \
}\
}
}
// mapping of (core #, index of the block) to the global block index
-#define BLOCKINDEX2(c, n) (gc_core2block[(2*(c))+((n)%2)]+((NUMCORES*2)*((n)/2)))
+#define BLOCKINDEX2(c, n) (gc_core2block[(2*(c))+((n)%2)]+((NUMCORES4GC*2)*((n)/2)))
// mapping of (core #, number of the block) to the base pointer of the block
#define BASEPTR(c, n, p) \
{ \
int b = BLOCKINDEX2((c), (n)); \
- if(b < (NUMCORES)) { \
+ if(b < (NUMCORES4GC)) { \
(*((int*)p)) = gcbaseva + b * (BAMBOO_SMEM_SIZE_L); \
} else { \
(*((int*)p)) = gcbaseva+(BAMBOO_LARGE_SMEM_BOUND)+ \
- (b-(NUMCORES))*(BAMBOO_SMEM_SIZE); \
+ (b-(NUMCORES4GC))*(BAMBOO_SMEM_SIZE); \
} \
}
// the next core in the top of the heap
-#define NEXTTOPCORE(b) (gc_block2core[((b)+1)%(NUMCORES*2)])
+#define NEXTTOPCORE(b) (gc_block2core[((b)+1)%(NUMCORES4GC*2)])
inline void gc(struct garbagelist * stackptr); // core coordinator routine
inline void gc_collect(struct garbagelist* stackptr);//core collector routine
#define MULTICORE_HELPER_H
#ifdef GC_1
-// NUMCORES = 1
+// NUMCORES4GC = 1
static int gc_core2block[2] = {0,1};
static int gc_block2core[2] = { 0, 0};
#elif defined GC_62
-// NUMCORES = 62
-static int gc_core2block[124] = {0,123, 15,108, 16,107, 31,92, 32,91, 47,76,
- 1,122, 14,109, 17,106, 30,93, 33,90, 46,77, 48,75, 61,62,
- 2,121, 13,110, 18,105, 29,94, 34,89, 45,78, 49,74, 60,63,
- 3,120, 12,111, 19,104, 28,95, 35,88, 44,79, 50,73, 59,64,
- 4,119, 11,112, 20,103, 27,96, 36,87, 43,80, 51,72, 58,65,
- 5,118, 10,113, 21,102, 26,97, 37,86, 42,81, 52,71, 57,66,
- 6,117, 9,114, 22,101, 25,98, 38,85, 41,82, 53,70, 56,67,
- 7,116, 8,115, 23,100, 24,99, 39,84, 40,83, 54,69, 55,68};
+// NUMCORES4GC = 62
+static int gc_core2block[124] = {
+ 0,123, 15,108, 16,107, 31,92, 32,91, 47,76,
+ 1,122, 14,109, 17,106, 30,93, 33,90, 46,77, 48,75, 61,62,
+ 2,121, 13,110, 18,105, 29,94, 34,89, 45,78, 49,74, 60,63,
+ 3,120, 12,111, 19,104, 28,95, 35,88, 44,79, 50,73, 59,64,
+ 4,119, 11,112, 20,103, 27,96, 36,87, 43,80, 51,72, 58,65,
+ 5,118, 10,113, 21,102, 26,97, 37,86, 42,81, 52,71, 57,66,
+ 6,117, 9,114, 22,101, 25,98, 38,85, 41,82, 53,70, 56,67,
+ 7,116, 8,115, 23,100, 24,99, 39,84, 40,83, 54,69, 55,68
+};
-static int gc_block2core[124] = { 0, 6, 14, 22, 30, 38, 46, 54, 55, 47, 39, 31, 23, 15, 7, 1,
- 2, 8, 16, 24, 32, 40, 48, 56, 57, 49, 41, 33, 25, 17, 9, 3,
- 4, 10, 18, 26, 34, 42, 50, 58, 59, 51, 43, 35, 27, 19, 11, 5,
- 12, 20, 28, 36, 44, 52, 60, 61, 53, 45, 37, 29, 21, 13,
- 13, 21, 29, 37, 45, 53, 61, 60, 52, 44, 36, 28, 20, 12,
- 5, 11, 19, 27, 35, 43, 51, 59, 58, 50, 42, 34, 26, 18, 10, 4,
- 3, 9, 17, 25, 33, 41, 49, 57, 56, 48, 40, 32, 24, 16, 8, 2,
- 1, 7, 15, 23, 31, 39, 47, 55, 54, 46, 38, 30, 22, 14, 6, 0};
+static int gc_block2core[124] = {
+ 0, 6, 14, 22, 30, 38, 46, 54, 55, 47, 39, 31, 23, 15, 7, 1,
+ 2, 8, 16, 24, 32, 40, 48, 56, 57, 49, 41, 33, 25, 17, 9, 3,
+ 4, 10, 18, 26, 34, 42, 50, 58, 59, 51, 43, 35, 27, 19, 11, 5,
+ 12, 20, 28, 36, 44, 52, 60, 61, 53, 45, 37, 29, 21, 13,
+ 13, 21, 29, 37, 45, 53, 61, 60, 52, 44, 36, 28, 20, 12,
+ 5, 11, 19, 27, 35, 43, 51, 59, 58, 50, 42, 34, 26, 18, 10, 4,
+ 3, 9, 17, 25, 33, 41, 49, 57, 56, 48, 40, 32, 24, 16, 8, 2,
+ 1, 7, 15, 23, 31, 39, 47, 55, 54, 46, 38, 30, 22, 14, 6, 0
+};
#endif
#endif // MULTICORE_HELPER_H
MSGEND
} MSGTYPE;
+/////////////////////////////////////////////////////////////////////////////////
+// NOTE: BAMBOO_TOTALCORE -- number of the available cores in the processor.
+// No greater than the number of all the cores in
+// the processor
+// NUMCORES -- number of cores chosen to deploy the application. It can
+// be greater than that required to fully parallelize the
+// application. The same as NUMCORES.
+// NUMCORESACTIVE -- number of cores that really execute the
+// application. No greater than NUMCORES
+// NUMCORES4GC -- number of cores for gc. No greater than NUMCORES.
+// NOTE: currently only support ontinuous cores as gc
+// cores, i.e. 0~NUMCORES4GC-1
+////////////////////////////////////////////////////////////////////////////////
// data structures of status for termination
// only check working cores
int corestatus[NUMCORESACTIVE]; // records status of each core
#define BAMBOO_BASE_VA 0xd000000
#ifdef GC_DEBUG
#include "structdefs.h"
-#define BAMBOO_NUM_PAGES (NUMCORES*(2+1)+3)
+#define BAMBOO_NUM_PAGES (NUMCORES4GC*(2+1)+3)
#define BAMBOO_PAGE_SIZE (64 * 64)
#define BAMBOO_SMEM_SIZE (64 * 64) // (BAMBOO_PAGE_SIZE)
#define BAMBOO_SHARED_MEM_SIZE ((BAMBOO_PAGE_SIZE) * (BAMBOO_NUM_PAGES))
SMEMLOCAL = 0x0, // 0x0, using local mem only
SMEMFIXED, // 0x1, use local mem in lower address space(1 block only)
// and global mem in higher address space
- SMEMMIXED, // 0x2, like FIXED mode but use a threshold to control
- SMEMGLOBAL, // 0x3, using global mem only
+ SMEMMIXED, // 0x2, like FIXED mode but use a threshold to control
+ SMEMGLOBAL, // 0x3, using global mem only
SMEMEND
} SMEMSTRATEGY;
/////////////////////////////////////////////////////////////////////////////
// For each version of BAMBOO runtime, there should be a header file named //
// runtim_arch.h defining following MARCOS: //
-// BAMBOO_TOTALCORE: the total # of cores available in the processor //
+// BAMBOO_TOTALCORE: the total # of cores in the processor //
// BAMBOO_NUM_OF_CORE: the # of current residing core //
// BAMBOO_GET_NUM_OF_CORE(): compute the # of current residing core //
// BAMBOO_DEBUGPRINT(x): print out integer x //
// BAMBOO_MSG_AVAIL(): checking if there are msgs coming in //
// BAMBOO_GCMSG_AVAIL(): checking if there are gcmsgs coming in //
// BAMBOO_GET_EXE_TIME(): rountine to get current clock cycle number //
+// //
+// runtime_arch.h should also define following global parameters: //
+// bamboo_cpu2coords: map the cpu # to (x,y) coordinates //
+// bamboo_coords2cpu: map the (x,y) coordinates to cpu # //
/////////////////////////////////////////////////////////////////////////////
#endif // #ifdef MULTICORE
#endif
} // for(i = 0; i < NUMCORESACTIVE; ++i)
#ifdef MULTICORE_GC
- for(i = 0; i < NUMCORES; ++i) {
+ for(i = 0; i < NUMCORES4GC; ++i) {
gccorestatus[i] = 1;
gcnumsendobjs[i] = 0;
gcnumreceiveobjs[i] = 0;
gcrequiredmems[i] = 0;
gcstopblock[i] = 0;
gcfilledblocks[i] = 0;
- } // for(i = 0; i < NUMCORES; ++i)
+ } // for(i = 0; i < NUMCORES4GC; ++i)
#endif
numconfirm = 0;
waitconfirm = false;
struct freeMemItem * prev = NULL;
int i = 0;
int j = 0;
- *tofindb = gc_core2block[2*coren+i]+(NUMCORES*2)*j;
+ *tofindb = gc_core2block[2*coren+i]+(NUMCORES4GC*2)*j;
// check available shared mem chunks
do {
int foundsmem = 0;
i = 0;
j++;
}
- *tofindb = gc_core2block[2*coren+i]+(NUMCORES*2)*j;
+ *tofindb = gc_core2block[2*coren+i]+(NUMCORES4GC*2)*j;
} // while(startb > tofindb)
if(startb <= *tofindb) {
if((endb >= *tofindb) && (freemem->size >= isize)) {
}
} else {
// use the global mem
- if(((startb > NUMCORES-1) && (freemem->size >= isize)) ||
- ((endb > NUMCORES-1) && ((freemem->size-
+ if(((startb > NUMCORES4GC-1) && (freemem->size >= isize)) ||
+ ((endb > NUMCORES4GC-1) && ((freemem->size-
(gcbaseva+BAMBOO_LARGE_SMEM_BOUND-freemem->ptr))>=isize))) {
foundsmem = 1;
}
void * mem = NULL;
int startb = freemem->startblock;
int endb = freemem->endblock;
- int tmpptr = gcbaseva+((tofindb<NUMCORES)?tofindb*BAMBOO_SMEM_SIZE_L
- :BAMBOO_LARGE_SMEM_BOUND+(tofindb-NUMCORES)*BAMBOO_SMEM_SIZE);
+ int tmpptr = gcbaseva+((tofindb<NUMCORES4GC)?tofindb*BAMBOO_SMEM_SIZE_L
+ :BAMBOO_LARGE_SMEM_BOUND+(tofindb-NUMCORES4GC)*BAMBOO_SMEM_SIZE);
if((freemem->size+freemem->ptr-tmpptr)>=isize) {
mem = (tmpptr>freemem->ptr)?((void *)tmpptr):(freemem->ptr);
} else {
BAMBOO_DEBUGPRINT(0xe88c);
BAMBOO_DEBUGPRINT_REG(msgdata[1]);
#endif
- if(msgdata[1] < NUMCORES) {
+ if(msgdata[1] < NUMCORES4GC) {
gccorestatus[msgdata[1]] = 0;
}
}
#endif
BAMBOO_EXIT(0xb002);
}
- if(msgdata[1] < NUMCORES) {
+ if(msgdata[1] < NUMCORES4GC) {
gccorestatus[msgdata[1]] = 0;
gcnumsendobjs[msgdata[1]] = msgdata[2];
gcnumreceiveobjs[msgdata[1]] = msgdata[3];
int filledblocks = msgdata[2];
int heaptop = msgdata[3];
int data4 = msgdata[4];
- if(cnum < NUMCORES) {
+ if(cnum < NUMCORES4GC) {
if(COMPACTPHASE == gcphase) {
gcfilledblocks[cnum] = filledblocks;
gcloads[cnum] = heaptop;
// check if there is pending move request
/*if(gcmovepending > 0) {
int j;
- for(j = 0; j < NUMCORES; j++) {
+ for(j = 0; j < NUMCORES4GC; j++) {
if(gcrequiredmems[j]>0) {
break;
}
}
- if(j < NUMCORES) {
+ if(j < NUMCORES4GC) {
// find match
int tomove = 0;
int startaddr = 0;
if(gcrequiredmems[j] == 0) {
gcmovepending--;
}
- } // if(j < NUMCORES)
+ } // if(j < NUMCORES4GC)
} // if(gcmovepending > 0) */
} // if(data4>0)
- } // if(cnum < NUMCORES)
+ } // if(cnum < NUMCORES4GC)
break;
}
#endif
BAMBOO_EXIT(0xb004);
}
- if(msgdata[1] < NUMCORES) {
+ if(msgdata[1] < NUMCORES4GC) {
gccorestatus[msgdata[1]] = 0;
}
break;
case GCMARKCONFIRM: {
// received a marked phase finish confirm request msg
if((BAMBOO_NUM_OF_CORE == STARTUPCORE)
- || (BAMBOO_NUM_OF_CORE > NUMCORES - 1)) {
+ || (BAMBOO_NUM_OF_CORE > NUMCORES4GC - 1)) {
// wrong core to receive such msg
BAMBOO_EXIT(0xb005);
} else {
// received a large objs info response msg
numconfirm--;
- if(BAMBOO_NUM_OF_CORE > NUMCORES - 1) {
+ if(BAMBOO_NUM_OF_CORE > NUMCORES4GC - 1) {
#ifndef CLOSE_PRINT
BAMBOO_DEBUGPRINT_REG(msgdata[2]);
#endif
echo "-rawconfig config raw simulator as 4xn (should be used together with -raw)"
echo -threadsimulate generate multi-thread simulate version binary
echo -multicoregc generate multi-core binary with garbage collection
+echo "-numcore4gc set the number of cores for gc (should be used together with -multicoregc), defaultly set as 0"
echo -optional enable optional
echo -debug generate debug symbols
echo -prefetch do prefetch analysis
JAVAOPTS="$JAVAOPTS -numcore $2"
GCCORES="GC_$2"
shift
+elif [[ $1 = '-numcore4gc' ]]
+then
+JAVAOPTS="$JAVAOPTS -numcore4gc $2"
+shift
elif [[ $1 = '-raw' ]]
then
RAWFLAG=true