From: jjenista Date: Thu, 6 Aug 2009 00:00:07 +0000 (+0000) Subject: fully realized system for primitives that displays parent-child stalling and sibling... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7a30a66fa42f7ae52249c51d9b21704379b2886a;p=IRC.git fully realized system for primitives that displays parent-child stalling and sibling dependence --- diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index 82cd89a6..7bd56721 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -771,25 +771,21 @@ public class MLPAnalysis { case FKind.FlatSESEEnterNode: { FlatSESEEnterNode fsen = (FlatSESEEnterNode) fn; - // don't bother for the root SESE, there are no - // tokens for its in-set - if( fsen == rootSESE ) { - break; - } - // track the source types of the in-var set so generated // code at this SESE issue can compute the number of // dependencies properly Iterator inVarItr = fsen.getInVarSet().iterator(); while( inVarItr.hasNext() ) { TempDescriptor inVar = inVarItr.next(); - Integer srcType = vstTable.getRefVarSrcType( inVar, currentSESE ); + Integer srcType = vstTable.getRefVarSrcType( inVar, fsen.getParent() ); if( srcType.equals( VarSrcTokTable.SrcType_DYNAMIC ) ) { - //fsen.addDynamicInVar( inVar ); + fsen.addDynamicInVar( inVar ); } else if( srcType.equals( VarSrcTokTable.SrcType_STATIC ) ) { + fsen.addStaticInVar( inVar ); VariableSourceToken vst = vstTable.get( inVar ).iterator().next(); + fsen.putStaticInVar2src( inVar, vst ); fsen.addStaticInVarSrc( new SESEandAgePair( vst.getSESE(), vst.getAge() ) @@ -797,6 +793,7 @@ public class MLPAnalysis { } else { assert srcType.equals( VarSrcTokTable.SrcType_READY ); + fsen.addReadyInVar( inVar ); } } @@ -915,6 +912,7 @@ public class MLPAnalysis { currentSESE.addNeededStaticName( new SESEandAgePair( vst.getSESE(), vst.getAge() ) ); + currentSESE.mustTrackAtLeastAge( vst.getAge() ); } // if any variable at this node has a static source (exactly one sese) diff --git a/Robust/src/Analysis/MLP/VarSrcTokTable.java b/Robust/src/Analysis/MLP/VarSrcTokTable.java index b2417acb..29b234fe 100644 --- a/Robust/src/Analysis/MLP/VarSrcTokTable.java +++ b/Robust/src/Analysis/MLP/VarSrcTokTable.java @@ -498,6 +498,10 @@ public class VarSrcTokTable { FlatSESEEnterNode parent ) { assert refVar != null; + if( parent == null ) { + return SrcType_READY; + } + Set srcs = get( refVar ); assert !srcs.isEmpty(); diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 28653932..6c4bc13d 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -1774,14 +1774,16 @@ public class BuildCode { outputStructs.println(" INTPTR size;"); outputStructs.println(" void * next;"); - // in-set source pointers - Iterator itrInSet = fsen.getInVarSet().iterator(); - while( itrInSet.hasNext() ) { - TempDescriptor temp = itrInSet.next(); - outputStructs.println(" INTPTR "+temp.getSafeSymbol()+"__srcAddr_;"); + // in-set source tracking + // in-vars that are READY come from parent, don't need anything + // stuff STATIC needs a custom SESE pointer for each age pair + Iterator itrStaticInVarSrcs = fsen.getStaticInVarSrcs().iterator(); + while( itrStaticInVarSrcs.hasNext() ) { + SESEandAgePair srcPair = itrStaticInVarSrcs.next(); + outputStructs.println(" "+srcPair.getSESE().getSESErecordName()+"* "+srcPair+";"); } - // all in and out set primitives + // space for all in and out set primitives Iterator itrPrims = inSetAndOutSetPrims.iterator(); while( itrPrims.hasNext() ) { TempDescriptor temp = itrPrims.next(); @@ -1870,37 +1872,52 @@ public class BuildCode { output.println(" void* "+p+";"); } - // declare local temps for in-set primitives + // declare local temps for in-set primitives, and if it is + // a ready-source variable, get the value from the record Iterator itrInSet = fsen.getInVarSet().iterator(); while( itrInSet.hasNext() ) { TempDescriptor temp = itrInSet.next(); TypeDescriptor type = temp.getType(); if( !type.isPtr() ) { - output.println(" "+type+" "+temp+";"); + if( fsen.getReadyInVarSet().contains( temp ) ) { + output.println(" "+type+" "+temp+" = "+paramsprefix+"->"+temp+";"); + } else { + output.println(" "+type+" "+temp+";"); + } } } - // copy in-set into place - itrInSet = fsen.getInVarSet().iterator(); - while( itrInSet.hasNext() ) { - TempDescriptor temp = itrInSet.next(); - TypeDescriptor type = temp.getType(); + // copy in-set into place, ready vars were already + // copied when the SESE was issued + Iterator tempItr; - // TODO !! make a deep copy of objects ! + // static vars are from a known SESE + tempItr = fsen.getStaticInVarSet().iterator(); + while( tempItr.hasNext() ) { + TempDescriptor temp = tempItr.next(); + TypeDescriptor type = temp.getType(); + VariableSourceToken vst = fsen.getStaticInVarSrc( temp ); + String to; + String size; if( type.isPtr() ) { - output.println(" memcpy( "+ - "(void*) &("+paramsprefix+"->"+temp.getSafeSymbol()+"), "+ // to - "(void*) ("+paramsprefix+"->"+temp.getSafeSymbol()+"__srcAddr_),"+ // from - " sizeof( "+paramsprefix+"->"+temp.getSafeSymbol()+" ) );"); // size + to = "(void*) "; + size = "sizeof "; } else { - output.println(" memcpy( "+ - "(void*) &("+temp.getSafeSymbol()+"), "+ // to - "(void*) ("+paramsprefix+"->"+temp.getSafeSymbol()+"__srcAddr_),"+ // from - " sizeof( "+paramsprefix+"->"+temp.getSafeSymbol()+" ) );"); // size - } + //to = "(void*) &("+temp.getSafeSymbol()+")"; + to = temp.getSafeSymbol(); + size = "sizeof( "+temp.getSafeSymbol()+" )"; + } + + SESEandAgePair srcPair = new SESEandAgePair( vst.getSESE(), vst.getAge() ); + //String from = "(void*) &("+paramsprefix+"->"+srcPair+"->"+vst.getAddrVar()+")"; + String from = paramsprefix+"->"+srcPair+"->"+vst.getAddrVar(); + + //output.println(" memcpy( "+to+", "+from+", "+size+" );"); + output.println(" "+to+" = "+from+";"); } + // Check to see if we need to do a GC if this is a // multi-threaded program... if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) { @@ -1918,7 +1935,6 @@ public class BuildCode { exitset.add(seseExit); - generateCode(fsen.getNext(0), fm, null, exitset, output, true); output.println("}\n\n"); @@ -2734,27 +2750,6 @@ public class BuildCode { output.println(" seseToIssue->common.classID = "+fsen.getIdentifier()+";"); output.println(" psem_init( &(seseToIssue->common.stallSem) );"); - // give pointers to in-set variables, when this SESE is ready to - // execute it should copy values from the pointers because they - // will be guaranteed to be ready for consumption then - Iterator itr = fsen.getInVarSet().iterator(); - while( itr.hasNext() ) { - TempDescriptor temp = itr.next(); - output.print(" seseToIssue->"+temp.getSafeSymbol()+"__srcAddr_ = "); - - // if we are root (no parent) or the temp is in the in or out - // out set, we know it is in the params structure, otherwise its - // a method local variable - if( fsen.getParent() == null || - fsen.getParent().getInVarSet().contains( temp ) || - fsen.getParent().getOutVarSet().contains( temp ) - ) { - output.println("(INTPTR) &("+paramsprefix+"->"+temp.getSafeSymbol()+");"); - } else { - output.println("(INTPTR) &("+temp.getSafeSymbol()+");"); - } - } - // 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 );"); @@ -2764,6 +2759,34 @@ public class BuildCode { output.println(" seseToIssue->common.unresolvedDependencies = 0;"); output.println(" seseToIssue->common.doneExecuting = FALSE;"); + // all READY in-vars should be copied now and be done with it + Iterator tempItr = fsen.getReadyInVarSet().iterator(); + while( tempItr.hasNext() ) { + TempDescriptor temp = tempItr.next(); + TypeDescriptor type = temp.getType(); + + // if we are root (no parent) or the source of the in-var is in + // the in or out set, we know it is in the params structure, + // otherwise its a method-local variable + String from; + if( fsen.getParent() == null || + fsen.getParent().getInVarSet().contains( temp ) || + fsen.getParent().getOutVarSet().contains( temp ) + ) { + //from = "(void*) &("+paramsprefix+"->"+temp.getSafeSymbol()+")"; + from = paramsprefix+"->"+temp.getSafeSymbol(); + } else { + from = temp.getSafeSymbol(); + } + + //String to = "(void*) &(seseToIssue->"+temp.getSafeSymbol()+")"; + String to = "seseToIssue->"+temp.getSafeSymbol(); + String size = "sizeof( seseToIssue->"+temp.getSafeSymbol()+" )"; + + //output.println(" memcpy( "+to+", "+from+", "+size+" );"); + output.println(" "+to+" = "+from+";"); + } + if( fsen != mlpa.getRootSESE() ) { // count up outstanding dependencies, static first, then dynamic @@ -2773,7 +2796,8 @@ public class BuildCode { output.println(" {"); output.println(" SESEcommon* src = (SESEcommon*)"+srcPair+";"); output.println(" pthread_mutex_lock( &(src->lock) );"); - output.println(" if( seseToIssue == peekItem( src->forwardList ) ) {"); + output.println(" if( !isEmpty( src->forwardList ) &&"); + output.println(" seseToIssue == peekItem( src->forwardList ) ) {"); output.println(" printf( \"This shouldnt already be here\\n\");"); output.println(" exit( -1 );"); output.println(" }"); @@ -2781,14 +2805,21 @@ public class BuildCode { output.println(" ++(seseToIssue->common.unresolvedDependencies);"); output.println(" pthread_mutex_unlock( &(src->lock) );"); output.println(" }"); - } - /* + // whether or not it is an outstanding dependency, make sure + // to pass the static name to the child's record + output.println(" seseToIssue->"+srcPair+" = "+srcPair+";"); + } + // maintain pointers for for finding dynamic SESE // instances from static names + for( int i = fsen.getOldestAgeToTrack(); i > 0; --i ) { + SESEandAgePair p1 = new SESEandAgePair( fsen, i ); + SESEandAgePair p2 = new SESEandAgePair( fsen, i-1 ); + output.println(" "+p1+" = "+p2+";"); + } SESEandAgePair p = new SESEandAgePair( fsen, 0 ); output.println(" "+p+" = seseToIssue;"); - */ } // if there were no outstanding dependencies, issue here @@ -2875,7 +2906,7 @@ public class BuildCode { ParamsObject objectparams=(ParamsObject)paramstable.get(lb!=null ? locality.getBinding(lb, fc) : md); ClassDescriptor cn=md.getClassDesc(); output.println("{"); - if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC) { + if ((GENERATEPRECISEGC) || (this.state.MULTICOREGC)) { if (lb!=null) { LocalityBinding fclb=locality.getBinding(lb, fc); output.print(" struct "+cn.getSafeSymbol()+fclb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={"); diff --git a/Robust/src/IR/Flat/FlatSESEEnterNode.java b/Robust/src/IR/Flat/FlatSESEEnterNode.java index 6466c33d..cd0d17a1 100644 --- a/Robust/src/IR/Flat/FlatSESEEnterNode.java +++ b/Robust/src/IR/Flat/FlatSESEEnterNode.java @@ -18,14 +18,22 @@ public class FlatSESEEnterNode extends FlatNode { protected FlatSESEExitNode exit; protected SESENode treeNode; protected FlatSESEEnterNode parent; + protected Integer oldestAgeToTrack; protected Set children; protected Set inVars; protected Set outVars; + protected Set needStaticNameInCode; + protected Set staticInVarSrcs; - protected Set dynamicInVars; + protected Set readyInVars; + protected Set staticInVars; + protected Set dynamicInVars; + + protected Hashtable staticInVar2src; + // scope info for this SESE protected FlatMethod fmEnclosing; @@ -42,12 +50,18 @@ public class FlatSESEEnterNode extends FlatNode { this.id = identifier++; treeNode = sn; parent = null; + oldestAgeToTrack = new Integer( 0 ); + children = new HashSet(); inVars = new HashSet(); outVars = new HashSet(); needStaticNameInCode = new HashSet(); staticInVarSrcs = new HashSet(); + readyInVars = new HashSet(); + staticInVars = new HashSet(); dynamicInVars = new HashSet(); + + staticInVar2src = new Hashtable(); } public void rewriteUse() { @@ -186,7 +200,31 @@ public class FlatSESEEnterNode extends FlatNode { return staticInVarSrcs; } - /* + public void addReadyInVar( TempDescriptor td ) { + readyInVars.add( td ); + } + + public Set getReadyInVarSet() { + return readyInVars; + } + + public void addStaticInVar( TempDescriptor td ) { + staticInVars.add( td ); + } + + public Set getStaticInVarSet() { + return staticInVars; + } + + public void putStaticInVar2src( TempDescriptor staticInVar, + VariableSourceToken vst ) { + staticInVar2src.put( staticInVar, vst ); + } + + public VariableSourceToken getStaticInVarSrc( TempDescriptor staticInVar ) { + return staticInVar2src.get( staticInVar ); + } + public void addDynamicInVar( TempDescriptor td ) { dynamicInVars.add( td ); } @@ -194,7 +232,16 @@ public class FlatSESEEnterNode extends FlatNode { public Set getDynamicInVarSet() { return dynamicInVars; } - */ + + public void mustTrackAtLeastAge( Integer age ) { + if( age > oldestAgeToTrack ) { + oldestAgeToTrack = new Integer( age ); + } + } + + public Integer getOldestAgeToTrack() { + return oldestAgeToTrack; + } public void setfmEnclosing( FlatMethod fm ) { fmEnclosing = fm; } public FlatMethod getfmEnclosing() { return fmEnclosing; } diff --git a/Robust/src/Tests/mlp/tinyTest/test.java b/Robust/src/Tests/mlp/tinyTest/test.java index c993e422..9ddb52e4 100644 --- a/Robust/src/Tests/mlp/tinyTest/test.java +++ b/Robust/src/Tests/mlp/tinyTest/test.java @@ -10,6 +10,8 @@ public class Test { int x = Integer.parseInt( args[0] ); int y = Integer.parseInt( args[1] ); + System.out.println( "root: x="+x+", y="+y ); + //Foo f; sese fi { @@ -37,7 +39,7 @@ public class Test { // see that values from sese fi are // forwarded to this sibling sese fo { - System.out.println( "root: x="+x+", y="+y ); + System.out.println( "fo: x="+x+", y="+y ); } /*