From: jjenista Date: Fri, 8 May 2009 22:38:35 +0000 (+0000) Subject: Change isAvailable to notAvailable, updated computations for that analysis, use those... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=8bc3a26f6254cc20c4f20907c43b9461402e82a9;p=IRC.git Change isAvailable to notAvailable, updated computations for that analysis, use those results to prune waitSet for stalls--looks good\! --- diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index 7dddb90a..bda09d77 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -25,7 +25,7 @@ public class MLPAnalysis { private Hashtable< FlatNode, Set > livenessRootView; private Hashtable< FlatNode, Set > livenessVirtualReads; private Hashtable< FlatNode, VarSrcTokTable > variableResults; - private Hashtable< FlatNode, Set > isAvailableResults; + private Hashtable< FlatNode, Set > notAvailableResults; private Hashtable< FlatNode, CodePlan > codePlans; @@ -46,7 +46,7 @@ public class MLPAnalysis { seseStacks = new Hashtable< FlatNode, Stack >(); livenessVirtualReads = new Hashtable< FlatNode, Set >(); variableResults = new Hashtable< FlatNode, VarSrcTokTable >(); - isAvailableResults = new Hashtable< FlatNode, Set >(); + notAvailableResults = new Hashtable< FlatNode, Set >(); codePlans = new Hashtable< FlatNode, CodePlan >(); @@ -103,9 +103,9 @@ public class MLPAnalysis { Descriptor d = methItr.next(); FlatMethod fm = state.getMethodFlat( d ); - // compute is available for every live variable at - // every program point, in a forward fixed-point pass - isAvailableForward( fm ); + // compute what is not available at every program + // point, in a forward fixed-point pass + notAvailableForward( fm ); } @@ -504,7 +504,7 @@ public class MLPAnalysis { } - private void isAvailableForward( FlatMethod fm ) { + private void notAvailableForward( FlatMethod fm ) { Set flatNodesToVisit = new HashSet(); flatNodesToVisit.add( fm ); @@ -516,27 +516,22 @@ public class MLPAnalysis { Stack seseStack = seseStacks.get( fn ); assert seseStack != null; - Set prev = isAvailableResults.get( fn ); + Set prev = notAvailableResults.get( fn ); - // merge control flow joins where something is available - // into this node only if it is available on every incoming - // node, so do intersect of all incoming nodes with live in - HashSet rootLiveSet = (HashSet) livenessRootView.get( fn ); - Set inIntersect = (Set) rootLiveSet.clone(); - + Set inUnion = new HashSet(); for( int i = 0; i < fn.numPrev(); i++ ) { FlatNode nn = fn.getPrev( i ); - Set availIn = isAvailableResults.get( nn ); - if( availIn != null ) { - inIntersect.retainAll( availIn ); + Set notAvailIn = notAvailableResults.get( nn ); + if( notAvailIn != null ) { + inUnion.addAll( notAvailIn ); } } - Set curr = isAvailable_nodeActions( fn, inIntersect, seseStack.peek() ); + Set curr = notAvailable_nodeActions( fn, inUnion, seseStack.peek() ); // if a new result, schedule forward nodes for analysis if( !curr.equals( prev ) ) { - isAvailableResults.put( fn, curr ); + notAvailableResults.put( fn, curr ); for( int i = 0; i < fn.numNext(); i++ ) { FlatNode nn = fn.getNext( i ); @@ -546,38 +541,94 @@ public class MLPAnalysis { } } - private Set isAvailable_nodeActions( FlatNode fn, - Set isAvailSet, - FlatSESEEnterNode currentSESE ) { - // any temps that get added to the available set - // at this node should be marked in this node's - // code plan as temps to be grabbed at runtime! + private Set notAvailable_nodeActions( FlatNode fn, + Set notAvailSet, + FlatSESEEnterNode currentSESE ) { + + // any temps that are removed from the not available set + // at this node should be marked in this node's code plan + // as temps to be grabbed at runtime! switch( fn.kind() ) { case FKind.FlatSESEEnterNode: { FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; assert fsen.equals( currentSESE ); + notAvailSet.clear(); } break; case FKind.FlatSESEExitNode: { FlatSESEExitNode fsexn = (FlatSESEExitNode) fn; FlatSESEEnterNode fsen = fsexn.getFlatEnter(); assert currentSESE.getChildren().contains( fsen ); - isAvailSet.addAll( fsen.getOutVarSet() ); + + Set liveTemps = livenessRootView.get( fn ); + assert liveTemps != null; + + VarSrcTokTable vstTable = variableResults.get( fn ); + assert vstTable != null; + + Set notAvailAtEnter = notAvailableResults.get( fsen ); + assert notAvailAtEnter != null; + + Iterator tdItr = liveTemps.iterator(); + while( tdItr.hasNext() ) { + TempDescriptor td = tdItr.next(); + + if( vstTable.get( fsen, td ).size() > 0 ) { + // there is at least one child token for this variable + notAvailSet.add( td ); + continue; + } + + if( notAvailAtEnter.contains( td ) ) { + // wasn't available at enter, not available now + notAvailSet.add( td ); + continue; + } + } } break; + case FKind.FlatOpNode: { + FlatOpNode fon = (FlatOpNode) fn; + + if( fon.getOp().getOp() == Operation.ASSIGN ) { + TempDescriptor lhs = fon.getDest(); + TempDescriptor rhs = fon.getLeft(); + + // copy makes lhs same availability as rhs + if( notAvailSet.contains( rhs ) ) { + notAvailSet.add( lhs ); + } else { + notAvailSet.remove( lhs ); + } + + // only break if this is an ASSIGN op node, + // otherwise fall through to default case + break; + } + } + + // note that FlatOpNode's that aren't ASSIGN + // fall through to this default case default: { + TempDescriptor [] writeTemps = fn.writesTemps(); + for( int i = 0; i < writeTemps.length; i++ ) { + TempDescriptor wTemp = writeTemps[i]; + notAvailSet.remove( wTemp ); + } TempDescriptor [] readTemps = fn.readsTemps(); for( int i = 0; i < readTemps.length; i++ ) { TempDescriptor rTemp = readTemps[i]; - isAvailSet.add( rTemp ); + notAvailSet.remove( rTemp ); + //// THESE VARIABLES MIGHT COME FROM SESE'S + //// THAT WE CAN GRAB MORE DATA FROM! } } break; } // end switch - return isAvailSet; + return notAvailSet; } @@ -622,7 +673,7 @@ public class MLPAnalysis { if( state.MLPDEBUG ) { //System.out.println( fm.printMethod( livenessRootView ) ); //System.out.println( fm.printMethod( variableResults ) ); - //System.out.println( fm.printMethod( isAvailableResults ) ); + //System.out.println( fm.printMethod( notAvailableResults ) ); System.out.println( fm.printMethod( codePlans ) ); } } @@ -644,13 +695,20 @@ public class MLPAnalysis { } break; default: { - // decide if we must stall for variables - // dereferenced at this node - Set stallSet = vstTable.getStallSet( currentSESE ); + // decide if we must stall for variables dereferenced at this node + Set notAvailSet = notAvailableResults.get( fn ); + Set stallSet = vstTable.getStallSet( currentSESE ); + TempDescriptor[] readarray = fn.readsTemps(); for( int i = 0; i < readarray.length; i++ ) { - Set forRemoval = new HashSet(); TempDescriptor readtmp = readarray[i]; + + // ignore temps that are definitely available + // when considering to stall on it + if( !notAvailSet.contains( readtmp ) ) { + continue; + } + Set readSet = vstTable.get( readtmp ); //containsAny for( Iterator readit = readSet.iterator(); @@ -660,23 +718,9 @@ public class MLPAnalysis { if( before == null ) { before = "**STALL for:"; } - before += "("+vst+" "+readtmp+")"; - - // mark any other variables from the static SESE for - // removal, because after this stall we'll have them - // all for later statements - forRemoval.addAll( vstTable.get( vst.getSESE(), - vst.getAge() - ) - ); + before += "("+vst+" "+readtmp+")"; } } - - Iterator vstItr = forRemoval.iterator(); - while( vstItr.hasNext() ) { - VariableSourceToken vst = vstItr.next(); - vstTable.remove( vst ); - } } // if any variable at this node has a static source (exactly one sese) diff --git a/Robust/src/Tests/mlp/tinyTest/test.java b/Robust/src/Tests/mlp/tinyTest/test.java index be14764f..ed654965 100644 --- a/Robust/src/Tests/mlp/tinyTest/test.java +++ b/Robust/src/Tests/mlp/tinyTest/test.java @@ -31,5 +31,6 @@ public class Test { x = x + 1; y = y + 1; + x = x + 1; } }