Just getting a capture, there is a bug in correctly informing code plan of the copy...
authorjjenista <jjenista>
Thu, 18 Jun 2009 22:55:33 +0000 (22:55 +0000)
committerjjenista <jjenista>
Thu, 18 Jun 2009 22:55:33 +0000 (22:55 +0000)
Robust/src/Analysis/MLP/CodePlan.java
Robust/src/Analysis/MLP/MLPAnalysis.java
Robust/src/Analysis/MLP/VarSrcTokTable.java
Robust/src/IR/Flat/BuildCode.java

index ed90f2c282029b1a806c2f3f36a02f6455e6bb41..1a3f322bb9468b1ba564b3366908f51d6a9326dc 100644 (file)
@@ -11,11 +11,17 @@ import java.io.*;
 public class CodePlan {
 
   private Set<VariableSourceToken> writeToDynamicSrc;
+
+  private Hashtable< SESEandAgePair, Set<TempDescriptor> > stall2copySet;
+
   
   public CodePlan() {
     writeToDynamicSrc = null;
+
+    stall2copySet = new Hashtable< SESEandAgePair, Set<TempDescriptor> >();
   }
 
+
   public void setWriteToDynamicSrc( 
                Set<VariableSourceToken> writeToDynamicSrc 
                                  ) {
@@ -26,6 +32,23 @@ public class CodePlan {
     return writeToDynamicSrc;
   }
 
+
+  public void addStall2CopySet( SESEandAgePair      stallPair,
+                               Set<TempDescriptor> copySet ) {
+
+    if( stall2copySet.containsKey( stallPair ) ) {
+      Set<TempDescriptor> priorCopySet = stall2copySet.get( stallPair );
+      priorCopySet.addAll( copySet );
+    } else {
+      stall2copySet.put( stallPair, copySet );
+    }
+  }
+
+  public Hashtable< SESEandAgePair, Set<TempDescriptor> > getStall2copySet() {
+    return stall2copySet;
+  }
+
+
   public boolean equals( Object o ) {
     if( o == null ) {
       return false;
@@ -43,8 +66,10 @@ public class CodePlan {
     } else {
       dynamicSetEq = (writeToDynamicSrc.equals( cp.writeToDynamicSrc ));
     }
+
+    boolean copySetsEq = (stall2copySet.equals( cp.stall2copySet ));
         
-    return dynamicSetEq;
+    return dynamicSetEq && copySetsEq;
   }
 
   public int hashCode() {
@@ -53,7 +78,9 @@ public class CodePlan {
       dynamicSetHC = writeToDynamicSrc.hashCode();
     }
 
-    return dynamicSetHC;
+    int copySetsHC = stall2copySet.hashCode();
+
+    return dynamicSetHC ^ 3*copySetsHC;
   }
 
   public String toString() {
@@ -71,6 +98,21 @@ public class CodePlan {
       s += "]";
     }
 
+    if( !stall2copySet.entrySet().isEmpty() ) {
+      s += "[STALLS:";
+    }
+    Iterator cpsItr = stall2copySet.entrySet().iterator();
+    while( cpsItr.hasNext() ) {
+      Map.Entry           me        = (Map.Entry)           cpsItr.next();
+      SESEandAgePair      stallPair = (SESEandAgePair)      me.getKey();
+      Set<TempDescriptor> copySet   = (Set<TempDescriptor>) me.getValue();
+
+      s += "("+stallPair+"->"+copySet+")";
+    }
+    if( !stall2copySet.entrySet().isEmpty() ) {
+      s += "]";
+    }
+
     return s;
   }
 }
index a60feb299824e1e41926d9df93dadaea14fb9eed..e50017517bb2998167dceda56e1fdea9d8e86204 100644 (file)
@@ -140,9 +140,9 @@ public class MLPAnalysis {
       System.out.println( "" );
       //System.out.println( "\nSESE Hierarchy\n--------------\n" ); printSESEHierarchy();
       //System.out.println( "\nSESE Liveness\n-------------\n" ); printSESELiveness();
-      //System.out.println( "\nLiveness Root View\n------------------\n"+fmMain.printMethod( livenessRootView ) );
-      //System.out.println( "\nVariable Results\n----------------\n"+fmMain.printMethod( variableResults ) );
-      //System.out.println( "\nNot Available Results\n---------------------\n"+fmMain.printMethod( notAvailableResults ) );
+      System.out.println( "\nLiveness Root View\n------------------\n"+fmMain.printMethod( livenessRootView ) );
+      System.out.println( "\nVariable Results\n----------------\n"+fmMain.printMethod( variableResults ) );
+      System.out.println( "\nNot Available Results\n---------------------\n"+fmMain.printMethod( notAvailableResults ) );
       System.out.println( "\nCode Plans\n----------\n"+fmMain.printMethod( codePlans ) );
     }
 
@@ -789,6 +789,12 @@ public class MLPAnalysis {
       // decide if we must stall for variables dereferenced at this node
       Set<VariableSourceToken> stallSet = vstTable.getStallSet( currentSESE );
 
+      // a node with no live set has nothing to stall for
+      Set<TempDescriptor> liveSet = livenessRootView.get( fn );
+      if( liveSet == null ) {
+       break;
+      }
+
       TempDescriptor[] readarray = fn.readsTemps();
       for( int i = 0; i < readarray.length; i++ ) {
         TempDescriptor readtmp = readarray[i];
@@ -799,56 +805,66 @@ public class MLPAnalysis {
          continue;
        }
 
-        Set<VariableSourceToken> readSet = vstTable.get( readtmp );
+       // Two cases:
+        Set<VariableSourceToken> srcs = vstTable.get( readtmp );
+       assert !srcs.isEmpty();
 
-       //Two cases:
-
-       //1) Multiple token/age pairs or unknown age: Stall for
-       //dynamic name only.
-       
+       // 1) Multiple token/age pairs or unknown age: Stall for
+       // dynamic name only.
+       if( srcs.size() > 1 || 
+           srcs.iterator().next().getAge() == maxSESEage ) {
+         
+         
 
+       // 2) Single token/age pair: Stall for token/age pair, and copy
+       // all live variables with same token/age pair at the same
+       // time.  This is the same stuff that the notavaialable analysis 
+       // marks as now available.        
+       } else {          
+         VariableSourceToken vst = srcs.iterator().next();                       
 
-       //2) Single token/age pair: Stall for token/age pair, and copy
-       //all live variables with same token/age pair at the same
-       //time.  This is the same stuff that the notavaialable analysis 
-       //marks as now available.
+         Iterator<VariableSourceToken> availItr = 
+           vstTable.get( vst.getSESE(), 
+                         vst.getAge()
+                       ).iterator();
 
-       //VarSrcTokTable table = variableResults.get( fn );
-       //Set<VariableSourceToken> srcs = table.get( rTemp );
+         System.out.println( "Considering a stall on "+vst+
+                             " and also getting\n    "+vstTable.get( vst.getSESE(), 
+                         vst.getAge()
+                                                                     ) );
 
-       //XXXXXXXXXX: Note: We have to generate code to do these
-       //copies in the codeplan.  Note we should only copy the
-       //variables that are live!
+         // only grab additional stuff that is live
+         Set<TempDescriptor> copySet = new HashSet<TempDescriptor>();
 
-       /*
-       if( srcs.size() == 1 ) {
-         VariableSourceToken vst = srcs.iterator().next();
-         
-         Iterator<VariableSourceToken> availItr = table.get( vst.getSESE(), 
-                                                             vst.getAge()
-                                                           ).iterator();
          while( availItr.hasNext() ) {
            VariableSourceToken vstAlsoAvail = availItr.next();
-           notAvailSet.removeAll( vstAlsoAvail.getRefVars() );
+
+           if( liveSet.contains( vstAlsoAvail.getAddrVar() ) ) {
+             copySet.add( vstAlsoAvail.getAddrVar() );
+           }
+
+           /*
+           Iterator<TempDescriptor> refVarItr = vstAlsoAvail.getRefVars().iterator();
+           while( refVarItr.hasNext() ) {
+             TempDescriptor refVar = refVarItr.next();
+             if( liveSet.contains( refVar ) ) {
+               copySet.add( refVar );
+             }
+           }
+           */
          }
-       }
-       */
+         
 
+         SESEandAgePair stallPair = new SESEandAgePair( vst.getSESE(), vst.getAge() );   
+         plan.addStall2CopySet( stallPair, copySet );
+         System.out.println( "("+stallPair+"->"+copySet+")" );
+       }
 
-       // assert notAvailSet.containsAll( writeSet );
+       // assert that everything being stalled for is in the
+       // "not available" set coming into this flat node and
+       // that every VST identified is in the possible "stall set"
+       // that represents VST's from children SESE's
 
-        /*
-        for( Iterator<VariableSourceToken> readit = readSet.iterator(); 
-             readit.hasNext(); ) {
-          VariableSourceToken vst = readit.next();
-          if( stallSet.contains( vst ) ) {
-            if( before == null ) {
-              before = "**STALL for:";
-            }
-            before += "("+vst+" "+readtmp+")";     
-          }
-        }
-        */
       }      
     } break;
 
index a7b275c5468ce70b2f4fe2c996e6b849317c41e6..d3cffae3beaf710233a00f209b185b024dc3e24a 100644 (file)
@@ -418,6 +418,7 @@ public class VarSrcTokTable {
   }
 
   
+  // get the set of VST's that come from a child
   public Set<VariableSourceToken> getStallSet( FlatSESEEnterNode curr ) {
     
     Set<VariableSourceToken> out = new HashSet<VariableSourceToken>();
index bf7c372f298e94972ff5f91529fc20f79aaae9f2..2b16515319ecc3d9f25a1784eb68e88055cdd49b 100644 (file)
@@ -270,6 +270,9 @@ public class BuildCode {
   private void outputMainMethod(PrintWriter outmethod) {
     outmethod.println("int main(int argc, const char *argv[]) {");
     outmethod.println("  int i;");
+    if (state.MLP) {
+      outmethod.println("  mlpInit( "+mlpa.getAllSESEs().size()+", "+mlpa.getMaxSESEage()+" );");
+    }
     if (state.DSM) {
       outmethod.println("#ifdef TRANSSTATS \n");
       outmethod.println("handle();\n");
@@ -2364,7 +2367,7 @@ public class BuildCode {
     }
 
     output.println("   mlpIssue( tempSESE );");
-    output.println("   tempSESE = mlpSchedule();");
+    //output.println("   tempSESE = mlpSchedule();");
 
     // do a pthread_create wit invokeSESE as the argument
     // and pack all args into a single void*