From: jjenista Date: Fri, 14 Aug 2009 21:03:10 +0000 (+0000) Subject: a bunch of dynamic var bugs X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=9e0bb51191b5dfac758cd3f69f2efc780a665c1f;p=IRC.git a bunch of dynamic var bugs --- diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index 6faa8829..63bb037d 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -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 ); diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 3b633ba2..9b7389a7 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -1783,6 +1783,14 @@ public class BuildCode { outputStructs.println(" "+srcPair.getSESE().getSESErecordName()+"* "+srcPair+";"); } + // DYNAMIC stuff needs a source SESE ptr and offset + Iterator 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 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 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 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, diff --git a/Robust/src/Tests/mlp/tinyTest/debugging.txt b/Robust/src/Tests/mlp/tinyTest/debugging.txt index c7330059..96c48048 100644 --- a/Robust/src/Tests/mlp/tinyTest/debugging.txt +++ b/Robust/src/Tests/mlp/tinyTest/debugging.txt @@ -1,3 +1,2 @@ -break garbage.c:721 -break garbage.c:731 +break methods.c:6664 run diff --git a/Robust/src/Tests/mlp/tinyTest/test.java b/Robust/src/Tests/mlp/tinyTest/test.java index 6f38215b..050b8998 100644 --- a/Robust/src/Tests/mlp/tinyTest/test.java +++ b/Robust/src/Tests/mlp/tinyTest/test.java @@ -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 ); + }