private State state;
private TypeUtil typeUtil;
private CallGraph callGraph;
+ private Liveness liveness;
private RBlockRelationAnalysis rblockRel;
private HeapAnalysis disjointAnalysisTaints;
private DisjointAnalysis disjointAnalysisReach;
ArrayReferencees arrayReferencees ) {
State.logEvent("Starting OoOJavaAnalysis");
- this.state = state;
- this.typeUtil = typeUtil;
- this.callGraph = callGraph;
+ this.state = state;
+ this.typeUtil = typeUtil;
+ this.callGraph = callGraph;
+ this.liveness = liveness;
this.maxSESEage = state.OOO_MAXSESEAGE;
livenessGlobalView = new Hashtable<FlatNode, Set<TempDescriptor>>();
Iterator<FlatSESEEnterNode> seseItr = rblockRel.getLocalRootSESEs().iterator();
while (seseItr.hasNext()) {
FlatSESEEnterNode sese = seseItr.next();
- livenessAnalysisBackward(sese,liveness);
+ livenessAnalysisBackward(sese);
}
seseItr = rblockRel.getLocalRootSESEs().iterator();
while (seseItr.hasNext()) {
FlatSESEEnterNode sese = seseItr.next();
- livenessAnalysisBackward(sese,liveness);
+ livenessAnalysisBackward(sese);
}
State.logEvent("OoOJavaAnalysis 4th pass completed");
while (methItr.hasNext()) {
Descriptor d = methItr.next();
FlatMethod fm = state.getMethodFlat(d);
- codePlansForward(fm,liveness);
+ codePlansForward(fm);
}
State.logEvent("OoOJavaAnalysis 12th pass completed");
}
- private void livenessAnalysisBackward(FlatSESEEnterNode fsen,Liveness liveness) {
+ private void livenessAnalysisBackward(FlatSESEEnterNode fsen) {
// flow backward across nodes to compute liveness, and
// take special care with sese enter/exit nodes that
}
}
- Set<TempDescriptor> curr = liveness_nodeActions( fn, livein, liveness );
+ Set<TempDescriptor> curr = liveness_nodeActions( fn, livein );
// if a new result, schedule backward nodes for analysis
if( !curr.equals( prev ) ) {
}
private Set<TempDescriptor> liveness_nodeActions( FlatNode fn,
- Set<TempDescriptor> liveIn, Liveness liveness
+ Set<TempDescriptor> liveIn
) {
switch( fn.kind() ) {
FlatSESEExitNode fsexn = fsen.getFlatExit();
//note: liveness analysis can have corresponding decisions
Set<TempDescriptor> livetemps= liveness.getLiveInTemps(fsen.getfmEnclosing(), fsexn);
-// Set<TempDescriptor> livetemps = livenessGlobalView.get( fsexn );
if( livetemps != null && livetemps.contains( writeTemps[i] ) ) {
fsen.addOutVar( writeTemps[i] );
}
// written by an SESE and should be added to the in-set
// anything virtually read by this SESE should be pruned
// of parent or sibling sources
- Set<TempDescriptor> liveVars = livenessGlobalView.get(fn);
+ Set<TempDescriptor> liveVars = liveness.getLiveInTemps(fsen.getfmEnclosing(),
+ fn);
+
Set<TempDescriptor> fsenVirtReads =
vstTable.calcVirtReadsAndPruneParentAndSiblingTokens(fsen,
liveVars);
}
livenessVirtualReads.put(fn, fsenVirtReads);
+ // virtual reads are forced in-vars!
+ fsen.addInVarSet( fsenVirtReads );
+
+
// then all child out-set tokens are guaranteed
// to be filled in, so clobber those entries with
// the latest, clean sources
}
- private void codePlansForward(FlatMethod fm, Liveness liveness) {
+ private void codePlansForward(FlatMethod fm) {
// start from flat method top, visit every node in
// method exactly once
}
codePlans_nodeActions(fm, fn,
- /*dotSTlive*/liveness, dotSTtable, dotSTnotAvailSet,
+ dotSTtable, dotSTnotAvailSet,
currentSESE);
for (int i = 0; i < fn.numNext(); i++) {
private void codePlans_nodeActions(FlatMethod fm,
FlatNode fn,
-// Set<TempDescriptor> liveSetIn,
- Liveness liveness,
VarSrcTokTable vstTableIn,
Set<TempDescriptor> notAvailSetIn,
FlatSESEEnterNode currentSESE) {
// variable and the child needs space in its SESE record
if (srcType.equals(VarSrcTokTable.SrcType_DYNAMIC)) {
fsen.addDynamicInVar(inVar);
- addDynamicVar( fsen, fm, inVar );
+ addDynamicVar( parent, fm, inVar );
} else if (srcType.equals(VarSrcTokTable.SrcType_STATIC)) {
fsen.addStaticInVar(inVar);
VariableSourceToken vst = vstIfStatic.vst;
fsen.putStaticInVar2src(inVar, vst);
fsen.addStaticInVarSrc(new SESEandAgePair(vst.getSESE(), vst.getAge()));
+
} else {
assert srcType.equals(VarSrcTokTable.SrcType_READY);
fsen.addReadyInVar(inVar);
case FKind.FlatSESEExitNode: {
FlatSESEExitNode fsexn = (FlatSESEExitNode) fn;
- //TODO! Shouldn't there be a code plan for task exit
- // where the exiting task calculates whether its own
- // siblings need variables from its children, so the
- // exiter should copy those variables into its own out-set
- // and make the available?
+
+ // Classify the sources of out-set variables so code
+ // gen can acquire them from children if necessary
+ // before this task exits
+ FlatSESEEnterNode exiter = fsexn.getFlatEnter();
+
+ Iterator<TempDescriptor> outVarItr = exiter.getOutVarSet().iterator();
+ while( outVarItr.hasNext() ) {
+ TempDescriptor outVar = outVarItr.next();
+
+ VSTWrapper vstIfStatic = new VSTWrapper();
+ Integer srcType = vstTableIn.getRefVarSrcType( outVar,
+ exiter,
+ vstIfStatic
+ );
+
+ if( srcType.equals( VarSrcTokTable.SrcType_DYNAMIC ) ) {
+ // if the out-var is dynamic, put it in the set of dyn out vars
+ // so exiting code gen knows to look for the value, but also put
+ // it in the set of dynamic vars the exiter must track!
+ exiter.addDynamicOutVar( outVar );
+ addDynamicVar( exiter, fm, outVar );
+
+ } else if( srcType.equals( VarSrcTokTable.SrcType_STATIC ) ) {
+ exiter.addStaticOutVar( outVar );
+ VariableSourceToken vst = vstIfStatic.vst;
+ exiter.putStaticOutVar2src( outVar, vst );
+ exiter.addStaticOutVarSrc( new SESEandAgePair( vst.getSESE(), vst.getAge() ) );
+
+ } else {
+ assert srcType.equals( VarSrcTokTable.SrcType_READY );
+ exiter.addReadyOutVar( outVar );
+ }
+ }
} break;
case FKind.FlatOpNode: {
while (refVarItr.hasNext()) {
TempDescriptor refVar = refVarItr.next();
//note: this should just use normal liveness in...only want to copy live variables...
-// if (liveSetIn.contains(refVar)) {
-// copySet.add(refVar);
-// }
- if(liveness.getLiveInTemps(fm, fn).contains(refVar)){
- copySet.add(refVar);
- }
+ if(liveness.getLiveInTemps(fm, fn).contains(refVar)){
+ copySet.add(refVar);
+ }
}
if (!copySet.isEmpty()) {
codePlans.put(fn, plan);
- // if any variables at this-node-*dot* have a static source (exactly one
- // vst)
+
+
+
+ // if any variables at this-node-*dot* have a static source (exactly one vst)
// but go to a dynamic source at next-node-*dot*, create a new IR graph
// node on that edge to track the sources dynamically
+ // NOTE: for this calculation use the currentSESE variable, except when the
+ // FlatNode fn is an Exit--in that case currentSESE is for the exiting task,
+ // be we want to consider that the parent is tracking a variable coming out
+ // of the exiting task
+ FlatSESEEnterNode fsenDoingTracking;
+ if( fn instanceof FlatSESEExitNode ) {
+ fsenDoingTracking = currentSESE.getLocalParent();
+
+ if( fsenDoingTracking == null ) {
+ // if there is no local parent, there are one of two cases
+ // 1) the current task is main, in which case this FlatNode
+ // is the main's exit, and doesn't need to do any of the
+ // following dynamic tracking
+ // 2) the current task is defined in a method, so use the
+ // caller proxy in the variable source calcs below
+ if( currentSESE.equals( rblockRel.getMainSESE() ) ) {
+ return;
+ } else {
+ fsenDoingTracking = rblockRel.getCallerProxySESE();
+ }
+ }
+ } else {
+ fsenDoingTracking = currentSESE;
+ }
+
+
+ if( fsenDoingTracking.getPrettyIdentifier().equals( "workLoop" ) ) {
+ System.out.println( "\n\nWriteDyn for "+fsenDoingTracking+" at "+fn );
+ }
+
+
VarSrcTokTable thisVstTable = variableResults.get(fn);
for (int i = 0; i < fn.numNext(); i++) {
FlatNode nn = fn.getNext(i);
VarSrcTokTable nextVstTable = variableResults.get(nn);
// note: using the result of liveness analysis regardless of task structures
- // Set<TempDescriptor> nextLiveIn = livenessGlobalView.get(nn);
Set<TempDescriptor> nextLiveIn=liveness.getLiveInTemps(fm, nn);
// the table can be null if it is one of the few IR nodes
if (nextVstTable != null && nextLiveIn != null) {
Hashtable<TempDescriptor, VSTWrapper> readyOrStatic2dynamicSet =
- thisVstTable.getReadyOrStatic2DynamicSet(nextVstTable, nextLiveIn, currentSESE);
+ thisVstTable.getReadyOrStatic2DynamicSet(nextVstTable, nextLiveIn, fsenDoingTracking);
if (!readyOrStatic2dynamicSet.isEmpty()) {
+
+
+ if( fsenDoingTracking.getPrettyIdentifier().equals( "workLoop" ) ) {
+ System.out.println( " found newly dyn vars: "+readyOrStatic2dynamicSet );
+ }
+
+
// either add these results to partial fixed-point result
// or make a new one if we haven't made any here yet
FlatEdge fe = new FlatEdge(fn, nn);
FlatWriteDynamicVarNode fwdvn = wdvNodesToSpliceIn.get(fe);
if (fwdvn == null) {
- fwdvn = new FlatWriteDynamicVarNode(fn, nn, readyOrStatic2dynamicSet, currentSESE);
+ fwdvn = new FlatWriteDynamicVarNode(fn, nn, readyOrStatic2dynamicSet, fsenDoingTracking);
wdvNodesToSpliceIn.put(fe, fwdvn);
} else {
fwdvn.addMoreVar2Src(readyOrStatic2dynamicSet);
}
}
}
+
+ if( fsenDoingTracking.getPrettyIdentifier().equals( "workLoop" ) ) {
+ System.out.println( "WriteDyn for "+fsenDoingTracking+" at "+fn+" is done\n\n" );
+ }
}
private void addDynamicVar( FlatSESEEnterNode fsen,
// note: dynamic variable declarations are always located in the flat method that encloses task block
// there is no need to set fnContext to fsen
-// if( fsen.getIsCallerProxySESE() ) {
-// // attach the dynamic variable to track to
-// // the flat method, so it can be declared at entry
-// fnContext = fm;
-// } else {
-// // otherwise the code context is a task body
-// fnContext = fsen;
-// }
- fnContext=fm;
+ if( fsen.getIsCallerProxySESE() ) {
+ // attach the dynamic variable to track to
+ // the flat method, so it can be declared at entry
+ fnContext = fm;
+ } else {
+ // otherwise the code context is a task body
+ fnContext = fsen;
+ }
+ //fnContext=fm;
ContextTaskNames ctn = fn2contextTaskNames.get( fnContext );
if( ctn == null ) {
bw.write(" Dynamic vars to manage: " + getContextTaskNames( fsen ).getDynamicVarSet() + "\n");
bw.write(" out-set: " + fsen.getOutVarSet() + "\n");
+ tItr = fsen.getOutVarSet().iterator();
+ while (tItr.hasNext()) {
+ TempDescriptor outVar = tItr.next();
+ if (fsen.getReadyOutVarSet().contains(outVar)) {
+ bw.write(" (ready) " + outVar + "\n");
+ }
+ if (fsen.getStaticOutVarSet().contains(outVar)) {
+ bw.write(" (static) " + outVar + " from " + fsen.getStaticOutVarSrc(outVar) + "\n");
+ }
+ if (fsen.getDynamicOutVarSet().contains(outVar)) {
+ bw.write(" (dynamic)" + outVar + "\n");
+ }
+ }
bw.write(" local parent: " + fsen.getLocalParent() + "\n");
bw.write(" local children: " + fsen.getLocalChildren() + "\n");
public void remapChildTokens( FlatSESEEnterNode curr ) {
Iterator<FlatSESEEnterNode> childItr = curr.getLocalChildren().iterator();
- if( childItr.hasNext() ) {
+ while( childItr.hasNext() ) {
FlatSESEEnterNode child = childItr.next();
// set of VSTs for removal
HashSet<VariableSourceToken> removalSet=new HashSet<VariableSourceToken>();
// set of VSTs for additon
HashSet<VariableSourceToken> additionSet=new HashSet<VariableSourceToken>();
-
+
Iterator<VariableSourceToken> vstItr = get( child ).iterator();
while( vstItr.hasNext() ) {
VariableSourceToken vst = vstItr.next();
removalSet.add(vst);
- additionSet.add(new VariableSourceToken( vst.getRefVars(),
- curr,
- new Integer( 0 ),
- vst.getAddrVar()
- ));
+
+ additionSet.add( new VariableSourceToken( vst.getRefVars(),
+ curr,
+ new Integer( 0 ),
+ vst.getAddrVar()
+ )
+ );
}
// remove( eah item in forremoval )
alternateSESEs.add( sibling );
}
}
-
-
// VSTs to remove if they are alternate sources for exiter VSTs
// whose variables will become virtual reads
forRemoval.add( vstPossibleOtherSrc );
} else {
- if( !vstPossibleOtherSrc.getSESE().equals( exiter ) ||
- !vstPossibleOtherSrc.getAge().equals( 0 )
+ if( !(vstPossibleOtherSrc.getSESE().equals( exiter ) &&
+ vstPossibleOtherSrc.getAge().equals( 0 )
+ )
) {
System.out.println( "For refVar="+refVar+" at exit of "+exiter+
", unexpected possible variable source "+vstPossibleOtherSrc );
System.out.println( "done gc" );
- Node [] nodesForBadTris = new Node [numWorkers];
- Cavity[] cavities = new Cavity[numWorkers];
- Cavity lastAppliedCavity = null;
+ //int zzz = 0;
- int zzz = 0;
+ long startTime = System.currentTimeMillis();
- long startTime = System.currentTimeMillis();
- while (!worklist.isEmpty()) {
-
- // Phase 1, grab enough work from list for
- // each worker in the parent
- for(int i=0;i<numWorkers;i++) {
- if(worklist.isEmpty()) {
- nodesForBadTris[i] = null;
- } else {
- nodesForBadTris[i] = (Node) worklist.pop();
+ sese workLoop {
+
+ Node [] nodesForBadTris = new Node [numWorkers];
+ Cavity[] cavities = new Cavity[numWorkers];
+ Cavity lastAppliedCavity = null;
+
+ while (!worklist.isEmpty()) {
+
+ // Phase 1, grab enough work from list for
+ // each worker in the parent
+ for(int i=0;i<numWorkers;i++) {
+ if(worklist.isEmpty()) {
+ nodesForBadTris[i] = null;
+ } else {
+ nodesForBadTris[i] = (Node) worklist.pop();
+ }
}
- }
- // Phase 2, read mesh and compute cavities in parallel
- for(int i=0;i<numWorkers;i++) {
+ // Phase 2, read mesh and compute cavities in parallel
+ for(int i=0;i<numWorkers;i++) {
- Node nodeForBadTri = nodesForBadTris[i];
+ Node nodeForBadTri = nodesForBadTris[i];
- if (nodeForBadTri != null &&
- nodeForBadTri.inGraph
- ) {
+ if (nodeForBadTri != null &&
+ nodeForBadTri.inGraph
+ ) {
- //System.out.println( "computing a cavity for tri "+
- // mesh.getNodeData( nodeForBadTri )+"..." );
+ //System.out.println( "computing a cavity for tri "+
+ // mesh.getNodeData( nodeForBadTri )+"..." );
- sese computeCavity {
- //takes < 1 sec
- Cavity cavity = new Cavity(mesh);
+ sese computeCavity {
+ //takes < 1 sec
+ Cavity cavity = new Cavity(mesh);
- //Appears to only call getters (only possible conflict is inherent in Hashmap)
- cavity.initialize(nodeForBadTri);
+ //Appears to only call getters (only possible conflict is inherent in Hashmap)
+ cavity.initialize(nodeForBadTri);
- //Takes up 15% of computation
- //Problem:: Build is recursive upon building neighbor upon neighbor upon neighbor
- //This is could be a problem....
- //TODO check dimensions problem
- cavity.build();
+ //Takes up 15% of computation
+ //Problem:: Build is recursive upon building neighbor upon neighbor upon neighbor
+ //This is could be a problem....
+ //TODO check dimensions problem
+ cavity.build();
- //Takes up a whooping 50% of computation time and changes NOTHING but cavity :D
- cavity.update();
+ //Takes up a whooping 50% of computation time and changes NOTHING but cavity :D
+ cavity.update();
- /*
- LinkedList nodes = cavity.getPre().getNodes();
- LinkedList border = cavity.getPre().getBorder();
- LinkedList edges = cavity.getPre().getEdges();
+ /*
+ LinkedList nodes = cavity.getPre().getNodes();
+ LinkedList border = cavity.getPre().getBorder();
+ LinkedList edges = cavity.getPre().getEdges();
- String s = "nodes: \n";
+ String s = "nodes: \n";
- for( Iterator iter = nodes.iterator(); iter.hasNext(); ) {
- Node node = (Node) iter.next();
- Element element = (Element) mesh.getNodeData(node);
- s += " "+element+"\n";
- }
+ for( Iterator iter = nodes.iterator(); iter.hasNext(); ) {
+ Node node = (Node) iter.next();
+ Element element = (Element) mesh.getNodeData(node);
+ s += " "+element+"\n";
+ }
- s += "\nborder: \n";
+ s += "\nborder: \n";
- for( Iterator iter = border.iterator(); iter.hasNext(); ) {
- Node node = (Node) iter.next();
- Element element = (Element) mesh.getNodeData(node);
- s += " "+element+"\n";
- }
+ for( Iterator iter = border.iterator(); iter.hasNext(); ) {
+ Node node = (Node) iter.next();
+ Element element = (Element) mesh.getNodeData(node);
+ s += " "+element+"\n";
+ }
- s += "\nedges: \n";
+ s += "\nedges: \n";
- for( Iterator iter = edges.iterator(); iter.hasNext(); ) {
- Edge_d edge = (Edge_d) iter.next();
- Element element = (Element) mesh.getEdgeData(edge);
- s += " "+element+"\n";
- }
+ for( Iterator iter = edges.iterator(); iter.hasNext(); ) {
+ Edge_d edge = (Edge_d) iter.next();
+ Element element = (Element) mesh.getEdgeData(edge);
+ s += " "+element+"\n";
+ }
- System.out.println( "Pre:\n"+s );
- */
+ System.out.println( "Pre:\n"+s );
+ */
- }
+ }
- sese storeCavity {
- cavities[i] = cavity;
- }
+ sese storeCavity {
+ cavities[i] = cavity;
+ }
- } else {
- sese storeNoCavity {
- cavities[i] = null;
+ } else {
+ sese storeNoCavity {
+ cavities[i] = null;
+ }
}
}
- }
- // Phase 3, apply cavities to mesh, if still applicable
- // this phase can proceed in parallel when a cavity's
- // start nodes are still present
- for(int i=0;i<numWorkers;i++) {
-
- Cavity cavity = cavities[i];
- boolean appliedCavity = false;
- Node nodeForBadTri = nodesForBadTris[i];
+ // Phase 3, apply cavities to mesh, if still applicable
+ // this phase can proceed in parallel when a cavity's
+ // start nodes are still present
+ for(int i=0;i<numWorkers;i++) {
+
+ Cavity cavity = cavities[i];
+ Node nodeForBadTri = nodesForBadTris[i];
+
- sese applyCavity {
+ sese applyCavity {
+
+ int appliedCavity = 0;
- // go ahead with applying cavity when all of its
- // pre-nodes are still in
- if( cavity != null &&
- cavity.getPre().allNodesAndBorderStillInCompleteGraph() ) {
+ // go ahead with applying cavity when all of its
+ // pre-nodes are still in
+ if( cavity != null &&
+ cavity.getPre().allNodesAndBorderStillInCompleteGraph() ) {
- appliedCavity = true;
- lastAppliedCavity = cavity;
+ appliedCavity = 1;
- //boolean printChange = true; //(zzz % 10 == 0);
+ //boolean printChange = true; //(zzz % 10 == 0);
- //remove old data
- Node node;
- //if( printChange ) {
- // System.out.println( "\n\n\nbad tri: "+mesh.getNodeData( nodeForBadTri ) );
- // System.out.println( "\npre nodes: " );
- //}
- //Takes up 8.9% of runtime
- for (Iterator iterator = cavity.getPre().getNodes().iterator();
- iterator.hasNext();) {
-
- node = (Node) iterator.next();
+ //remove old data
+ Node node;
//if( printChange ) {
- // System.out.println( " "+mesh.getNodeData( node ) );
- //}
- mesh.removeNode(node);
- }
+ // System.out.println( "\n\n\nbad tri: "+mesh.getNodeData( nodeForBadTri ) );
+ // System.out.println( "\npre nodes: " );
+ //}
+ //Takes up 8.9% of runtime
+ for (Iterator iterator = cavity.getPre().getNodes().iterator();
+ iterator.hasNext();) {
+
+ node = (Node) iterator.next();
+ //if( printChange ) {
+ // System.out.println( " "+mesh.getNodeData( node ) );
+ //}
+ mesh.removeNode(node);
+ }
- //add new data
- //if( printChange ) {
- // System.out.println( "post nodes: " );
- //}
- //Takes up 1.7% of runtime
- for (Iterator iterator1 = cavity.getPost().getNodes().iterator();
- iterator1.hasNext();) {
-
- node = (Node) iterator1.next();
+ //add new data
//if( printChange ) {
- // System.out.println( " "+mesh.getNodeData( node ) );
- //}
- mesh.addNode(node);
- }
+ // System.out.println( "post nodes: " );
+ //}
+ //Takes up 1.7% of runtime
+ for (Iterator iterator1 = cavity.getPost().getNodes().iterator();
+ iterator1.hasNext();) {
+
+ node = (Node) iterator1.next();
+ //if( printChange ) {
+ // System.out.println( " "+mesh.getNodeData( node ) );
+ //}
+ mesh.addNode(node);
+ }
- //if( printChange ) {
- // System.out.println( "post edges: " );
- //}
- //Takes up 7.8% of runtime
- Edge_d edge;
- for (Iterator iterator2 = cavity.getPost().getEdges().iterator();
- iterator2.hasNext();) {
-
- edge = (Edge_d) iterator2.next();
//if( printChange ) {
- // System.out.println( " "+mesh.getEdgeData( edge ) );
- //}
- mesh.addEdge(edge);
- }
-
+ // System.out.println( "post edges: " );
+ //}
+ //Takes up 7.8% of runtime
+ Edge_d edge;
+ for (Iterator iterator2 = cavity.getPost().getEdges().iterator();
+ iterator2.hasNext();) {
+
+ edge = (Edge_d) iterator2.next();
+ //if( printChange ) {
+ // System.out.println( " "+mesh.getEdgeData( edge ) );
+ //}
+ mesh.addEdge(edge);
+ }
- for (Iterator iterator1 = cavity.getPost().getNodes().iterator();
- iterator1.hasNext();) {
- node = (Node) iterator1.next();
+ /*
+ for (Iterator iterator1 = cavity.getPost().getNodes().iterator();
+ iterator1.hasNext();) {
+ node = (Node) iterator1.next();
- Element e = (Element)mesh.getNodeData( node );
+ Element e = (Element)mesh.getNodeData( node );
- int cntOutNeighbors = 0;
- for (Iterator iterator = mesh.getOutNeighbors(node); iterator.hasNext();) {
- ++cntOutNeighbors;
- Node neighbor = (Node) iterator.next();
- }
+ int cntOutNeighbors = 0;
+ for (Iterator iterator = mesh.getOutNeighbors(node); iterator.hasNext();) {
+ ++cntOutNeighbors;
+ Node neighbor = (Node) iterator.next();
+ }
- int dim = e.getDim();
- int out = cntOutNeighbors;
+ int dim = e.getDim();
+ int out = cntOutNeighbors;
- if( dim == 3 && out < 3 ) {
- System.out.println( e+" has dim="+dim+" and num out-neighbors in graph="+out );
+ if( dim == 3 && out < 3 ) {
+ System.out.println( e+" has dim="+dim+" and num out-neighbors in graph="+out );
+ }
}
- }
+ */
+ }
}
- }
- sese scheduleMoreBad {
+ sese scheduleMoreBad {
- if( appliedCavity ) {
- // we did apply the cavity, and we may
- // have introduced new bad triangles
- HashMapIterator it2 = cavity.getPost().newBad(mesh).iterator();
- while (it2.hasNext()) {
- worklist.push((Node)it2.next());
+ if( appliedCavity == 1 ) {
+
+ lastAppliedCavity = cavity;
+
+ // we did apply the cavity, and we may
+ // have introduced new bad triangles
+ HashMapIterator it2 = cavity.getPost().newBad(mesh).iterator();
+ while (it2.hasNext()) {
+ worklist.push((Node)it2.next());
+ }
}
- }
- // the logic of having this out here seems wacky, and overconservative,
- // but it matches the original algorithm and it works...
- if( nodeForBadTri != null && mesh.containsNode( nodeForBadTri ) ) {
- worklist.push( nodeForBadTri );
- }
+ // the logic of having this out here seems wacky, and overconservative,
+ // but it matches the original algorithm and it works...
+ if( nodeForBadTri != null && mesh.containsNode( nodeForBadTri ) ) {
+ worklist.push( nodeForBadTri );
+ }
- /*
- if( !appliedCavity ) {
+ /*
+ if( appliedCavity != 1 ) {
- // if we couldn't even apply this cavity, just
- // throw it back on the worklist
- if( nodeForBadTri != null && nodeForBadTri.inGraph ) {
+ // if we couldn't even apply this cavity, just
+ // throw it back on the worklist
+ if( nodeForBadTri != null && nodeForBadTri.inGraph ) {
worklist.push( nodeForBadTri );
- } else {
+ } else {
System.out.println( "\n\n\nthis tri no longer a concern: "+
- mesh.getNodeData( nodeForBadTri ) );
- }
+ mesh.getNodeData( nodeForBadTri ) );
+ }
- } else {
- // otherwise we did apply the cavity,
- // and we may have introduced new bad triangles
- HashMapIterator it2 = cavity.getPost().newBad(mesh).iterator();
- while (it2.hasNext()) {
+ } else {
+ // otherwise we did apply the cavity,
+ // and we may have introduced new bad triangles
+ HashMapIterator it2 = cavity.getPost().newBad(mesh).iterator();
+ while (it2.hasNext()) {
worklist.push((Node)it2.next());
- }
- }
- */
+ }
+ }
+ */
- } // end scheduleMoreBad
- } // end phase 3
+ } // end scheduleMoreBad
+ } // end phase 3
- //++zzz;
- //Node aNode = (Node)lastAppliedCavity.getPost().getNodes().iterator().next();
- //mesh.discoverAllNodes( aNode );
- //System.out.println( "\n\ntris="+mesh.getNumNodes()+
- // " [wl="+worklist.size()+"]");
- //if( zzz == 10 ) { System.exit( 0 ); }
+ //++zzz;
+ //Node aNode = (Node)lastAppliedCavity.getPost().getNodes().iterator().next();
+ //mesh.discoverAllNodes( aNode );
+ //System.out.println( "\n\ntris="+mesh.getNumNodes()+
+ // " [wl="+worklist.size()+"]");
+ //if( zzz == 10 ) { System.exit( 0 ); }
- } // end while( !worklist.isEmpty() )
+ } // end while( !worklist.isEmpty() )
+ } // end sese workLoop
long time = System.currentTimeMillis() - startTime;
System.out.println("runtime: " + time + " ms");
USEOOO= -ooojava $(NUM_OOO_WORKERS) 2 -squeue #-ooodebug-disable-task-mem-pool
-USERCR= -ooojava $(NUM_RCR_WORKERS) 2 -rcr -squeue
+USERCR= -ooodebug -ooojava $(NUM_RCR_WORKERS) 2 -rcr -squeue
OOODEBUG= -ooodebug -printlinenum
RCRDEBUG= -rcr_debug -printlinenum
RCRDEBUGV= -rcr_debug_verbose -printlinenum
-BSFLAGS= -64bit -mainclass $(PROGRAM) -heapsize-mb 8000 -garbagestats -joptimize -noloop -optimize -debug #-nooptimize #src-after-pp
+BSFLAGS= -64bit -mainclass $(PROGRAM) -heapsize-mb 8000 -garbagestats -joptimize -noloop -nooptimize -debug # #src-after-pp -optimize
DRELEASEMODE=-disjoint-release-mode -disjoint-dvisit-stack-callees-on-top -disjoint-alias-file aliases.txt tabbed
output.println(" }");
- // copy out-set from local temps into the sese record
- Iterator<TempDescriptor> itr = fsen.getOutVarSet().iterator();
+
+ ////////////////////////////////////////
+ // go through all out-vars and determine where to get them
+ ////////////////////////////////////////
+ output.println(" // copy ready out-set primitive variables from locals into record");
+ Iterator<TempDescriptor> itr = fsen.getReadyOutVarSet().iterator();
while( itr.hasNext() ) {
TempDescriptor temp = itr.next();
- // only have to do this for primitives non-arrays
+ // only have to do this for primitives, non-arrays
if( !(
temp.getType().isPrimitive() && !temp.getType().isArray()
- )
- ) {
+ )
+ ) {
continue;
}
- String from;
-
- // determine whether this new task instance is in a method context,
- // or within the body of another task
- assert !fsen.getIsCallerProxySESE();
- FlatSESEEnterNode parent = fsen.getLocalParent();
- if( parent != null && !parent.getIsCallerProxySESE() ) {
- from = generateTemp( parent.getfmBogus(), temp );
- } else {
- from = generateTemp( fsen.getfmEnclosing(), temp );
- }
+ String from = generateTemp( fsen.getfmBogus(), temp );
output.println(" "+paramsprefix+
"->"+temp.getSafeSymbol()+
" = "+from+";");
- }
+ }
+
+ // static vars are from a known SESE
+ Iterator<TempDescriptor> tempItr;
+ output.println(" // copy out-set from static sources");
+ tempItr = fsen.getStaticOutVarSet().iterator();
+ while( tempItr.hasNext() ) {
+ TempDescriptor temp = tempItr.next();
+ VariableSourceToken vst = fsen.getStaticOutVarSrc( temp );
+ SESEandAgePair srcPair = new SESEandAgePair( vst.getSESE(), vst.getAge() );
+ output.println(" "+paramsprefix+
+ "->"+temp.getSafeSymbol()+
+ " = "+paramsprefix+"->"+srcPair+"->"+vst.getAddrVar()+";");
+ }
+
+ //output.println(" // decrement references to static sources");
+ //for( Iterator<SESEandAgePair> pairItr = fsen.getStaticOutVarSrcs().iterator(); pairItr.hasNext(); ) {
+ // SESEandAgePair srcPair = pairItr.next();
+ // output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ // output.println(" {");
+ // output.println(" SESEcommon* src = &("+paramsprefix+"->"+srcPair+"->common);");
+ // output.println(" RELEASE_REFERENCE_TO( src );");
+ // output.println(" }");
+ // output.println("#endif // OOO_DISABLE_TASKMEMPOOL" );
+ //}
+
+ output.println(" // copy out-set from dynamic sources");
+ tempItr = fsen.getDynamicOutVarSet().iterator();
+ while( tempItr.hasNext() ) {
+ TempDescriptor temp = tempItr.next();
+ TypeDescriptor type = temp.getType();
+
+ // go grab it from the SESE source, when the source is NULL it is
+ // this exiting task, so nothing to do!
+ output.println(" if( "+temp+"_srcSESE != NULL ) {");
+
+ output.println(" "+paramsprefix+
+ "->"+temp.getSafeSymbol()+
+ " = (void*)"+
+ temp+"_srcSESE + "+
+ temp+"_srcOffset;");
+
+ //output.println("#ifndef OOO_DISABLE_TASKMEMPOOL" );
+ //output.println(" SESEcommon* src = "+paramsprefix+"->"+temp+"_srcSESE;");
+ //output.println(" RELEASE_REFERENCE_TO( src );");
+ //output.println("#endif // OOO_DISABLE_TASKMEMPOOL" );
+
+ output.println(" }");
+ }
+
+
+
// mark yourself done, your task data is now read-only
output.println(" runningSESE->doneExecuting = TRUE;");
protected Set<TempDescriptor> inVars;
protected Set<TempDescriptor> outVars;
+
+ // for in-vars, classify them by source type to drive
+ // code gen for issuing this task
protected Set<TempDescriptor> readyInVars;
protected Set<TempDescriptor> staticInVars;
protected Set<TempDescriptor> dynamicInVars;
-
protected Set<SESEandAgePair> staticInVarSrcs;
-
protected Hashtable<TempDescriptor, VariableSourceToken> staticInVar2src;
+ // for out-vars, classify them by source type to drive
+ // code gen for when this task exits: if the exiting task
+ // has to assume the values from any of its children, it needs
+ // to know how to acquire those values before it can truly exit
+ protected Set<TempDescriptor> readyOutVars;
+ protected Set<TempDescriptor> staticOutVars;
+ protected Set<TempDescriptor> dynamicOutVars;
+ protected Set<SESEandAgePair> staticOutVarSrcs;
+ protected Hashtable<TempDescriptor, VariableSourceToken> staticOutVar2src;
+
+
+
// get the oldest age of this task that other contexts
// have a static name for when tracking variables
protected Integer oldestAgeToTrack;
staticInVars = new HashSet<TempDescriptor>();
dynamicInVars = new HashSet<TempDescriptor>();
staticInVarSrcs = new HashSet<SESEandAgePair>();
+ readyOutVars = new HashSet<TempDescriptor>();
+ staticOutVars = new HashSet<TempDescriptor>();
+ dynamicOutVars = new HashSet<TempDescriptor>();
+ staticOutVarSrcs = new HashSet<SESEandAgePair>();
oldestAgeToTrack = new Integer( 0 );
- staticInVar2src = new Hashtable<TempDescriptor, VariableSourceToken>();
+ staticInVar2src = new Hashtable<TempDescriptor, VariableSourceToken>();
+ staticOutVar2src = new Hashtable<TempDescriptor, VariableSourceToken>();
inVarsForDynamicCoarseConflictResolution = new Vector<TempDescriptor>();
}
+
+ public void addReadyOutVar( TempDescriptor td ) {
+ readyOutVars.add( td );
+ }
+
+ public Set<TempDescriptor> getReadyOutVarSet() {
+ return readyOutVars;
+ }
+
+ public void addStaticOutVarSrc( SESEandAgePair p ) {
+ staticOutVarSrcs.add( p );
+ }
+
+ public Set<SESEandAgePair> getStaticOutVarSrcs() {
+ return staticOutVarSrcs;
+ }
+
+ public void addStaticOutVar( TempDescriptor td ) {
+ staticOutVars.add( td );
+ }
+
+ public Set<TempDescriptor> getStaticOutVarSet() {
+ return staticOutVars;
+ }
+
+ public void putStaticOutVar2src( TempDescriptor staticOutVar,
+ VariableSourceToken vst ) {
+ staticOutVar2src.put( staticOutVar, vst );
+ }
+
+ public VariableSourceToken getStaticOutVarSrc( TempDescriptor staticOutVar ) {
+ return staticOutVar2src.get( staticOutVar );
+ }
+
+ public void addDynamicOutVar( TempDescriptor td ) {
+ dynamicOutVars.add( td );
+ }
+
+ public Set<TempDescriptor> getDynamicOutVarSet() {
+ return dynamicOutVars;
+ }
+
+
+
+
public void setfmEnclosing( FlatMethod fm ) { fmEnclosing = fm; }
public FlatMethod getfmEnclosing() { return fmEnclosing; }