From 73af94c76100233d9197847792d52a203167cbf1 Mon Sep 17 00:00:00 2001 From: jjenista Date: Thu, 18 Jun 2009 22:55:33 +0000 Subject: [PATCH] Just getting a capture, there is a bug in correctly informing code plan of the copy set for stalls --- Robust/src/Analysis/MLP/CodePlan.java | 46 +++++++++- Robust/src/Analysis/MLP/MLPAnalysis.java | 98 ++++++++++++--------- Robust/src/Analysis/MLP/VarSrcTokTable.java | 1 + Robust/src/IR/Flat/BuildCode.java | 5 +- 4 files changed, 106 insertions(+), 44 deletions(-) diff --git a/Robust/src/Analysis/MLP/CodePlan.java b/Robust/src/Analysis/MLP/CodePlan.java index ed90f2c2..1a3f322b 100644 --- a/Robust/src/Analysis/MLP/CodePlan.java +++ b/Robust/src/Analysis/MLP/CodePlan.java @@ -11,11 +11,17 @@ import java.io.*; public class CodePlan { private Set writeToDynamicSrc; + + private Hashtable< SESEandAgePair, Set > stall2copySet; + public CodePlan() { writeToDynamicSrc = null; + + stall2copySet = new Hashtable< SESEandAgePair, Set >(); } + public void setWriteToDynamicSrc( Set writeToDynamicSrc ) { @@ -26,6 +32,23 @@ public class CodePlan { return writeToDynamicSrc; } + + public void addStall2CopySet( SESEandAgePair stallPair, + Set copySet ) { + + if( stall2copySet.containsKey( stallPair ) ) { + Set priorCopySet = stall2copySet.get( stallPair ); + priorCopySet.addAll( copySet ); + } else { + stall2copySet.put( stallPair, copySet ); + } + } + + public Hashtable< SESEandAgePair, Set > getStall2copySet() { + return stall2copySet; + } + + public boolean equals( Object o ) { if( o == null ) { return false; @@ -43,8 +66,10 @@ public class CodePlan { } else { dynamicSetEq = (writeToDynamicSrc.equals( cp.writeToDynamicSrc )); } + + boolean copySetsEq = (stall2copySet.equals( cp.stall2copySet )); - return dynamicSetEq; + return dynamicSetEq && copySetsEq; } public int hashCode() { @@ -53,7 +78,9 @@ public class CodePlan { dynamicSetHC = writeToDynamicSrc.hashCode(); } - return dynamicSetHC; + int copySetsHC = stall2copySet.hashCode(); + + return dynamicSetHC ^ 3*copySetsHC; } public String toString() { @@ -71,6 +98,21 @@ public class CodePlan { s += "]"; } + if( !stall2copySet.entrySet().isEmpty() ) { + s += "[STALLS:"; + } + Iterator cpsItr = stall2copySet.entrySet().iterator(); + while( cpsItr.hasNext() ) { + Map.Entry me = (Map.Entry) cpsItr.next(); + SESEandAgePair stallPair = (SESEandAgePair) me.getKey(); + Set copySet = (Set) me.getValue(); + + s += "("+stallPair+"->"+copySet+")"; + } + if( !stall2copySet.entrySet().isEmpty() ) { + s += "]"; + } + return s; } } diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index a60feb29..e5001751 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -140,9 +140,9 @@ public class MLPAnalysis { System.out.println( "" ); //System.out.println( "\nSESE Hierarchy\n--------------\n" ); printSESEHierarchy(); //System.out.println( "\nSESE Liveness\n-------------\n" ); printSESELiveness(); - //System.out.println( "\nLiveness Root View\n------------------\n"+fmMain.printMethod( livenessRootView ) ); - //System.out.println( "\nVariable Results\n----------------\n"+fmMain.printMethod( variableResults ) ); - //System.out.println( "\nNot Available Results\n---------------------\n"+fmMain.printMethod( notAvailableResults ) ); + System.out.println( "\nLiveness Root View\n------------------\n"+fmMain.printMethod( livenessRootView ) ); + System.out.println( "\nVariable Results\n----------------\n"+fmMain.printMethod( variableResults ) ); + System.out.println( "\nNot Available Results\n---------------------\n"+fmMain.printMethod( notAvailableResults ) ); System.out.println( "\nCode Plans\n----------\n"+fmMain.printMethod( codePlans ) ); } @@ -789,6 +789,12 @@ public class MLPAnalysis { // decide if we must stall for variables dereferenced at this node Set stallSet = vstTable.getStallSet( currentSESE ); + // a node with no live set has nothing to stall for + Set liveSet = livenessRootView.get( fn ); + if( liveSet == null ) { + break; + } + TempDescriptor[] readarray = fn.readsTemps(); for( int i = 0; i < readarray.length; i++ ) { TempDescriptor readtmp = readarray[i]; @@ -799,56 +805,66 @@ public class MLPAnalysis { continue; } - Set readSet = vstTable.get( readtmp ); + // Two cases: + Set srcs = vstTable.get( readtmp ); + assert !srcs.isEmpty(); - //Two cases: - - //1) Multiple token/age pairs or unknown age: Stall for - //dynamic name only. - + // 1) Multiple token/age pairs or unknown age: Stall for + // dynamic name only. + if( srcs.size() > 1 || + srcs.iterator().next().getAge() == maxSESEage ) { + + + // 2) Single token/age pair: Stall for token/age pair, and copy + // 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. + } else { + VariableSourceToken vst = srcs.iterator().next(); - //2) Single token/age pair: Stall for token/age pair, and copy - //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. + Iterator availItr = + vstTable.get( vst.getSESE(), + vst.getAge() + ).iterator(); - //VarSrcTokTable table = variableResults.get( fn ); - //Set srcs = table.get( rTemp ); + System.out.println( "Considering a stall on "+vst+ + " and also getting\n "+vstTable.get( vst.getSESE(), + vst.getAge() + ) ); - //XXXXXXXXXX: Note: We have to generate code to do these - //copies in the codeplan. Note we should only copy the - //variables that are live! + // only grab additional stuff that is live + Set copySet = new HashSet(); - /* - if( srcs.size() == 1 ) { - VariableSourceToken vst = srcs.iterator().next(); - - Iterator availItr = table.get( vst.getSESE(), - vst.getAge() - ).iterator(); while( availItr.hasNext() ) { VariableSourceToken vstAlsoAvail = availItr.next(); - notAvailSet.removeAll( vstAlsoAvail.getRefVars() ); + + if( liveSet.contains( vstAlsoAvail.getAddrVar() ) ) { + copySet.add( vstAlsoAvail.getAddrVar() ); + } + + /* + Iterator refVarItr = vstAlsoAvail.getRefVars().iterator(); + while( refVarItr.hasNext() ) { + TempDescriptor refVar = refVarItr.next(); + if( liveSet.contains( refVar ) ) { + copySet.add( refVar ); + } + } + */ } - } - */ + + SESEandAgePair stallPair = new SESEandAgePair( vst.getSESE(), vst.getAge() ); + plan.addStall2CopySet( stallPair, copySet ); + System.out.println( "("+stallPair+"->"+copySet+")" ); + } - // assert notAvailSet.containsAll( writeSet ); + // assert that everything being stalled for is in the + // "not available" set coming into this flat node and + // that every VST identified is in the possible "stall set" + // that represents VST's from children SESE's - /* - for( Iterator readit = readSet.iterator(); - readit.hasNext(); ) { - VariableSourceToken vst = readit.next(); - if( stallSet.contains( vst ) ) { - if( before == null ) { - before = "**STALL for:"; - } - before += "("+vst+" "+readtmp+")"; - } - } - */ } } break; diff --git a/Robust/src/Analysis/MLP/VarSrcTokTable.java b/Robust/src/Analysis/MLP/VarSrcTokTable.java index a7b275c5..d3cffae3 100644 --- a/Robust/src/Analysis/MLP/VarSrcTokTable.java +++ b/Robust/src/Analysis/MLP/VarSrcTokTable.java @@ -418,6 +418,7 @@ public class VarSrcTokTable { } + // get the set of VST's that come from a child public Set getStallSet( FlatSESEEnterNode curr ) { Set out = new HashSet(); diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index bf7c372f..2b165153 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -270,6 +270,9 @@ public class BuildCode { private void outputMainMethod(PrintWriter outmethod) { outmethod.println("int main(int argc, const char *argv[]) {"); outmethod.println(" int i;"); + if (state.MLP) { + outmethod.println(" mlpInit( "+mlpa.getAllSESEs().size()+", "+mlpa.getMaxSESEage()+" );"); + } if (state.DSM) { outmethod.println("#ifdef TRANSSTATS \n"); outmethod.println("handle();\n"); @@ -2364,7 +2367,7 @@ public class BuildCode { } output.println(" mlpIssue( tempSESE );"); - output.println(" tempSESE = mlpSchedule();"); + //output.println(" tempSESE = mlpSchedule();"); // do a pthread_create wit invokeSESE as the argument // and pack all args into a single void* -- 2.34.1