Add BAMBOOCOMPILETIME flag into the state class. When this flag is set, only excute...
authorjzhou <jzhou>
Thu, 25 Mar 2010 17:17:38 +0000 (17:17 +0000)
committerjzhou <jzhou>
Thu, 25 Mar 2010 17:17:38 +0000 (17:17 +0000)
Robust/src/Analysis/Scheduling/MCImplSynthesis.java
Robust/src/Analysis/Scheduling/ScheduleAnalysis.java
Robust/src/Analysis/Scheduling/ScheduleSimulator.java
Robust/src/IR/State.java
Robust/src/Main/Main.java

index fbac0574aadb52aa3a46ea579ac91031d6134c25..08792bf18431daaffb8eb7a8b1d59cafd7fd1180 100644 (file)
@@ -101,9 +101,11 @@ public class MCImplSynthesis {
     // Create a new output stream for the stcriticalPathandard output.
     PrintStream stdout  = null;
     try {
+      if(!state.BAMBOOCOMPILETIME) {
       stdout = new PrintStream(
           new FileOutputStream(this.state.outputdir + "SimulatorResult_" 
               + this.coreNum + ".out"));
+      }
     } catch (Exception e) {
       // Sigh.  Couldn't open the file.
       System.out.println("Redirect:  Unable to open output file!");
@@ -118,7 +120,9 @@ public class MCImplSynthesis {
     //origOut.println ("Test output via 'origOut' reference.");
 
     // Set the System out and err streams to use our replacements.
-    System.setOut(stdout);
+    if(!state.BAMBOOCOMPILETIME) {
+      System.setOut(stdout);
+    }
 
     Vector<Schedule> scheduling = null;
     Vector<ScheduleNode> schedulinggraph = null;
@@ -164,8 +168,10 @@ public class MCImplSynthesis {
     int threshold = this.scheduleThreshold;
     // simulate the generated schedulings and try to optimize it
     do {
+       if(!state.BAMBOOCOMPILETIME) {
       System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n");
       System.out.print("Simulate and optimize round: #" + tryindex + ": \n");
+    }
       gid += newscheduleGraphs.size();
       if(scheduleGraphs != null) {
         for(int i = 0; i < scheduleGraphs.size(); i++) {
@@ -219,24 +225,31 @@ public class MCImplSynthesis {
             selectedSchedulings.elementAt(0));
         selectedSimExeGraph_bk = selectedSimExeGraphs.elementAt(0);
         
+        if(!state.BAMBOOCOMPILETIME) {
         System.out.print("end of: #" + tryindex + " (bestexetime: " 
             + bestexetime + ")\n");
         System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+        }
         tryindex++;
         threshold = this.scheduleThreshold;
       } else if(tmpexetime == bestexetime) {
+        if(!state.BAMBOOCOMPILETIME) {
         System.out.print("end of: #" + tryindex + " (bestexetime: " 
             + bestexetime + ")\n");
         System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+        }
         tryindex++;
-        threshold = this.scheduleThreshold;
-        if((Math.abs(rand.nextInt()) % 100) < this.probThreshold) {
+        threshold += 10;
+        if((threshold > 40) || 
+            ((Math.abs(rand.nextInt()) % 100) < this.probThreshold + 10)) {
           break;
         }
       } else {
+        if(!state.BAMBOOCOMPILETIME) {
         System.out.print("end of: #" + tryindex + " (bestexetime: " 
             + bestexetime + ")\n");
         System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+        }
         tryindex++;
         if(threshold == this.scheduleThreshold) {
           if(scheduleGraphs != null) {
@@ -253,13 +266,14 @@ public class MCImplSynthesis {
           selectedSimExeGraphs.addElement(selectedSimExeGraph_bk);
         }
         threshold += 10;
-        if((Math.abs(rand.nextInt()) % 100) < this.probThreshold + 1) {
+        if( (threshold > 40) || 
+            ((Math.abs(rand.nextInt()) % 100) < this.probThreshold + 1)) {
           break;
         }
-        //break;
+        break;
       }
 
-      //if(tooptimize) {
+      if(tooptimize) {
       // try to optimize the best one scheduling
       //do {
       newscheduleGraphs = optimizeScheduling(scheduleGraphs, 
@@ -286,9 +300,9 @@ public class MCImplSynthesis {
         scheduleGraphs.removeElementAt(selectedSchedulings.elementAt(0));
         selectedSimExeGraphs.removeElementAt(0);
       }
-      /*} else {
+      } else {
         break;
-      }*/
+      }
     }while(newscheduleGraphs != null); // TODO: could it possibly lead to endless loop?
 
     if(scheduleGraphs != null) {
@@ -308,16 +322,22 @@ public class MCImplSynthesis {
     td2maincd.clear();
     td2maincd = null;
 
+    if(!state.BAMBOOCOMPILETIME) {
     System.out.print("+++++++++++++++++++++++++++++++++++++++++++++++++++\n");
+    }
     System.out.print("selected bestexetime: " + bestexetime + "\n");
+    if(!state.BAMBOOCOMPILETIME) {
     String path = this.state.outputdir + "scheduling_selected.dot";
     SchedulingUtil.printScheduleGraph(path, schedulinggraph);
+    }
 
     // Close the streams.
     try {
+      if(!state.BAMBOOCOMPILETIME) {
       stdout.close();
       stdout = null;
       System.setOut(origOut);
+      }
     } catch (Exception e) {
       origOut.println("Redirect:  Unable to close files!");
     }
@@ -955,6 +975,7 @@ public class MCImplSynthesis {
           }
 
           // flush the dependences and earliest start time
+          if(!state.BAMBOOCOMPILETIME) {
           it_cores = tooptimize.keySet().iterator();
           while(it_cores.hasNext()) {
             int corenum = it_cores.next();
@@ -1002,6 +1023,7 @@ public class MCImplSynthesis {
             left -= ops.size();
           }
           ops = null;
+          }
         } else {
           // there are spare cores, try to reorganize the tasks to the spare 
           // cores
@@ -1124,7 +1146,7 @@ public class MCImplSynthesis {
       CombinationUtil.allocateCombineGenerator(rootNodes, nodes2combine);
     Random rand = new Random();
     while ((left > 0) && (cGen.nextGen())) {
-    //while ((left > 0) && (cGen.randomGen())) {
+    //while ((left > 0) && (cGen.randomGenE())) {
       if(Math.abs(rand.nextInt()) % 100 > this.generateThreshold) {
         Vector<Vector<CombinationUtil.Combine>> combine = cGen.getCombine();
         Vector<ScheduleNode> sNodes = 
index f2cce70ab2b81efbbb8e4c3dc0392e3895a1fccb..44910e3d37a7ef5c80d0e6a81fa4a3ec7294d816 100644 (file)
@@ -1233,11 +1233,11 @@ public class ScheduleAnalysis {
       int gid = 1;
       boolean isBig = Math.pow(this.coreNum, reduceNum) > 1000;
       Random rand = new Random();
-      if(false) {
+      if(isBig && state.BAMBOOCOMPILETIME) {
          CombinationUtil.RootsGenerator rGen = 
                CombinationUtil.allocateRootsGenerator(sNodeVecs, 
                                                       this.coreNum);
-         while((!isBig || (gid <= this.scheduleThreshold)) && (rGen.nextGen())) {
+         while((gid <= this.scheduleThreshold) && (rGen.nextGen())) {
              // first get the chosen rootNodes
              Vector<Vector<ScheduleNode>> rootNodes = rGen.getRootNodes();
              Vector<Vector<ScheduleNode>> nodes2combine = rGen.getNode2Combine();
@@ -1245,7 +1245,7 @@ public class ScheduleAnalysis {
              CombinationUtil.CombineGenerator cGen = 
                  CombinationUtil.allocateCombineGenerator(rootNodes, 
                          nodes2combine);
-             while((!isBig || (gid <= this.scheduleThreshold)) && (cGen.randomGenE())) {  
+             while((gid <= this.scheduleThreshold) && (cGen.randomGenE())) {  
                  boolean implement = true;
                  /*if(isBig) {
                      implement = Math.abs(rand.nextInt()) % 100 > generateThreshold;
@@ -1277,7 +1277,7 @@ public class ScheduleAnalysis {
                CombinationUtil.allocateRandomGenerator(sNodeVecs, 
                                                        this.coreNum);
          // random genenration
-         while((!isBig || (gid <= this.scheduleThreshold)) && (rGen.nextGen())) {
+         while((gid <= this.scheduleThreshold) && (rGen.nextGen())) {
              Vector<Vector<ScheduleNode>> mapping = rGen.getMapping();
              boolean implement = true;
              if(isBig) {
index 2459b5f53a241d03981f01baca4a4c868b5408d7..23ea4b3faf07700ab9730703210a3a3057dec2ff 100644 (file)
@@ -130,7 +130,9 @@ public class ScheduleSimulator {
          while(it_scheduling.hasNext()) {
              Vector<Schedule> scheduling = 
                  (Vector<Schedule>)it_scheduling.next();
+          if(!state.BAMBOOCOMPILETIME) {
              System.out.println("Scheduling index:" + scheduling.elementAt(0).getGid());
+          }
              this.setScheduling(scheduling);
              Vector<SimExecutionNode> simexegraph = new Vector<SimExecutionNode>();
              Vector<CheckPoint> checkpoints = new Vector<CheckPoint>();
@@ -156,12 +158,14 @@ public class ScheduleSimulator {
          it_scheduling = null;
       //}
       
+      if(!state.BAMBOOCOMPILETIME) {
       System.out.print("Selected schedulings with least exectution time " + processTime + ": \n\t");
       for(int i = 0; i < selectedScheduling.size(); i++) {
          int gid = schedulings.elementAt(selectedScheduling.elementAt(i)).elementAt(0).getGid();
          System.out.print(gid + ", ");
       }
       System.out.println();
+      }
       
       return processTime;
   }
@@ -479,12 +483,14 @@ public class ScheduleSimulator {
                                             this.coreNum, 
                                             checkpoints);
     }
+    if(!state.BAMBOOCOMPILETIME) {
     System.out.println("Simulate scheduling #" + gid + ": ");
     System.out.println("\tTotal execution time is: " + this.processTime);
     System.out.println("\tUtility of cores: ");
     for(int j = 0; j < this.cores.size(); j++) {
       System.out.println("\t\tcore" + j + ": " + getUtility(j) + "%");
     }
+    }
     
     return this.processTime;
   }
index 1183d77c60279758cb530e3723b314ec3c236060..ba44145ea2c96b9e01f6e44b703dd0596bae9432 100644 (file)
@@ -58,8 +58,6 @@ public class State {
   public boolean FLATIRGRAPHTASKS=false;
   public boolean FLATIRGRAPHUSERMETHODS=false;
   public boolean FLATIRGRAPHLIBMETHODS=false;
-  public boolean MULTICORE=false;
-  public boolean MULTICOREGC=false;
   public boolean OWNERSHIP=false;
   public int OWNERSHIPALLOCDEPTH=3;
   public boolean OWNERSHIPWRITEDOTS=false;
@@ -86,12 +84,7 @@ public class State {
   public boolean DISJOINTSNAPSTOPAFTER=false;
 
   public boolean OPTIONAL=false;
-  public boolean ARRAYBOUNDARYCHECK=true;
-  public boolean RAW=false;
   public boolean ARRAYPAD=false;
-  public boolean SCHEDULING=false;
-  public boolean USEPROFILE=false;
-  public String profilename = null;
   public boolean THREAD=false;
   public boolean CONSCHECK=false;
   public boolean INSTRUCTIONFAILURE=false;
@@ -102,9 +95,7 @@ public class State {
   public boolean METHODEFFECTS=false;
   public static double TRUEPROB=0.8;
   public static boolean PRINTFLAT=false;
-  public static boolean PRINTSCHEDULING=false;
-  public static boolean PRINTSCHEDULESIM=false;
-  public static boolean PRINTCRITICALPATH=false;
+  
   //DSM options
   public boolean DSM=false;
   public boolean DSMTASK=false;
@@ -122,12 +113,25 @@ public class State {
   public boolean DELAYCOMP=false;
   public boolean DUALVIEW=false;
   public boolean HYBRID=false;
-  //Other options
+  
+  // Bamboo options
+  public boolean MULTICORE=false;
+  public boolean MULTICOREGC=false;
+  public boolean BAMBOOCOMPILETIME = false;
+  public boolean ARRAYBOUNDARYCHECK=true;
+  public boolean RAW=false;
+  public boolean SCHEDULING=false;
+  public boolean USEPROFILE=false;
+  public static boolean PRINTSCHEDULING=false;
+  public static boolean PRINTSCHEDULESIM=false;
+  public static boolean PRINTCRITICALPATH=false;
   public int CORENUM = 1;
   public int CORENUM4GC = 0;
+  public String profilename = null;
+  public String outputdir = "/scratch/";
+  //Other options
   public String structfile;
   public String main;
-  public String outputdir = "/scratch/";
   public boolean INLINEATOMIC=false;
   public int inlineatomicdepth;
   public HashSet selfloops;
index 03fff64b13144aaf19c92cda51da98251fb3fe88..a2c202688618ed7ab0ca5b521e0790a34d55a965 100644 (file)
@@ -140,6 +140,8 @@ public class Main {
       } else if (option.equals("-flatirlibmethods")) {
        state.FLATIRGRAPH=true;
        state.FLATIRGRAPHLIBMETHODS=true;
+      } else if (option.equals("-bamboocompiletime")) {
+        state.BAMBOOCOMPILETIME = true;
       } else if (option.equals("-multicore"))
        state.MULTICORE=true;
       else if (option.equals("-multicoregc"))
@@ -505,16 +507,18 @@ 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();
+        if(state.BAMBOOCOMPILETIME) {
+          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) {