From: jzhou Date: Tue, 12 Jan 2010 01:12:00 +0000 (+0000) Subject: change in the multicore version runtime. now it is able to choose which cores to... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e33201f8be840c89d9e1994a2e742bf01ca8ff0c;p=IRC.git change in the multicore version runtime. now it is able to choose which cores to execute the program and which cores to run gc --- diff --git a/Robust/src/IR/Flat/BuildCodeMultiCore.java b/Robust/src/IR/Flat/BuildCodeMultiCore.java index 3b614654..94380ba1 100644 --- a/Robust/src/IR/Flat/BuildCodeMultiCore.java +++ b/Robust/src/IR/Flat/BuildCodeMultiCore.java @@ -38,6 +38,7 @@ public class BuildCodeMultiCore extends BuildCode { private Vector scheduling; int coreNum; int tcoreNum; + int gcoreNum; Schedule currentSchedule; Hashtable[] fsate2qnames; String objqarrayprefix= "objqueuearray4class"; @@ -61,11 +62,13 @@ public class BuildCodeMultiCore extends BuildCode { SafetyAnalysis sa, Vector 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; @@ -295,7 +298,12 @@ public class BuildCodeMultiCore extends BuildCode { /* 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) { diff --git a/Robust/src/IR/State.java b/Robust/src/IR/State.java index 6765fba2..5d618735 100644 --- a/Robust/src/IR/State.java +++ b/Robust/src/IR/State.java @@ -117,6 +117,7 @@ public class State { public boolean HYBRID=false; //Other options public int CORENUM = 1; + public int CORENUM4GC = 0; public String structfile; public String main; public String outputdir = "/scratch/"; diff --git a/Robust/src/Main/Main.java b/Robust/src/Main/Main.java index 9eefae23..748c0027 100644 --- a/Robust/src/Main/Main.java +++ b/Robust/src/Main/Main.java @@ -92,6 +92,9 @@ public class Main { } 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")) { @@ -499,6 +502,7 @@ public class Main { sa, scheduling, mcImplSynthesis.getCoreNum(), + state.CORENUM4GC, pa); bcm.setOwnershipAnalysis(oa); bcm.buildCode(); diff --git a/Robust/src/Runtime/multicoregarbage.c b/Robust/src/Runtime/multicoregarbage.c index daa0177b..6e234efa 100644 --- a/Robust/src/Runtime/multicoregarbage.c +++ b/Robust/src/Runtime/multicoregarbage.c @@ -96,15 +96,17 @@ inline void dumpSMem() { } // 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); @@ -357,12 +359,12 @@ inline bool isLocal(void * ptr) { 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; } @@ -392,16 +394,16 @@ inline void checkMarkStatue() { // 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); @@ -419,12 +421,12 @@ inline void checkMarkStatue() { // 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); @@ -433,9 +435,9 @@ inline void checkMarkStatue() { // 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) @@ -523,7 +525,7 @@ inline bool preGC() { 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; @@ -531,7 +533,7 @@ inline void initGC() { 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; @@ -585,7 +587,7 @@ inline int loadbalance() { // 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; @@ -596,7 +598,7 @@ inline int loadbalance() { #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); @@ -728,9 +730,9 @@ void updateSmemTbl(int coren, 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 0)) { #ifdef DEBUG @@ -1526,7 +1531,7 @@ inline void compact2Heaptop() { } } // 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 @@ -1538,7 +1543,7 @@ inline void resolvePendingMoveRequest() { #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]); @@ -1555,7 +1560,7 @@ inline void resolvePendingMoveRequest() { 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) { @@ -1616,7 +1621,7 @@ inline void resolvePendingMoveRequest() { 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); @@ -1929,8 +1934,8 @@ inline int assignSpareMem_I(int sourcecore, int * startaddr) { int b = 0; BLOCKINDEX(gcloads[sourcecore], &b); - int boundptr = (b tofindb) if(startb <= *tofindb) { if((endb >= *tofindb) && (freemem->size >= isize)) { @@ -1236,8 +1236,8 @@ struct freeMemItem * findFreeMemChunk_I(int coren, } } 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; } @@ -1296,8 +1296,8 @@ void * localmalloc_I(int tofindb, void * mem = NULL; int startb = freemem->startblock; int endb = freemem->endblock; - int tmpptr = gcbaseva+((tofindbsize+freemem->ptr-tmpptr)>=isize) { mem = (tmpptr>freemem->ptr)?((void *)tmpptr):(freemem->ptr); } else { @@ -1949,7 +1949,7 @@ msg: BAMBOO_DEBUGPRINT(0xe88c); BAMBOO_DEBUGPRINT_REG(msgdata[1]); #endif - if(msgdata[1] < NUMCORES) { + if(msgdata[1] < NUMCORES4GC) { gccorestatus[msgdata[1]] = 0; } } @@ -1963,7 +1963,7 @@ msg: #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]; @@ -1985,7 +1985,7 @@ msg: 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; @@ -2007,12 +2007,12 @@ msg: // 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; @@ -2035,10 +2035,10 @@ msg: if(gcrequiredmems[j] == 0) { gcmovepending--; } - } // if(j < NUMCORES) + } // if(j < NUMCORES4GC) } // if(gcmovepending > 0) */ } // if(data4>0) - } // if(cnum < NUMCORES) + } // if(cnum < NUMCORES4GC) break; } @@ -2052,7 +2052,7 @@ msg: #endif BAMBOO_EXIT(0xb004); } - if(msgdata[1] < NUMCORES) { + if(msgdata[1] < NUMCORES4GC) { gccorestatus[msgdata[1]] = 0; } break; @@ -2067,7 +2067,7 @@ msg: 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 { @@ -2169,7 +2169,7 @@ msg: // 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 diff --git a/Robust/src/buildscript b/Robust/src/buildscript index eb1d2658..79cfb99d 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -56,6 +56,7 @@ echo "-raw generate raw version binary (should be used together with -multicore) 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 @@ -300,6 +301,10 @@ then JAVAOPTS="$JAVAOPTS -numcore $2" GCCORES="GC_$2" shift +elif [[ $1 = '-numcore4gc' ]] +then +JAVAOPTS="$JAVAOPTS -numcore4gc $2" +shift elif [[ $1 = '-raw' ]] then RAWFLAG=true