adjustments to stack-based method scheduling, debug controls, a micro benchmark,...
authorjjenista <jjenista>
Mon, 12 Apr 2010 22:46:02 +0000 (22:46 +0000)
committerjjenista <jjenista>
Mon, 12 Apr 2010 22:46:02 +0000 (22:46 +0000)
Robust/src/Analysis/Disjoint/DisjointAnalysis.java
Robust/src/Benchmarks/disjoint/makefile
Robust/src/IR/State.java
Robust/src/Main/Main.java
Robust/src/Tests/disjoint/littleMapReduceTag/makefile
Robust/src/Tests/disjoint/littleMapReduceTag/test.java

index f9f909deec19644080bb56459f61f1f241faf323..49aebc74717d66b2156e2f2a8a22d927e4caf72f 100644 (file)
@@ -368,7 +368,7 @@ public class DisjointAnalysis {
   // current descriptors to visit in fixed-point
   // interprocedural analysis, prioritized by
   // dependency in the call graph
-  protected Stack<DescriptorQWrapper>
+  protected Stack<Descriptor>
     descriptorsToVisitStack;
   protected PriorityQueue<DescriptorQWrapper> 
     descriptorsToVisitQ;
@@ -391,7 +391,6 @@ public class DisjointAnalysis {
   protected Set<Descriptor>
     calleesToEnqueue;
 
-
   // maps a descriptor to its current partial result
   // from the intraprocedural fixed-point analysis--
   // then the interprocedural analysis settles, this
@@ -508,7 +507,7 @@ public class DisjointAnalysis {
         state.DISJOINTDVISITSTACKEESONTOP 
         ) {
       descriptorsToVisitStack =
-        new Stack<DescriptorQWrapper>();
+        new Stack<Descriptor>();
     }
 
     if( state.DISJOINTDVISITPQUE ) {
@@ -657,32 +656,33 @@ public class DisjointAnalysis {
   // method's callees are updated, it must be reanalyzed
   protected void analyzeMethods() throws java.io.IOException {  
 
+    // task or non-task (java) mode determines what the roots
+    // of the call chain are, and establishes the set of methods
+    // reachable from the roots that will be analyzed
+    
     if( state.TASK ) {
-      // This analysis does not support Bamboo at the moment,
-      // but if it does in the future we would initialize the
-      // set of descriptors to analyze as the program-reachable
-      // tasks and the methods callable by them.  For Java,
-      // just methods reachable from the main method.
-      System.out.println( "Bamboo..." );
-      Iterator taskItr = state.getTaskSymbolTable().getDescriptorsIterator();
+      System.out.println( "Bamboo mode..." );
       
-      while (taskItr.hasNext()) {
-         TaskDescriptor td = (TaskDescriptor) taskItr.next();
-         if (!descriptorsToAnalyze.contains(td)) {           
-             descriptorsToAnalyze.add(td);
-             descriptorsToAnalyze.addAll(callGraph.getAllMethods(td));
-         }       
+      Iterator taskItr = state.getTaskSymbolTable().getDescriptorsIterator();      
+      while( taskItr.hasNext() ) {
+        TaskDescriptor td = (TaskDescriptor) taskItr.next();
+        if( !descriptorsToAnalyze.contains( td ) ) {
+          // add all methods transitively reachable from the
+          // tasks as well
+          descriptorsToAnalyze.add( td );
+          descriptorsToAnalyze.addAll( callGraph.getAllMethods( td ) );
+        }        
       }
-
+      
     } else {
+      System.out.println( "Java mode..." );
+
       // add all methods transitively reachable from the
       // source's main to set for analysis
       mdSourceEntry = typeUtil.getMain();
       descriptorsToAnalyze.add( mdSourceEntry );
-      descriptorsToAnalyze.addAll( 
-        callGraph.getAllMethods( mdSourceEntry ) 
-                                   );
-
+      descriptorsToAnalyze.addAll( callGraph.getAllMethods( mdSourceEntry ) );
+      
       // fabricate an empty calling context that will call
       // the source's main, but call graph doesn't know
       // about it, so explicitly add it
@@ -690,43 +690,64 @@ public class DisjointAnalysis {
       descriptorsToAnalyze.add( mdAnalysisEntry );
     }
 
-    // topologically sort according to the call graph so 
-    // leaf calls are ordered first, smarter analysis order
-    // CHANGED: order leaf calls last!!
-    LinkedList<Descriptor> sortedDescriptors = 
-      topologicalSort( descriptorsToAnalyze );
 
-    // add sorted descriptors to priority queue, and duplicate
-    // the queue as a set for efficiently testing whether some
-    // method is marked for analysis
-    int p = 0;
-    Iterator<Descriptor> dItr = sortedDescriptors.iterator();
-    while( dItr.hasNext() ) {
-      Descriptor d = dItr.next();
+    // now, depending on the interprocedural mode for visiting 
+    // methods, set up the needed data structures
 
-      mapDescriptorToPriority.put( d, new Integer( p ) );
-
-      if( state.DISJOINTDVISITSTACK ||
-          state.DISJOINTDVISITSTACKEESONTOP
-          ) {
-        descriptorsToVisitStack.add( new DescriptorQWrapper( p, d ) );
-
-      } else if( state.DISJOINTDVISITPQUE ) {
+    if( state.DISJOINTDVISITPQUE ) {
+    
+      // topologically sort according to the call graph so 
+      // leaf calls are last, helps build contexts up first
+      LinkedList<Descriptor> sortedDescriptors = 
+        topologicalSort( descriptorsToAnalyze );
+
+      // add sorted descriptors to priority queue, and duplicate
+      // the queue as a set for efficiently testing whether some
+      // method is marked for analysis
+      int p = 0;
+      Iterator<Descriptor> dItr;
+
+      // for the priority queue, give items at the head
+      // of the sorted list a low number (highest priority)
+      while( !sortedDescriptors.isEmpty() ) {
+        Descriptor d = sortedDescriptors.removeFirst();
+        mapDescriptorToPriority.put( d, new Integer( p ) );
         descriptorsToVisitQ.add( new DescriptorQWrapper( p, d ) );
+        descriptorsToVisitSet.add( d );
+        ++p;
       }
 
-      descriptorsToVisitSet.add( d );
-      ++p;
+    } else if( state.DISJOINTDVISITSTACK ||
+               state.DISJOINTDVISITSTACKEESONTOP 
+               ) {
+      // if we're doing the stack scheme, just throw the root
+      // method or tasks on the stack
+      if( state.TASK ) {
+        Iterator taskItr = state.getTaskSymbolTable().getDescriptorsIterator();      
+        while( taskItr.hasNext() ) {
+         TaskDescriptor td = (TaskDescriptor) taskItr.next();
+          descriptorsToVisitStack.add( td );
+          descriptorsToVisitSet.add( td );
+        }
+        
+      } else {
+        descriptorsToVisitStack.add( mdAnalysisEntry );
+        descriptorsToVisitSet.add( mdAnalysisEntry );
+      }
+
+    } else {
+      throw new Error( "Unknown method scheduling mode" );
     }
 
-    // analyze methods from the priority queue until it is empty
+
+    // analyze scheduled methods until there are no more to visit
     while( moreDescriptorsToVisit() ) {
       Descriptor d = null;
 
       if( state.DISJOINTDVISITSTACK ||
           state.DISJOINTDVISITSTACKEESONTOP
           ) {
-        d = descriptorsToVisitStack.pop().getDescriptor();
+        d = descriptorsToVisitStack.pop();
 
       } else if( state.DISJOINTDVISITPQUE ) {
         d = descriptorsToVisitQ.poll().getDescriptor();
@@ -755,19 +776,36 @@ public class DisjointAnalysis {
       if( !rg.equals( rgPrev ) ) {
         setPartial( d, rg );
         
+        if( state.DISJOINTDEBUGSCHEDULING ) {
+          System.out.println( "  complete graph changed, scheduling callers for analysis:" );
+        }
+
         // results for d changed, so enqueue dependents
         // of d for further analysis
        Iterator<Descriptor> depsItr = getDependents( d ).iterator();
        while( depsItr.hasNext() ) {
          Descriptor dNext = depsItr.next();
           enqueue( dNext );
+
+          if( state.DISJOINTDEBUGSCHEDULING ) {
+            System.out.println( "    "+dNext );
+          }
        }
 
         if( state.DISJOINTDVISITSTACKEESONTOP ) {
+
+          if( state.DISJOINTDEBUGSCHEDULING ) {
+            System.out.println( "  contexts changed, scheduling callees for analysis:" );
+          }
+
           depsItr = calleesToEnqueue.iterator();
           while( depsItr.hasNext() ) {
             Descriptor dNext = depsItr.next();
             enqueue( dNext );
+
+            if( state.DISJOINTDEBUGSCHEDULING ) {
+              System.out.println( "    "+dNext );
+            }
           }
           calleesToEnqueue.clear();
         }
@@ -1145,6 +1183,11 @@ public class DisjointAnalysis {
           calleesToEnqueue.add( mdCallee );
         } else {
           enqueue( mdCallee );
+
+          if( state.DISJOINTDEBUGSCHEDULING ) {
+            System.out.println( "  context changed, scheduling callee: "+mdCallee );
+          }
+
         }
 
       }
@@ -1191,6 +1234,10 @@ public class DisjointAnalysis {
             calleesToEnqueue.add( mdPossible );
           } else {
             enqueue( mdPossible );
+
+            if( state.DISJOINTDEBUGSCHEDULING ) {
+              System.out.println( "  callee hasn't been analyzed, scheduling: "+mdPossible );
+            }
           }
 
         } else {
@@ -1535,17 +1582,16 @@ public class DisjointAnalysis {
 
 
   protected void enqueue( Descriptor d ) {
+
     if( !descriptorsToVisitSet.contains( d ) ) {
-      Integer priority = mapDescriptorToPriority.get( d );
 
       if( state.DISJOINTDVISITSTACK ||
           state.DISJOINTDVISITSTACKEESONTOP
           ) {
-        descriptorsToVisitStack.add( new DescriptorQWrapper( priority, 
-                                                             d ) 
-                                     );
+        descriptorsToVisitStack.add( d );
 
       } else if( state.DISJOINTDVISITPQUE ) {
+        Integer priority = mapDescriptorToPriority.get( d );
         descriptorsToVisitQ.add( new DescriptorQWrapper( priority, 
                                                          d ) 
                                  );
@@ -1615,14 +1661,25 @@ public class DisjointAnalysis {
   }
 
   private AllocSite createParameterAllocSite( ReachGraph     rg, 
-                                              TempDescriptor tempDesc
+                                              TempDescriptor tempDesc,
+                                              boolean        flagRegions
                                               ) {
     
-    FlatNew flatNew = new FlatNew( tempDesc.getType(), // type
-                                   tempDesc,           // param temp
-                                   false,              // global alloc?
-                                   "param"+tempDesc    // disjoint site ID string
-                                   );
+    FlatNew flatNew;
+    if( flagRegions ) {
+      flatNew = new FlatNew( tempDesc.getType(), // type
+                             tempDesc,           // param temp
+                             false,              // global alloc?
+                             "param"+tempDesc    // disjoint site ID string
+                             );
+    } else {
+      flatNew = new FlatNew( tempDesc.getType(), // type
+                             tempDesc,           // param temp
+                             false,              // global alloc?
+                             null                // disjoint site ID string
+                             );
+    }
+
     // create allocation site
     AllocSite as = AllocSite.factory( allocationDepth, 
                                       flatNew, 
@@ -1674,7 +1731,7 @@ private Set<FieldDescriptor> getFieldSetTobeAnalyzed(TypeDescriptor typeDesc){
                        if(i==dimCount){
                                as = alloc;
                        }else{
-                               as = createParameterAllocSite(rg, tempDesc);
+                          as = createParameterAllocSite(rg, tempDesc, false);
                        }
                        // make a new reference to allocated node
                    hrnSummary = 
@@ -1732,7 +1789,7 @@ private Set<FieldDescriptor> getFieldSetTobeAnalyzed(TypeDescriptor typeDesc){
        typeDesc.setArrayCount(0);
        if(!mapToExistingNode.containsKey(typeDesc)){
                TempDescriptor tempDesc=new TempDescriptor(type.getSymbol(),typeDesc);
-               AllocSite as = createParameterAllocSite(rg, tempDesc);
+               AllocSite as = createParameterAllocSite(rg, tempDesc, false);
                // make a new reference to allocated node
                    HeapRegionNode hrnSummary = 
                                rg.createNewHeapRegionNode(as.getSummary(), // id or null to generate a new one
@@ -1796,7 +1853,7 @@ private ReachGraph createInitialTaskReachGraph(FlatMethod fm) {
        
        TempDescriptor tempDesc = fm.getParameter(idx);
        
-       AllocSite as = createParameterAllocSite(rg, tempDesc);
+       AllocSite as = createParameterAllocSite(rg, tempDesc, true);
        VariableNode lnX = rg.getVariableNodeFromTemp(tempDesc);
        Integer idNewest = as.getIthOldest(0);
        HeapRegionNode hrnNewest = rg.id2hrn.get(idNewest);
@@ -1847,7 +1904,7 @@ private ReachGraph createInitialTaskReachGraph(FlatMethod fm) {
                    //corresponding allocsite has already been created for a parameter variable.
                        allocSite=as;
                    }else{
-                       allocSite = createParameterAllocSite(rg, td);
+                      allocSite = createParameterAllocSite(rg, td, false);
                    }
                    String strDesc = allocSite.toStringForDOT()
                        + "\\nsummary";
index 7ae40543c6e9c09c41274dae9af4d12356871258..fc58a8261fb6ced5560c9ed6ce991fcf5a0c0aa5 100644 (file)
@@ -13,7 +13,10 @@ BUILDSCRIPT=~/research/Robust/src/buildscript
 ##       after capture (or let it run on normally)
 ##
 #################################################
-#DEBUGFLAGS= -disjoint-debug-callsite addInterOutput t6 50 5 false
+#DEBUGFLAGS= -disjoint-debug-callsite addInterOutput t6 44 2 false
+#DEBUGFLAGS= -disjoint-debug-callsite addElement addInterOutput 30 100 false
+
+#DEBUGFLAGS= -disjoint-debug-callsite setPartial reduceOutput 1 20 false
 
 
 #################################################
@@ -31,12 +34,17 @@ BUILDSCRIPT=~/research/Robust/src/buildscript
 #################################################
 #SNAPFLAGS= -disjoint-debug-snap-method calcGoodFeatureTask 5 10 true
 #SNAPFLAGS= -disjoint-debug-snap-method calcGoodFeature 5 1 true
-SNAPFLAGS= -disjoint-debug-snap-method t6 30 1 false
-#SNAPFLAGS= -disjoint-debug-snap-method reduceOutput 5 50 true
+
+#SNAPFLAGS= -disjoint-debug-snap-method t6 20 1 false
+#SNAPFLAGS= -disjoint-debug-snap-method addInterOutput 10 50 false
+
+#SNAPFLAGS= -disjoint-debug-snap-method reduceOutput 1 20 true
 #SNAPFLAGS= -disjoint-debug-snap-method setReduceFinish 5 50 true
 #SNAPFLAGS= -disjoint-debug-snap-method setPartial 1 50 true
 
 
+
+
 BAMBOOFLAGS= -recover
 JAVAFLAGS= -mainclass test
 
@@ -47,7 +55,7 @@ VISITMODE= -disjoint-dvisit-stack-callees-on-top
 DEBUGMODE= -enable-assertions -disjoint-write-dots final -disjoint-alias-file aliases.txt normal -disjoint-desire-determinism
 RELEASEMODE= -disjoint-release-mode -disjoint-alias-file aliases.txt tabbed
 
-BSFLAGS= -justanalyze -disjoint -disjoint-k 1 -flatirusermethods
+BSFLAGS= -justanalyze -disjoint -disjoint-k 1 -flatirusermethods -flatirtasks
 
 all:
        echo 'pass another arg: <bamboo/bamboo-release/java/java-release>'
index 97ee6e81041ae3f11ed48f010634ff62675d1521..e12612dc72ca73e12b1e0d0a3c1600d9aa7270cc 100644 (file)
@@ -93,6 +93,8 @@ public class State {
   public boolean DISJOINTDVISITPQUE=false;
   public boolean DISJOINTDVISITSTACKEESONTOP=false;
 
+  public boolean DISJOINTDEBUGSCHEDULING=false;
+
   public boolean OPTIONAL=false;
   public boolean ARRAYPAD=false;
   public boolean THREAD=false;
index c186b6c2730d3991ffc9c5d7f46bfec23716cb97..08e19581e5bc40c6abf68311ed8334bbacee0d2c 100644 (file)
@@ -255,6 +255,10 @@ public class Main {
         state.DISJOINTDVISITSTACKEESONTOP = true;
         state.DISJOINTDVISITPQUE          = false;
         state.DISJOINTDVISITSTACK         = false;
+
+
+      } else if( option.equals( "-disjoint-debug-scheduling" ) ) {
+        state.DISJOINTDEBUGSCHEDULING = true;
       }
       
 
index cd46ac2b41808f1d3a3cc11ae15d6211f805421c..2ae8bcc3a1d31fa0c733ac502e64d2681e87ef91 100644 (file)
@@ -9,9 +9,9 @@ BAMBOOFLAGS= -recover
 #VISITMODE= -disjoint-dvisit-pqueue
 VISITMODE= -disjoint-dvisit-stack-callees-on-top
 
-DEBUGMODE= -enable-assertions -disjoint-write-dots all -disjoint-alias-file aliases.txt normal -disjoint-desire-determinism
+DEBUGMODE= -enable-assertions -disjoint-write-dots all -disjoint-alias-file aliases.txt normal -disjoint-desire-determinism -disjoint-debug-scheduling
 
-BSFLAGS= -justanalyze -disjoint -disjoint-k 1 -flatirusermethods -flatirtasks
+BSFLAGS= -justanalyze -disjoint -disjoint-k 1 #-flatirusermethods #-flatirtasks
 
 bamboo:
        $(BUILDSCRIPT) $(BAMBOOFLAGS) $(DEBUGMODE)   $(VISITMODE) $(BSFLAGS) $(DEBUGFLAGS) $(SNAPFLAGS) *.java
index d05e749ea5715d091d15878208ce694e015fb559..597447a8d26d23abb6a991b7f4fd0c88c914e016 100644 (file)
@@ -4,19 +4,28 @@ task startup( StartupObject s{initialstate} ) {
   taskexit( s{!initialstate} );
 }
 
-
+/*
 task reduceOutput( Master master{reduceoutput} ) {
-  master.setPartial( true );
+  if( false ) {
+    master.addInterOutput();
+  } else {
+    master.setPartial( true );
+    taskexit( master{!reduceoutput} );
+  }
+
   taskexit( master{!reduceoutput} );
 }
-
+*/
 
 public class Master {
   flag reduceoutput;
-  boolean partial;
+
+  boolean  partial;
+  Vector[] interoutputs;
 
   public Master() {
-    this.partial = false;
+    this.partial      = false;
+    this.interoutputs = new Vector[1];
   }
   
   public boolean isPartial() {
@@ -26,6 +35,19 @@ public class Master {
   public void setPartial( boolean partial ) {
     this.partial = partial || this.partial;
   }
+
+  public void addInterOutput() {
+    interoutputs[0].addElement( new Vector() );
+  }
   
-  public void assignMap() {}
+  public void assignMap() {
+    assignMap2();
+  }
+
+  public void assignMap2() {
+    assignMap3();
+  }
+
+  public void assignMap3() {}
+
 }