Add the runtime for multicore gc version w/o tasks. Now can start multiple threads...
authorjzhou <jzhou>
Thu, 14 Oct 2010 01:09:55 +0000 (01:09 +0000)
committerjzhou <jzhou>
Thu, 14 Oct 2010 01:09:55 +0000 (01:09 +0000)
Robust/src/IR/Flat/BuildCode.java
Robust/src/IR/Flat/BuildCodeMGC.java [new file with mode: 0644]
Robust/src/IR/Flat/BuildCodeMultiCore.java
Robust/src/IR/State.java
Robust/src/Main/Main.java
Robust/src/Runtime/bamboo/multicoremem.h
Robust/src/Runtime/bamboo/multicoreruntime.c
Robust/src/Runtime/bamboo/multicoreruntime.h
Robust/src/Runtime/runtime.h
Robust/src/buildscript

index 7c9e338c8b23948a58d3c9d00d38683bc080955e..3e119b9fd8218b1909a5752889f60f0a9930a48f 100644 (file)
@@ -387,7 +387,7 @@ public class BuildCode {
    * The main C method packs up the arguments into a string array
    * and passes it to the java main method. */
 
-  private void outputMainMethod(PrintWriter outmethod) {
+  protected void outputMainMethod(PrintWriter outmethod) {
     outmethod.println("int main(int argc, const char *argv[]) {");
     outmethod.println("  int i;");
 
@@ -600,7 +600,9 @@ public class BuildCode {
       outmethod.println("#include \"localobjects.h\"");
     }
     if(state.MULTICORE) {
-      outmethod.println("#include \"task.h\"");
+      if(state.TASK) {
+        outmethod.println("#include \"task.h\"");
+      }
          outmethod.println("#include \"multicoreruntime.h\"");
          outmethod.println("#include \"runtime_arch.h\"");
     }
@@ -765,6 +767,13 @@ public class BuildCode {
       outclassdefs.println("  void * lockentry;");
       outclassdefs.println("  int lockcount;");
     }
+    if(state.MGC) {
+      outclassdefs.println("  int mutex;");  
+      outclassdefs.println("  int objlock;");
+      if(state.MULTICOREGC) {
+        outclassdefs.println("  int marked;");
+      }
+    } 
     if (state.TASK) {
       outclassdefs.println("  int flag;");
       if(!state.MULTICORE) {
@@ -1511,7 +1520,13 @@ public class BuildCode {
       classdefout.println("  void * lockentry;");
       classdefout.println("  int lockcount;");
     }
-
+    if(state.MGC) {
+      classdefout.println("  int mutex;");  
+      classdefout.println("  int objlock;");
+      if(state.MULTICOREGC) {
+        classdefout.println("  int marked;");
+      }
+    } 
     if (state.TASK) {
       classdefout.println("  int flag;");
       if((!state.MULTICORE) || (cn.getSymbol().equals("TagDescriptor"))) {
diff --git a/Robust/src/IR/Flat/BuildCodeMGC.java b/Robust/src/IR/Flat/BuildCodeMGC.java
new file mode 100644 (file)
index 0000000..85ffe66
--- /dev/null
@@ -0,0 +1,168 @@
+package IR.Flat;
+
+import java.io.FileOutputStream;
+import java.io.PrintWriter;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Queue;
+import java.util.Set;
+import java.util.Vector;
+
+import Analysis.Locality.LocalityBinding;
+import Analysis.Scheduling.Schedule;
+import Analysis.TaskStateAnalysis.FEdge;
+import Analysis.TaskStateAnalysis.FlagState;
+import Analysis.TaskStateAnalysis.SafetyAnalysis;
+import Analysis.OwnershipAnalysis.AllocationSite;
+import Analysis.OwnershipAnalysis.OwnershipAnalysis;
+import Analysis.OwnershipAnalysis.HeapRegionNode;
+import Analysis.Prefetch.*;
+import IR.ClassDescriptor;
+import IR.Descriptor;
+import IR.FlagDescriptor;
+import IR.MethodDescriptor;
+import IR.State;
+import IR.TagVarDescriptor;
+import IR.TaskDescriptor;
+import IR.TypeDescriptor;
+import IR.TypeUtil;
+import IR.VarDescriptor;
+import IR.Tree.DNFFlag;
+import IR.Tree.DNFFlagAtom;
+import IR.Tree.FlagExpressionNode;
+import IR.Tree.TagExpressionList;
+
+public class BuildCodeMGC extends BuildCode {
+  int coreNum;
+  int tcoreNum;
+  int gcoreNum;
+  int startupcorenum;    // record the core containing startup task, s
+  // uppose only one core can have startup object
+
+  public BuildCodeMGC(State st, 
+                      Hashtable temptovar, 
+                      TypeUtil typeutil, 
+                      SafetyAnalysis sa,
+                      int coreNum, 
+                      int tcoreNum,
+                      int gcoreNum,
+                      PrefetchAnalysis pa) {
+    super(st, temptovar, typeutil, sa, pa);
+    this.coreNum = coreNum; // # of the active cores
+    this.tcoreNum = tcoreNum; // # of the total number of cores
+    this.gcoreNum = gcoreNum; // # of the cores for gc if any
+    this.startupcorenum = 0;
+  }
+
+  public void buildCode() {
+    /* Create output streams to write to */
+    PrintWriter outclassdefs=null;
+    PrintWriter outstructs=null;
+    PrintWriter outmethodheader=null;
+    PrintWriter outmethod=null;
+    PrintWriter outvirtual=null;
+
+    try {
+      outstructs=new PrintWriter(new FileOutputStream(PREFIX+"structdefs.h"), true);
+      outmethodheader=new PrintWriter(new FileOutputStream(PREFIX+"methodheaders.h"), true);
+      outclassdefs=new PrintWriter(new FileOutputStream(PREFIX+"classdefs.h"), true);
+      outvirtual=new PrintWriter(new FileOutputStream(PREFIX+"virtualtable.h"), true);
+      outmethod=new PrintWriter(new FileOutputStream(PREFIX+"methods.c"), true);
+    } catch (Exception e) {
+      e.printStackTrace();
+      System.exit(-1);
+    }
+
+    /* Build the virtual dispatch tables */
+    super.buildVirtualTables(outvirtual);
+
+    /* Output includes */
+    outmethodheader.println("#ifndef METHODHEADERS_H");
+    outmethodheader.println("#define METHODHEADERS_H");
+    outmethodheader.println("#include \"structdefs.h\"");
+
+    /* Output Structures */
+    super.outputStructs(outstructs);
+
+    // Output the C class declarations
+    // These could mutually reference each other
+    super.outputClassDeclarations(outclassdefs);
+
+    // Output function prototypes and structures for parameters
+    Iterator it=state.getClassSymbolTable().getDescriptorsIterator();
+    int numclasses = this.state.numClasses();
+    while(it.hasNext()) {
+      ClassDescriptor cn=(ClassDescriptor)it.next();
+      super.generateCallStructs(cn, outclassdefs, outstructs, outmethodheader);
+    }
+    outclassdefs.close();
+
+    /* Build the actual methods */
+    super.outputMethods(outmethod);
+
+    /* Record maximum number of task parameters */
+    //outstructs.println("#define MAXTASKPARAMS "+maxtaskparams);
+    /* Record maximum number of all types, i.e. length of classsize[] */
+    outstructs.println("#define NUMTYPES "+(state.numClasses() + state.numArrays()));
+    /* Record number of total cores */
+    outstructs.println("#define NUMCORES "+this.tcoreNum);
+    /* Record number of active cores */
+    outstructs.println("#define NUMCORESACTIVE "+this.coreNum); // this.coreNum 
+                                    // can be reset by the scheduling analysis
+    /* Record number of garbage collection cores */
+    outstructs.println("#ifdef MULTICORE_GC");
+    outstructs.println("#define NUMCORES4GC "+this.gcoreNum);
+    outstructs.println("#endif");
+    /* Record number of core containing startup task */
+    outstructs.println("#define STARTUPCORE "+this.startupcorenum);
+    
+    if (state.main!=null) {
+    /* Generate main method */
+      outputMainMethod(outmethod);
+    }
+
+    /* Close files */
+    outmethodheader.println("#endif");
+    outmethodheader.close();
+    outmethod.close();
+    outstructs.println("#endif");
+    outstructs.close();
+  }
+  
+  protected void outputMainMethod(PrintWriter outmethod) {
+    outmethod.println("int mgc_main(int argc, const char *argv[]) {");
+    outmethod.println("  int i;");
+    
+    if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
+      outmethod.println("  struct ArrayObject * stringarray=allocate_newarray(NULL, STRINGARRAYTYPE, argc-1);");
+    } else {
+      outmethod.println("  struct ArrayObject * stringarray=allocate_newarray(STRINGARRAYTYPE, argc-1);");
+    }
+    outmethod.println("  for(i=1;i<argc;i++) {");
+    outmethod.println("    int length=strlen(argv[i]);");
+    if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
+      outmethod.println("    struct ___String___ *newstring=NewString(NULL, argv[i], length);");
+    } else {
+      outmethod.println("    struct ___String___ *newstring=NewString(argv[i], length);");
+    }
+    outmethod.println("    ((void **)(((char *)& stringarray->___length___)+sizeof(int)))[i-1]=newstring;");
+    outmethod.println("  }");
+
+    MethodDescriptor md=typeutil.getMain();
+    ClassDescriptor cd=typeutil.getMainClass();
+
+    outmethod.println("   {");
+    if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) {
+      outmethod.print("       struct "+cd.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={");
+      outmethod.println("1, NULL,"+"stringarray};");
+      outmethod.println("     "+cd.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"(& __parameterlist__);");
+    } else {
+      outmethod.println("     "+cd.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"(stringarray);");
+    }
+    outmethod.println("   }");
+
+    outmethod.println("}");
+  }
+}
index 4d97167e83b4eb46262f0bf63e5d3d64186c812a..ba46a7a8d383126dbe533151a392d6c234b08cdd 100644 (file)
@@ -301,9 +301,9 @@ public class BuildCodeMultiCore extends BuildCode {
       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("#ifdef MULTICORE_GC");
       outstructs.println("#define NUMCORES4GC "+this.gcoreNum);
-      outtask.println("#endif");
+      outstructs.println("#endif");
       /* Record number of core containing startup task */
       outstructs.println("#define STARTUPCORE "+this.startupcorenum);
     }     //else if (state.main!=null) {
index 5980ee086cb367d33ea1090097d85e4d12abeed8..3844d94d3e6eadbf39d3348abd69ad68a137eef9 100644 (file)
@@ -153,6 +153,9 @@ public class State {
   public int CORENUM4GC = 0;
   public String profilename = null;
   public String outputdir = "/scratch/";
+  // MGC options
+  public boolean MGC=false;
+  
   //Other options
   public String structfile;
   public String main;
index 33e717ba5205858bbcebb8d4d1fa066a308ec56b..e95f14c98a3c22828e120bcc7c63521fa9660ca7 100644 (file)
@@ -15,6 +15,7 @@ import IR.Tree.ParseNode;
 import IR.Tree.BuildIR;
 import IR.Tree.SemanticCheck;
 import IR.Flat.BuildCodeMultiCore;
+import IR.Flat.BuildCodeMGC;
 import IR.Flat.BuildFlat;
 import IR.Flat.BuildCode;
 import IR.Flat.Inliner;
@@ -147,6 +148,8 @@ public class Main {
        state.MULTICORE=true;
       else if (option.equals("-multicoregc"))
         state.MULTICOREGC=true;
+      else if (option.equals("-mgc"))
+        state.MGC = true;
       else if (option.equals("-ownership"))
        state.OWNERSHIP=true;
       else if (option.equals("-ownallocdepth")) {
@@ -569,7 +572,7 @@ public class Main {
        CallGraph callGraph = new CallGraph(state);
        Liveness liveness = new Liveness();
         ArrayReferencees ar = new ArrayReferencees(state);
-       OwnershipAnalysis oa = new OwnershipAnalysis(state,
+       OwnershipAnalysis oa = null;/*new OwnershipAnalysis(state,
                                                     tu,
                                                     callGraph,
                                                  liveness,
@@ -577,7 +580,7 @@ public class Main {
                                                     state.OWNERSHIPALLOCDEPTH,
                                                     state.OWNERSHIPWRITEDOTS,
                                                     state.OWNERSHIPWRITEALL,
-                                                    state.OWNERSHIPALIASFILE);
+                                                    state.OWNERSHIPALIASFILE);*/
        
        // synthesis a layout according to target multicore processor
        MCImplSynthesis mcImplSynthesis = new MCImplSynthesis(state,
@@ -617,6 +620,22 @@ public class Main {
        }
       }
     }
+    
+    if (state.MGC) {
+      // generate multicore codes
+      if(state.MULTICORE) {
+        BuildCodeMGC bcmgc=new BuildCodeMGC(state,
+                                            bf.getMap(),
+                                            tu,
+                                            sa,
+                                            state.CORENUM,
+                                            state.CORENUM,
+                                            state.CORENUM4GC,
+                                            pa);
+        bcmgc.buildCode();
+      }
+    }
+  
     if(!state.MULTICORE) {
       if (state.DSM||state.SINGLETM) {
        CallGraph callgraph=new CallGraph(state);
index 6d124e5e93df812d4e30249ae4a13a1e262da942..44b19805fa97010a1183bfe874304577a4a7b776 100644 (file)
@@ -1,5 +1,7 @@
 #ifndef MULTICORE_MEM_H
 #define MULTICORE_MEM_H
+#include "Queue.h"
+#include "SimpleHash.h"
 
 #ifndef INTPTR
 #ifdef BIT64
@@ -88,9 +90,6 @@
 
 #ifdef MULTICORE_GC
 volatile bool gc_localheap_s;
-#endif
-
-#ifdef MULTICORE_GC
 #include "multicoregarbage.h"
 
 typedef enum {
@@ -133,7 +132,7 @@ volatile INTPTR bamboo_smem_zero_top;
 //volatile mspace bamboo_free_msp;
 INTPTR bamboo_free_smemp;
 int bamboo_free_smem_size;
-#endif
+#endif // MULTICORE_GC
 volatile bool smemflag;
 volatile INTPTR bamboo_cur_msp;
 volatile int bamboo_smem_size;
index 7e33af8351f6b137a5968183380c2b04b1c7bb3c..6913fc748192d13c4f92d59cfd6e6c18de969215 100644 (file)
@@ -9,9 +9,6 @@
 #ifndef RAW
 #include <stdio.h>
 #endif
-#ifdef MGC
-#include "thread.h"
-#endif
 
 #ifndef INLINE
 #define INLINE    inline __attribute__((always_inline))
@@ -32,6 +29,9 @@ extern unsigned int gcmem_mixed_usedmem;
 #endif // MULTICORE_GC
 
 int debugtask=0;
+#ifdef MGC
+int corenum = 0;
+#endif
 
 int instanceof(struct ___Object___ *ptr, int type) {
   int i=ptr->type;
@@ -117,6 +117,20 @@ long CALL00(___System______currentTimeMillis____) {
 }
 
 void CALL01(___System______printString____L___String___,struct ___String___ * ___s___) {
+#ifdef MGC
+#ifdef TILERA_BME
+  struct ArrayObject * chararray=VAR(___s___)->___value___;
+  int i;
+  int offset=VAR(___s___)->___offset___;
+  tprintf("");
+  for(i=0; i<VAR(___s___)->___count___; i++) {
+       short sc=
+         ((short *)(((char *)&chararray->___length___)+sizeof(int)))[i+offset];
+    printf("%c", sc);
+  }
+  printf("\n");
+#endif // TILERA_BME
+#endif // MGC
 }
 
 /* Object allocation function */
@@ -126,9 +140,11 @@ void * allocate_new(void * ptr, int type) {
   struct ___Object___ * v=
        (struct ___Object___*)FREEMALLOC((struct garbagelist*) ptr,classsize[type]);
   v->type=type;
+#ifdef TASK
   v->version = 0;
   v->lock = NULL;
   v->lockcount = 0;
+#endif
   initlock(v);
 #ifdef GC_PROFILE
   extern unsigned int gc_num_obj;
@@ -144,8 +160,10 @@ struct ArrayObject * allocate_newarray(void * ptr, int type, int length) {
        FREEMALLOC((struct garbagelist*)ptr,
                sizeof(struct ArrayObject)+length*classsize[type]);
   v->type=type;
+#ifdef TASK
   v->version = 0;
   v->lock = NULL;
+#endif
   if (length<0) {
     return NULL;
   }
@@ -162,8 +180,10 @@ struct ArrayObject * allocate_newarray(void * ptr, int type, int length) {
 void * allocate_new(int type) {
   struct ___Object___ * v=FREEMALLOC(classsize[type]);
   v->type=type;
+#ifdef TASK
   v->version = 0;
   v->lock = NULL;
+#endif
   initlock(v);
   return v;
 }
@@ -174,8 +194,10 @@ struct ArrayObject * allocate_newarray(int type, int length) {
   struct ArrayObject * v=
        FREEMALLOC(sizeof(struct ArrayObject)+length*classsize[type]);
   v->type=type;
+#ifdef TASK
   v->version = 0;
   v->lock = NULL;
+#endif
   v->___length___=length;
   initlock(v);
   return v;
@@ -369,9 +391,9 @@ INLINE void initruntimedata() {
 #endif
 
 #ifdef MGC
-  // TODO
-  threadlocks = 0;
-#endif
+  initializethreads();
+  bamboo_current_thread = NULL;
+#endif // MGC
 
 #ifdef TASK
   inittaskdata();
@@ -536,10 +558,8 @@ INLINE void checkCoreStatus() {
 }
 
 // main function for each core
-inline void run(void * arg) {
+inline void run(int argc, char** argv) {
   int i = 0;
-  int argc = 1;
-  char ** argv = NULL;
   bool sendStall = false;
   bool isfirst = true;
   bool tocontinue = false;
@@ -592,6 +612,13 @@ inline void run(void * arg) {
     BAMBOO_DEBUGPRINT(0xee00);
 #endif
 
+#ifdef MGC
+       if(STARTUPCORE == BAMBOO_NUM_OF_CORE) {
+         // run the main method in the specified mainclass
+         mgc_main(argc, argv);
+       }
+#endif
+
     while(true) {
 
 #ifdef MULTICORE_GC
@@ -619,7 +646,8 @@ inline void run(void * arg) {
       // if yes, enqueue them and executetasks again
       tocontinue = checkObjQueue();
 #elif defined MGC
-         // TODO
+         trystartthread();
+         tocontinue = false;
 #endif
 
       if(!tocontinue) {
index dd423081eb32a8ef14bc22da756e75f221e1b369..bcff03a3d6da6146513967ed3e2c726c96573f81 100644 (file)
@@ -1,7 +1,6 @@
 #ifndef MULTICORE_RUNTIME
 #define MULTICORE_RUNTIME
 #include "structdefs.h"
-#include "Queue.h"
 
 #ifndef INLINE
 #define INLINE    inline __attribute__((always_inline))
@@ -25,6 +24,31 @@ int totalexetime;
 bool reside;
 #endif
 
+#ifdef MGC
+// shared memory pointer for global thread queue
+// In MGC version, this block of memory is located at the very bottom of the 
+// shared memory with the base address as BAMBOO_BASE_VA.
+// The bottom of the shared memory = global thread queue + sbstart tbl 
+//                                  + smemtbl + NUMCORES4GC bamboo_rmsp
+// This queue is always reside at the bottom of the shared memory.  It is 
+// considered as runtime structure, during gc, it is scanned for mark and flush 
+// phase but never been compacted.
+//
+// This is a loop array and the first 4 int fields of the queue are:
+//     mutex + thread counter + start pointer + end pointer
+#ifdef GC_SMALLPAGESIZE
+#define BAMBOO_THREAD_QUEUE_SIZE (1024 * 1024)
+#else
+#define BAMBOO_THREAD_QUEUE_SIZE (BAMBOO_SMEM_SIZE) // (45 * 16 * 1024)
+#endif
+// data structures for threads
+INTPTR * bamboo_thread_queue;
+unsigned int bamboo_max_thread_num_mask;
+INTPTR bamboo_current_thread;
+
+extern int corenum;
+#endif // MGC
+
 // data structures for msgs
 #define BAMBOO_OUT_BUF_LENGTH 2048
 #define BAMBOO_OUT_BUF_MASK (0x7FF)
@@ -405,7 +429,7 @@ INLINE void cache_msg_6(int targetcore,
                         unsigned long n3,
                         unsigned long n4,
                         unsigned long n5);
-INLINE int receiveMsg(uint32_t send_port_pending);
+INLINE int receiveMsg(unsigned int send_port_pending);
 
 #ifdef MULTICORE_GC
 INLINE void transferMarkResults();
@@ -461,7 +485,6 @@ void outputProfileData();
 // BAMBOO_DIE(x): error exit routine with error msg                        //
 // BAMBOO_GET_EXE_TIME(): rountine to get current clock cycle number       //
 // BAMBOO_MSG_AVAIL(): checking if there are msgs coming in                //
-// BAMBOO_GCMSG_AVAIL(): checking if there are gcmsgs coming in            //
 // BAMBOO_ENTER_RUNTIME_MODE_FROM_CLIENT(): change to runtime mode from    //
 //                                          client mode                    //
 // BAMBOO_ENTER_CLIENT_MODE_FROM_RUNTIME(): change to client mode from     //
index 47b912833fc13679d10d5dd585c7054962697305..f9090d483a5553b70e449f0bb39b230a4114dbf0 100644 (file)
@@ -120,8 +120,17 @@ void createstartupobject();
 #define CALL35(name, rest, rest2, rest3, alt1, alt2, alt3, alt4, alt5) name(alt1, alt2, alt3, alt4, alt5)
 #endif
 
-#ifdef TASK
+#ifdef MULTICORE
 #include "SimpleHash.h"
+inline void run(int argc, char** argv);
+int receiveObject(int send_port_pending);
+void * smemalloc_I(int coren, int size, int * allocsize);
+#ifdef MULTICORE_GC
+inline void setupsmemmode(void);
+#endif
+#endif
+
+#ifdef TASK
 #ifndef MULTICORE
 #include "chash.h"
 #include "ObjectHash.h"
@@ -156,11 +165,6 @@ extern struct ___Object___ * ___fcrevert___;
 #endif
 
 #ifdef MULTICORE
-inline void run(void * arg);
-#ifdef MULTICORE_GC
-inline void setupsmemmode(void);
-#endif
-int receiveObject(int send_port_pending);
 void flagorand(void * ptr, int ormask, int andmask, struct parameterwrapper ** queues, int length);
 void flagorandinit(void * ptr, int ormask, int andmask);
 void enqueueObject(void * ptr, struct parameterwrapper ** queues,int length);
@@ -170,7 +174,6 @@ inline void addNewObjInfo(void * nobj);
 #endif
 int * getAliasLock(void ** ptrs, int length, struct RuntimeHash * tbl);
 void addAliasLock(void * ptr, int lock);
-void * smemalloc_I(int coren, int size, int * allocsize);
 #else
 void flagorand(void * ptr, int ormask, int andmask);
 void flagorandinit(void * ptr, int ormask, int andmask);
index a4b4958d4f8148e0a50dd5190e6230a3492eb197..d1a13169a36158b4a1f94289c930a8ad9cb9be79 100755 (executable)
@@ -508,6 +508,7 @@ GCCACHESAMPLINGFLAG=true
 elif [[ $1 = '-mgc' ]]
 then
 MGCFLAG=true
+JAVAOPTS="$JAVAOPTS -mgc"
 elif [[ $1 = '-dmalloc' ]]
 then
 USEDMALLOC=true
@@ -716,6 +717,10 @@ elif $THREADFLAG
 then
 #threading java stuff
 JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/JavaThread"
+elif $MGCFLAG
+then
+#base multicore gc files
+JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/MGC"
 fi
 #base java stuff
 JAVAOPTS="$JAVAOPTS -classlibrary $ROBUSTROOT/ClassLibrary/Java"
@@ -882,7 +887,12 @@ cd $TILERADIR
 make clean
 rm ./*
 
+if $MGCFLAG
+then
+export TILERACFLAGS="-DMULTICORE -DCLOSE_PRINT -DTILERA"
+else
 export TILERACFLAGS="-DTASK -DMULTICORE -DCLOSE_PRINT -DTILERA"
+fi
 
 if $TILERAMEMPROFFLAG
 then # not only with 1 core
@@ -1043,7 +1053,12 @@ then # GC_CACHE_ADAPT version
 TILERACFLAGS="${TILERACFLAGS} -DGC_CACHE_SAMPLING"
 fi
 
+if $MGCFLAG
+then
+cp $ROBUSTROOT/Tilera/Runtime/MGC/$MAKEFILE ./Makefile
+else
 cp $ROBUSTROOT/Tilera/Runtime/$TILERA_INDIR/$MAKEFILE ./Makefile
+fi
 if $TILERABMEFLAG
 then # TILERABMEFLAG
 cp $ROBUSTROOT/Tilera/Runtime/$TILERA_INDIR/$SIMHVC ./sim.hvc
@@ -1058,7 +1073,10 @@ fi
 cp ../Runtime/Queue.c ./
 cp ../Runtime/file.c ./
 cp ../Runtime/math.c ./
+if [ !$MGCFLAG ]
+then
 cp ../Runtime/object.c ./
+fi
 cp ../Runtime/GenericHashtable.c ./
 cp ../Runtime/SimpleHash.c ./
 cp ../Runtime/ObjectHash.c ./
@@ -1066,7 +1084,10 @@ cp ../Runtime/socket.c ./
 cp ../Runtime/mem.c ./
 cp ../Runtime/GenericHashtable.h ./
 cp ../Runtime/mem.h ./
+if [ !$MGCFLAG ]
+then
 cp ../Runtime/object.h ./
+fi
 cp ../Runtime/ObjectHash.h ./
 cp ../Runtime/Queue.h ./
 cp ../Runtime/runtime.h ./
@@ -1100,6 +1121,11 @@ fi
 #then # TILERAMEMPROFFLAG
 cp ../Tilera/Runtime/$TILERA_INDIR/linux_client.c ./
 #fi
+if $MGCFLAG
+then
+cp ../Tilera/Runtime/MGC/*.c ./
+cp ../Tilera/Runtime/MGC/*.h ./
+fi
 cp ../Tilera/lib/* ./
 cp ../$tmpbuilddirectory/*.c ./
 cp ../$tmpbuilddirectory/*.h ./