pruneVariableResultsWithLiveness( fm );
}
if( state.MLPDEBUG ) {
- //System.out.println( "\nVariable Results-Out\n----------------\n"+fmMain.printMethod( variableResults ) );
+ System.out.println( "\nVariable Results-Out\n----------------\n"+fmMain.printMethod( variableResults ) );
}
//System.out.println( "\nCode Plans\n----------\n"+fmMain.printMethod( codePlans ) );
}
-
// splice new IR nodes into graph after all
// analysis passes are complete
Iterator spliceItr = wdvNodesToSpliceIn.entrySet().iterator();
fwdvn.spliceIntoIR();
}
+ // detailed per-SESE information
+ if( state.MLPDEBUG ) {
+ System.out.println( "\nSESE info\n-------------\n" ); printSESEInfo();
+ }
double timeEndAnalysis = (double) System.nanoTime();
double dt = (timeEndAnalysis - timeStartAnalysis)/(Math.pow( 10.0, 9.0 ) );
}
}
+ private void printSESEInfo() {
+ printSESEInfoTree( rootSESE );
+ System.out.println( "" );
+ }
+
+ private void printSESEInfoTree( FlatSESEEnterNode fsen ) {
+
+ System.out.println( "SESE "+fsen.getPrettyIdentifier()+" {" );
+
+ System.out.println( " in-set: "+fsen.getInVarSet() );
+ Iterator<TempDescriptor> tItr = fsen.getInVarSet().iterator();
+ while( tItr.hasNext() ) {
+ TempDescriptor inVar = tItr.next();
+ if( fsen.getReadyInVarSet().contains( inVar ) ) {
+ System.out.println( " (ready) "+inVar );
+ }
+ if( fsen.getStaticInVarSet().contains( inVar ) ) {
+ System.out.println( " (static) "+inVar );
+ }
+ if( fsen.getDynamicInVarSet().contains( inVar ) ) {
+ System.out.println( " (dynamic)"+inVar );
+ }
+ }
+
+ System.out.println( " out-set: "+fsen.getOutVarSet() );
+
+ /*
+ System.out.println( " static names to track:" );
+ tItr = fsen.getOutVarSet().iterator();
+ while( tItr.hasNext() ) {
+ System.out.println( " "+tItr.next() );
+ }
+ */
+
+ System.out.println( "}" );
+
+ Iterator<FlatSESEEnterNode> childItr = fsen.getChildren().iterator();
+ while( childItr.hasNext() ) {
+ FlatSESEEnterNode fsenChild = childItr.next();
+ printSESEInfoTree( fsenChild );
+ }
+ }
+
private void variableAnalysisForward( FlatMethod fm ) {
// just stall for the exact thing we need and move on
plan.addDynamicStall( readtmp );
currentSESE.addDynamicVar( readtmp );
-
+
} else if( srcType.equals( VarSrcTokTable.SrcType_STATIC ) ) {
// 2) Single token/age pair: Stall for token/age pair, and copy
// all live variables with same token/age pair at the same
TempDescriptor temp = tempItr.next();
VariableSourceToken vst = fsen.getStaticInVarSrc( temp );
SESEandAgePair srcPair = new SESEandAgePair( vst.getSESE(), vst.getAge() );
+
+ // can't grab something from this source until it is done
+ output.println(" {");
+ output.println(" SESEcommon* com = (SESEcommon*)"+paramsprefix+"->"+srcPair+";" );
+ output.println(" pthread_mutex_lock( &(com->lock) );");
+ output.println(" while( com->doneExecuting == FALSE ) {");
+ output.println(" pthread_cond_wait( &(com->doneCond), &(com->lock) );");
+ output.println(" }");
+ output.println(" pthread_mutex_unlock( &(com->lock) );");
+
output.println(" "+generateTemp( fsen.getfmBogus(), temp, null )+
" = "+paramsprefix+"->"+srcPair+"->"+vst.getAddrVar()+";");
+
+ output.println(" }");
}
// dynamic vars come from an SESE and src
// go grab it from the SESE source
output.println(" if( "+paramsprefix+"->"+temp+"_srcSESE != NULL ) {");
+
+ // gotta wait until the source is done
+ output.println(" SESEcommon* com = (SESEcommon*)"+paramsprefix+"->"+temp+"_srcSESE;" );
+ output.println(" pthread_mutex_lock( &(com->lock) );");
+ output.println(" while( com->doneExecuting == FALSE ) {");
+ output.println(" pthread_cond_wait( &(com->doneCond), &(com->lock) );");
+ output.println(" }");
+ output.println(" pthread_mutex_unlock( &(com->lock) );");
+
output.println(" "+generateTemp( fsen.getfmBogus(), temp, null )+
" = *(("+temp.getType().toPrettyString()+"*) ("+
paramsprefix+"->"+temp+"_srcSESE + "+
output.println(" {");
output.println(" SESEcommon* common = (SESEcommon*) "+p+";");
- output.println(" psem_take( &(common->stallSem) );");
+
+ output.println(" pthread_mutex_lock( &(common->lock) );");
+ output.println(" while( common->doneExecuting == FALSE ) {");
+ output.println(" pthread_cond_wait( &(common->doneCond), &(common->lock) );");
+ output.println(" }");
+ output.println(" pthread_mutex_unlock( &(common->lock) );");
+
+ //output.println(" psem_take( &(common->stallSem) );");
// copy things we might have stalled for
output.println(" "+p.getSESE().getSESErecordName()+"* child = ("+
output.println(" seseToIssue->common.classID = "+fsen.getIdentifier()+";");
output.println(" psem_init( &(seseToIssue->common.stallSem) );");
- // before potentially adding this SESE to other forwarding lists,
- // create it's lock and take it immediately
- output.println(" pthread_mutex_init( &(seseToIssue->common.lock), NULL );");
- output.println(" pthread_mutex_lock( &(seseToIssue->common.lock) );");
-
output.println(" seseToIssue->common.forwardList = createQueue();");
output.println(" seseToIssue->common.unresolvedDependencies = 0;");
+ output.println(" pthread_cond_init( &(seseToIssue->common.doneCond), NULL );");
output.println(" seseToIssue->common.doneExecuting = FALSE;");
output.println(" pthread_cond_init( &(seseToIssue->common.runningChildrenCond), NULL );");
output.println(" seseToIssue->common.numRunningChildren = 0;");
}
}
+ // before potentially adding this SESE to other forwarding lists,
+ // create it's lock and take it immediately
+ output.println(" pthread_mutex_init( &(seseToIssue->common.lock), NULL );");
+ output.println(" pthread_mutex_lock( &(seseToIssue->common.lock) );");
+
if( fsen != mlpa.getRootSESE() ) {
// count up outstanding dependencies, static first, then dynamic
Iterator<SESEandAgePair> staticSrcsItr = fsen.getStaticInVarSrcs().iterator();
output.println(" printf( \"This shouldnt already be here\\n\");");
output.println(" exit( -1 );");
output.println(" }");
- output.println(" addNewItem( src->forwardList, seseToIssue );");
- output.println(" ++(seseToIssue->common.unresolvedDependencies);");
+ output.println(" if( !src->doneExecuting ) {");
+ output.println(" addNewItem( src->forwardList, seseToIssue );");
+ output.println(" ++(seseToIssue->common.unresolvedDependencies);");
+ output.println(" }");
output.println(" pthread_mutex_unlock( &(src->lock) );");
output.println(" }");
output.println(" pthread_mutex_lock( &(src->lock) );");
output.println(" if( isEmpty( src->forwardList ) ||");
output.println(" seseToIssue != peekItem( src->forwardList ) ) {");
- output.println(" addNewItem( src->forwardList, seseToIssue );");
- output.println(" ++(seseToIssue->common.unresolvedDependencies);");
+ output.println(" if( !src->doneExecuting ) {");
+ output.println(" addNewItem( src->forwardList, seseToIssue );");
+ output.println(" ++(seseToIssue->common.unresolvedDependencies);");
+ output.println(" }");
output.println(" }");
output.println(" pthread_mutex_unlock( &(src->lock) );");
output.println(" seseToIssue->"+dynInVar+"_srcOffset = "+dynInVar+"_srcOffset;");
output.println(" while( "+com+".numRunningChildren > 0 ) {");
output.println(" pthread_cond_wait( &("+com+".runningChildrenCond), &("+com+".lock) );");
output.println(" }");
- output.println(" pthread_mutex_unlock( &("+com+".lock) );");
+ //output.println(" pthread_mutex_unlock( &("+com+".lock) );");
// copy out-set from local temps into the sese record
Iterator<TempDescriptor> itr = fsexn.getFlatEnter().getOutVarSet().iterator();
}
// mark yourself done, your SESE data is now read-only
- output.println(" pthread_mutex_lock( &("+com+".lock) );");
+ //output.println(" pthread_mutex_lock( &("+com+".lock) );");
output.println(" "+com+".doneExecuting = TRUE;");
+ output.println(" pthread_cond_signal( &("+com+".doneCond) );");
output.println(" pthread_mutex_unlock( &("+com+".lock) );");
// decrement dependency count for all SESE's on your forwarding list
TempDescriptor refVar = (TempDescriptor) me.getKey();
VariableSourceToken vst = (VariableSourceToken) me.getValue();
- SESEandAgePair instance = new SESEandAgePair( vst.getSESE(), vst.getAge() );
-
FlatSESEEnterNode current = fwdvn.getEnclosingSESE();
+ // only do this if the variable in question should be tracked,
+ // meaning that it was explicitly added to the dynamic var set
+ if( !current.getDynamicVarSet().contains( vst.getAddrVar() ) ) {
+ continue;
+ }
+
+ SESEandAgePair instance = new SESEandAgePair( vst.getSESE(), vst.getAge() );
+
output.println(" {");
if( current.equals( vst.getSESE() ) ) {