From: jjenista Date: Thu, 28 Jan 2010 23:55:59 +0000 (+0000) Subject: bug fix for ready-static-dynamic variable classification, which rippled into other... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=b179cffe7a5ef4d784ff7badab49a367eb7dd457;p=IRC.git bug fix for ready-static-dynamic variable classification, which rippled into other bug fixes. Tested on my tiny test, but the regression test still does not match up: there are more bugs out there --- diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index 16d977b3..397161ec 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -643,6 +643,8 @@ public class MLPAnalysis { FlatSESEEnterNode fsen = fsexn.getFlatEnter(); assert currentSESE.getChildren().contains( fsen ); + // remap all of this child's children tokens to be + // from this child as the child exits vstTable.remapChildTokens( fsen ); // liveness virtual reads are things that might be @@ -913,14 +915,16 @@ public class MLPAnalysis { // get other things from this source as well VarSrcTokTable vstTable = variableResults.get( fn ); + VSTWrapper vstIfStatic = new VSTWrapper(); Integer srcType = vstTable.getRefVarSrcType( rTemp, currentSESE, - currentSESE.getParent() ); + vstIfStatic + ); if( srcType.equals( VarSrcTokTable.SrcType_STATIC ) ) { - VariableSourceToken vst = vstTable.get( rTemp ).iterator().next(); + VariableSourceToken vst = vstIfStatic.vst; Iterator availItr = vstTable.get( vst.getSESE(), vst.getAge() @@ -936,10 +940,12 @@ public class MLPAnalysis { // if a variable is available from the same source, AND it ALSO // only comes from one statically known source, mark it available + VSTWrapper vstIfStaticNotUsed = new VSTWrapper(); Integer srcTypeAlso = vstTable.getRefVarSrcType( refVarAlso, currentSESE, - currentSESE.getParent() ); + vstIfStaticNotUsed + ); if( srcTypeAlso.equals( VarSrcTokTable.SrcType_STATIC ) ) { notAvailSet.remove( refVarAlso ); } @@ -3274,6 +3280,7 @@ public class MLPAnalysis { case FKind.FlatSESEEnterNode: { FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; + assert fsen.equals( currentSESE ); // track the source types of the in-var set so generated // code at this SESE issue can compute the number of @@ -3281,10 +3288,19 @@ public class MLPAnalysis { Iterator inVarItr = fsen.getInVarSet().iterator(); while( inVarItr.hasNext() ) { TempDescriptor inVar = inVarItr.next(); + + // when we get to an SESE enter node we change the + // currentSESE variable of this analysis to the + // child that is declared by the enter node, so + // in order to classify in-vars correctly, pass + // the parent SESE in--at other FlatNode types just + // use the currentSESE + VSTWrapper vstIfStatic = new VSTWrapper(); Integer srcType = - vstTableIn.getRefVarSrcType( inVar, - fsen, - fsen.getParent() ); + vstTableIn.getRefVarSrcType( inVar, + fsen.getParent(), + vstIfStatic + ); // the current SESE needs a local space to track the dynamic // variable and the child needs space in its SESE record @@ -3294,13 +3310,12 @@ public class MLPAnalysis { } else if( srcType.equals( VarSrcTokTable.SrcType_STATIC ) ) { fsen.addStaticInVar( inVar ); - VariableSourceToken vst = vstTableIn.get( inVar ).iterator().next(); + VariableSourceToken vst = vstIfStatic.vst; fsen.putStaticInVar2src( inVar, vst ); fsen.addStaticInVarSrc( new SESEandAgePair( vst.getSESE(), vst.getAge() ) ); - } else { assert srcType.equals( VarSrcTokTable.SrcType_READY ); fsen.addReadyInVar( inVar ); @@ -3324,15 +3339,17 @@ public class MLPAnalysis { // source and delay until we need to use value // ask whether lhs and rhs sources are dynamic, static, etc. + VSTWrapper vstIfStatic = new VSTWrapper(); Integer lhsSrcType = vstTableIn.getRefVarSrcType( lhs, currentSESE, - currentSESE.getParent() ); - + vstIfStatic + ); Integer rhsSrcType = vstTableIn.getRefVarSrcType( rhs, currentSESE, - currentSESE.getParent() ); + vstIfStatic + ); if( rhsSrcType.equals( VarSrcTokTable.SrcType_DYNAMIC ) ) { // if rhs is dynamic going in, lhs will definitely be dynamic @@ -3373,14 +3390,16 @@ public class MLPAnalysis { } // check the source type of this variable + VSTWrapper vstIfStatic = new VSTWrapper(); Integer srcType = vstTableIn.getRefVarSrcType( readtmp, currentSESE, - currentSESE.getParent() ); + vstIfStatic + ); if( srcType.equals( VarSrcTokTable.SrcType_DYNAMIC ) ) { // 1) It is not clear statically where this variable will - // come from statically, so dynamically we must keep track + // come from, so dynamically we must keep track // along various control paths, and therefore when we stall, // just stall for the exact thing we need and move on plan.addDynamicStall( readtmp ); @@ -3391,8 +3410,7 @@ public class MLPAnalysis { // 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. - - VariableSourceToken vst = vstTableIn.get( readtmp ).iterator().next(); + VariableSourceToken vst = vstIfStatic.vst; Iterator availItr = vstTableIn.get( vst.getSESE(), vst.getAge() ).iterator(); @@ -3474,12 +3492,11 @@ public class MLPAnalysis { // completely outside of the root SESE scope if( nextVstTable != null && nextLiveIn != null ) { - Hashtable readyOrStatic2dynamicSet = + Hashtable readyOrStatic2dynamicSet = thisVstTable.getReadyOrStatic2DynamicSet( nextVstTable, nextLiveIn, - currentSESE, - currentSESE.getParent() - ); + currentSESE + ); if( !readyOrStatic2dynamicSet.isEmpty() ) { diff --git a/Robust/src/Analysis/MLP/VSTWrapper.java b/Robust/src/Analysis/MLP/VSTWrapper.java new file mode 100644 index 00000000..68987f4b --- /dev/null +++ b/Robust/src/Analysis/MLP/VSTWrapper.java @@ -0,0 +1,17 @@ +package Analysis.MLP; + +import IR.*; +import IR.Flat.*; +import java.util.*; +import java.io.*; + +// the reason for this class is to allow a VariableSourceToken +// to be null in some circumstances + +public class VSTWrapper { + public VariableSourceToken vst; + + public VSTWrapper() { + vst = null; + } +} diff --git a/Robust/src/Analysis/MLP/VarSrcTokTable.java b/Robust/src/Analysis/MLP/VarSrcTokTable.java index 84c7cca8..8d29306f 100644 --- a/Robust/src/Analysis/MLP/VarSrcTokTable.java +++ b/Robust/src/Analysis/MLP/VarSrcTokTable.java @@ -530,40 +530,17 @@ public class VarSrcTokTable { } - // get a sufficient set of VariableSourceTokens to cover all static sources - public Set getStaticSet( FlatSESEEnterNode current, - FlatSESEEnterNode parent - ) { - - Set out = new HashSet(); - - Iterator itr = var2vst.entrySet().iterator(); - while( itr.hasNext() ) { - Map.Entry me = (Map.Entry) itr.next(); - TempDescriptor var = (TempDescriptor) me.getKey(); - HashSet s1 = (HashSet) me.getValue(); - - if( getRefVarSrcType( var, current, parent ) == SrcType_STATIC ) { - out.add( s1.iterator().next() ); - } - } - - return out; - } - - // given a table from a subsequent program point, decide - // which variables are going from a static source to a + // which variables are going from a non-dynamic to a // dynamic source and return them - public Hashtable + public Hashtable getReadyOrStatic2DynamicSet( VarSrcTokTable nextTable, Set nextLiveIn, - FlatSESEEnterNode current, - FlatSESEEnterNode parent + FlatSESEEnterNode current ) { - Hashtable out = - new Hashtable(); + Hashtable out = + new Hashtable(); Iterator itr = var2vst.entrySet().iterator(); while( itr.hasNext() ) { @@ -573,15 +550,21 @@ public class VarSrcTokTable { // only worth tracking if live if( nextLiveIn.contains( var ) ) { + + VSTWrapper vstIfStaticBefore = new VSTWrapper(); + VSTWrapper vstIfStaticAfter = new VSTWrapper(); + + Integer srcTypeBefore = this.getRefVarSrcType( var, current, vstIfStaticBefore ); + Integer srcTypeAfter = nextTable.getRefVarSrcType( var, current, vstIfStaticAfter ); - if( ( this.getRefVarSrcType( var, current, parent ) == SrcType_READY || - this.getRefVarSrcType( var, current, parent ) == SrcType_STATIC ) - && - nextTable.getRefVarSrcType( var, current, parent ) == SrcType_DYNAMIC - ) { - // remember the variable and a static source + if( !srcTypeBefore.equals( SrcType_DYNAMIC ) && + srcTypeAfter.equals( SrcType_DYNAMIC ) + ) { + // remember the variable and a source // it had before crossing the transition - out.put( var, s1.iterator().next() ); + // 1) if it was ready, vstIfStatic.vst is null + // 2) if is was static, use vstIfStatic.vst + out.put( var, vstIfStaticBefore ); } } } @@ -592,75 +575,62 @@ public class VarSrcTokTable { // for some reference variable, return the type of source // it might have in this table, which might be: - // 1. Ready -- this variable comes from your parent and is + // 1. Ready -- this variable is // definitely available when you are issued. - // 2. Static -- there is definitely one SESE that will - // produce the value for this variable + // 2. Static -- there is definitely one child SESE with + // a known age that will produce the value // 3. Dynamic -- we don't know where the value will come - // from, so we'll track it dynamically + // from statically, so we'll track it dynamically public Integer getRefVarSrcType( TempDescriptor refVar, FlatSESEEnterNode current, - FlatSESEEnterNode parent ) { - assert refVar != null; - - // if you have no parent (root) and the variable in - // question is in your in-set, it's a command line - // argument and it is definitely available - if( parent == null && - current.getInVarSet().contains( refVar ) ) { + VSTWrapper vstIfStatic ) { + assert refVar != null; + assert vstIfStatic != null; + + vstIfStatic.vst = null; + + // when the current SESE is null, that simply means it is + // an unknown placeholder, in which case the system will + // ensure that any variables are READY + if( current == null ) { return SrcType_READY; } // if there appear to be no sources, it means this variable // comes from outside of any statically-known SESE scope, - // which means the system guarantees its READY - Set srcs = get( refVar ); - if( srcs.isEmpty() ) { - return SrcType_READY; - } + // which means the system guarantees its READY, so jump over + // while loop + Set srcs = get( refVar ); + Iterator itrSrcs = srcs.iterator(); + while( itrSrcs.hasNext() ) { + VariableSourceToken vst = itrSrcs.next(); + + // to make the refVar non-READY we have to find at least + // one child token + if( current.getChildren().contains( vst.getSESE() ) ) { + + // if we ever have at least one child source with an + // unknown age, have to treat var as dynamic + if( vst.getAge().equals( MLPAnalysis.maxSESEage ) ) { + return SrcType_DYNAMIC; + } - // if the variable may have more than one source it might be - // dynamic, unless all sources are from a placeholder - if( srcs.size() > 1 ) { - Iterator itrSrcs = srcs.iterator(); - VariableSourceToken oneSrc = itrSrcs.next(); - while( itrSrcs.hasNext() ) { - VariableSourceToken anotherSrc = itrSrcs.next(); - if( !oneSrc.getSESE().equals( anotherSrc.getSESE() ) || - !oneSrc.getAge( ).equals( anotherSrc.getAge( ) ) - ) { - return SrcType_DYNAMIC; - } - } - - // all sources were same SESE and age, BUT, make sure it's - // not a placeholder SESE, who's vars are always ready - if( oneSrc.getSESE().getIsCallerSESEplaceholder() ) { - return SrcType_READY; + // if we have a known-age child source, this var is + // either static or dynamic now: it's static if this + // source is the only source, otherwise dynamic + if( srcs.size() > 1 ) { + return SrcType_DYNAMIC; + } + + vstIfStatic.vst = vst; + return SrcType_STATIC; } - - return SrcType_DYNAMIC; - } - - VariableSourceToken singleSrc = srcs.iterator().next(); - // if the one source is max age, track it dynamically - if( singleSrc.getAge() == MLPAnalysis.maxSESEage ) { - return SrcType_DYNAMIC; - } - - // if it has one source that comes from the parent, it's ready - if( singleSrc.getSESE() == parent ) { - return SrcType_READY; - } - - // if the one source is a placeholder SESE then it's ready - if( singleSrc.getSESE().getIsCallerSESEplaceholder() ) { - return SrcType_READY; } - // otherwise it comes from one source not the parent (sibling) - // and we know exactly which static SESE/age it will come from - return SrcType_STATIC; + // if we never found a child source, all other + // sources must be READY before we could even + // begin executing! + return SrcType_READY; } diff --git a/Robust/src/Analysis/MLP/VariableSourceToken.java b/Robust/src/Analysis/MLP/VariableSourceToken.java index 3d528eb6..b34b88c7 100644 --- a/Robust/src/Analysis/MLP/VariableSourceToken.java +++ b/Robust/src/Analysis/MLP/VariableSourceToken.java @@ -77,6 +77,6 @@ public class VariableSourceToken { public String toString() { - return refVars+"\tref "+addrVar+"\t@"+sese.getPrettyIdentifier()+"("+seseAge+")"; + return refVars+"\tref "+addrVar+"\t@"+sese.toPrettyString()+"("+seseAge+")"; } } diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index cdcfb03f..780723d3 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -32,6 +32,7 @@ import Analysis.MLP.MLPAnalysis; import Analysis.MLP.ParentChildConflictsMap; import Analysis.MLP.SESELock; import Analysis.MLP.VariableSourceToken; +import Analysis.MLP.VSTWrapper; import Analysis.MLP.CodePlan; import Analysis.MLP.SESEandAgePair; import Analysis.MLP.WaitingElement; @@ -1769,8 +1770,8 @@ public class BuildCode { output.println(" /* static SESE names */"); Iterator pItr = callerSESEplaceholder.getNeededStaticNames().iterator(); while( pItr.hasNext() ) { - SESEandAgePair p = pItr.next(); - output.println(" void* "+p+";"); + SESEandAgePair pair = pItr.next(); + output.println(" void* "+pair+";"); } // declare variables for tracking dynamic sources @@ -1915,10 +1916,6 @@ public class BuildCode { for(int i=0; i pItr = fsen.getNeededStaticNames().iterator(); while( pItr.hasNext() ) { - SESEandAgePair p = pItr.next(); - output.println(" void* "+p+";"); + SESEandAgePair pair = pItr.next(); + output.println(" void* "+pair+";"); } // declare variables for tracking dynamic sources @@ -2617,7 +2614,6 @@ public class BuildCode { TempObject objecttemps=(TempObject) tempstable.get(lb!=null ? lb : md!=null ? md : task); if (objecttemps.isLocalPrim(td)||objecttemps.isParamPrim(td)) { - //System.out.println("generateTemp returns " + td.getSafeSymbol()); return td.getSafeSymbol(); } @@ -2649,22 +2645,20 @@ public class BuildCode { while( vstItr.hasNext() ) { VariableSourceToken vst = vstItr.next(); - SESEandAgePair p = new SESEandAgePair( vst.getSESE(), vst.getAge() ); + SESEandAgePair pair = new SESEandAgePair( vst.getSESE(), vst.getAge() ); output.println(" {"); - output.println(" SESEcommon* common = (SESEcommon*) "+p+";"); + output.println(" SESEcommon* common = (SESEcommon*) "+pair+";"); 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 = ("+ - p.getSESE().getSESErecordName()+"*) "+p+";"); + output.println(" "+pair.getSESE().getSESErecordName()+"* child = ("+ + pair.getSESE().getSESErecordName()+"*) "+pair+";"); Iterator tdItr = cp.getCopySet( vst ).iterator(); while( tdItr.hasNext() ) { @@ -2723,17 +2717,9 @@ public class BuildCode { // dynamic source vars to the current SESE dynItr = cp.getDynAssignCurr().iterator(); while( dynItr.hasNext() ) { - TempDescriptor dynVar = dynItr.next(); - - // I would like to change the analysis, IF POSSIBLE, to "push" unneeded - // variable source tokens away while analyzing a child and "pop" them - // back at the child exit, otherwise we sometimes think we should inject - // the following code inside a child that is for a parent's variable--in other - // words the variable is not dynamically tracked for the child, but should - // be by the parent. Quick fix is to use test to rule out whether we do this - if( currentSESE.getDynamicVarSet().contains(dynVar) ) { - output.println(" "+dynVar+"_srcSESE = NULL;"); - } + TempDescriptor dynVar = dynItr.next(); + assert currentSESE.getDynamicVarSet().contains( dynVar ); + output.println(" "+dynVar+"_srcSESE = NULL;"); } // eom @@ -3536,20 +3522,20 @@ public class BuildCode { output.println(" seseToIssue->"+dynInVar+"_srcSESE = "+dynInVar+"_srcSESE;"); } - // maintain pointers for for finding dynamic SESE + // maintain pointers for finding dynamic SESE // instances from static names - SESEandAgePair p = new SESEandAgePair( fsen, 0 ); + SESEandAgePair pair = new SESEandAgePair( fsen, 0 ); if( fsen.getParent() != null && //!fsen.getParent().getIsCallerSESEplaceholder() && - fsen.getParent().getNeededStaticNames().contains( p ) + fsen.getParent().getNeededStaticNames().contains( pair ) ) { for( int i = fsen.getOldestAgeToTrack(); i > 0; --i ) { - SESEandAgePair p1 = new SESEandAgePair( fsen, i ); - SESEandAgePair p2 = new SESEandAgePair( fsen, i-1 ); - output.println(" "+p1+" = "+p2+";"); + SESEandAgePair pair1 = new SESEandAgePair( fsen, i ); + SESEandAgePair pair2 = new SESEandAgePair( fsen, i-1 ); + output.println(" "+pair1+" = "+pair2+";"); } - output.println(" "+p+" = seseToIssue;"); + output.println(" "+pair+" = seseToIssue;"); } } @@ -3776,42 +3762,37 @@ public class BuildCode { throw new Error("Unexpected presence of FlatWriteDynamicVarNode"); } - Hashtable writeDynamic = - fwdvn.getVar2src(); + Hashtable writeDynamic = fwdvn.getVar2src(); assert writeDynamic != null; Iterator wdItr = writeDynamic.entrySet().iterator(); while( wdItr.hasNext() ) { - Map.Entry me = (Map.Entry) wdItr.next(); - TempDescriptor refVar = (TempDescriptor) me.getKey(); - VariableSourceToken vst = (VariableSourceToken) me.getValue(); - - FlatSESEEnterNode current = fwdvn.getEnclosingSESE(); + Map.Entry me = (Map.Entry) wdItr.next(); + TempDescriptor refVar = (TempDescriptor) me.getKey(); + VSTWrapper vstW = (VSTWrapper) me.getValue(); + VariableSourceToken vst = vstW.vst; + /* // 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() ) ) { - // if the src comes from this SESE, it's a method local variable, + if( vst == null ) { + // if there is no given source, this variable is ready so // mark src pointer NULL to signify that the var is up-to-date - output.println(" "+vst.getAddrVar()+"_srcSESE = NULL;"); - - } else { - // otherwise we track where it will come from - output.println(" "+vst.getAddrVar()+"_srcSESE = "+instance+";"); - output.println(" "+vst.getAddrVar()+"_srcOffset = (int) &((("+ - vst.getSESE().getSESErecordName()+"*)0)->"+vst.getAddrVar()+");"); + output.println(" "+refVar+"_srcSESE = NULL;"); + continue; } - output.println(" }"); + // otherwise we track where it will come from + SESEandAgePair instance = new SESEandAgePair( vst.getSESE(), vst.getAge() ); + output.println(" "+refVar+"_srcSESE = "+instance+";"); + output.println(" "+refVar+"_srcOffset = (int) &((("+ + vst.getSESE().getSESErecordName()+"*)0)->"+vst.getAddrVar()+");"); } } diff --git a/Robust/src/IR/Flat/FlatSESEEnterNode.java b/Robust/src/IR/Flat/FlatSESEEnterNode.java index 2e59a992..e2e88057 100644 --- a/Robust/src/IR/Flat/FlatSESEEnterNode.java +++ b/Robust/src/IR/Flat/FlatSESEEnterNode.java @@ -122,6 +122,10 @@ public class FlatSESEEnterNode extends FlatNode { public String toString() { return "sese "+getPrettyIdentifier()+" enter"; } + + public String toPrettyString() { + return "sese "+getPrettyIdentifier()+getIdentifier(); + } public void setParent( FlatSESEEnterNode parent ) { this.parent = parent; diff --git a/Robust/src/IR/Flat/FlatWriteDynamicVarNode.java b/Robust/src/IR/Flat/FlatWriteDynamicVarNode.java index ec85959b..552b845b 100644 --- a/Robust/src/IR/Flat/FlatWriteDynamicVarNode.java +++ b/Robust/src/IR/Flat/FlatWriteDynamicVarNode.java @@ -1,5 +1,5 @@ package IR.Flat; -import Analysis.MLP.VariableSourceToken; +import Analysis.MLP.VSTWrapper; import java.util.Hashtable; @@ -13,14 +13,14 @@ public class FlatWriteDynamicVarNode extends FlatNode { protected FlatNode tailNode; protected FlatNode headNode; - protected Hashtable var2src; + protected Hashtable var2src; protected FlatSESEEnterNode enclosingSESE; public FlatWriteDynamicVarNode( FlatNode t, FlatNode h, - Hashtable v2s, + Hashtable v2s, FlatSESEEnterNode c ) { tailNode = t; @@ -37,11 +37,11 @@ public class FlatWriteDynamicVarNode extends FlatNode { this.addNext( headNode ); } - public void addMoreVar2Src( Hashtable more ) { + public void addMoreVar2Src( Hashtable more ) { var2src.putAll( more ); } - public Hashtable getVar2src() { + public Hashtable getVar2src() { return var2src; } diff --git a/Robust/src/Makefile b/Robust/src/Makefile index c6fc2c71..e5185d39 100644 --- a/Robust/src/Makefile +++ b/Robust/src/Makefile @@ -93,6 +93,7 @@ Analysis/Disjoint/DisjointAnalysis.class \ Analysis/Disjoint/ReachGraph.class \ Analysis/MLP/MLPAnalysis.class \ Analysis/MLP/VariableSourceToken.class \ +Analysis/MLP/VSTWrapper.class \ Analysis/MLP/SVKey.class \ Analysis/MLP/VarSrcTokTable.class \ Analysis/MLP/CodePlan.class \ diff --git a/Robust/src/Tests/mlp/regression/makefile b/Robust/src/Tests/mlp/regression/makefile index 294772a8..9375cb3b 100644 --- a/Robust/src/Tests/mlp/regression/makefile +++ b/Robust/src/Tests/mlp/regression/makefile @@ -5,13 +5,14 @@ SOURCE_FILES=test.java BUILDSCRIPT=~/research/Robust/src/buildscript -USEMLP= -mlp 8 2 -mlpdebug # use to turn mlp on and off and make sure rest of build not broken -BSFLAGS= -nooptimize -debug -garbagestats -mainclass Test -ownership -ownallocdepth 1 -enable-assertions -ownaliasfile aliases.txt +USEMLP= -mlp 8 2 -mlpdebug -methodeffects -ownership -ownallocdepth 1 -ownaliasfile aliases.txt +BSFLAGS= -nooptimize -debug -garbagestats -mainclass Test -enable-assertions all: $(PROGRAM1).bin $(PROGRAM2).bin $(PROGRAM1).bin: $(SOURCE_FILES) $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM1) $(SOURCE_FILES) + rm -fr tmpbuilddirectory $(PROGRAM2).bin: $(SOURCE_FILES) $(BUILDSCRIPT) $(USEMLP) $(BSFLAGS) -o $(PROGRAM2) $(SOURCE_FILES) @@ -25,4 +26,5 @@ clean: rm -f *.png rm -f aliases.txt rm -f mlpReport*txt + rm -f MethodEffects*txt rm -f results*txt diff --git a/Robust/src/Tests/mlp/regression/runTests b/Robust/src/Tests/mlp/regression/runTests index 53dbd1b3..2ff3c533 100755 --- a/Robust/src/Tests/mlp/regression/runTests +++ b/Robust/src/Tests/mlp/regression/runTests @@ -10,8 +10,8 @@ echo 'running...' ./testMulti.bin $[ i ] >> resultsMulti.txt ./testSingle.bin $[ i*7 ] >> resultsSingle.txt ./testMulti.bin $[ i*7 ] >> resultsMulti.txt -./testSingle.bin $[ 50+i*7 ] >> resultsSingle.txt -./testMulti.bin $[ 50+i*7 ] >> resultsMulti.txt +./testSingle.bin $[ 50+i*9 ] >> resultsSingle.txt +./testMulti.bin $[ 50+i*9 ] >> resultsMulti.txt done echo 'Diffing results' diff --git a/Robust/src/Tests/mlp/regression/test.java b/Robust/src/Tests/mlp/regression/test.java index 1f2572f6..87da0340 100644 --- a/Robust/src/Tests/mlp/regression/test.java +++ b/Robust/src/Tests/mlp/regression/test.java @@ -11,29 +11,51 @@ public class Test { public static void main( String args[] ) { int x = Integer.parseInt( args[0] ); Foo f = new Foo( x + 10000 ); - doSomeWork( x, f ); + int s = doSomeWork( x, f ); + int t = moreWork( x, f ); nullMethodBodyFinalNode(); + int r = s+t; + System.out.println( "s+t="+r ); } - public static void doSomeWork( int x, Foo f ) { + public static int doSomeWork( int x, Foo f ) { + float delta = 1.0f; for( int i = 0; i < x; ++i ) { sese calc { Foo g = new Foo( i ); int sum = 0; - for( int j = 0; j <= i; ++j ) { + for( int j = 0; j <= i % 10; ++j ) { sum = calculateStuff( sum, 1, 0 ); } } sese forceVirtualReal { - if( i % 3 == 0 ) { + if( i % 7 == 0 ) { sum = sum + (i % 20); - } + } + for( int z = 0; z < x % 50; ++z ) { + if( i % 2 == 0 ) { + delta += 1.0f; + } + } g.z = sum + 1000; } + sese arrayAlloc { + int tempArray[] = new int[x]; + for( int k = 0; k < x/20; ++k ) { + tempArray[k] = g.z / (i+1); + } + } + sese gather { + int inter = 1; + for( int k = 0; k < x/20; ++k ) { + inter = inter + tempArray[k]; + } + sum = sum + inter / 10; + } sese modobj { g.z = g.z + f.z; } - if( i % 2 == 0 ) { + if( i % 11 == 0 ) { sese change { for( int k = 0; k < i*2; ++k ) { sum = calculateStuff( sum, k, 1 ); @@ -46,9 +68,10 @@ public class Test { } } sese prnt { - mightPrint( x, i, sum, g ); + mightPrint( x, i, sum + (int)delta, g ); } } + return x; } public static int calculateStuff( int sum, int num, int mode ) { @@ -73,6 +96,36 @@ public class Test { return answer; } + public static int moreWork( int x, Foo f ) { + + int total = 0; + + for( int j = 0; j < x; ++j ) { + sese doe { + Foo g = new Foo( j ); + int prod = 1; + } + sese rae { + if( j % 7 == 0 ) { + prod = prod * j; + } + g.z = prod / x; + } + sese mi { + g.z = g.z + f.z; + } + if( j % 3 == 0 ) { + sese fa { + prod = prod / 2; + } + } + + total = total + prod - g.z; + } + + return total; + } + public static void nullMethodBodyFinalNode() { int y = 1; sese nothing { diff --git a/Robust/src/Tests/mlp/tinyTest/makefile b/Robust/src/Tests/mlp/tinyTest/makefile index 294772a8..9375cb3b 100644 --- a/Robust/src/Tests/mlp/tinyTest/makefile +++ b/Robust/src/Tests/mlp/tinyTest/makefile @@ -5,13 +5,14 @@ SOURCE_FILES=test.java BUILDSCRIPT=~/research/Robust/src/buildscript -USEMLP= -mlp 8 2 -mlpdebug # use to turn mlp on and off and make sure rest of build not broken -BSFLAGS= -nooptimize -debug -garbagestats -mainclass Test -ownership -ownallocdepth 1 -enable-assertions -ownaliasfile aliases.txt +USEMLP= -mlp 8 2 -mlpdebug -methodeffects -ownership -ownallocdepth 1 -ownaliasfile aliases.txt +BSFLAGS= -nooptimize -debug -garbagestats -mainclass Test -enable-assertions all: $(PROGRAM1).bin $(PROGRAM2).bin $(PROGRAM1).bin: $(SOURCE_FILES) $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM1) $(SOURCE_FILES) + rm -fr tmpbuilddirectory $(PROGRAM2).bin: $(SOURCE_FILES) $(BUILDSCRIPT) $(USEMLP) $(BSFLAGS) -o $(PROGRAM2) $(SOURCE_FILES) @@ -25,4 +26,5 @@ clean: rm -f *.png rm -f aliases.txt rm -f mlpReport*txt + rm -f MethodEffects*txt rm -f results*txt diff --git a/Robust/src/Tests/mlp/tinyTest/runTests b/Robust/src/Tests/mlp/tinyTest/runTests index 53dbd1b3..2ff3c533 100755 --- a/Robust/src/Tests/mlp/tinyTest/runTests +++ b/Robust/src/Tests/mlp/tinyTest/runTests @@ -10,8 +10,8 @@ echo 'running...' ./testMulti.bin $[ i ] >> resultsMulti.txt ./testSingle.bin $[ i*7 ] >> resultsSingle.txt ./testMulti.bin $[ i*7 ] >> resultsMulti.txt -./testSingle.bin $[ 50+i*7 ] >> resultsSingle.txt -./testMulti.bin $[ 50+i*7 ] >> resultsMulti.txt +./testSingle.bin $[ 50+i*9 ] >> resultsSingle.txt +./testMulti.bin $[ 50+i*9 ] >> resultsMulti.txt done echo 'Diffing results' diff --git a/Robust/src/Tests/mlp/tinyTest/test.java b/Robust/src/Tests/mlp/tinyTest/test.java index 968b4a58..3b8fd609 100644 --- a/Robust/src/Tests/mlp/tinyTest/test.java +++ b/Robust/src/Tests/mlp/tinyTest/test.java @@ -11,37 +11,40 @@ public class Test { public static void main( String args[] ) { int x = Integer.parseInt( args[0] ); Foo f = new Foo( x + 10000 ); - doSomeWork( x, f ); + int s = doSomeWork( x, f ); + int t = moreWork( x, f ); + int r = s+t; + System.out.println( "s+t="+r ); } - public static void doSomeWork( int x, Foo f ) { - + public static int doSomeWork( int x, Foo f ) { int total = 0; + float delta = 0.0f; - for( int i = 0; i < x; ++i ) { - sese calc { - Foo g = new Foo( i ); - int sum = 0; - } - sese forceVirtualReal { - if( i % 3 == 0 ) { - sum = sum + (i % 20); - } - g.z = sum + 1000; + for( int i = 0; i < 10; ++i ) { + sese parallel { + int[] d = new int[1]; + d[0] = 2*i; + //int d = 2*i; } - sese modobj { - g.z = g.z + f.z; + sese waste { + if( true ) { + total = total + 1 + d[0]; + //total = total + 1 + d; + } + + for( int j=0; j < 1; ++j ) { + if( true ) { + delta += 1.0f; + } + } } - if( i % 2 == 0 ) { - sese change { - sum = sum + 1; - } - } - total = total + sum + g.z; - } + } + int temp = 100 + total + (int)delta; + return x + temp; + } - sese prnt { - System.out.println( "Results "+x+", "+total ); - } + public static int moreWork( int x, Foo f ) { + return f.z - 9000; } }