change in the multicore version runtime. now it is able to choose which cores to...
[IRC.git] / Robust / src / Main / Main.java
index 340df9d83c74f66365996ec0f47e2b7a37cf28a6..748c0027fa06bdfcf33a21ecfae53e671574d0e8 100644 (file)
@@ -41,8 +41,11 @@ import Analysis.Locality.GenerateConversions;
 import Analysis.Prefetch.PrefetchAnalysis;
 import Analysis.FlatIRGraph.FlatIRGraph;
 import Analysis.OwnershipAnalysis.OwnershipAnalysis;
+import Analysis.Disjoint.DisjointAnalysis;
 import Analysis.MLP.MLPAnalysis;
 import Analysis.Loops.*;
+import Analysis.Liveness;
+import Analysis.ArrayReferencees;
 import IR.MethodDescriptor;
 import IR.Flat.FlatMethod;
 import Interface.*;
@@ -89,6 +92,9 @@ public class Main {
       } else if(option.equals("-numcore")) {
        ++i;
        state.CORENUM = Integer.parseInt(args[i]);
+      } else if(option.equals("-numcore4gc")) {
+        ++i;
+        state.CORENUM4GC = Integer.parseInt(args[i]);
       } else if (option.equals("-mainclass"))
        state.main=args[++i];
       else if (option.equals("-trueprob")) {
@@ -111,10 +117,20 @@ public class Main {
        state.TASK=true;
       else if (option.equals("-abortreaders"))
        state.ABORTREADERS=true;
+      else if (option.equals("-sandbox"))
+       state.SANDBOX=true;
       else if (option.equals("-taskstate"))
        state.TASKSTATE=true;
       else if (option.equals("-tagstate"))
        state.TAGSTATE=true;
+      else if (option.equals("-stmarray"))
+       state.STMARRAY=true;
+      else if (option.equals("-eventmonitor"))
+       state.EVENTMONITOR=true;
+      else if (option.equals("-dualview"))
+       state.DUALVIEW=true;
+      else if (option.equals("-hybrid"))
+       state.HYBRID=true;
       else if (option.equals("-flatirtasks")) {
        state.FLATIRGRAPH=true;
        state.FLATIRGRAPHTASKS=true;
@@ -126,6 +142,8 @@ public class Main {
        state.FLATIRGRAPHLIBMETHODS=true;
       } else if (option.equals("-multicore"))
        state.MULTICORE=true;
+      else if (option.equals("-multicoregc"))
+        state.MULTICOREGC=true;
       else if (option.equals("-ownership"))
        state.OWNERSHIP=true;
       else if (option.equals("-ownallocdepth")) {
@@ -135,8 +153,47 @@ public class Main {
        if (args[++i].equals("all")) {
          state.OWNERSHIPWRITEALL=true;
        }
-      } else if (option.equals("-ownaliasfile"))
+      } else if (option.equals("-ownaliasfile")) {
        state.OWNERSHIPALIASFILE=args[++i];
+      } else if (option.equals("-ownaliasfiletab")) {
+       state.OWNERSHIPALIASFILE=args[++i];
+        state.OWNERSHIPALIASTAB=true;      
+      } else if (option.equals("-owndebugcallee")) {
+       state.OWNERSHIPDEBUGCALLEE=args[++i];
+      } else if (option.equals("-owndebugcaller")) {
+       state.OWNERSHIPDEBUGCALLER=args[++i];
+      } else if (option.equals("-owndebugcallcount")) {
+       state.OWNERSHIPDEBUGCALLCOUNT=Integer.parseInt(args[++i]);
+      }
+      else if (option.equals("-disjoint"))
+       state.DISJOINT=true;
+      else if (option.equals("-disjoint-k")) {
+       state.DISJOINTALLOCDEPTH=Integer.parseInt(args[++i]);
+      } else if (option.equals("-disjoint-write-dots")) {
+       state.DISJOINTWRITEDOTS = true;
+        String arg = args[++i];
+       if( arg.equals("all") ) {
+         state.DISJOINTWRITEALL = true;
+       } else if( arg.equals("final") ) {
+          state.DISJOINTWRITEALL = false;
+        } else {
+          throw new Error("disjoint-write-dots requires argument <all/final>");
+        }
+      } else if (option.equals("-disjoint-alias-file")) {
+       state.DISJOINTALIASFILE = args[++i];
+        String arg = args[++i];
+       if( arg.equals("normal") ) {
+         state.DISJOINTALIASTAB = false;
+       } else if( arg.equals("tabbed") ) {
+          state.DISJOINTALIASTAB = true;
+        } else {
+          throw new Error("disjoint-alias-file requires arguments <filename> <normal/tabbed>");
+        }
+      } else if (option.equals("-disjoint-debug-callsite")) {
+       state.DISJOINTDEBUGCALLEE=args[++i];
+       state.DISJOINTDEBUGCALLER=args[++i];
+       state.DISJOINTDEBUGCALLCOUNT=Integer.parseInt(args[++i]);
+      }
       else if (option.equals("-optional"))
        state.OPTIONAL=true;
       else if (option.equals("-optimize"))
@@ -165,6 +222,10 @@ public class Main {
        state.THREAD=true;
       else if (option.equals("-dsm"))
        state.DSM=true;
+      else if (option.equals("-recoverystats"))
+  state.DSMRECOVERYSTATS=true;
+      else if (option.equals("-dsmtask"))
+  state.DSMTASK=true;
       else if (option.equals("-singleTM"))
        state.SINGLETM=true;
       else if (option.equals("-readset"))
@@ -175,14 +236,19 @@ public class Main {
        state.INSTRUCTIONFAILURE=true;
       else if (option.equals("-abcclose"))
        state.ARRAYBOUNDARYCHECK=false;
+
       else if (option.equals("-mlp")) {
-       state.MLP=true;
-       state.OWNERSHIP=true;
+       state.MLP            = true;
+       state.OWNERSHIP      = true;
+       state.MLP_NUMCORES   = Integer.parseInt( args[++i] );
+       state.MLP_MAXSESEAGE = Integer.parseInt( args[++i] );
+
       } else if (option.equals("-mlpdebug")) {
-       state.MLP=true;
        state.MLPDEBUG=true;
-       state.OWNERSHIP=true;
-      } else if (option.equals("-help")) {
+
+      } else if (option.equals("-methodeffects")) {
+       state.METHODEFFECTS=true;
+      }else if (option.equals("-help")) {
        System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
        System.out.println("-selfloop task -- this task doesn't self loop its parameters forever");
        System.out.println("-dir outputdirectory -- output code in outputdirectory");
@@ -212,8 +278,8 @@ public class Main {
        System.out.println("-optional -- enable optional arguments");
        System.out.println("-abcclose close the array boundary check");
        System.out.println("-scheduling do task scheduling");
-       System.out.println("-mlp build mlp code");
-       System.out.println("-mlp build mlp code, report progress and interim results");
+       System.out.println("-mlp <num cores> <max sese age> build mlp code");
+       System.out.println("-mlpdebug if mlp, report progress and interim results");
        System.out.println("-multicore generate multi-core version binary");
        System.out.println("-numcore set the number of cores (should be used together with -multicore), defaultly set as 1");
        System.out.println("-interrupt generate raw version binary with interruption (should be used togethere with -raw)");
@@ -231,7 +297,7 @@ public class Main {
        sourcefiles.add(args[i]);
       }
     }
-
+    
     //add default classpath
     if (state.classpath.size()==1)
       state.classpath.add(ClassLibraryPrefix);
@@ -314,40 +380,57 @@ public class Main {
         }
       }
     }
-    
+
     if (state.FLATIRGRAPH) {
       FlatIRGraph firg = new FlatIRGraph(state,
                                          state.FLATIRGRAPHTASKS,
                                          state.FLATIRGRAPHUSERMETHODS,
                                          state.FLATIRGRAPHLIBMETHODS);
     }
-
+    
     if (state.OWNERSHIP && !state.MLP) {
       CallGraph callGraph = new CallGraph(state);
+      Liveness liveness = new Liveness();
+      ArrayReferencees ar = new ArrayReferencees(state);
       OwnershipAnalysis oa = new OwnershipAnalysis(state,
                                                    tu,
                                                    callGraph,
+                                                  liveness,
+                                                   ar,
                                                    state.OWNERSHIPALLOCDEPTH,
                                                    state.OWNERSHIPWRITEDOTS,
                                                    state.OWNERSHIPWRITEALL,
-                                                   state.OWNERSHIPALIASFILE);
+                                                   state.OWNERSHIPALIASFILE,
+                                                   state.METHODEFFECTS);
     }
 
     if (state.MLP) {
       CallGraph callGraph = new CallGraph(state);
+      Liveness liveness = new Liveness();
+      ArrayReferencees ar = new ArrayReferencees(state);
       OwnershipAnalysis oa = new OwnershipAnalysis(state,
                                                    tu,
                                                    callGraph,
+                                                  liveness,
+                                                   ar,
                                                   state.OWNERSHIPALLOCDEPTH,
                                                    state.OWNERSHIPWRITEDOTS,
                                                    state.OWNERSHIPWRITEALL,
-                                                   state.OWNERSHIPALIASFILE);
+                                                   state.OWNERSHIPALIASFILE,
+                                                   state.METHODEFFECTS);
       mlpa = new MLPAnalysis(state,
                              tu,
                              callGraph,
                              oa);
     }    
 
+    if (state.DISJOINT) {
+      CallGraph        cg = new CallGraph(state);
+      Liveness         l  = new Liveness();
+      ArrayReferencees ar = new ArrayReferencees(state);
+      DisjointAnalysis oa = new DisjointAnalysis(state, tu, cg, l, ar);
+    }
+
     if (state.TAGSTATE) {
       CallGraph callgraph=new CallGraph(state);
       TagAnalysis taganalysis=new TagAnalysis(state, callgraph);
@@ -381,9 +464,13 @@ public class Main {
       if (state.SCHEDULING) {
        // Use ownership analysis to get alias information
        CallGraph callGraph = new CallGraph(state);
+       Liveness liveness = new Liveness();
+        ArrayReferencees ar = new ArrayReferencees(state);
        OwnershipAnalysis oa = new OwnershipAnalysis(state,
                                                     tu,
                                                     callGraph,
+                                                    liveness,
+                                                     ar,
                                                     state.OWNERSHIPALLOCDEPTH,
                                                     state.OWNERSHIPWRITEDOTS,
                                                     state.OWNERSHIPWRITEALL,
@@ -396,16 +483,16 @@ public class Main {
        if(isDistributeInfo) {
            mcImplSynthesis.distribution(isDisAll, startnum);
        } else {
-           double timeStartAnalysis = (double) System.nanoTime();
+           //double timeStartAnalysis = (double) System.nanoTime();
            mcImplSynthesis.setScheduleThreshold(20);
            mcImplSynthesis.setProbThreshold(0);
            mcImplSynthesis.setGenerateThreshold(30);
            Vector<Schedule> scheduling = mcImplSynthesis.synthesis();
            
-           double timeEndAnalysis = (double) System.nanoTime();
-           double dt = (timeEndAnalysis - timeStartAnalysis)/(Math.pow( 10.0, 9.0 ) );
-           System.err.println("The analysis took" + dt +  "sec.");
-        System.exit(0);
+           //double timeEndAnalysis = (double) System.nanoTime();
+           //double dt = (timeEndAnalysis - timeStartAnalysis)/(Math.pow( 10.0, 9.0 ) );
+           //System.err.println("The analysis took" + dt +  "sec.");
+        //System.exit(0);
 
            // generate multicore codes
            if(state.MULTICORE) {
@@ -415,6 +502,7 @@ public class Main {
                                                              sa,
                                                              scheduling,
                                                              mcImplSynthesis.getCoreNum(),
+                                                  state.CORENUM4GC,
                                                              pa);
                bcm.setOwnershipAnalysis(oa);
                bcm.buildCode();
@@ -447,8 +535,18 @@ public class Main {
   }
 
   public static void loadClass(State state, BuildIR bir, String sourcefile) {
-    ParseNode pn=readSourceFile(state, sourcefile);
-    bir.buildtree(pn, null);
+    try {
+      ParseNode pn=readSourceFile(state, sourcefile);
+      bir.buildtree(pn, null);
+    } catch (Exception e) {
+      System.out.println("Error in sourcefile:"+sourcefile);
+      e.printStackTrace();
+      System.exit(-1);
+    } catch (Error e) {
+      System.out.println("Error in sourcefile:"+sourcefile);
+      e.printStackTrace();
+      System.exit(-1);
+    }
   }
 
   /** Reads in a source file and adds the parse tree to the state object. */