From: jjenista Date: Fri, 31 Jul 2009 22:31:20 +0000 (+0000) Subject: still isn't getting the right answer, but one variable gets into a child and back... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=97b284a83a6a4ce66eb3a016ffad38c92ec79caa;p=IRC.git still isn't getting the right answer, but one variable gets into a child and back into parent correctly--also has some thread race condition problem, apparently --- diff --git a/Robust/src/Analysis/MLP/CodePlan.java b/Robust/src/Analysis/MLP/CodePlan.java index 2d2d8e8a..9450be18 100644 --- a/Robust/src/Analysis/MLP/CodePlan.java +++ b/Robust/src/Analysis/MLP/CodePlan.java @@ -11,14 +11,14 @@ import java.io.*; public class CodePlan { private Set writeToDynamicSrc; - - private Hashtable< SESEandAgePair, Set > stall2copySet; + + private Hashtable< VariableSourceToken, Set > stall2copySet; public CodePlan() { writeToDynamicSrc = null; - stall2copySet = new Hashtable< SESEandAgePair, Set >(); + stall2copySet = new Hashtable< VariableSourceToken, Set >(); } @@ -32,23 +32,23 @@ public class CodePlan { return writeToDynamicSrc; } - public void addStall2CopySet( SESEandAgePair stallPair, + public void addStall2CopySet( VariableSourceToken stallToken, Set copySet ) { - if( stall2copySet.containsKey( stallPair ) ) { - Set priorCopySet = stall2copySet.get( stallPair ); + if( stall2copySet.containsKey( stallToken ) ) { + Set priorCopySet = stall2copySet.get( stallToken ); priorCopySet.addAll( copySet ); } else { - stall2copySet.put( stallPair, copySet ); + stall2copySet.put( stallToken, copySet ); } } - public Set getStallPairs() { + public Set getStallTokens() { return stall2copySet.keySet(); } - public Set getCopySet( SESEandAgePair stallPair ) { - return stall2copySet.get( stallPair ); + public Set getCopySet( VariableSourceToken stallToken ) { + return stall2copySet.get( stallToken ); } @@ -87,7 +87,7 @@ public class CodePlan { } public String toString() { - String s = ""; + String s = " PLAN: "; if( writeToDynamicSrc != null ) { s += "[WRITE DYN"; @@ -106,11 +106,11 @@ public class CodePlan { } 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(); + Map.Entry me = (Map.Entry) cpsItr.next(); + VariableSourceToken stallToken = (VariableSourceToken) me.getKey(); + Set copySet = (Set) me.getValue(); - s += "("+stallPair+"->"+copySet+")"; + s += "("+stallToken+"->"+copySet+")"; } if( !stall2copySet.entrySet().isEmpty() ) { s += "]"; diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index 38f378c4..036ccc5d 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -792,8 +792,10 @@ public class MLPAnalysis { // note that FlatOpNode's that aren't ASSIGN // fall through to this default case default: { + // decide if we must stall for variables dereferenced at this node - Set stallSet = vstTable.getStallSet( currentSESE ); + Set potentialStallSet = + vstTable.getChildrenVSTs( currentSESE ); // a node with no live set has nothing to stall for Set liveSet = livenessRootView.get( fn ); @@ -819,6 +821,14 @@ public class MLPAnalysis { // dynamic name only. if( srcs.size() > 1 || srcs.iterator().next().getAge() == maxSESEage ) { + + // identify that this is a stall, and allocate an integer + // pointer in the generated code that keeps a pointer to + // the source SESE and the address of where to get this thing + // --then the stall is just wait for that, and copy the + // one thing because we're not sure if we can copy other stuff + + // NEEDS WORK! @@ -830,26 +840,32 @@ public class MLPAnalysis { VariableSourceToken vst = srcs.iterator().next(); Iterator availItr = - vstTable.get( vst.getSESE(), - vst.getAge() - ).iterator(); + vstTable.get( vst.getSESE(), vst.getAge() ).iterator(); + /* System.out.println( "Considering a stall on "+vst+ " and also getting\n "+vstTable.get( vst.getSESE(), vst.getAge() - ) ); + ) );*/ // only grab additional stuff that is live Set copySet = new HashSet(); + //System.out.println( "*** live in = "+liveSet+" @node "+fn ); + while( availItr.hasNext() ) { VariableSourceToken vstAlsoAvail = availItr.next(); + /* + Iterator refVarItr = + vstAlsoAvail.getRefVars().iterator(); + + if( liveSet.contains( vstAlsoAvail.getAddrVar() ) ) { copySet.add( vstAlsoAvail.getAddrVar() ); } + */ - /* Iterator refVarItr = vstAlsoAvail.getRefVars().iterator(); while( refVarItr.hasNext() ) { TempDescriptor refVar = refVarItr.next(); @@ -857,13 +873,11 @@ public class MLPAnalysis { copySet.add( refVar ); } } - */ - } - - SESEandAgePair stallPair = new SESEandAgePair( vst.getSESE(), vst.getAge() ); - plan.addStall2CopySet( stallPair, copySet ); - System.out.println( "("+stallPair+"->"+copySet+")" ); + //System.out.println( vstAlsoAvail+" is available, copySet = "+copySet ); + } + + plan.addStall2CopySet( vst, copySet ); } // assert that everything being stalled for is in the diff --git a/Robust/src/Analysis/MLP/VarSrcTokTable.java b/Robust/src/Analysis/MLP/VarSrcTokTable.java index d3cffae3..7e16c100 100644 --- a/Robust/src/Analysis/MLP/VarSrcTokTable.java +++ b/Robust/src/Analysis/MLP/VarSrcTokTable.java @@ -419,7 +419,7 @@ public class VarSrcTokTable { // get the set of VST's that come from a child - public Set getStallSet( FlatSESEEnterNode curr ) { + public Set getChildrenVSTs( FlatSESEEnterNode curr ) { Set out = new HashSet(); diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index ed217a47..c1127472 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -1812,28 +1812,6 @@ public class BuildCode { outputMethHead.print("void "); outputMethHead.print(fsen.getSESEmethodName()+"("); outputMethHead.print(fsen.getSESErecordName()+"* "+paramsprefix); - - /* - boolean printcomma=false; - if (GENERATEPRECISEGC) { - outputMethHead.print("struct "+cn.getSafeSymbol()+ - bogusmd.getSafeSymbol()+"_"+ - bogusmd.getSafeMethodDescriptor()+"_params * "+paramsprefix); - printcomma=true; - } - // Output parameter list - for(int i=0; i"+temp.getSafeSymbol()+"), "+ // to - "(void*) ("+paramsprefix+"->"+temp.getSafeSymbol()+"__srcAddr_),"+ // from - " sizeof( "+paramsprefix+"->"+temp.getSafeSymbol()+" ) );"); // size + if( type.isPtr() ) { + output.println(" memcpy( "+ + "(void*) &("+paramsprefix+"->"+temp.getSafeSymbol()+"), "+ // to + "(void*) ("+paramsprefix+"->"+temp.getSafeSymbol()+"__srcAddr_),"+ // from + " sizeof( "+paramsprefix+"->"+temp.getSafeSymbol()+" ) );"); // size + } else { + output.println(" memcpy( "+ + "(void*) &("+temp.getSafeSymbol()+"), "+ // to + "(void*) ("+paramsprefix+"->"+temp.getSafeSymbol()+"__srcAddr_),"+ // from + " sizeof( "+paramsprefix+"->"+temp.getSafeSymbol()+" ) );"); // size + } // make a deep copy of objects //if( type.isPtr() ) { @@ -2227,12 +2210,29 @@ public class BuildCode { // for each sese and age pair that this parent statement // must stall on, take that child's stall semaphore, the // copying of values comes after the statement - Iterator pItr = cp.getStallPairs().iterator(); - while( pItr.hasNext() ) { - SESEandAgePair p = pItr.next(); + Iterator vstItr = cp.getStallTokens().iterator(); + while( vstItr.hasNext() ) { + VariableSourceToken vst = vstItr.next(); + + SESEandAgePair p = new SESEandAgePair( vst.getSESE(), vst.getAge() ); + output.println(" {"); - output.println(" SESEcommon* child = (SESEcommon*) "+p+";"); - output.println(" psem_take( &(child->stallSem) );"); + output.println(" SESEcommon* common = (SESEcommon*) "+p+";"); + output.println(" psem_take( &(common->stallSem) );"); + + // copy things we might have stalled for + output.println(" "+p.getSESE().getSESErecordName()+"* child = ("+ + p.getSESE().getSESErecordName()+"*) "+p+";"); + + Iterator tdItr = cp.getCopySet( vst ).iterator(); + while( tdItr.hasNext() ) { + TempDescriptor td = tdItr.next(); + output.println(" "+td.getSafeSymbol()+" = child->"+ + vst.getAddrVar().getSafeSymbol()+";"); + output.println("printf(\"copied %d into "+td.getSafeSymbol()+" from "+vst.getAddrVar().getSafeSymbol()+ + "\\n\", "+td.getSafeSymbol()+" );"); + } + output.println(" }"); } } @@ -2345,11 +2345,13 @@ public class BuildCode { throw new Error(); } - // insert post-node actions from the code-plan - /* + // insert post-node actions from the code-plan if( state.MLP ) { CodePlan cp = mlpa.getCodePlan( fn ); + if( cp != null ) { + + /* Set writeDynamic = cp.getWriteToDynamicSrc(); if( writeDynamic != null ) { Iterator vstItr = writeDynamic.iterator(); @@ -2358,9 +2360,9 @@ public class BuildCode { } } + */ } - } - */ + } } public void generateFlatOffsetNode(FlatMethod fm, LocalityBinding lb, FlatOffsetNode fofn, PrintWriter output) { @@ -2737,6 +2739,17 @@ public class BuildCode { return; } + // copy out-set from local temps into the sese record + Iterator itr = fsexn.getFlatEnter().getOutVarSet().iterator(); + while( itr.hasNext() ) { + TempDescriptor temp = itr.next(); + + output.println(" "+paramsprefix+"->"+temp.getSafeSymbol()+" = "+temp.getSafeSymbol()+";" ); + + output.println(" printf(\" putting "+temp.getSafeSymbol()+" in out with val=%d\\n\", "+temp.getSafeSymbol()+");"); + } + + // if parent is stalling on you, let them know you're done if( fsexn.getFlatEnter() != mlpa.getRootSESE() ) { output.println(" {"); output.println(" psem_give( &("+paramsprefix+"->common.stallSem) );"); diff --git a/Robust/src/Tests/mlp/tinyTest/makefile b/Robust/src/Tests/mlp/tinyTest/makefile index dc89f190..67e822cc 100644 --- a/Robust/src/Tests/mlp/tinyTest/makefile +++ b/Robust/src/Tests/mlp/tinyTest/makefile @@ -5,7 +5,7 @@ SOURCE_FILES=$(PROGRAM).java BUILDSCRIPT=~/research/Robust/src/buildscript USEMLP= -mlp 1 2 -mlpdebug # use to turn mlp on and off and make sure rest of build not broken -BSFLAGS= $(USEMLP) -nooptimize -debug -garbagestats -mainclass Test -ownership -ownallocdepth 1 -ownwritedots final -enable-assertions -flatirusermethods -ownaliasfile aliases.txt +BSFLAGS= -nooptimize -debug -garbagestats -mainclass Test -ownership -ownallocdepth 1 -ownwritedots final -enable-assertions -flatirusermethods -ownaliasfile aliases.txt all: $(PROGRAM).bin @@ -18,6 +18,9 @@ PNGs: DOTs DOTs: $(PROGRAM).bin $(PROGRAM).bin: $(SOURCE_FILES) + $(BUILDSCRIPT) $(USEMLP) $(BSFLAGS) -o $(PROGRAM) $(SOURCE_FILES) + +nomlp: $(SOURCE_FILES) $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM) $(SOURCE_FILES) clean: