change in the multicore version runtime. now it is able to choose which cores to...
authorjzhou <jzhou>
Tue, 12 Jan 2010 01:12:00 +0000 (01:12 +0000)
committerjzhou <jzhou>
Tue, 12 Jan 2010 01:12:00 +0000 (01:12 +0000)
Robust/src/IR/Flat/BuildCodeMultiCore.java
Robust/src/IR/State.java
Robust/src/Main/Main.java
Robust/src/Runtime/multicoregarbage.c
Robust/src/Runtime/multicoregarbage.h
Robust/src/Runtime/multicorehelper.h
Robust/src/Runtime/multicoreruntime.h
Robust/src/Runtime/multicoretask.c
Robust/src/buildscript

index 3b6146543d822ec8add15783a4f25309100987b4..94380ba1356f6bca699ceb8bacd75a3b6e290b8b 100644 (file)
@@ -38,6 +38,7 @@ public class BuildCodeMultiCore extends BuildCode {
   private Vector<Schedule> 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<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;
@@ -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) {
index 6765fba2097e6163f29c81ba6d7ef688df03f5a4..5d618735f07b24a738d049dd1bfcfe35bdbe30ef 100644 (file)
@@ -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/";
index 9eefae238d2a5af96974f13832542e5c97cd9ec4..748c0027fa06bdfcf33a21ecfae53e671574d0e8 100644 (file)
@@ -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();
index daa0177b645d9bc77c4aefc53e8748e3a81a3a7d..6e234efa084ea910b11bc3d2e32427f80e4c0815 100644 (file)
@@ -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<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;
@@ -804,7 +806,7 @@ inline void moveLObjs() {
        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);
@@ -823,7 +825,7 @@ inline void moveLObjs() {
 #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
@@ -841,8 +843,9 @@ inline void moveLObjs() {
        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
@@ -945,11 +948,11 @@ inline void moveLObjs() {
                                        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;
                                        }
                                }
@@ -1056,8 +1059,8 @@ inline void moveLObjs() {
                                // 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 {
@@ -1068,9 +1071,9 @@ inline void moveLObjs() {
                                        //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 {
@@ -1081,7 +1084,7 @@ inline void moveLObjs() {
                                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++) {
@@ -1463,8 +1466,9 @@ inline void compact2Heaptophelper(int coren,
                *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);
@@ -1485,8 +1489,9 @@ inline void compact2Heaptop() {
        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
@@ -1509,7 +1514,7 @@ inline void compact2Heaptop() {
                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
@@ -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<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];
@@ -1954,7 +1959,7 @@ inline bool gcfindSpareMem_I(int * startaddr,
                                                                                                   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);
@@ -2452,7 +2457,7 @@ inline void gc(struct garbagelist * stackptr) {
                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);
                }
@@ -2479,7 +2484,7 @@ inline void gc(struct garbagelist * stackptr) {
                // 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);
@@ -2497,8 +2502,8 @@ inline void gc(struct garbagelist * stackptr) {
                        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;
@@ -2536,7 +2541,7 @@ inline void gc(struct garbagelist * stackptr) {
                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
@@ -2601,7 +2606,7 @@ inline void gc(struct garbagelist * stackptr) {
                        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;
@@ -2669,7 +2674,7 @@ inline void gc(struct garbagelist * stackptr) {
 
                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);
@@ -2690,7 +2695,7 @@ inline void gc(struct garbagelist * stackptr) {
                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;
index ac4b1c9734d5b7463bc24443858b982ee70d34e2..a2963af41c073ffafb9fbfcb00f06239336f53df 100644 (file)
@@ -14,7 +14,7 @@
 #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
 
@@ -33,18 +33,18 @@ volatile GCPHASETYPE gcphase; // indicating GC phase
 
 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
 
@@ -53,13 +53,13 @@ int gcnumlobjs;
 // 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
@@ -96,19 +96,19 @@ int * gcsmemtbl;
                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))]; \
        }\
 }
 
@@ -132,22 +132,22 @@ int * gcsmemtbl;
        }
 
 // 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
index ed80ec3b7b57ffa5dfc121bd15040fb9838dd0c7..faf4ca38aa7292a77d540abaa9bf89173ecb234a 100644 (file)
@@ -2,29 +2,33 @@
 #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
index 0d1865df503236e32d7de7451ed17903bfd87b4d..d1c29257084cddf5bbe910ff4c942c8b6abb7272 100644 (file)
@@ -179,6 +179,19 @@ typedef enum {
        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
@@ -218,7 +231,7 @@ struct Queue * totransobjqueue; // queue to hold objs to be transferred
 #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))
@@ -236,8 +249,8 @@ typedef enum {
        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;
 
@@ -416,7 +429,7 @@ void outputProfileData();
 /////////////////////////////////////////////////////////////////////////////
 // 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                               //
@@ -454,6 +467,10 @@ void outputProfileData();
 // 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
index 7770bcd0d82a6c8054d4a5431d23713d4a8651b1..bda2bd20d6ab19946725f53ebbeb548f147d8f14 100644 (file)
@@ -54,7 +54,7 @@ void initruntimedata() {
 #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;
@@ -62,7 +62,7 @@ void initruntimedata() {
                        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; 
@@ -1200,7 +1200,7 @@ struct freeMemItem * findFreeMemChunk_I(int coren,
        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;
@@ -1214,7 +1214,7 @@ struct freeMemItem * findFreeMemChunk_I(int coren,
                                                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)) {
@@ -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+((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 {
@@ -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
index eb1d2658e67eb74b483d5fffbb5f76fc8849288f..79cfb99dd8cd71af5a8c3cef613b534500075550 100755 (executable)
@@ -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