found one reason for system hang--there is still at least one other problem that...
authorjjenista <jjenista>
Tue, 18 Aug 2009 17:32:54 +0000 (17:32 +0000)
committerjjenista <jjenista>
Tue, 18 Aug 2009 17:32:54 +0000 (17:32 +0000)
Robust/src/Analysis/MLP/MLPAnalysis.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/mlp_runtime.h
Robust/src/Tests/mlp/tinyTest/test.java

index ea827af068658f8e529d739e1bed90a430d0ccea..49fca039d9d326c7b1eeafcdb2e8754cac55f476 100644 (file)
@@ -143,7 +143,7 @@ public class MLPAnalysis {
       pruneVariableResultsWithLiveness( fm );
     }
     if( state.MLPDEBUG ) {      
-      //System.out.println( "\nVariable Results-Out\n----------------\n"+fmMain.printMethod( variableResults ) );
+      System.out.println( "\nVariable Results-Out\n----------------\n"+fmMain.printMethod( variableResults ) );
     }
     
 
@@ -175,7 +175,6 @@ public class MLPAnalysis {
       //System.out.println( "\nCode Plans\n----------\n"+fmMain.printMethod( codePlans ) );
     }
 
-
     // splice new IR nodes into graph after all
     // analysis passes are complete
     Iterator spliceItr = wdvNodesToSpliceIn.entrySet().iterator();
@@ -185,6 +184,10 @@ public class MLPAnalysis {
       fwdvn.spliceIntoIR();
     }
 
+    // detailed per-SESE information
+    if( state.MLPDEBUG ) {
+      System.out.println( "\nSESE info\n-------------\n" ); printSESEInfo();
+    }
 
     double timeEndAnalysis = (double) System.nanoTime();
     double dt = (timeEndAnalysis - timeStartAnalysis)/(Math.pow( 10.0, 9.0 ) );
@@ -447,6 +450,49 @@ public class MLPAnalysis {
     }
   }
 
+  private void printSESEInfo() {
+    printSESEInfoTree( rootSESE );
+    System.out.println( "" );
+  }
+
+  private void printSESEInfoTree( FlatSESEEnterNode fsen ) {
+
+    System.out.println( "SESE "+fsen.getPrettyIdentifier()+" {" );
+
+    System.out.println( "  in-set: "+fsen.getInVarSet() );
+    Iterator<TempDescriptor> tItr = fsen.getInVarSet().iterator();
+    while( tItr.hasNext() ) {
+      TempDescriptor inVar = tItr.next();
+      if( fsen.getReadyInVarSet().contains( inVar ) ) {
+       System.out.println( "    (ready)  "+inVar );
+      }
+      if( fsen.getStaticInVarSet().contains( inVar ) ) {
+       System.out.println( "    (static) "+inVar );
+      } 
+      if( fsen.getDynamicInVarSet().contains( inVar ) ) {
+       System.out.println( "    (dynamic)"+inVar );
+      }
+    }
+
+    System.out.println( "  out-set: "+fsen.getOutVarSet() );
+
+    /*
+    System.out.println( "  static names to track:" );
+    tItr = fsen.getOutVarSet().iterator();
+    while( tItr.hasNext() ) {
+      System.out.println( "    "+tItr.next() );
+    }
+    */
+
+    System.out.println( "}" );
+
+    Iterator<FlatSESEEnterNode> childItr = fsen.getChildren().iterator();
+    while( childItr.hasNext() ) {
+      FlatSESEEnterNode fsenChild = childItr.next();
+      printSESEInfoTree( fsenChild );
+    }
+  }
+
 
   private void variableAnalysisForward( FlatMethod fm ) {
 
@@ -957,7 +1003,7 @@ public class MLPAnalysis {
          // just stall for the exact thing we need and move on
          plan.addDynamicStall( readtmp );
          currentSESE.addDynamicVar( readtmp );
-         
+
        } else if( srcType.equals( VarSrcTokTable.SrcType_STATIC ) ) {    
          // 2) Single token/age pair: Stall for token/age pair, and copy
          // all live variables with same token/age pair at the same
index cff00ce7efd5b137aa6271030de098e4b10ad9dc..789d90e42d1138f4be40319d205df2a671197567 100644 (file)
@@ -1931,8 +1931,20 @@ public class BuildCode {
       TempDescriptor temp = tempItr.next();
       VariableSourceToken vst = fsen.getStaticInVarSrc( temp );
       SESEandAgePair srcPair = new SESEandAgePair( vst.getSESE(), vst.getAge() );
+      
+      // can't grab something from this source until it is done
+      output.println("   {");
+      output.println("     SESEcommon* com = (SESEcommon*)"+paramsprefix+"->"+srcPair+";" );
+      output.println("     pthread_mutex_lock( &(com->lock) );");
+      output.println("     while( com->doneExecuting == FALSE ) {");
+      output.println("       pthread_cond_wait( &(com->doneCond), &(com->lock) );");
+      output.println("     }");
+      output.println("     pthread_mutex_unlock( &(com->lock) );");
+
       output.println("     "+generateTemp( fsen.getfmBogus(), temp, null )+
                     " = "+paramsprefix+"->"+srcPair+"->"+vst.getAddrVar()+";");
+
+      output.println("   }");
     }
 
     // dynamic vars come from an SESE and src
@@ -1942,6 +1954,15 @@ public class BuildCode {
 
       // go grab it from the SESE source
       output.println("   if( "+paramsprefix+"->"+temp+"_srcSESE != NULL ) {");
+
+      // gotta wait until the source is done
+      output.println("     SESEcommon* com = (SESEcommon*)"+paramsprefix+"->"+temp+"_srcSESE;" );
+      output.println("     pthread_mutex_lock( &(com->lock) );");
+      output.println("     while( com->doneExecuting == FALSE ) {");
+      output.println("       pthread_cond_wait( &(com->doneCond), &(com->lock) );");
+      output.println("     }");
+      output.println("     pthread_mutex_unlock( &(com->lock) );");
+
       output.println("     "+generateTemp( fsen.getfmBogus(), temp, null )+
                             " = *(("+temp.getType().toPrettyString()+"*) ("+
                             paramsprefix+"->"+temp+"_srcSESE + "+
@@ -2289,7 +2310,14 @@ public class BuildCode {
 
          output.println("   {");
          output.println("     SESEcommon* common = (SESEcommon*) "+p+";");
-         output.println("     psem_take( &(common->stallSem) );");
+
+         output.println("     pthread_mutex_lock( &(common->lock) );");
+         output.println("     while( common->doneExecuting == FALSE ) {");
+         output.println("       pthread_cond_wait( &(common->doneCond), &(common->lock) );");
+         output.println("     }");
+         output.println("     pthread_mutex_unlock( &(common->lock) );");
+                 
+         //output.println("     psem_take( &(common->stallSem) );");
 
          // copy things we might have stalled for        
          output.println("     "+p.getSESE().getSESErecordName()+"* child = ("+
@@ -2814,13 +2842,9 @@ public class BuildCode {
     output.println("     seseToIssue->common.classID = "+fsen.getIdentifier()+";");
     output.println("     psem_init( &(seseToIssue->common.stallSem) );");
 
-    // before potentially adding this SESE to other forwarding lists,
-    //  create it's lock and take it immediately
-    output.println("     pthread_mutex_init( &(seseToIssue->common.lock), NULL );");
-    output.println("     pthread_mutex_lock( &(seseToIssue->common.lock) );");
-
     output.println("     seseToIssue->common.forwardList = createQueue();");
     output.println("     seseToIssue->common.unresolvedDependencies = 0;");
+    output.println("     pthread_cond_init( &(seseToIssue->common.doneCond), NULL );");
     output.println("     seseToIssue->common.doneExecuting = FALSE;");    
     output.println("     pthread_cond_init( &(seseToIssue->common.runningChildrenCond), NULL );");
     output.println("     seseToIssue->common.numRunningChildren = 0;");
@@ -2844,6 +2868,11 @@ public class BuildCode {
       }
     }
 
+    // before potentially adding this SESE to other forwarding lists,
+    //  create it's lock and take it immediately
+    output.println("     pthread_mutex_init( &(seseToIssue->common.lock), NULL );");
+    output.println("     pthread_mutex_lock( &(seseToIssue->common.lock) );");
+
     if( fsen != mlpa.getRootSESE() ) {
       // count up outstanding dependencies, static first, then dynamic
       Iterator<SESEandAgePair> staticSrcsItr = fsen.getStaticInVarSrcs().iterator();
@@ -2857,8 +2886,10 @@ public class BuildCode {
        output.println("         printf( \"This shouldnt already be here\\n\");");
        output.println("         exit( -1 );");
        output.println("       }");
-       output.println("       addNewItem( src->forwardList, seseToIssue );");
-       output.println("       ++(seseToIssue->common.unresolvedDependencies);");
+       output.println("       if( !src->doneExecuting ) {");
+       output.println("         addNewItem( src->forwardList, seseToIssue );");
+       output.println("         ++(seseToIssue->common.unresolvedDependencies);");
+       output.println("       }");
        output.println("       pthread_mutex_unlock( &(src->lock) );");
        output.println("     }");
 
@@ -2882,8 +2913,10 @@ public class BuildCode {
        output.println("         pthread_mutex_lock( &(src->lock) );");
        output.println("         if( isEmpty( src->forwardList ) ||");
        output.println("             seseToIssue != peekItem( src->forwardList ) ) {");
-       output.println("           addNewItem( src->forwardList, seseToIssue );");
-       output.println("           ++(seseToIssue->common.unresolvedDependencies);");
+       output.println("           if( !src->doneExecuting ) {");
+       output.println("             addNewItem( src->forwardList, seseToIssue );");
+       output.println("             ++(seseToIssue->common.unresolvedDependencies);");
+       output.println("           }");
        output.println("         }");
        output.println("         pthread_mutex_unlock( &(src->lock) );");       
        output.println("         seseToIssue->"+dynInVar+"_srcOffset = "+dynInVar+"_srcOffset;");
@@ -2939,7 +2972,7 @@ public class BuildCode {
     output.println("   while( "+com+".numRunningChildren > 0 ) {");
     output.println("     pthread_cond_wait( &("+com+".runningChildrenCond), &("+com+".lock) );");
     output.println("   }");
-    output.println("   pthread_mutex_unlock( &("+com+".lock) );");    
+    //output.println("   pthread_mutex_unlock( &("+com+".lock) );");    
 
     // copy out-set from local temps into the sese record
     Iterator<TempDescriptor> itr = fsexn.getFlatEnter().getOutVarSet().iterator();
@@ -2951,8 +2984,9 @@ public class BuildCode {
     }    
     
     // mark yourself done, your SESE data is now read-only
-    output.println("   pthread_mutex_lock( &("+com+".lock) );");
+    //output.println("   pthread_mutex_lock( &("+com+".lock) );");
     output.println("   "+com+".doneExecuting = TRUE;");
+    output.println("   pthread_cond_signal( &("+com+".doneCond) );");
     output.println("   pthread_mutex_unlock( &("+com+".lock) );");
 
     // decrement dependency count for all SESE's on your forwarding list
@@ -3002,10 +3036,16 @@ public class BuildCode {
       TempDescriptor      refVar = (TempDescriptor)      me.getKey();
       VariableSourceToken vst    = (VariableSourceToken) me.getValue();
       
-      SESEandAgePair instance = new SESEandAgePair( vst.getSESE(), vst.getAge() );
-      
       FlatSESEEnterNode current = fwdvn.getEnclosingSESE();
 
+      // only do this if the variable in question should be tracked,
+      // meaning that it was explicitly added to the dynamic var set
+      if( !current.getDynamicVarSet().contains( vst.getAddrVar() ) ) {
+       continue;
+      }
+
+      SESEandAgePair instance = new SESEandAgePair( vst.getSESE(), vst.getAge() );      
+
       output.println("   {");
 
       if( current.equals( vst.getSESE() ) ) {
index f2f291d3e92473bf74c54dffa0b819d7cb61da41..859a430bffdf8f5141ab58243ac34b2a08a00ff0 100644 (file)
@@ -39,10 +39,13 @@ typedef struct SESEcommon_t {
 
   struct Queue*   forwardList;
   int             unresolvedDependencies;
+
+  pthread_cond_t  doneCond;
   int             doneExecuting;
 
   pthread_cond_t  runningChildrenCond;
   int             numRunningChildren;
+
   SESEcommon_p    parent;
 
 } SESEcommon;
index 17e45e0b93c6aa12be024d9bfef37ebcf397d78a..c7637214c489143e1eee840c0e0b18daec5db0bd 100644 (file)
@@ -8,8 +8,8 @@ public class Test {
 
   public static void main( String args[] ) {
     
-    int x = Integer.parseInt( args[0] );
-    int y = Integer.parseInt( args[1] );
+    //int x = Integer.parseInt( args[0] );
+    //int y = Integer.parseInt( args[1] );
     //System.out.println( "root: x="+x+", y="+y );
 
     /*
@@ -26,16 +26,32 @@ public class Test {
     }
     */
 
+    
     int total = 0;
-    for( int i = 0; i < x; ++i ) {
+    for( int i = 0; i < 5; ++i ) {
+
+      System.out.println( "i="+i );
+
       sese sum {
        total = total + i;
       }
     }
-
+    
 
     //setTo3( foo );
 
+
+
+    /*
+    int total = 0;
+    sese kemper {
+      for( int i = 0; i < 5; ++i ) {
+       total = total + i;
+      }
+    }
+    */
+
+
     System.out.println( "total="+total );
 
     // just for testing root's ability to