From: jjenista Date: Tue, 4 Oct 2011 23:49:19 +0000 (+0000) Subject: Bug fix, subtle errors in exist pred hashcode, and a cycle pred.hashCode to state... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4bed1bed14ed723994ccc736398a38d24e61580e;p=IRC.git Bug fix, subtle errors in exist pred hashcode, and a cycle pred.hashCode to state.hashCode and back --- diff --git a/Robust/src/Analysis/Disjoint/ExistPred.java b/Robust/src/Analysis/Disjoint/ExistPred.java index d1aef27b..87c5e842 100644 --- a/Robust/src/Analysis/Disjoint/ExistPred.java +++ b/Robust/src/Analysis/Disjoint/ExistPred.java @@ -48,6 +48,10 @@ public class ExistPred extends Canonical { // The reach state may be null--if not the predicate is // satisfied when the edge exists AND it has the state. protected Integer n_hrnID; + + // the preds on this state are irrelevant, so always strip them off + // when we store it in this ExistPred to make sure it equals other + // ExistPred objects with the same ne_state, preds ignored. protected ReachState ne_state; // An edge existence predicate is satisfied if the elements @@ -121,7 +125,7 @@ public class ExistPred extends Canonical { ReachState state) { assert hrnID != null; this.n_hrnID = hrnID; - this.ne_state = state; + this.ne_state = removePreds( state ); this.predType = TYPE_NODE; e_tdSrc = null; e_hrnSrcID = null; @@ -186,7 +190,7 @@ public class ExistPred extends Canonical { this.e_hrnDstID = hrnDstID; this.e_type = type; this.e_field = field; - this.ne_state = state; + this.ne_state = removePreds( state ); this.e_taint = taint; this.predType = TYPE_EDGE; n_hrnID = null; @@ -226,6 +230,11 @@ public class ExistPred extends Canonical { + private ReachState removePreds( ReachState state ) { + return state == null ? null : Canonical.attach( state, ExistPredSet.factory() ); + } + + // only consider the subest of the caller elements that // are reachable by callee when testing predicates--if THIS @@ -435,7 +444,7 @@ public class ExistPred extends Canonical { if( pred.ne_state != null ) { return false; } - } else if( !ne_state.equals(pred.ne_state) ) { + } else if( !ne_state.equalsIgnorePreds(pred.ne_state) ) { return false; } @@ -508,6 +517,7 @@ public class ExistPred extends Canonical { public int hashCodeSpecific() { + if( predType == TYPE_TRUE ) { return 1; } @@ -516,7 +526,7 @@ public class ExistPred extends Canonical { int hash = n_hrnID.intValue()*17; if( ne_state != null ) { - hash ^= ne_state.hashCode(); + hash ^= ne_state.hashCodeNoPreds(); } return hash; @@ -536,17 +546,17 @@ public class ExistPred extends Canonical { } else { hash ^= e_hrnSrcID.hashCode()*11; if( e_srcOutCalleeContext ) { - hash ^= 0xf1aeb; + hash ^= 0x01; } if( e_srcOutCallerContext ) { - hash ^= 0x875d; + hash ^= 0x80; } } hash += e_hrnDstID.hashCode(); if( ne_state != null ) { - hash ^= ne_state.hashCode(); + hash ^= ne_state.hashCodeNoPreds(); } if( e_taint != null ) { diff --git a/Robust/src/Analysis/Disjoint/HeapRegionNode.java b/Robust/src/Analysis/Disjoint/HeapRegionNode.java index c38617c9..93621d23 100644 --- a/Robust/src/Analysis/Disjoint/HeapRegionNode.java +++ b/Robust/src/Analysis/Disjoint/HeapRegionNode.java @@ -94,7 +94,6 @@ public class HeapRegionNode extends RefSrcNode { // fixed point, so use this method to determine if // a node is "equal" to some previous visit, basically public boolean equalsIncludingAlphaAndPreds(HeapRegionNode hrn) { - return equals(hrn) && alpha.equals(hrn.alpha) && preds.equals(hrn.preds); diff --git a/Robust/src/Analysis/Disjoint/ReachGraph.java b/Robust/src/Analysis/Disjoint/ReachGraph.java index 2b0e935d..3e5a0433 100644 --- a/Robust/src/Analysis/Disjoint/ReachGraph.java +++ b/Robust/src/Analysis/Disjoint/ReachGraph.java @@ -3950,7 +3950,7 @@ public class ReachGraph { - static boolean dbgEquals = false; + static public boolean dbgEquals = false; // it is necessary in the equals() member functions @@ -4176,9 +4176,7 @@ public class ReachGraph { // there is an edge in the right place with the right field, // but do they have the same attributes? - if( edgeA.getBeta().equals(edgeB.getBeta() ) && - edgeA.equalsPreds(edgeB) - ) { + if( edgeA.equalsIncludingBetaPredsTaints( edgeB ) ) { edgeFound = true; } } diff --git a/Robust/src/Analysis/Disjoint/ReachState.java b/Robust/src/Analysis/Disjoint/ReachState.java index 5cea5b85..36897df2 100644 --- a/Robust/src/Analysis/Disjoint/ReachState.java +++ b/Robust/src/Analysis/Disjoint/ReachState.java @@ -137,6 +137,11 @@ public class ReachState extends Canonical { } + public int hashCodeNoPreds() { + return reachTuples.hashCode(); + } + + public boolean equalsIgnorePreds(Object o) { if( o == null ) { return false; diff --git a/Robust/src/Analysis/Disjoint/RefEdge.java b/Robust/src/Analysis/Disjoint/RefEdge.java index 9dc4faa6..457e752e 100644 --- a/Robust/src/Analysis/Disjoint/RefEdge.java +++ b/Robust/src/Analysis/Disjoint/RefEdge.java @@ -2,6 +2,8 @@ package Analysis.Disjoint; import IR.*; import IR.Flat.*; +import java.util.*; + public class RefEdge { @@ -104,10 +106,19 @@ public class RefEdge { return false; } - // Equality of edges is only valid within a graph, so - // compare src and dst by reference - if( !(src == edge.src) || - !(dst == edge.dst) ) { + if( src instanceof VariableNode ) { + VariableNode vsrc = (VariableNode) src; + if( !vsrc.equals( (VariableNode) edge.src ) ) { + return false; + } + } else { + HeapRegionNode hsrc = (HeapRegionNode) src; + if( !hsrc.equalsIncludingAlphaAndPreds( (HeapRegionNode) edge.src ) ) { + return false; + } + } + + if( !dst.equalsIncludingAlphaAndPreds( edge.dst ) ) { return false; } diff --git a/Robust/src/Benchmarks/oooJava/barneshut/Barneshut.java b/Robust/src/Benchmarks/oooJava/barneshut/Barneshut.java index 7bc6e6a8..04b08a70 100644 --- a/Robust/src/Benchmarks/oooJava/barneshut/Barneshut.java +++ b/Robust/src/Benchmarks/oooJava/barneshut/Barneshut.java @@ -243,20 +243,35 @@ public void ComputeCenterOfMass(ArrayIndexedGraph octree, ArrayIndexedNode roo long start_time = System.currentTimeMillis(); for (int step = 0; step < local_ntimesteps; step++) { // time-step the system ComputeCenterAndDiameter(); - ArrayIndexedGraph octree = new ArrayIndexedGraph(8); + ArrayIndexedGraph octree = disjoint AIG new ArrayIndexedGraph(8); ArrayIndexedNode root = octree.createNode(new OctTreeNodeData(centerx, centery, centerz)); // create the tree's root octree.addNode(root); double radius = diameter * 0.5; + + genreach b0; + for (int i = 0; i < local_nbodies; i++) { Insert(octree, root, body[i], radius); // grow the tree by inserting each body body[i].root=root; } curr = 0; + + + genreach b1; + + // summarize subtree info in each internal node (plus restructure tree and sort bodies for performance reasons) ComputeCenterOfMass(octree, root); + + genreach b2; + + sese force { + + genreach b3; + for(int i=0; i < local_nbodies; i++){ // compute the acceleration of each body (consumes most of the total runtime) // n.ComputeForce(octree, root, diameter, itolsq, step, dthf, epssq); @@ -266,6 +281,7 @@ public void ComputeCenterOfMass(ArrayIndexedGraph octree, ArrayIndexedNode roo double dt=dthf; double ep=epssq; sese parallel{ + genreach intoPar; eachbody.ComputeForce(octree, di, it, step, dt, ep); } } @@ -277,6 +293,7 @@ public void ComputeCenterOfMass(ArrayIndexedGraph octree, ArrayIndexedNode roo } // end of time step + long end_time=System.currentTimeMillis(); if (isFirstRun) {