throw new Error( "IO Exception while writing disjointness analysis output." );
}
- if( doEffectsAnalysis ) {
- effectsAnalysis.writeEffects( "effects.txt" );
- }
}
} else if (type == ConflictGraph.COARSE_GRAIN_EDGE) {
return "\"C_CONFLICT\"";
} else {
- return "CONFLICT\"";
+ return "\"CONFLICT\"";
}
}
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.Collection;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
String id = var + "_fn" + fn.hashCode();
ConflictNode node = id2cn.get(id);
if (node == null) {
- node = new ConflictNode(id, ConflictNode.STALLSITE);
+ node = new ConflictNode(id, ConflictNode.STALLSITE, t.getVar(), t.getStallSite());
}
node.addEffect(as, e);
String id = invar + "_sese" + sese.getIdentifier();
ConflictNode node = id2cn.get(id);
if (node == null) {
- node = new ConflictNode(id, ConflictNode.INVAR);
+ node = new ConflictNode(id, ConflictNode.INVAR, t.getVar(), t.getSESE());
}
node.addEffect(as, e);
return false;
}
+ public boolean isFineElement(int type) {
+ if (type == ConflictNode.FINE_READ || type == ConflictNode.FINE_WRITE
+ || type == ConflictNode.PARENT_READ || type == ConflictNode.PARENT_WRITE) {
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ public SESEWaitingQueue getWaitingElementSetBySESEID(int seseID,
+ HashSet<SESELock> seseLockSet) {
+
+ HashSet<WaitingElement> waitingElementSet = new HashSet<WaitingElement>();
+
+ Iterator iter = id2cn.entrySet().iterator();
+ while (iter.hasNext()) {
+ Entry entry = (Entry) iter.next();
+ String conflictNodeID = (String) entry.getKey();
+ ConflictNode node = (ConflictNode) entry.getValue();
+
+ if (node.isInVarNode()) {
+ if (node.getSESEIdentifier() == seseID) {
+
+ Set<ConflictEdge> edgeSet = node.getEdgeSet();
+ for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
+ ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
+
+ for (Iterator<SESELock> seseLockIter = seseLockSet.iterator(); seseLockIter.hasNext();) {
+ SESELock seseLock = seseLockIter.next();
+ if (seseLock.containsConflictNode(node)
+ && seseLock.containsConflictEdge(conflictEdge)) {
+ WaitingElement newElement = new WaitingElement();
+ newElement.setQueueID(seseLock.getID());
+ newElement.setStatus(seseLock.getNodeType(node));
+ if (isFineElement(newElement.getStatus())) {
+ newElement.setDynID(node.getVar().toString());
+ newElement.setTempDesc(node.getVar());
+ }
+ if (!waitingElementSet.contains(newElement)) {
+ waitingElementSet.add(newElement);
+ }
+
+ }
+ }
+ }
+
+ }
+ }
+
+ }
+
+ // handle the case that multiple enqueues by an SESE for different live-in
+ // into the same queue
+ return refineQueue(waitingElementSet);
+// return waitingElementSet;
+
+ }
+
+ public SESEWaitingQueue refineQueue(Set<WaitingElement> waitingElementSet) {
+
+ Set<WaitingElement> refinedSet=new HashSet<WaitingElement>();
+ HashMap<Integer, Set<WaitingElement>> map = new HashMap<Integer, Set<WaitingElement>>();
+ SESEWaitingQueue seseDS=new SESEWaitingQueue();
+
+ for (Iterator iterator = waitingElementSet.iterator(); iterator
+ .hasNext();) {
+ WaitingElement waitingElement = (WaitingElement) iterator.next();
+ Set<WaitingElement> set=map.get(new Integer(waitingElement.getQueueID()));
+ if(set==null){
+ set=new HashSet<WaitingElement>();
+ }
+ set.add(waitingElement);
+ map.put(new Integer(waitingElement.getQueueID()), set);
+ }
+
+ Set<Integer> keySet=map.keySet();
+ for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
+ Integer queueID = (Integer) iterator.next();
+ Set<WaitingElement> queueWEset=map.get(queueID);
+ refineQueue(queueID.intValue(),queueWEset,seseDS);
+ }
+
+ return seseDS;
+ }
+
+
+ private void refineQueue(int queueID,
+ Set<WaitingElement> waitingElementSet, SESEWaitingQueue seseDS) {
+
+ if (waitingElementSet.size() > 1) {
+ //only consider there is more than one element submitted by same SESE
+ Set<WaitingElement> refinedSet = new HashSet<WaitingElement>();
+
+ int numCoarse = 0;
+ int numRead = 0;
+ int numWrite = 0;
+ int total=waitingElementSet.size();
+ WaitingElement SCCelement = null;
+ WaitingElement coarseElement = null;
+
+ for (Iterator iterator = waitingElementSet.iterator(); iterator
+ .hasNext();) {
+ WaitingElement waitingElement = (WaitingElement) iterator
+ .next();
+ if (waitingElement.getStatus() == ConflictNode.FINE_READ) {
+ numRead++;
+ } else if (waitingElement.getStatus() == ConflictNode.FINE_WRITE) {
+ numWrite++;
+ } else if (waitingElement.getStatus() == ConflictNode.COARSE) {
+ numCoarse++;
+ coarseElement = waitingElement;
+ } else if (waitingElement.getStatus() == ConflictNode.SCC) {
+ SCCelement = waitingElement;
+ }
+ }
+
+ if (SCCelement != null) {
+ // if there is at lease one SCC element, just enqueue SCC and
+ // ignore others.
+ refinedSet.add(SCCelement);
+ } else if (numCoarse == 1 && (numRead + numWrite == total)) {
+ // if one is a coarse, the othere are reads/write, enqueue SCC.
+ WaitingElement we = new WaitingElement();
+ we.setQueueID(queueID);
+ we.setStatus(ConflictNode.SCC);
+ refinedSet.add(we);
+ } else if (numCoarse == total) {
+ // if there are multiple coarses, enqueue just one coarse.
+ refinedSet.add(coarseElement);
+ } else if(numWrite==total || (numRead+numWrite)==total){
+ // code generator is going to handle the case for multiple writes & read/writes.
+ seseDS.setType(queueID, SESEWaitingQueue.EXCEPTION);
+ refinedSet.addAll(waitingElementSet);
+ } else{
+ // otherwise, enqueue everything.
+ refinedSet.addAll(waitingElementSet);
+ }
+ seseDS.setWaitingElementSet(queueID, refinedSet);
+ } else {
+ seseDS.setWaitingElementSet(queueID, waitingElementSet);
+ }
+
+ }
+
+ public Set<WaitingElement> getStallSiteWaitingElementSet(FlatNode stallSite,
+ HashSet<SESELock> seseLockSet) {
+
+ HashSet<WaitingElement> waitingElementSet = new HashSet<WaitingElement>();
+ Iterator iter = id2cn.entrySet().iterator();
+ while (iter.hasNext()) {
+ Entry entry = (Entry) iter.next();
+ String conflictNodeID = (String) entry.getKey();
+ ConflictNode node = (ConflictNode) entry.getValue();
+
+ if (node.isStallSiteNode() && node.getStallSiteFlatNode().equals(stallSite)) {
+ Set<ConflictEdge> edgeSet = node.getEdgeSet();
+ for (Iterator iter2 = edgeSet.iterator(); iter2.hasNext();) {
+ ConflictEdge conflictEdge = (ConflictEdge) iter2.next();
+
+ for (Iterator<SESELock> seseLockIter = seseLockSet.iterator(); seseLockIter.hasNext();) {
+ SESELock seseLock = seseLockIter.next();
+ if (seseLock.containsConflictNode(node) && seseLock.containsConflictEdge(conflictEdge)) {
+ WaitingElement newElement = new WaitingElement();
+ newElement.setQueueID(seseLock.getID());
+ newElement.setStatus(seseLock.getNodeType(node));
+ if (isFineElement(newElement.getStatus())) {
+ newElement.setDynID(node.getVar().toString());
+ }
+ waitingElementSet.add(newElement);
+ }
+ }
+
+ }
+
+ }
+
+ }
+
+ return waitingElementSet;
+ }
+
public void writeGraph(String graphName, boolean filter) throws java.io.IOException {
graphName = graphName.replaceAll("[\\W]", "");
String attributes = "[";
- attributes += "label=\"ID" + node.getID() + "\\n";
+ attributes += "label=\"" + node.getID() + "\\n";
if (node.isStallSiteNode()) {
attributes += "STALL SITE" + "\\n" + "\"]";
}
if (!addedSet.contains(conflictEdge)) {
- bw.write(" " + u.getID() + "--" + v.getID() + "[label="
- + conflictEdge.toGraphEdgeString() + ",decorate];\n");
+ bw.write("" + u.getID() + "--" + v.getID() + "[label=" + conflictEdge.toGraphEdgeString()
+ + ",decorate];\n");
addedSet.add(conflictEdge);
}
import Analysis.Disjoint.AllocSite;
import Analysis.Disjoint.Effect;
import IR.Flat.FlatNew;
+import IR.Flat.FlatNode;
+import IR.Flat.FlatSESEEnterNode;
+import IR.Flat.TempDescriptor;
public class ConflictNode {
protected Hashtable<AllocSite, Set<Effect>> alloc2strongUpdateEffectSet;
protected int nodeType;
- protected int type;
protected String id;
+ protected FlatNode stallSite;
+ protected TempDescriptor var;
+ protected FlatSESEEnterNode fsen;
public static final int FINE_READ = 0;
public static final int FINE_WRITE = 1;
public static final int INVAR = 0;
public static final int STALLSITE = 1;
+
+ public ConflictNode(String id, int nodeType, TempDescriptor var, FlatNode stallSite){
+ this(id, var, nodeType);
+ this.stallSite=stallSite;
+ }
+
+ public ConflictNode(String id, int nodeType, TempDescriptor var, FlatSESEEnterNode fsen){
+ this(id, var, nodeType);
+ this.fsen=fsen;
+ }
- public ConflictNode(String id, int nodeType) {
+
+ public ConflictNode(String id, TempDescriptor var, int nodeType) {
edgeSet = new HashSet<ConflictEdge>();
// redundant views of access root's
// allocation sites for efficient retrieval
this.id = id;
this.nodeType = nodeType;
+ this.var=var;
}
public void addEffect(AllocSite as, Effect e) {
}
return fnSet;
}
+
+ public TempDescriptor getVar(){
+ return var;
+ }
public Set<ConflictEdge> getEdgeSet() {
return edgeSet;
edgeSet.add(edge);
}
- public int getType() {
- return type;
- }
-
public String getID() {
return id;
}
-
+
+ public FlatNode getStallSiteFlatNode(){
+ return stallSite;
+ }
+
+ public int getSESEIdentifier(){
+ return fsen.getIdentifier();
+ }
+
public boolean equals(Object o) {
if (o == null) {
package Analysis.OoOJava;
+import java.io.BufferedWriter;
+import java.io.FileWriter;
import java.io.IOException;
import java.util.Enumeration;
import java.util.HashSet;
null, // don't do effects analysis again!
null // don't do effects analysis again!
);
-
+writeConflictGraph();
// 10th pass, calculate conflicts with reachability info
calculateConflicts(null, true);
writeConflictGraph();
*/
+ if( state.OOODEBUG ) {
+ try {
+ writeReports( "" );
+ disjointAnalysisTaints.getEffectsAnalysis().writeEffects( "effects.txt" );
+ writeConflictGraph();
+ } catch( IOException e ) {}
+ }
+
}
private void livenessAnalysisBackward(FlatSESEEnterNode fsen, boolean toplevel,
conflictGraph2SESELock.put(conflictGraph, lockSet);
}
+
+ public void writeReports( String timeReport ) throws java.io.IOException {
+
+ BufferedWriter bw = new BufferedWriter( new FileWriter( "mlpReport_summary.txt" ) );
+ bw.write( "MLP Analysis Results\n\n" );
+ bw.write( timeReport+"\n\n" );
+ printSESEHierarchy( bw );
+ bw.write( "\n" );
+ printSESEInfo( bw );
+ bw.close();
+
+ Iterator<Descriptor> methItr = disjointAnalysisTaints.getDescriptorsToAnalyze().iterator();
+ while( methItr.hasNext() ) {
+ MethodDescriptor md = (MethodDescriptor) methItr.next();
+ FlatMethod fm = state.getMethodFlat( md );
+ if (fm!=null) {
+ bw =
+ new BufferedWriter(new FileWriter("mlpReport_" + md.getClassMethodName()
+ + md.getSafeMethodDescriptor() + ".txt"));
+ bw.write("MLP Results for " + md + "\n-------------------\n");
+
+ FlatSESEEnterNode implicitSESE = (FlatSESEEnterNode) fm.getNext(0);
+ if (!implicitSESE.getIsCallerSESEplaceholder() && implicitSESE != rblockRel.getMainSESE()) {
+ System.out.println(implicitSESE + " is not implicit?!");
+ System.exit(-1);
+ }
+ bw.write("Dynamic vars to manage:\n " + implicitSESE.getDynamicVarSet());
+
+ bw.write("\n\nLive-In, Root View\n------------------\n" + fm.printMethod(livenessRootView));
+ bw.write("\n\nVariable Results-Out\n----------------\n" + fm.printMethod(variableResults));
+ bw.write("\n\nNot Available Results-Out\n---------------------\n"
+ + fm.printMethod(notAvailableResults));
+ bw.write("\n\nCode Plans\n----------\n" + fm.printMethod(codePlans));
+ bw.close();
+ }
+ }
+ }
+
+ private void printSESEHierarchy( BufferedWriter bw ) throws java.io.IOException {
+ bw.write( "SESE Hierarchy\n--------------\n" );
+ Iterator<FlatSESEEnterNode> rootItr = rblockRel.getRootSESEs().iterator();
+ while( rootItr.hasNext() ) {
+ FlatSESEEnterNode root = rootItr.next();
+ if( root.getIsCallerSESEplaceholder() ) {
+ if( !root.getChildren().isEmpty() ) {
+ printSESEHierarchyTree( bw, root, 0 );
+ }
+ } else {
+ printSESEHierarchyTree( bw, root, 0 );
+ }
+ }
+ }
+
+ private void printSESEHierarchyTree( BufferedWriter bw,
+ FlatSESEEnterNode fsen,
+ int depth
+ ) throws java.io.IOException {
+ for( int i = 0; i < depth; ++i ) {
+ bw.write( " " );
+ }
+ bw.write( "- "+fsen.getPrettyIdentifier()+"\n" );
+
+ Iterator<FlatSESEEnterNode> childItr = fsen.getChildren().iterator();
+ while( childItr.hasNext() ) {
+ FlatSESEEnterNode fsenChild = childItr.next();
+ printSESEHierarchyTree( bw, fsenChild, depth + 1 );
+ }
+ }
+
+
+ private void printSESEInfo( BufferedWriter bw ) throws java.io.IOException {
+ bw.write("\nSESE info\n-------------\n" );
+ Iterator<FlatSESEEnterNode> rootItr = rblockRel.getRootSESEs().iterator();
+ while( rootItr.hasNext() ) {
+ FlatSESEEnterNode root = rootItr.next();
+ if( root.getIsCallerSESEplaceholder() ) {
+ if( !root.getChildren().isEmpty() ) {
+ printSESEInfoTree( bw, root );
+ }
+ } else {
+ printSESEInfoTree( bw, root );
+ }
+ }
+ }
+
+ private void printSESEInfoTree( BufferedWriter bw,
+ FlatSESEEnterNode fsen
+ ) throws java.io.IOException {
+
+ if( !fsen.getIsCallerSESEplaceholder() ) {
+ bw.write( "SESE "+fsen.getPrettyIdentifier()+" {\n" );
+
+ bw.write( " in-set: "+fsen.getInVarSet()+"\n" );
+ Iterator<TempDescriptor> tItr = fsen.getInVarSet().iterator();
+ while( tItr.hasNext() ) {
+ TempDescriptor inVar = tItr.next();
+ if( fsen.getReadyInVarSet().contains( inVar ) ) {
+ bw.write( " (ready) "+inVar+"\n" );
+ }
+ if( fsen.getStaticInVarSet().contains( inVar ) ) {
+ bw.write( " (static) "+inVar+" from "+
+ fsen.getStaticInVarSrc( inVar )+"\n" );
+ }
+ if( fsen.getDynamicInVarSet().contains( inVar ) ) {
+ bw.write( " (dynamic)"+inVar+"\n" );
+ }
+ }
+
+ bw.write( " Dynamic vars to manage: "+fsen.getDynamicVarSet()+"\n");
+
+ bw.write( " out-set: "+fsen.getOutVarSet()+"\n" );
+ bw.write( "}\n" );
+ }
+
+ Iterator<FlatSESEEnterNode> childItr = fsen.getChildren().iterator();
+ while( childItr.hasNext() ) {
+ FlatSESEEnterNode fsenChild = childItr.next();
+ printSESEInfoTree( bw, fsenChild );
+ }
+ }
}
return false;
}
- private boolean isFineNode(ConflictNode node) {
-
- if (node.getType() < 4) {
- return true;
- }
-
- return false;
-
- }
-
- public ConflictNode getNewNodeCoarseConnectedWithGroup(ConflictEdge newEdge) {
-
- // check whether or not the new node has a fine-grained edges to all
- // current nodes.
-
- ConflictNode newNode;
- if (conflictNodeSet.contains(newEdge.getVertexU())) {
- newNode = newEdge.getVertexV();
- } else if (conflictNodeSet.contains(newEdge.getVertexV())) {
- newNode = newEdge.getVertexU();
- } else {
- return null;
- }
-
- int count = 0;
- Set<ConflictEdge> edgeSet = newNode.getEdgeSet();
- for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
- ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
- if (!conflictEdge.getVertexU().equals(newNode)
- && conflictNodeSet.contains(conflictEdge.getVertexU())
- && isFineNode(conflictEdge.getVertexU())) {
- count++;
- } else if (!conflictEdge.getVertexV().equals(newNode)
- && conflictNodeSet.contains(conflictEdge.getVertexV())
- && isFineNode(conflictEdge.getVertexU())) {
- count++;
- }
- }
-
- if (count == conflictNodeSet.size()) {
- // connected to all current nodes in group
- return newNode;
- }
-
- return null;
-
- }
-
public ConflictNode getNewNodeConnectedWithGroup(ConflictEdge newEdge) {
// check whether or not the new node has a fine-grained edges to all
--- /dev/null
+package Analysis.OoOJava;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+
+public class SESEWaitingQueue {
+ public static final int NORMAL= 0; // enqueue all stuff.
+ public static final int EXCEPTION= 1; // dynamically decide whether a waiting element is enqueued or not.
+
+ private HashMap<Integer, Set<WaitingElement>>mapWaitingElement;
+ private HashMap<Integer, Integer>mapType;
+
+ public SESEWaitingQueue(){
+ mapWaitingElement=new HashMap<Integer, Set<WaitingElement>>();
+ mapType=new HashMap<Integer, Integer>();
+ }
+
+ public void setType(int queueID, int type){
+ mapType.put(new Integer(queueID), new Integer(type));
+ }
+
+ public int getType(int queueID){
+ Integer type=mapType.get(new Integer(queueID));
+ if(type==null){
+ return SESEWaitingQueue.NORMAL;
+ }else{
+ return type.intValue();
+ }
+ }
+
+ public void setWaitingElementSet(int queueID, Set<WaitingElement> set){
+ mapWaitingElement.put(new Integer(queueID), set);
+ }
+
+ public Set<WaitingElement> getWaitingElementSet(int queueID){
+ return mapWaitingElement.get(new Integer(queueID));
+ }
+
+ public Set<Integer> getQueueIDSet(){
+ return mapWaitingElement.keySet();
+ }
+
+ public int getWaitingElementSize(){
+ int size=0;
+ Set<Integer> keySet=mapWaitingElement.keySet();
+ for (Iterator iterator = keySet.iterator(); iterator.hasNext();) {
+ Integer key = (Integer) iterator.next();
+ size+=mapWaitingElement.get(key).size();
+ }
+ return size;
+ }
+}
--- /dev/null
+package Analysis.OoOJava;
+
+import IR.Flat.TempDescriptor;
+
+public class WaitingElement {
+
+ private int queueID;
+ private int status;
+ private String dynID="";
+ private TempDescriptor tempDesc;
+
+ public void setTempDesc(TempDescriptor tempDesc){
+ this.tempDesc=tempDesc;
+ }
+
+ public TempDescriptor getTempDesc(){
+ return tempDesc;
+ }
+
+ public void setQueueID(int queueID) {
+ this.queueID = queueID;
+ }
+
+ public String getDynID(){
+ return dynID;
+ }
+
+ public void setDynID(String dynID){
+ this.dynID=dynID;
+ }
+
+ public int getQueueID() {
+ return queueID;
+ }
+
+ public void setStatus(int status) {
+ this.status = status;
+ }
+
+ public int getStatus() {
+ return status;
+ }
+
+ public boolean equals(Object o) {
+
+ if (o == null) {
+ return false;
+ }
+
+ if (!(o instanceof WaitingElement)) {
+ return false;
+ }
+
+ WaitingElement in = (WaitingElement) o;
+
+ if (queueID == in.getQueueID() && status == in.getStatus() && dynID.equals(in.getDynID()) ) {
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+
+ public String toString() {
+ return "[waitingID=" + queueID + " status=" + status + " dynID="
+ + dynID + "]";
+ }
+
+ public int hashCode() {
+
+ int hash = 1;
+
+ hash = hash * 31 + queueID;
+
+ hash += status;
+
+ hash += dynID.hashCode();
+
+ return hash;
+
+ }
+
+}
\ No newline at end of file
public boolean DISJOINTDEBUGSCHEDULING=false;
public boolean OOOJAVA=false;
+ public boolean OOODEBUG=false;
public boolean OPTIONAL=false;
state.OOOJAVA = true;
state.DISJOINT = true;
- }else if (option.equals("-help")) {
+ } else if (option.equals("-ooodebug") ){
+ state.OOODEBUG = true;
+ } else if (option.equals("-help")) {
System.out.println("-classlibrary classlibrarydirectory -- directory where classlibrary is located");
System.out.println("-selfloop task -- this task doesn't self loop its parameters forever");
System.out.println("-dir outputdirectory -- output code in outputdirectory");