a bunch of dynamic var bugs
authorjjenista <jjenista>
Fri, 14 Aug 2009 21:03:10 +0000 (21:03 +0000)
committerjjenista <jjenista>
Fri, 14 Aug 2009 21:03:10 +0000 (21:03 +0000)
Robust/src/Analysis/MLP/MLPAnalysis.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/Tests/mlp/tinyTest/debugging.txt
Robust/src/Tests/mlp/tinyTest/test.java

index 6faa882949d475a5f7915839b166445d89a09b20..63bb037d675089597d8eb6c0ddf1d8849f75889a 100644 (file)
@@ -865,11 +865,14 @@ public class MLPAnalysis {
        TempDescriptor inVar = inVarItr.next();
        Integer srcType = 
          vstTableIn.getRefVarSrcType( inVar, 
-                                    fsen,
-                                    fsen.getParent() );
+                                      fsen,
+                                      fsen.getParent() );
 
+       // the current SESE needs a local space to track the dynamic
+       // variable and the child needs space in its SESE record
        if( srcType.equals( VarSrcTokTable.SrcType_DYNAMIC ) ) {
          fsen.addDynamicInVar( inVar );
+         fsen.getParent().addDynamicVar( inVar );
 
        } else if( srcType.equals( VarSrcTokTable.SrcType_STATIC ) ) {
          fsen.addStaticInVar( inVar );
index 3b633ba2e2973b6d474c5c9d6917c13f2ab1f488..9b7389a74ade79ef041344ce6d43918ea6518de0 100644 (file)
@@ -1783,6 +1783,14 @@ public class BuildCode {
       outputStructs.println("  "+srcPair.getSESE().getSESErecordName()+"* "+srcPair+";");
     }    
 
+    // DYNAMIC stuff needs a source SESE ptr and offset
+    Iterator<TempDescriptor> itrDynInVars = fsen.getDynamicInVarSet().iterator();
+    while( itrDynInVars.hasNext() ) {
+      TempDescriptor dynInVar = itrDynInVars.next();
+      outputStructs.println("  void* "+dynInVar+"_srcSESE;");
+      outputStructs.println("  int   "+dynInVar+"_srcOffset;");
+    }    
+
     // space for all in and out set primitives
     Iterator<TempDescriptor> itrPrims = inSetAndOutSetPrims.iterator();
     while( itrPrims.hasNext() ) {
@@ -1902,26 +1910,29 @@ public class BuildCode {
     // static vars are from a known SESE
     tempItr = fsen.getStaticInVarSet().iterator();
     while( tempItr.hasNext() ) {
-      TempDescriptor      temp = tempItr.next();
-      TypeDescriptor      type = temp.getType();
-      VariableSourceToken vst  = fsen.getStaticInVarSrc( temp );
-
-      String to;
-      String size;
-      if( type.isPtr() ) {
-       to = "(void*) ";
-       size = "sizeof ";
-      } else {
-       to = temp.getSafeSymbol();
-       size = "sizeof( "+temp.getSafeSymbol()+" )";
-      }
-
+      TempDescriptor temp = tempItr.next();
+      VariableSourceToken vst = fsen.getStaticInVarSrc( temp );
       SESEandAgePair srcPair = new SESEandAgePair( vst.getSESE(), vst.getAge() );
-      String from = paramsprefix+"->"+srcPair+"->"+vst.getAddrVar();
-      
-      output.println("     "+to+" = "+from+";");
+      String from = paramsprefix+"->"+srcPair+"->"+vst.getAddrVar();      
+      output.println("     "+temp+" = "+from+";");
     }
 
+    // dynamic vars come from an SESE and src
+    tempItr = fsen.getDynamicInVarSet().iterator();
+    while( tempItr.hasNext() ) {
+      TempDescriptor temp = tempItr.next();
+
+      // go grab it from the SESE source
+      output.println("     if( "+paramsprefix+"->"+temp+"_srcSESE != NULL ) {");
+      output.println("       "+temp+" = *(("+temp.getType()+"*) ("+
+                            paramsprefix+"->"+temp+"_srcSESE + "+
+                            paramsprefix+"->"+temp+"_srcOffset));");
+
+      // or if the source was our parent, its in the record to grab
+      output.println("     } else {");
+      output.println("       "+temp+" = "+paramsprefix+"->"+temp+";");
+      output.println("     }");
+    }
 
     // Check to see if we need to do a GC if this is a
     // multi-threaded program...    
@@ -2767,9 +2778,11 @@ public class BuildCode {
 
     // before doing anything, lock your own record and increment the running children
     if( fsen != mlpa.getRootSESE() ) {
+      /*
       output.println("     pthread_mutex_lock( &("+paramsprefix+"->common.lock) );");
       output.println("     ++("+paramsprefix+"->common.numRunningChildren);");
       output.println("     pthread_mutex_unlock( &("+paramsprefix+"->common.lock) );");
+      */
     }
 
     // just allocate the space for this record
@@ -2817,8 +2830,7 @@ public class BuildCode {
        from = temp.getSafeSymbol();
       }
    
-      String to   = "seseToIssue->"+temp.getSafeSymbol();
-      String size = "sizeof( seseToIssue->"+temp.getSafeSymbol()+" )";
+      String to = "seseToIssue->"+temp.getSafeSymbol();
 
       output.println("     "+to+" = "+from+";");
     }
@@ -2845,6 +2857,36 @@ public class BuildCode {
        // to pass the static name to the child's record
        output.println("     seseToIssue->"+srcPair+" = "+srcPair+";");
       }
+
+      // dynamic sources might already be accounted for in the static list,
+      // so only add them to forwarding lists if they're not already there
+      Iterator<TempDescriptor> dynVarsItr = fsen.getDynamicInVarSet().iterator();
+      while( dynVarsItr.hasNext() ) {
+       TempDescriptor dynInVar = dynVarsItr.next();
+       output.println("     {");
+       output.println("       SESEcommon* src = (SESEcommon*)"+dynInVar+"_srcSESE;");
+
+       // the dynamic source is NULL if it comes from your own space--you can't pass
+       // the address off to the new child, because you're not done executing and
+       // might change the variable, so copy it right now
+       output.println("       if( src != NULL ) {");
+       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("         }");
+       output.println("         pthread_mutex_unlock( &(src->lock) );");       
+       output.println("         seseToIssue->"+dynInVar+"_srcOffset = "+dynInVar+"_srcOffset;");
+       output.println("       } else {");
+       output.println("         seseToIssue->"+dynInVar+" = "+dynInVar+";");
+       output.println("       }");
+       output.println("     }");
+       
+       // even if the value is already copied, make sure your NULL source
+       // gets passed so child knows it already has the dynamic value
+       output.println("     seseToIssue->"+dynInVar+"_srcSESE = "+dynInVar+"_srcSESE;");
+      }
       
       // maintain pointers for for finding dynamic SESE 
       // instances from static names
@@ -2884,11 +2926,13 @@ public class BuildCode {
     // this SESE cannot be done until all of its children are done
     // so grab your own lock with the condition variable for watching
     // that the number of your running children is greater than zero
+    /*
     output.println("   pthread_mutex_lock( &("+com+".lock) );");
     output.println("   while( "+com+".numRunningChildren > 0 ) {");
     output.println("     pthread_cond_wait( &("+com+".runningChildrenCond), &("+com+".lock) );");
     output.println("   }");
     output.println("   pthread_mutex_unlock( &("+com+".lock) );");    
+    */
 
     // copy out-set from local temps into the sese record
     Iterator<TempDescriptor> itr = fsexn.getFlatEnter().getOutVarSet().iterator();
@@ -2921,12 +2965,14 @@ public class BuildCode {
     }
 
     // last of all, decrement your parent's number of running children
+    /*
     output.println("     if( "+paramsprefix+"->common.parent != NULL ) {");
     output.println("       pthread_mutex_lock( &("+paramsprefix+"->common.parent->lock) );");
     output.println("       --("+paramsprefix+"->common.parent->numRunningChildren);");
     output.println("       pthread_cond_signal( &("+paramsprefix+"->common.parent->runningChildrenCond) );");
     output.println("       pthread_mutex_lock( &("+paramsprefix+"->common.parent->lock) );");
     output.println("     }");
+    */
   }
 
   public void generateFlatWriteDynamicVarNode( FlatMethod fm,  
index c7330059a51e2bdfcf282f0a026e7b60411cf163..96c48048bc8a655006f74f65ac8328f78b44c8b2 100644 (file)
@@ -1,3 +1,2 @@
-break garbage.c:721
-break garbage.c:731
+break methods.c:6664
 run
index 6f38215b55337f343b3e9f8ebc313182e9c3ecad..050b8998aeb1611fadcc306455a025417bca090b 100644 (file)
@@ -13,11 +13,12 @@ public class Test {
     
     int x = Integer.parseInt( args[0] );
     int y = Integer.parseInt( args[1] );
-    System.out.println( "root: x="+x+", y="+y );
+    //System.out.println( "root: x="+x+", y="+y );
 
     if( x > 3 ) {
       sese fee {
        y = y + 10;
+       //System.out.println( "fee: y="+y );
       }
     }
 
@@ -30,11 +31,11 @@ public class Test {
 
     // see that values from sese fi are
     // forwarded to this sibling
-    //sese foe {
+    sese foe {
     //System.out.println( "fo: x="+x+", y="+y );
     //System.out.println( "y="+y+" xyz="+xyz );
-    System.out.println( "y="+y );
-    //}
+      System.out.println( "foe: y="+y );
+    }