From d455c62e5a66a2806cf9e637a1a9d034615b5940 Mon Sep 17 00:00:00 2001 From: jjenista Date: Fri, 4 Sep 2009 00:09:10 +0000 Subject: [PATCH] Fixed variable dynamic source bookkeeping bug, regression test runs for single and parallelized binaries agree --- Robust/src/Analysis/MLP/CodePlan.java | 49 +++++++--------------- Robust/src/Analysis/MLP/MLPAnalysis.java | 22 +++++++--- Robust/src/IR/Flat/BuildCode.java | 8 ++++ Robust/src/Tests/mlp/tinyTest/test.java | 52 +++++------------------- 4 files changed, 48 insertions(+), 83 deletions(-) diff --git a/Robust/src/Analysis/MLP/CodePlan.java b/Robust/src/Analysis/MLP/CodePlan.java index 76a50404..d5d398dd 100644 --- a/Robust/src/Analysis/MLP/CodePlan.java +++ b/Robust/src/Analysis/MLP/CodePlan.java @@ -13,13 +13,15 @@ public class CodePlan { private Hashtable< VariableSourceToken, Set > stall2copySet; private Set dynamicStallSet; private Hashtable dynAssign_lhs2rhs; + private Set dynAssign_lhs2curr; private FlatSESEEnterNode currentSESE; public CodePlan( FlatSESEEnterNode fsen ) { - stall2copySet = new Hashtable< VariableSourceToken, Set >(); - dynamicStallSet = new HashSet(); - dynAssign_lhs2rhs = new Hashtable(); - currentSESE = fsen; + stall2copySet = new Hashtable< VariableSourceToken, Set >(); + dynamicStallSet = new HashSet(); + dynAssign_lhs2rhs = new Hashtable(); + dynAssign_lhs2curr = new HashSet(); + currentSESE = fsen; } public FlatSESEEnterNode getCurrentSESE() { @@ -63,39 +65,12 @@ public class CodePlan { return dynAssign_lhs2rhs; } - public boolean equals( Object o ) { - if( o == null ) { - return false; - } - - if( !(o instanceof CodePlan) ) { - return false; - } - - CodePlan cp = (CodePlan) o; - - boolean copySetsEq = (stall2copySet.equals( cp.stall2copySet )); - - boolean dynStallSetEq = (dynamicStallSet.equals( cp.dynamicStallSet )); - - boolean dynAssignEq = (dynAssign_lhs2rhs.equals( cp.dynAssign_lhs2rhs )); - - return copySetsEq && dynStallSetEq && dynAssignEq; + public void addDynAssign( TempDescriptor lhs ) { + dynAssign_lhs2curr.add( lhs ); } - public int hashCode() { - - int copySetsHC = stall2copySet.hashCode(); - - int dynStallSetHC = dynamicStallSet.hashCode(); - - int dynAssignHC = dynAssign_lhs2rhs.hashCode(); - - int hash = 7; - hash = 31*hash + copySetsHC; - hash = 31*hash + dynStallSetHC; - hash = 31*hash + dynAssignHC; - return hash; + public Set getDynAssignCurr() { + return dynAssign_lhs2curr; } public String toString() { @@ -124,6 +99,10 @@ public class CodePlan { s += "[DYN ASSIGNS:"+dynAssign_lhs2rhs+"]"; } + if( !dynAssign_lhs2curr.isEmpty() ) { + s += "[DYN ASS2CURR:"+dynAssign_lhs2curr+"]"; + } + return s; } } diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index 1dbb8d14..1c9e8eec 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -901,19 +901,29 @@ public class MLPAnalysis { // if this is an op node, don't stall, copy // source and delay until we need to use value - // but check the source type of rhs variable - // and if dynamic, lhs becomes dynamic, too, - // and we need to keep dynamic sources during - Integer srcType + // ask whether lhs and rhs sources are dynamic, static, etc. + Integer lhsSrcType + = vstTableIn.getRefVarSrcType( lhs, + currentSESE, + currentSESE.getParent() ); + + Integer rhsSrcType = vstTableIn.getRefVarSrcType( rhs, currentSESE, currentSESE.getParent() ); - if( srcType.equals( VarSrcTokTable.SrcType_DYNAMIC ) ) { + if( rhsSrcType.equals( VarSrcTokTable.SrcType_DYNAMIC ) ) { + // if rhs is dynamic going in, lhs will definitely be dynamic + // going out of this node, so track that here plan.addDynAssign( lhs, rhs ); currentSESE.addDynamicVar( lhs ); currentSESE.addDynamicVar( rhs ); - } + + } else if( lhsSrcType.equals( VarSrcTokTable.SrcType_DYNAMIC ) ) { + // otherwise, if the lhs is dynamic, but the rhs is not, we + // need to update the variable's dynamic source as "current SESE" + plan.addDynAssign( lhs ); + } // only break if this is an ASSIGN op node, // otherwise fall through to default case diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index f17905a5..9c24aa68 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -2431,6 +2431,14 @@ public class BuildCode { output.println(" "+lhs+"_srcSESE = "+rhs+"_srcSESE;"); output.println(" "+lhs+"_srcOffset = "+rhs+"_srcOffset;"); } + + // for each lhs that is dynamic from a non-dynamic source, set the + // dynamic source vars to the current SESE + dynItr = cp.getDynAssignCurr().iterator(); + while( dynItr.hasNext() ) { + TempDescriptor dynVar = dynItr.next(); + output.println(" "+dynVar+"_srcSESE = NULL;"); + } } } diff --git a/Robust/src/Tests/mlp/tinyTest/test.java b/Robust/src/Tests/mlp/tinyTest/test.java index 3c779968..75e30bb8 100644 --- a/Robust/src/Tests/mlp/tinyTest/test.java +++ b/Robust/src/Tests/mlp/tinyTest/test.java @@ -1,36 +1,23 @@ public class Test { - public static void main( String args[] ) { + public static void main( String args[] ) { int x = Integer.parseInt( args[0] ); doSomeWork( x ); } public static void doSomeWork( int x ) { for( int i = 0; i < x; ++i ) { - sese calc { - int sum = 0; - for( int j = 0; j <= i; ++j ) { - sum = calculateStuff( sum, 1, 0 ); - } - } - sese forceVirtualReal { - if( i % 3 == 0 ) { - sum = sum + (i % 20); - } - } - if( i % 2 == 0 ) { - sese change { - for( int k = 0; k < i*2; ++k ) { - sum = calculateStuff( sum, k, 1 ); - } - sum = sum + 1; - } + int sum = 0; - for( int l = 0; l < 3; ++l ) { - sum = calculateStuff( sum, 2, 2 ); - } + sese change { + sum = sum + 1; + } + + for( int l = 0; l < 3; ++l ) { + sum = calculateStuff( sum, 2, 2 ); } + sese prnt { mightPrint( x, i, sum ); } @@ -38,26 +25,7 @@ public class Test { } public static int calculateStuff( int sum, int num, int mode ) { - int answer = sum; - sese makePlaceholderStallAfter { - sum = sum + 1; - } - sum = sum + 1; - if( mode == 0 ) { - sese mode1 { - answer = sum + num; - } - } else if( mode == 1 ) { - sese mode2 { - answer = sum + (num/2); - } - } else if( mode == 2 ) { - sese mode3 { - answer = sum + (num/2); - } - } - - return answer; + return sum + 10; } public static void mightPrint( int x, int i, int sum ) { -- 2.34.1