public class CodePlan {
private Set<VariableSourceToken> writeToDynamicSrc;
-
- private Hashtable< SESEandAgePair, Set<TempDescriptor> > stall2copySet;
+
+ private Hashtable< VariableSourceToken, Set<TempDescriptor> > stall2copySet;
public CodePlan() {
writeToDynamicSrc = null;
- stall2copySet = new Hashtable< SESEandAgePair, Set<TempDescriptor> >();
+ stall2copySet = new Hashtable< VariableSourceToken, Set<TempDescriptor> >();
}
return writeToDynamicSrc;
}
- public void addStall2CopySet( SESEandAgePair stallPair,
+ public void addStall2CopySet( VariableSourceToken stallToken,
Set<TempDescriptor> copySet ) {
- if( stall2copySet.containsKey( stallPair ) ) {
- Set<TempDescriptor> priorCopySet = stall2copySet.get( stallPair );
+ if( stall2copySet.containsKey( stallToken ) ) {
+ Set<TempDescriptor> priorCopySet = stall2copySet.get( stallToken );
priorCopySet.addAll( copySet );
} else {
- stall2copySet.put( stallPair, copySet );
+ stall2copySet.put( stallToken, copySet );
}
}
- public Set<SESEandAgePair> getStallPairs() {
+ public Set<VariableSourceToken> getStallTokens() {
return stall2copySet.keySet();
}
- public Set<TempDescriptor> getCopySet( SESEandAgePair stallPair ) {
- return stall2copySet.get( stallPair );
+ public Set<TempDescriptor> getCopySet( VariableSourceToken stallToken ) {
+ return stall2copySet.get( stallToken );
}
}
public String toString() {
- String s = "";
+ String s = " PLAN: ";
if( writeToDynamicSrc != null ) {
s += "[WRITE DYN";
}
Iterator cpsItr = stall2copySet.entrySet().iterator();
while( cpsItr.hasNext() ) {
- Map.Entry me = (Map.Entry) cpsItr.next();
- SESEandAgePair stallPair = (SESEandAgePair) me.getKey();
- Set<TempDescriptor> copySet = (Set<TempDescriptor>) me.getValue();
+ Map.Entry me = (Map.Entry) cpsItr.next();
+ VariableSourceToken stallToken = (VariableSourceToken) me.getKey();
+ Set<TempDescriptor> copySet = (Set<TempDescriptor>) me.getValue();
- s += "("+stallPair+"->"+copySet+")";
+ s += "("+stallToken+"->"+copySet+")";
}
if( !stall2copySet.entrySet().isEmpty() ) {
s += "]";
// 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<VariableSourceToken> stallSet = vstTable.getStallSet( currentSESE );
+ Set<VariableSourceToken> potentialStallSet =
+ vstTable.getChildrenVSTs( currentSESE );
// a node with no live set has nothing to stall for
Set<TempDescriptor> liveSet = livenessRootView.get( fn );
// 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!
VariableSourceToken vst = srcs.iterator().next();
Iterator<VariableSourceToken> 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<TempDescriptor> copySet = new HashSet<TempDescriptor>();
+ //System.out.println( "*** live in = "+liveSet+" @node "+fn );
+
while( availItr.hasNext() ) {
VariableSourceToken vstAlsoAvail = availItr.next();
+ /*
+ Iterator<TempDescriptor> refVarItr =
+ vstAlsoAvail.getRefVars().iterator();
+
+
if( liveSet.contains( vstAlsoAvail.getAddrVar() ) ) {
copySet.add( vstAlsoAvail.getAddrVar() );
}
+ */
- /*
Iterator<TempDescriptor> refVarItr = vstAlsoAvail.getRefVars().iterator();
while( refVarItr.hasNext() ) {
TempDescriptor refVar = refVarItr.next();
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
// get the set of VST's that come from a child
- public Set<VariableSourceToken> getStallSet( FlatSESEEnterNode curr ) {
+ public Set<VariableSourceToken> getChildrenVSTs( FlatSESEEnterNode curr ) {
Set<VariableSourceToken> out = new HashSet<VariableSourceToken>();
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<objectparams.numPrimitives(); i++) {
- TempDescriptor temp=objectparams.getPrimitive(i);
- if (printcomma)
- outputMethHead.print(", ");
- printcomma=true;
- if (temp.getType().isClass()||temp.getType().isArray())
- outputMethHead.print("struct " + temp.getType().getSafeSymbol()+" * "+temp.getSafeSymbol());
- else
- outputMethHead.print(temp.getType().getSafeSymbol()+" "+temp.getSafeSymbol());
- }
- */
-
outputMethHead.println(");\n");
generateFlatMethodSESE( fsen.getfmBogus(),
MethodDescriptor md=fm.getMethod();
- //generateHeader(fm, null, md, output, true);
-
output.print("void ");
output.print(fsen.getSESEmethodName()+"(");
output.print(fsen.getSESErecordName()+"* "+paramsprefix);
TempDescriptor temp = itrInSet.next();
TypeDescriptor type = temp.getType();
- output.println(" memcpy( "+
- "(void*) &("+paramsprefix+"->"+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() ) {
// 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<SESEandAgePair> pItr = cp.getStallPairs().iterator();
- while( pItr.hasNext() ) {
- SESEandAgePair p = pItr.next();
+ Iterator<VariableSourceToken> 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<TempDescriptor> 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(" }");
}
}
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<VariableSourceToken> writeDynamic = cp.getWriteToDynamicSrc();
if( writeDynamic != null ) {
Iterator<VariableSourceToken> vstItr = writeDynamic.iterator();
}
}
+ */
}
- }
- */
+ }
}
public void generateFlatOffsetNode(FlatMethod fm, LocalityBinding lb, FlatOffsetNode fofn, PrintWriter output) {
return;
}
+ // copy out-set from local temps into the sese record
+ Iterator<TempDescriptor> 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) );");
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
DOTs: $(PROGRAM).bin
$(PROGRAM).bin: $(SOURCE_FILES)
+ $(BUILDSCRIPT) $(USEMLP) $(BSFLAGS) -o $(PROGRAM) $(SOURCE_FILES)
+
+nomlp: $(SOURCE_FILES)
$(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM) $(SOURCE_FILES)
clean: