version runs specJBB...finally...
authorbdemsky <bdemsky>
Sat, 9 Jul 2011 00:29:20 +0000 (00:29 +0000)
committerbdemsky <bdemsky>
Sat, 9 Jul 2011 00:29:20 +0000 (00:29 +0000)
Robust/src/Runtime/bamboo/multicoreruntime.c
Robust/src/Runtime/bamboo/multicoreruntime.h
Robust/src/Runtime/bamboo/pmc_forward.c
Robust/src/Runtime/bamboo/pmc_garbage.c
Robust/src/Runtime/bamboo/pmc_garbage.h
Robust/src/Runtime/bamboo/pmc_mem.c
Robust/src/Runtime/bamboo/pmc_refupdate.c
Robust/src/Runtime/mem.c

index 7ee0a50b0fc56a1ec26db4498ebe81cd900a3491..dbad8e8c3eb7cdf239091b59d69866bd8fb6a5c0 100644 (file)
@@ -5,6 +5,8 @@
 #include "multicoregarbage.h"
 #ifdef PMC_GC
 #include "multicoregcprofile.h"
+#include "multicoregc.h"
+#include "pmc_garbage.h"
 #endif
 #include "multicore_arch.h"
 #include <stdio.h>
index 7b107b6f6dde3d35b0b1e6c242f142c4e953420b..560fd9dd4d5cafbbf49392b188e79c037e192fb5 100644 (file)
@@ -8,6 +8,11 @@
 #include "multicoretask.h"
 #include "multicoremgc.h"
 #include "multicorecache.h"
+#ifdef PMC_GC
+#include "multicoregc.h"
+#include "pmc_garbage.h"
+#endif
+
 
 //Define the following line if the base object type has pointers
 //#define OBJECTHASPOINTERS
index 83a01b429298ae890e9dfe978a2cbd1ba4db7b34..14788db45ba6434b7bf8175637dd491b294f5183 100644 (file)
@@ -11,7 +11,7 @@ void pmc_count() {
       //got lock
       void *unitbase=(i==0)?gcbaseva:pmc_heapptr->units[i-1].endptr;
       void *unittop=pmc_heapptr->units[i].endptr;
-      tprintf("Cnt: %x - %x\n", unitbase, unittop);
+      //tprintf("Cnt: %x - %x\n", unitbase, unittop);
       pmc_countbytes(&pmc_heapptr->units[i], unitbase, unittop);
     }
   }
@@ -49,8 +49,16 @@ void pmc_processunits() {
   int totalbytes=0;
   int numregions=0;
 
+  pmc_heapptr->regions[0].startptr=gcbaseva;
+  pmc_heapptr->regions[0].lowunit=0;
+
   for(int i=0;i<NUMPMCUNITS;i++) {
     if (numregions>0&&(totalbytes+pmc_heapptr->units[i].numbytes)>livebytespercore) {
+      pmc_heapptr->regions[regionnum].highunit=i;
+      pmc_heapptr->regions[regionnum].endptr=pmc_heapptr->units[i-1].endptr;
+
+      pmc_heapptr->regions[regionnum+1].startptr=pmc_heapptr->units[i-1].endptr;
+      pmc_heapptr->regions[regionnum+1].lowunit=i;
       regionnum++;
       totalbytes-=livebytespercore;
       numregions=0;
@@ -60,6 +68,15 @@ void pmc_processunits() {
     tmc_spin_mutex_init(&pmc_heapptr->units[i].lock);
     totalbytes+=pmc_heapptr->units[i].numbytes;
   }
+  pmc_heapptr->regions[regionnum].highunit=NUMPMCUNITS;
+  pmc_heapptr->regions[regionnum].endptr=pmc_heapptr->units[NUMPMCUNITS-1].endptr;
+  regionnum++;
+  for(;regionnum<NUMCORES4GC;regionnum++) {
+    pmc_heapptr->regions[regionnum].highunit=NUMPMCUNITS;
+    pmc_heapptr->regions[regionnum].endptr=pmc_heapptr->units[NUMPMCUNITS-1].endptr;
+    pmc_heapptr->regions[regionnum+1].startptr=pmc_heapptr->units[NUMPMCUNITS-1].endptr;
+    pmc_heapptr->regions[regionnum+1].lowunit=NUMPMCUNITS;
+  }
 }
 
 void pmc_doforward() {
@@ -67,30 +84,10 @@ void pmc_doforward() {
   int endregion=-1;
   unsigned int totalbytes=0;
   struct pmc_region * region=&pmc_heapptr->regions[BAMBOO_NUM_OF_CORE];
-  for(int i=0;i<NUMPMCUNITS;i++) {
-    if (startregion==-1&&BAMBOO_NUM_OF_CORE==pmc_heapptr->units[i].regionnum) {
-      startregion=i;
-    }
-    if (BAMBOO_NUM_OF_CORE<pmc_heapptr->units[i].regionnum) {
-      endregion=i;
-      break;
-    }
-    if (startregion!=-1) {
-      totalbytes+=pmc_heapptr->units[i].numbytes;
-    }
-  }
-  if (startregion==-1) {
-    //out of regions....
-    region->lowunit=region->highunit=NUMPMCUNITS;
-    region->lastptr=region->startptr=region->endptr=pmc_heapptr->units[region->highunit-1].endptr;
-    return;
+  for(int index=region->lowunit; index<region->highunit;index++) {
+    totalbytes+=pmc_heapptr->units[index].numbytes;
   }
-  if (endregion==-1)
-    endregion=NUMPMCUNITS;
-  region->lowunit=startregion;
-  region->highunit=endregion;
-  region->startptr=(startregion==0)?gcbaseva:pmc_heapptr->units[startregion-1].endptr;
-  region->endptr=pmc_heapptr->units[endregion-1].endptr;
+
   if (BAMBOO_NUM_OF_CORE&1) {
     //upward in memory
     region->lastptr=region->endptr-totalbytes;
@@ -109,22 +106,28 @@ void pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *botto
   struct ___Object___ *lastobj=NULL;
   unsigned int currunit=region->lowunit;
   void *endunit=pmc_unitend(currunit);
+  bool internal=!(BAMBOO_NUM_OF_CORE&1);
+  int highbound=internal?region->highunit:region->highunit-1;
+
 
   if (!lower) {
     //We're resetting the boundaries of units at the low address end of the region...
     //Be sure not to reset the boundary of our last unit...it is shared with another region
-    while(endunit<=region->lastptr&&(currunit<(region->highunit-1))) {
+
+    while(endunit<=region->lastptr&&(currunit<highbound)) {
       pmc_heapptr->units[currunit].endptr=endunit;
+      //tprintf("Ch2: %u -> %x\n", currunit, endunit);
       currunit++;
       endunit=pmc_unitend(currunit);
     }
   } else {
     //We're resetting the boundaries of units at the high address end of the region...
     //Very top most unit defines boundary of region...we can't move that right now
-    unsigned int lastunit=region->highunit-2;
+    unsigned int lastunit=internal?region->highunit-1:region->highunit-2;
     void * lastunitend=pmc_unitend(lastunit);
     while(lastunitend>=region->lastptr) {
       pmc_heapptr->units[lastunit].endptr=lastunitend;
+      //tprintf("Ch3: %u -> %x\n", lastunit, lastunitend);
       lastunit--;
       lastunitend=pmc_unitend(lastunit);
     }
@@ -146,8 +149,9 @@ void pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *botto
       void *newforwardptr=forwardptr+size;
       //Need to make sure that unit boundaries do not fall in the middle of an object...
       //Unless the unit boundary is at the end of the region...then just ignore it.
-      while(newforwardptr>=endunit&&currunit<(region->highunit-1)) {
+      while(newforwardptr>=endunit&&currunit<highbound) {
        pmc_heapptr->units[currunit].endptr=newforwardptr;
+       //tprintf("Ch4: %u -> %x\n", currunit, newforwardptr);
        currunit++;
        endunit=pmc_unitend(currunit);
       }
@@ -160,6 +164,6 @@ void pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *botto
     }
     tmpptr+=size;
   }
-  tprintf("forwardptr=%x\n",forwardptr);
+  //tprintf("forwardptr=%x\n",forwardptr);
   region->lastobj=lastobj;
 }
index 915471462754a25c5a30b4e4cef61c64b5cc1ed3..c0cde4adfb6e921a915a6d69644cd3fc72e57851 100644 (file)
@@ -33,7 +33,7 @@ void pmc_onceInit() {
     tmc_spin_barrier_init(&pmc_heapptr->barrier, NUMCORES4GC);
     for(int i=0;i<NUMPMCUNITS;i++) {
       pmc_heapptr->units[i].endptr=pmc_unitend(i);
-      tprintf("%u endptr=%x\n", i, pmc_heapptr->units[i].endptr);
+      //tprintf("Ch5: %u-> %x\n", i, pmc_heapptr->units[i].endptr);
     }
     
     for(int i=0;i<NUMCORES4GC;i+=2) {
@@ -47,9 +47,9 @@ void pmc_onceInit() {
       pmc_heapptr->regions[i+1].lowunit=4*(i+1);
       pmc_heapptr->regions[i+1].highunit=4*(i+2);
     }
-    for(int i=0;i<NUMCORES4GC;i++) {
-      tprintf("%u lastptr=%x\n", i, pmc_heapptr->regions[i].lastptr);
-    }
+    //for(int i=0;i<NUMCORES4GC;i++) {
+      //tprintf("%u lastptr=%x\n", i, pmc_heapptr->regions[i].lastptr);
+    //}
   }
 }
 
@@ -62,7 +62,7 @@ void pmc_init() {
       struct pmc_region *region=&pmc_heapptr->regions[i];
       unsigned int startindex=region->lowunit;
       unsigned int endindex=pmc_heapptr->regions[i+1].highunit;
-      tprintf("Free space in partition %u from %x to %x\n", i, startptr, finishptr);
+      //tprintf("Free space in partition %u from %x to %x\n", i, startptr, finishptr);
       for(unsigned int index=startindex;index<endindex;index++) {
        void *ptr=pmc_heapptr->units[index].endptr;
        if ((ptr>startptr)&&(ptr<=finishptr)) {
@@ -77,54 +77,63 @@ void pmc_init() {
     }
   }
   if (bamboo_smem_size) {
-        tprintf("Left over alloc space from %x to %x\n", bamboo_cur_msp, bamboo_cur_msp+bamboo_smem_size);
+    //tprintf("Left over alloc space from %x to %x\n", bamboo_cur_msp, bamboo_cur_msp+bamboo_smem_size);
     padspace(bamboo_cur_msp, bamboo_smem_size);  
   }
   tmc_spin_barrier_wait(&pmc_heapptr->barrier);
 }
 
 void gc(struct garbagelist *gl) {
-  tprintf("start GC\n");
+  if (BAMBOO_NUM_OF_CORE==STARTUPCORE)
+    tprintf("start GC\n");
   pmc_init();
   //mark live objects
-  tprintf("mark\n");
+  //tprintf("mark\n");
   pmc_mark(gl);
   //count live objects per unit
   tmc_spin_barrier_wait(&pmc_heapptr->barrier);
-  tprintf("count\n");
+  //tprintf("count\n");
   pmc_count();
   tmc_spin_barrier_wait(&pmc_heapptr->barrier);
   //divide up work
-  tprintf("divide\n");
+  //tprintf("divide\n");
   if (BAMBOO_NUM_OF_CORE==STARTUPCORE) {
     pmc_processunits();
   }
   tmc_spin_barrier_wait(&pmc_heapptr->barrier);
   //set up forwarding pointers
-  tprintf("forward\n");
+  //tprintf("forward\n");
   pmc_doforward();
   tmc_spin_barrier_wait(&pmc_heapptr->barrier);
   //update pointers
-  tprintf("updaterefs\n");
+  //tprintf("updaterefs\n");
   pmc_doreferenceupdate(gl);
   tmc_spin_barrier_wait(&pmc_heapptr->barrier);
   //compact data
-  tprintf("compact\n");
+  //tprintf("compact\n");
   pmc_docompact();
   //reset memory allocation
   bamboo_cur_msp=NULL;
   bamboo_smem_size=0;
-  tprintf("done\n");
+  //tprintf("done\n");
+
+  //if (BAMBOO_NUM_OF_CORE==STARTUPCORE) {
+    //    for(int i=0;i<NUMCORES4GC;i+=2) {
+    //      void *startptr=pmc_heapptr->regions[i].lastptr;
+    //      void *finishptr=pmc_heapptr->regions[i+1].lastptr;
+    //      tprintf("Partition %u from %x to %x\n", i, startptr, finishptr);
+    //      tprintf("%x %x %x %x\n", pmc_heapptr->regions[i].startptr, pmc_heapptr->regions[i].endptr, pmc_heapptr->regions[i+1].startptr, pmc_heapptr->regions[i+1].endptr);
+    //    }
+  //  }
 
   gcflag=false;
   tmc_spin_barrier_wait(&pmc_heapptr->barrier);
 
-  tprintf("exit GC\n");
+  //tprintf("exit GC\n");
 }
 
 void padspace(void *ptr, unsigned int length) {
   //zero small blocks
-    tprintf("Padspace from %x to %x\n", ptr, ptr+length);
   if (length<sizeof(struct ArrayObject)) {
     BAMBOO_MEMSET_WH(ptr,0,length);
   } else {
@@ -139,9 +148,9 @@ void padspace(void *ptr, unsigned int length) {
 
 void gettype_size(void * ptr, unsigned int * ttype, unsigned int * tsize) {
   int type = ((int *)ptr)[0];
-  if (type>TOTALNUMCLASSANDARRAY) {
-    tprintf("ptr=%x type=%u\n", ptr, type);
-  }
+  //  if (type>TOTALNUMCLASSANDARRAY) {
+  //    tprintf("ptr=%x type=%u\n", ptr, type);
+  //  }
 
   if(type < NUMCLASSES) {
     // a normal object
index e6c26e54d2360b599546a7ab4dab07648cd0d007..857ff23e170bb6ec7eef24299c5cafbd6cf94260 100644 (file)
@@ -4,8 +4,8 @@
 #include "pmc_queue.h"
 #include "structdefs.h"
 
-//#define PMC_MINALLOC 131072
-#define PMC_MINALLOC 2048
+#define PMC_MINALLOC 131072
+//#define PMC_MINALLOC 2048
 #define NUMPMCUNITS (4*NUMCORES4GC)
 #define UNITSIZE (BAMBOO_SHARED_MEM_SIZE/NUMPMCUNITS)
 
index 40d7f437ed917b15b6cf2ae16694f0d116ded9fd..1b488741104167432d09acb016aeddd59cdeadee 100644 (file)
@@ -28,9 +28,11 @@ void * pmc_alloc(unsigned int * numbytesallocated, unsigned int minimumbytes) {
        //update unit end points
        for(unsigned int index=startindex;index<(endindex-1);index++) {
          void *ptr=pmc_unitend(index);
-         if ((ptr>startptr)&&(ptr<newstartptr)) {
+         if ((ptr>startptr)&&(ptr<=newstartptr)) {
+           //tprintf("Ch: %u -> %x\n", index, newstartptr);
            pmc_heapptr->units[index].endptr=newstartptr;
          }
+
          if (ptr>newstartptr)
            break;
        }
@@ -38,6 +40,7 @@ void * pmc_alloc(unsigned int * numbytesallocated, unsigned int minimumbytes) {
 
        *numbytesallocated=(unsigned int)(newstartptr-startptr);
        tmc_spin_mutex_unlock(&region->lock);
+
        return startptr;
       } while(0);
       tmc_spin_mutex_unlock(&region->lock);
index 100cb9ed5031a8df56b5ce399e72f0c23c3e2749..93359c46b5e56ecbb4d54ed8bf9ea676866d2faa 100644 (file)
 
 #define pmcupdateObj(objptr) ((void *)((struct ___Object___ *)objptr)->marked)
 
-#define PMCUPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) {obj=pmcupdateObj(updatetmpptr);if (obj==NULL) {tprintf("BAD REF UPDATE %x->%x in %u\n",updatetmpptr,obj,__LINE__);}}}
+#define PMCUPDATEOBJ(obj) {void *updatetmpptr=obj; if (updatetmpptr!=NULL) {obj=pmcupdateObj(updatetmpptr);}}
+//if (obj==NULL) {tprintf("BAD REF UPDATE %x->%x in %u\n",updatetmpptr,obj,__LINE__);}}}
 
-#define PMCUPDATEOBJNONNULL(obj) {void *updatetmpptr=obj; obj=pmcupdateObj(updatetmpptr);if (obj==NULL) {tprintf("BAD REF UPDATE in %x->%x %u\n",updatetmpptr,obj,__LINE__);}}
+#define PMCUPDATEOBJNONNULL(obj) {void *updatetmpptr=obj; obj=pmcupdateObj(updatetmpptr);}
+//if (obj==NULL) {tprintf("BAD REF UPDATE in %x->%x %u\n",updatetmpptr,obj,__LINE__);}}
 
 void pmc_updatePtrs(void *ptr, int type) {
   unsigned int * pointer=pointerarray[type];
-  tprintf("Updating pointers in %x\n", ptr);
+  //tprintf("Updating pointers in %x\n", ptr);
   if (pointer==0) {
     /* Array of primitives */
   } else if (((unsigned int)pointer)==1) {
@@ -36,7 +38,7 @@ void pmc_updatePtrs(void *ptr, int type) {
       PMCUPDATEOBJ(*((void **)(((char *)ptr)+offset)));
     }
   }
-  tprintf("done\n");
+  //tprintf("done\n");
 }
 
 void pmc_updategarbagelist(struct garbagelist *listptr) {
@@ -149,7 +151,7 @@ void pmc_doreferenceupdate(struct garbagelist *stackptr) {
 
 void pmc_referenceupdate(void *bottomptr, void *topptr) {
   void *tmpptr=bottomptr;
-  tprintf("%x -- %x\n", bottomptr, topptr);
+  //tprintf("%x -- %x\n", bottomptr, topptr);
   while(tmpptr<topptr) {
     unsigned int type;
     unsigned int size;
index 98b9d197a575d843c8e5484a5fdc2f36b6a728df..d7eda8eeaf171372d03cf1e4b72b54a37905b8e9 100644 (file)
 #include "multicoremem.h"
 #include "multicoregarbage.h"
 #endif
+#ifdef PMC_GC
+#include "multicoregc.h"
+#include "pmc_garbage.h"
+#endif
 
 #if defined(MULTICORE_GC)||defined(PMC_GC)
 extern volatile bool gcflag;