outmethod.println(" int i;");
if (state.MLP) {
- outmethod.println(" pthread_once( &mlpOnceObj, mlpInitOncePerThread );");
+ //outmethod.println(" pthread_once( &mlpOnceObj, mlpInitOncePerThread );");
outmethod.println(" workScheduleInit( "+state.MLP_NUMCORES+", invokeSESEmethod );");
}
output.println(" "+type.getSafeSymbol()+" "+td.getSafeSymbol()+";");
}
+
+ if( state.MLP ) {
+ if( fm.getNext(0) instanceof FlatSESEEnterNode ) {
+ FlatSESEEnterNode callerSESEplaceholder = (FlatSESEEnterNode) fm.getNext( 0 );
+ if( callerSESEplaceholder != mlpa.getMainSESE() ) {
+ // declare variables for naming static SESE's
+ output.println(" /* static SESE names */");
+ Iterator<SESEandAgePair> pItr = callerSESEplaceholder.getNeededStaticNames().iterator();
+ while( pItr.hasNext() ) {
+ SESEandAgePair p = pItr.next();
+ output.println(" void* "+p+";");
+ }
+
+ // declare variables for tracking dynamic sources
+ output.println(" /* dynamic variable sources */");
+ Iterator<TempDescriptor> dynSrcItr = callerSESEplaceholder.getDynamicVarSet().iterator();
+ while( dynSrcItr.hasNext() ) {
+ TempDescriptor dynSrcVar = dynSrcItr.next();
+ output.println(" void* "+dynSrcVar+"_srcSESE;");
+ output.println(" int "+dynSrcVar+"_srcOffset;");
+ }
+ }
+ }
+ }
+
+
/* Check to see if we need to do a GC if this is a
* multi-threaded program...*/
protected void initializeSESE( FlatSESEEnterNode fsen ) {
-
+
FlatMethod fm = fsen.getfmEnclosing();
MethodDescriptor md = fm.getMethod();
ClassDescriptor cn = md.getClassDesc();
}
}
- HashSet<FlatNode> exitset=new HashSet<FlatNode>();
- exitset.add(seseExit);
+ // initialize thread-local var to a non-zero, invalid address
+ output.println(" seseCaller = (SESEcommon*) 0x2;");
+ HashSet<FlatNode> exitset=new HashSet<FlatNode>();
+ exitset.add(seseExit);
generateCode(fsen.getNext(0), fm, null, exitset, output, true);
output.println("primitives->"+tmp.getSafeSymbol()+"="+tmp.getSafeSymbol()+";");
}
}
+ if (state.MLP && stopset!=null) {
+ assert first.getPrev( 0 ) instanceof FlatSESEEnterNode;
+ assert current_node instanceof FlatSESEExitNode;
+ FlatSESEEnterNode fsen = (FlatSESEEnterNode) first.getPrev( 0 );
+ FlatSESEExitNode fsxn = (FlatSESEExitNode) current_node;
+ assert fsen.getFlatExit().equals( fsxn );
+ assert fsxn.getFlatEnter().equals( fsen );
+ }
if (current_node.kind()!=FKind.FlatReturnNode) {
output.println(" return;");
}
current_node=null;
} else if(current_node.numNext()==1) {
FlatNode nextnode;
- if (state.MLP && current_node.kind()==FKind.FlatSESEEnterNode) {
+ if (state.MLP &&
+ current_node.kind()==FKind.FlatSESEEnterNode &&
+ !((FlatSESEEnterNode)current_node).getIsCallerSESEplaceholder()
+ ) {
FlatSESEEnterNode fsen = (FlatSESEEnterNode)current_node;
generateFlatNode(fm, lb, current_node, output);
nextnode=fsen.getFlatExit().getNext(0);
Iterator<TempDescriptor> tdItr = cp.getCopySet( vst ).iterator();
while( tdItr.hasNext() ) {
TempDescriptor td = tdItr.next();
- output.println(" "+generateTemp( currentSESE.getfmBogus(), td, null )+
+ FlatMethod fmContext;
+ if( currentSESE.getIsCallerSESEplaceholder() ) {
+ fmContext = currentSESE.getfmEnclosing();
+ } else {
+ fmContext = currentSESE.getfmBogus();
+ }
+ output.println(" "+generateTemp( fmContext, td, null )+
" = child->"+vst.getAddrVar().getSafeSymbol()+";");
}
output.println(" if( "+dynVar+"_srcSESE != NULL ) {");
output.println(" SESEcommon* common = (SESEcommon*) "+dynVar+"_srcSESE;");
output.println(" psem_take( &(common->stallSem) );");
- output.println(" "+generateTemp( currentSESE.getfmBogus(), dynVar, null )+
- " = *(("+dynVar.getType()+"*) ("+
- dynVar+"_srcSESE + "+dynVar+"_srcOffset));");
+
+ FlatMethod fmContext;
+ if( currentSESE.getIsCallerSESEplaceholder() ) {
+ fmContext = currentSESE.getfmEnclosing();
+ } else {
+ fmContext = currentSESE.getfmBogus();
+ }
+ output.println(" "+generateTemp( fmContext, dynVar, null )+
+ " = *(("+dynVar.getType()+"*) ("+
+ dynVar+"_srcSESE + "+dynVar+"_srcOffset));");
+
output.println(" }");
output.println(" }");
}
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;");
+ }
}
}
FlatSESEEnterNode fsen,
PrintWriter output
) {
+
+ // if MLP flag is off, okay that SESE nodes are in IR graph,
+ // just skip over them and code generates exactly the same
if( !state.MLP ) {
- // SESE nodes can be parsed for normal compilation, just skip over them
return;
}
+ // there may be an SESE in an unreachable method, skip over
+ if( !mlpa.getAllSESEs().contains( fsen ) ) {
+ return;
+ }
+
+ // also, if we have encountered a placeholder, just skip it
+ if( fsen.getIsCallerSESEplaceholder() ) {
+ return;
+ }
+
output.println(" {");
// set up the parent
if( fsen == mlpa.getMainSESE() ) {
output.println(" SESEcommon* parentCommon = NULL;");
- } else if( fsen.getParent() != null ) {
- output.println(" SESEcommon* parentCommon = &("+paramsprefix+"->common);");
} else {
- output.println(" SESEcommon* parentCommon = (SESEcommon*) peekItem( seseCallStack );");
+ if( fsen.getParent() == null ) {
+ System.out.println( "in "+fm+", "+fsen+" has null parent" );
+ }
+ assert fsen.getParent() != null;
+ if( !fsen.getParent().getIsCallerSESEplaceholder() ) {
+ output.println(" SESEcommon* parentCommon = &("+paramsprefix+"->common);");
+ } else {
+ //output.println(" SESEcommon* parentCommon = (SESEcommon*) peekItem( seseCallStack );");
+ output.println(" SESEcommon* parentCommon = seseCaller;");
+ }
}
// before doing anything, lock your own record and increment the running children
fsen.getSESErecordName()+" ) );");
// and keep the thread-local sese stack up to date
- output.println(" addNewItem( seseCallStack, (void*) seseToIssue);");
+ //output.println(" addNewItem( seseCallStack, (void*) seseToIssue);");
// fill in common data
output.println(" seseToIssue->common.classID = "+fsen.getIdentifier()+";");
Iterator<TempDescriptor> tempItr = fsen.getReadyInVarSet().iterator();
while( tempItr.hasNext() ) {
TempDescriptor temp = tempItr.next();
- if( fsen != mlpa.getMainSESE() &&
- fsen.getParent() != null ) {
+
+ // when we are issuing the main SESE or an SESE with placeholder
+ // caller SESE as parent, generate temp child child's eclosing method,
+ // otherwise use the parent's enclosing method as the context
+ boolean useParentContext = false;
+
+ if( fsen != mlpa.getMainSESE() ) {
+ assert fsen.getParent() != null;
+ if( !fsen.getParent().getIsCallerSESEplaceholder() ) {
+ useParentContext = true;
+ }
+ }
+
+ if( useParentContext ) {
output.println(" seseToIssue->"+temp+" = "+
- generateTemp( fsen.getParent().getfmBogus(), temp, null )+";");
+ generateTemp( fsen.getParent().getfmBogus(), temp, null )+";");
} else {
output.println(" seseToIssue->"+temp+" = "+
generateTemp( fsen.getfmEnclosing(), temp, null )+";");
output.println(" pthread_mutex_unlock( &(src->lock) );");
output.println(" seseToIssue->"+dynInVar+"_srcOffset = "+dynInVar+"_srcOffset;");
output.println(" } else {");
- if( fsen.getParent() != null ) {
+
+ boolean useParentContext = false;
+ if( fsen != mlpa.getMainSESE() ) {
+ assert fsen.getParent() != null;
+ if( !fsen.getParent().getIsCallerSESEplaceholder() ) {
+ useParentContext = true;
+ }
+ }
+ if( useParentContext ) {
output.println(" seseToIssue->"+dynInVar+" = "+
generateTemp( fsen.getParent().getfmBogus(), dynInVar, null )+";");
} else {
output.println(" seseToIssue->"+dynInVar+" = "+
generateTemp( fsen.getfmEnclosing(), dynInVar, null )+";");
}
+
output.println(" }");
output.println(" }");
// maintain pointers for for finding dynamic SESE
// instances from static names
SESEandAgePair p = new SESEandAgePair( fsen, 0 );
- if( fsen.getParent() != null &&
- fsen.getParent().getNeededStaticNames().contains( p ) ) {
+ if( fsen.getParent() != null &&
+ //!fsen.getParent().getIsCallerSESEplaceholder() &&
+ fsen.getParent().getNeededStaticNames().contains( p )
+ ) {
for( int i = fsen.getOldestAgeToTrack(); i > 0; --i ) {
SESEandAgePair p1 = new SESEandAgePair( fsen, i );
FlatSESEExitNode fsexn,
PrintWriter output
) {
+
+ // if MLP flag is off, okay that SESE nodes are in IR graph,
+ // just skip over them and code generates exactly the same
if( !state.MLP ) {
- // SESE nodes can be parsed for normal compilation, just skip over them
+ return;
+ }
+
+ // there may be an SESE in an unreachable method, skip over
+ if( !mlpa.getAllSESEs().contains( fsexn.getFlatEnter() ) ) {
+ return;
+ }
+
+ // also, if we have encountered a placeholder, just jump it
+ if( fsexn.getFlatEnter().getIsCallerSESEplaceholder() ) {
return;
}
String com = paramsprefix+"->common";
- // take yourself off the thread-local sese call stack
- output.println(" if( isEmpty( seseCallStack ) ) {");
- output.println(" printf( \"Error, sese call stack is empty.\\n\" );");
- output.println(" exit( -1 );");
- output.println(" }");
- output.println(" if( (void*)"+paramsprefix+" != getItem( seseCallStack ) ) {");
- output.println(" printf( \"Error, sese call stack mismatch.\\n\" );");
- output.println(" exit( -1 );");
- output.println(" }");
-
// this SESE cannot be done until all of its children are done
// so grab your own lock with the condition variable for watching
// that the number of your running children is greater than zero
output.println(" pthread_cond_signal( &("+paramsprefix+"->common.parent->runningChildrenCond) );");
output.println(" pthread_mutex_unlock( &("+paramsprefix+"->common.parent->lock) );");
output.println(" }");
+
+ // this is a thread-only variable that can be handled when critical sese-to-sese
+ // data has been taken care of--set sese pointer to remember self over method
+ // calls to a non-zero, invalid address
+ output.println(" seseCaller = (SESEcommon*) 0x1;");
}
public void generateFlatWriteDynamicVarNode( FlatMethod fm,
}
private void generateFlatCall(FlatMethod fm, LocalityBinding lb, FlatCall fc, PrintWriter output) {
+
+ if( state.MLP && !nonSESEpass ) {
+ output.println(" seseCaller = (SESEcommon*)"+paramsprefix+";");
+ }
+
MethodDescriptor md=fc.getMethod();
ParamsObject objectparams=(ParamsObject)paramstable.get(lb!=null ? locality.getBinding(lb, fc) : md);
ClassDescriptor cn=md.getClassDesc();