Code clean. Change BAMBOO_EXIT macro to print out file name and line #
authorjzhou <jzhou>
Mon, 9 May 2011 23:50:54 +0000 (23:50 +0000)
committerjzhou <jzhou>
Mon, 9 May 2011 23:50:54 +0000 (23:50 +0000)
21 files changed:
Robust/src/IR/Flat/BuildCodeMultiCore.java
Robust/src/Runtime/ObjectHash.c
Robust/src/Runtime/SimpleHash.c
Robust/src/Runtime/bamboo/GCSharedHash.c
Robust/src/Runtime/bamboo/MGCHash.c
Robust/src/Runtime/bamboo/gcqueue.h
Robust/src/Runtime/bamboo/multicorecache.c
Robust/src/Runtime/bamboo/multicoregarbage.c
Robust/src/Runtime/bamboo/multicoregarbage.h
Robust/src/Runtime/bamboo/multicoregccompact.c
Robust/src/Runtime/bamboo/multicoregccompact.h
Robust/src/Runtime/bamboo/multicoregcflush.c
Robust/src/Runtime/bamboo/multicoregcmark.c
Robust/src/Runtime/bamboo/multicoremem.c
Robust/src/Runtime/bamboo/multicoremsg.c
Robust/src/Runtime/bamboo/multicoremsg.h
Robust/src/Runtime/bamboo/multicoreruntime.c
Robust/src/Runtime/bamboo/multicoreruntime.h
Robust/src/Runtime/bamboo/multicoretask.c
Robust/src/Runtime/bamboo/multicoretask.h
Robust/src/Runtime/mem.c

index 11a6fcc8745c405a2fa4635d509a1d71bcc70e41..87fe2d166061275834a72a3201b38563e2a63ffe 100644 (file)
@@ -728,20 +728,15 @@ public class BuildCodeMultiCore extends BuildCode {
       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) {
@@ -781,13 +776,9 @@ public class BuildCodeMultiCore extends BuildCode {
           //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);
@@ -1657,13 +1648,9 @@ public class BuildCodeMultiCore extends BuildCode {
       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);
index 776c9be31fd9bb60c72f9f022d21aff36f8d399c..e052c02edb63e98d39a5799a8076080f8a976a71 100755 (executable)
@@ -22,10 +22,10 @@ struct ObjectHash * noargallocateObjectHash() {
 }
 
 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);
index 1ebc88326e9ad34e299839026bd1ca8c1c7e35f1..f07f100f50f7ce1e659b92d81047ee2521406031 100755 (executable)
@@ -22,10 +22,10 @@ struct RuntimeHash * noargallocateRuntimeHash() {
 }
 
 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);
@@ -205,10 +205,10 @@ int RuntimeHashadd(struct RuntimeHash * thisvar,int key, int data) {
 
 #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);
index 796baac5b267ab8ac93a436d60ff12b85a955a9f..945a6ec2a481b090fcadfc72c905506903bbb0fb 100755 (executable)
@@ -35,7 +35,7 @@ struct GCSharedHash * allocateGCSharedHash(int size) {
   struct GCSharedHash *thisvar; 
   if (size <= 0) {
 #ifdef MULTICORE
-    BAMBOO_EXIT(0xf301);
+    BAMBOO_EXIT();
 #else
     printf("Negative Hashtable size Exception\n");
     exit(-1);
@@ -168,7 +168,7 @@ struct GCSharedHash * allocateGCSharedHash_I(int size) {
   struct GCSharedHash *thisvar;
   if (size <= 0) {
 #ifdef MULTICORE
-    BAMBOO_EXIT(0xf302);
+    BAMBOO_EXIT();
 #else
     printf("Negative Hashtable size Exception\n");
     exit(-1);
@@ -288,16 +288,16 @@ mgcsharedhashtbl_t * mgcsharedhashCreate(unsigned int size,
 
   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;
@@ -320,16 +320,16 @@ mgcsharedhashtbl_t * mgcsharedhashCreate_I(unsigned int size,
 
   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;
index 205c488ea87306f6d98363ac46a35a036bc9e6a5..f85a1adee63907e78a60bbdd9825a938b253b55c 100644 (file)
@@ -28,7 +28,7 @@ mgchashtable_t * mgchashCreate(unsigned int size, double loadfactor) {
 
   if (size <= 0) {
 #ifdef MULTICORE
-    BAMBOO_EXIT(0xf401);
+    BAMBOO_EXIT();
 #else
     printf("Negative Hashtable size Exception\n");
     exit(-1);
@@ -38,13 +38,13 @@ mgchashtable_t * mgchashCreate(unsigned int size, double loadfactor) {
   // 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;
@@ -131,7 +131,7 @@ mgchashtable_t * mgchashCreate_I(unsigned int size, double loadfactor) {
 
   if (size <= 0) {
 #ifdef MULTICORE
-    BAMBOO_EXIT(0xf404);
+    BAMBOO_EXIT();
 #else
     printf("Negative Hashtable size Exception\n");
     exit(-1);
@@ -141,13 +141,13 @@ mgchashtable_t * mgchashCreate_I(unsigned int size, double loadfactor) {
   // 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;
@@ -294,7 +294,7 @@ unsigned int mgchashResize_I(mgchashtable_t * tbl, unsigned int newsize) {
   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;
   }
@@ -312,29 +312,29 @@ unsigned int mgchashResize_I(mgchashtable_t * tbl, unsigned int newsize) {
       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;
@@ -367,7 +367,7 @@ struct MGCHash * allocateMGCHash(int size,
   struct MGCHash *thisvar;
   if (size <= 0) {
 #ifdef MULTICORE
-    BAMBOO_EXIT(0xf408);
+    BAMBOO_EXIT();
 #else
     printf("Negative Hashtable size Exception\n");
     exit(-1);
@@ -432,7 +432,7 @@ struct MGCHash * allocateMGCHash_I(int size,
   struct MGCHash *thisvar;
   if (size <= 0) {
 #ifdef MULTICORE
-    BAMBOO_EXIT(0xf409);
+    BAMBOO_EXIT();
 #else
     printf("Negative Hashtable size Exception\n");
     exit(-1);
@@ -487,9 +487,9 @@ int MGCHashcontains(struct MGCHash *thisvar, int data) {
   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
index 5b7a01f49638574093d9103cd3e9dc8199b5a655..22353795571a2530051b94a9f2fd1a4511333ac6 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef GCQUEUE_H
 #define GCQUEUE_H
 
+#include "stdio.h"
+
 #define NUMPTRS 120
 
 struct pointerblock {
@@ -57,6 +59,9 @@ static void gc_queueinit() {
   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;
@@ -72,8 +77,7 @@ static void gc_enqueue_I(unsigned int ptr) {
     gcheadindex=0;
   } 
   gchead->ptrs[gcheadindex++]=ptr;
-} 
-
+}
 
 // dequeue and destroy the queue
 static unsigned int gc_dequeue_I() {
@@ -214,4 +218,96 @@ static unsigned int gc_lobjdequeue4_I(unsigned int * length,
 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
index 970ca5833c6bd2b13402c54f5c47c6a1fe794536..70dddbe09b96b21bf73628358062fd434c2abbcc 100644 (file)
@@ -567,37 +567,21 @@ void cacheAdapt_phase_client() {
 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);
   }
 }
index 93137703d79c0abab4356f11c8e2758b90f29270..6de5d5666c412dda9b614068eb51bca987cdd969 100644 (file)
@@ -1,4 +1,3 @@
-// BAMBOO_EXIT(0xb000);
 // TODO: DO NOT support tag!!!
 #ifdef MULTICORE_GC
 #include "runtime.h"
@@ -9,6 +8,7 @@
 #include "multicoregcflush.h"
 #include "multicoreruntime.h"
 #include "multicoregcprofile.h"
+#include "gcqueue.h"
 
 #ifdef SMEMM
 extern unsigned int gcmem_mixed_threshold;
@@ -177,7 +177,7 @@ void initGC() {
   gccurr_heaptop = 0;
   gcdstcore = 0;
 
-  gcqueue_init();
+  gc_queueinit();
 
   freeMGCHash(gcforwardobjtbl);
   gcforwardobjtbl = allocateMGCHash(20, 3);
@@ -185,6 +185,19 @@ void initGC() {
   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) {
@@ -216,15 +229,10 @@ INLINE void checkMarkStatus() {
         // 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
@@ -730,8 +738,7 @@ void master_getlargeobjs() {
   }
   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) {
@@ -741,7 +748,7 @@ void master_getlargeobjs() {
   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() {
@@ -794,7 +801,7 @@ 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();
@@ -860,7 +867,7 @@ void gc_master(struct garbagelist * stackptr) {
   master_compact();
   
   // update the references
-  master_updaterefs();
+  master_updaterefs(stackptr);
 
   // do cache adaptation
   CACHEADAPT_PHASE_MASTER();
@@ -872,8 +879,9 @@ void gc_master(struct garbagelist * stackptr) {
   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;
@@ -890,9 +898,8 @@ void pregccheck_I() {
       BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
 
       while(!gcprecheck) ;
-      
-      BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT();
     } else {
+      BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
       return;
     }
   }
@@ -938,17 +945,14 @@ bool gc(struct garbagelist * stackptr) {
   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();
index 240d1c0338347a508a59cd5fc7f0e16dfc12e62d..9fa1ac310b873c07ec56d77d9ce6d918bfc9e602 100644 (file)
@@ -210,12 +210,9 @@ unsigned int size_cachepolicytbl;
   { \
     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(); \
     } \
   }
 
@@ -234,7 +231,7 @@ unsigned int size_cachepolicytbl;
 
 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
index 5b4f3adf546bc42cd986a1fddcd8c4409787b564..cfada61b6fcb30d3ee19e87f9709eafb2082e1c4 100644 (file)
@@ -5,14 +5,80 @@
 
 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,
@@ -25,7 +91,11 @@ INLINE void compact2Heaptophelper_I(unsigned int coren,
     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;
@@ -122,12 +192,10 @@ INLINE void resolvePendingMoveRequest() {
       // 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;
@@ -384,50 +452,46 @@ INLINE bool moveobj(struct moveHelper * orig, struct moveHelper * to, unsigned i
 } 
 
 // 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,
@@ -466,15 +530,12 @@ innercompact:
     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;
@@ -495,8 +556,7 @@ innercompact:
 
   if(orig->ptr < gcmarkedptrbound) {
     // still have unpacked obj
-    while(!gctomove)
-      ;
+    while(!gctomove) ;
     
     gctomove = false;
 
@@ -518,7 +578,7 @@ innercompact:
 }
 
 void compact() {
-  BAMBOO_ASSERT(COMPACTPHASE == gcphase, 0xb025);
+  BAMBOO_ASSERT(COMPACTPHASE == gcphase);
   
   // initialize pointers for comapcting
   struct moveHelper * orig = (struct moveHelper *)RUNMALLOC(sizeof(struct moveHelper));
@@ -556,17 +616,11 @@ void compact_master(struct moveHelper * orig, struct moveHelper * to) {
       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();
index d415e7281e85dd363300e3adb43077fece807637..d693d8d7940572fd4951a3be5dc0d814975bffc4 100644 (file)
@@ -21,11 +21,11 @@ struct moveHelper {
 #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
index ea4b45f8134dd13c52a8a8e3fd7b5f22a7dbd159..925cad92701574643a78506b64f86980e69d9d8e 100644 (file)
@@ -3,6 +3,7 @@
 #include "multicoreruntime.h"
 #include "ObjectHash.h"
 #include "GenericHashtable.h"
+#include "gcqueue.h"
 
 /* Task specific includes */
 
@@ -92,7 +93,7 @@ INLINE void flushRuntimeObj(struct garbagelist * stackptr) {
   }
 
   // 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);
@@ -177,18 +178,11 @@ void flush(struct garbagelist * stackptr) {
   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);
@@ -203,7 +197,7 @@ void flush(struct garbagelist * stackptr) {
   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);
index 619c0718a54c70bd916ccac9d49e4bddd1e5b015..72ddd5fa6f576392754319983aae65c8734e68ba 100644 (file)
@@ -77,21 +77,12 @@ INLINE void markObj(void * objptr) {
   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
@@ -116,7 +107,7 @@ INLINE void markgarbagelist(struct garbagelist * listptr) {
 
 // enqueue root objs
 INLINE void tomark(struct garbagelist * stackptr) {
-  BAMBOO_ASSERT(MARKPHASE == gcphase, 0xb010);
+  BAMBOO_ASSERT(MARKPHASE == gcphase);
 
   gcbusystatus = true;
   gcnumlobjs = 0;
@@ -272,16 +263,10 @@ INLINE void mark(bool isfirst, struct garbagelist * stackptr) {
   // 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;
@@ -292,10 +277,8 @@ INLINE void mark(bool isfirst, struct garbagelist * stackptr) {
         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);
@@ -321,8 +304,7 @@ INLINE void mark(bool isfirst, struct garbagelist * stackptr) {
       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;
       }
     }
index 8befb79414a021b7cd9f6afcd70a3453c0d76998..d65a70be79023dbf1e75320f8ba505695fbaf760 100644 (file)
@@ -679,20 +679,20 @@ void * smemalloc_I(int coren,
 
   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;
   }
@@ -745,7 +745,7 @@ void * smemalloc_I(int coren,
   if(mem == NULL) {
     // no enough shared global memory
     *allocsize = 0;
-    BAMBOO_EXIT(0xe103);
+    BAMBOO_EXIT();
   }
   return mem;
 } 
index 4c9a20bf44904cb6a67fd4a9220f33244720342c..e3466bff4610e8d56dd3d56988ee5a94541225e0 100644 (file)
@@ -3,6 +3,7 @@
 #include "runtime.h"
 #include "multicoreruntime.h"
 #include "multicoretaskprofile.h"
+#include "gcqueue.h"
 
 INLINE int checkMsgLength_I(int size) {
   int type = msgdata[msgdataindex];
@@ -21,7 +22,7 @@ INLINE int checkMsgLength_I(int size) {
   case GCSTARTPREF:
 #endif 
 #endif 
-    msglength = 1;
+    return 1;
     break;
 
 #ifdef TASK
@@ -37,12 +38,12 @@ INLINE int checkMsgLength_I(int size) {
   case GCFINISHPREF:
 #endif 
 #endif 
-    msglength = 2;
+    return 2;
     break;
 
   case MEMREQUEST:
   case MEMRESPONSE:
-    msglength = 3;
+    return 3;
     break;
     
   case TRANSTALL:
@@ -62,7 +63,7 @@ INLINE int checkMsgLength_I(int size) {
   case GCPROFILES:
 #endif
 #endif
-    msglength = 4;
+    return 4;
     break;
     
 #ifdef TASK
@@ -73,12 +74,12 @@ INLINE int checkMsgLength_I(int size) {
   case GCFINISHCOMPACT:
   case GCMARKREPORT:
 #endif
-    msglength = 5;
+    return 5;
     break;
     
 #ifdef TASK
   case REDIRECTLOCK:
-    msglength = 6;
+    return 6;
     break;
 #endif
 
@@ -90,7 +91,7 @@ INLINE int checkMsgLength_I(int size) {
 #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;
     }
@@ -98,16 +99,16 @@ INLINE int checkMsgLength_I(int size) {
   }
 
   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]; 
@@ -145,11 +146,9 @@ INLINE void processmsg_transobj_I() {
     } 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);
       }
     }
   }
@@ -157,7 +156,7 @@ INLINE void processmsg_transobj_I() {
 }
 
 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();
@@ -200,12 +199,12 @@ INLINE void processmsg_lockrequest_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
@@ -219,8 +218,8 @@ INLINE void processmsg_lockdeny_I() {
   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
@@ -251,16 +250,14 @@ INLINE void processmsg_redirectlock_I() {
   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);
     }
   }
 }
@@ -269,7 +266,7 @@ INLINE void processmsg_redirectgrount_I() {
   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();
@@ -287,8 +284,8 @@ INLINE void processmsg_redirectdeny_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
@@ -303,13 +300,13 @@ INLINE void processmsg_redirectrelease_I() {
   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();
@@ -326,7 +323,7 @@ INLINE void processmsg_profileoutput_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;
@@ -334,15 +331,13 @@ INLINE void processmsg_profilefinish_I() {
 #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);
   }
 }
 
@@ -356,7 +351,7 @@ INLINE void processmsg_statusreport_I() {
   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--;
   }
@@ -381,7 +376,7 @@ INLINE void processmsg_memrequest_I() {
   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
@@ -393,9 +388,9 @@ INLINE void processmsg_memrequest_I() {
     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
@@ -486,7 +481,7 @@ INLINE void processmsg_gcfinishpre_I() {
   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;
@@ -499,7 +494,7 @@ INLINE void processmsg_gcfinishinit_I() {
   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) {
@@ -515,7 +510,7 @@ INLINE void processmsg_gcfinishmark_I() {
   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) {
@@ -534,7 +529,7 @@ INLINE void processmsg_gcfinishmark_I() {
 }
 
 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();      
@@ -573,7 +568,7 @@ INLINE void processmsg_gcfinishflush_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) {
@@ -588,15 +583,13 @@ INLINE void processmsg_gcfinish_I() {
 }
 
 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);
   }
 }
 
@@ -610,9 +603,9 @@ INLINE void processmsg_gcmarkreport_I() {
   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--;
@@ -626,7 +619,7 @@ INLINE void processmsg_gcmarkreport_I() {
 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) {
@@ -655,7 +648,7 @@ INLINE void processmsg_gclobjinfo_I() {
   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;
@@ -707,7 +700,7 @@ INLINE void processmsg_gcfinishpref_I() {
   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) {
@@ -745,8 +738,9 @@ msg:
 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) {
@@ -766,7 +760,7 @@ processmsg:
 #ifdef TASK
     case TRANSOBJ: {
       // receive a object transfer msg
-      processmsg_transobj_I();
+      processmsg_transobj_I(msglength);
       break;
     }  
 #endif 
@@ -990,7 +984,6 @@ processmsg:
     default:
       break;
     }
-    msglength = BAMBOO_MSG_BUF_LENGTH;
 
     if((msgdataindex != msgdatalast) || (msgdatafull)) {
       // still have available msg
index 90cb9ad5af08d724f1fec834197fb83128f8fa9d..1069ec89596521ac6e1e7157d10cd09692ead657 100644 (file)
@@ -11,7 +11,7 @@ int msgdata[BAMBOO_MSG_BUF_LENGTH];
 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;
@@ -47,7 +47,7 @@ volatile bool isMsgHanging;
 #define OUTMSG_LASTINDEXINC() \
   outmsglast = (outmsglast + 1) & (BAMBOO_OUT_BUF_MASK); \
   if(outmsglast == outmsgindex) { \
-    BAMBOO_EXIT(0xd101); \
+    BAMBOO_EXIT(); \
   }
 
 #define OUTMSG_CACHE(n) \
@@ -207,74 +207,26 @@ typedef enum {
 } 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
index de05e9ccf7ae98463b34f4c9affef158d8587f4d..084f4a04db86a76fca3422780c0ab6336da11dff 100644 (file)
@@ -287,13 +287,11 @@ void CALL11(___System______exit____I,
 // 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
@@ -502,7 +500,7 @@ void failedboundschk(int num) {
 #ifdef THREADS
   threadexit();
 #elif defined MGC
-  BAMBOO_EXIT(0xa0000000 + num);
+  BAMBOO_EXIT();
 #else
   exit(-1);
 #endif
@@ -511,7 +509,7 @@ void failedboundschk(int num) {
   printf("Array out of bounds\n");
   longjmp(error_handler,2);
 #else
-  BAMBOO_EXIT(0xa0000000 + num);
+  BAMBOO_EXIT();
 #endif
 #endif
 }
@@ -543,7 +541,7 @@ void failednullptr(void * ptr) {
 #ifdef THREADS
   threadexit();
 #elif defined MGC
-  BAMBOO_EXIT(0xa001);
+  BAMBOO_EXIT();
 #else
   exit(-1);
 #endif
@@ -552,7 +550,7 @@ void failednullptr(void * ptr) {
   printf("NULL ptr\n");
   longjmp(error_handler,2);
 #else
-  BAMBOO_EXIT(0xa001);
+  BAMBOO_EXIT();
 #endif
 #endif
 }
@@ -593,7 +591,7 @@ INLINE void initruntimedata() {
   }
   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;
@@ -641,7 +639,7 @@ INLINE void recordtotalexetime() {
 #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();
@@ -720,7 +718,7 @@ INLINE void checkCoreStatus() {
           // 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();
@@ -838,8 +836,7 @@ inline void run(int argc, char** argv) {
             } 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;
index c54bd2cea4f83934eee8a900e772e6eeeea484e1..a26cf0a26288efc7c4e9a3b9ddbc653975c02306 100644 (file)
@@ -73,16 +73,6 @@ INLINE void initlock(struct ___Object___ * v);
 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);}
-
 ///////////////////////////////////////////////////////////
 
 /////////////////////////////////////////////////////////////////////////////
@@ -96,8 +86,11 @@ INLINE void terminatememprof(void);
 // 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    //
index a54a063e15f2bee2438aadd01ad534d5ade76a6c..d4b6f329ac5ae26ee2f6a39286425f7bedccb586 100644 (file)
@@ -98,12 +98,9 @@ INLINE bool checkObjQueue() {
   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;
@@ -115,7 +112,6 @@ INLINE bool checkObjQueue() {
       BAMBOO_WAITING_FOR_LOCK(0);
     } 
     grount = lockresult;
-    BAMBOO_DEBUGPRINT_REG(grount);
 
     lockresult = 0;
     lockobj = 0;
@@ -137,10 +133,7 @@ INLINE bool checkObjQueue() {
        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);
@@ -168,18 +161,15 @@ INLINE bool checkObjQueue() {
       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;
 }
 
@@ -959,37 +949,26 @@ void releasewritelock_r(void * lock, void * redirectlock) {
   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
@@ -1012,7 +991,6 @@ void executetasks() {
 newtask:
   while(hashsize(activetasks)>0) {
     GCCHECK(NULL);
-    BAMBOO_DEBUGPRINT(0xe990);
 
     /* See if there are any active tasks */
     int i;
@@ -1068,17 +1046,13 @@ newtask:
       }
     }  // 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);
       }
@@ -1098,11 +1072,8 @@ newtask:
       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           
@@ -1125,7 +1096,6 @@ newtask:
       }
     }   // 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];
@@ -1139,8 +1109,6 @@ newtask:
       /* 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);
@@ -1170,8 +1138,6 @@ newtask:
           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);
@@ -1199,7 +1165,6 @@ parameterpresent:
         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++) {
@@ -1233,7 +1198,6 @@ execute:
 #endif
       PROFILE_TASK_START(currtpd->task->name);
 
-      BAMBOO_DEBUGPRINT(0xe997);
       ((void (*)(void **))currtpd->task->taskptr)(taskpointerarray);
 
 #ifdef ACCURATEPROFILE
@@ -1242,17 +1206,11 @@ execute:
       // 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)) {
@@ -1279,10 +1237,8 @@ execute:
       RUNFREE(currtpd->parameterArray);
       RUNFREE(currtpd);
       currtpd = NULL;
-      BAMBOO_DEBUGPRINT(0xe99a);
     }   
   } //  while(hashsize(activetasks)>0)
-  BAMBOO_DEBUGPRINT(0xe99b);
 }
 
 /* This function processes an objects tags */
index 396e57b121d1d2fc246d7ace336e666d861fb2e1..d15d235899584e8dd2654f8e6523020852ef4a5a 100644 (file)
@@ -43,16 +43,16 @@ void releasewritelock_r(void * lock, void * redirectlock);
 // 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();
index 70c802962a58545190e8bbcf932e6e489aa796fc..dc502d5c37fa4d90ff62981b0f18f27d7a867a33 100644 (file)
@@ -32,7 +32,7 @@ memalloc:
       hasgc++;
     } else {
       // no more global shared memory
-      BAMBOO_EXIT(0xc001);
+      BAMBOO_EXIT();
     }
 
     // try to malloc again
@@ -55,7 +55,7 @@ void * mycalloc_share(int m,
   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
@@ -86,7 +86,7 @@ inermycalloc_i:
     }
 #endif
     printf("mycalloc %s %d \n", file, line);
-    BAMBOO_EXIT(0xc003);
+    BAMBOO_EXIT();
   }
   BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME();
   return p;
@@ -115,7 +115,7 @@ inermycalloc_i:
     }
 #endif
     tprintf("mycalloc_i %s %d \n", file, line);
-    BAMBOO_EXIT(0xc004);
+    BAMBOO_EXIT();
   }
   return p;
 }