changes.
authoryeom <yeom>
Mon, 18 Jan 2010 19:56:23 +0000 (19:56 +0000)
committeryeom <yeom>
Mon, 18 Jan 2010 19:56:23 +0000 (19:56 +0000)
Robust/src/Analysis/MLP/ConflictGraph.java
Robust/src/Analysis/MLP/LiveInNode.java
Robust/src/Analysis/MLP/MLPAnalysis.java
Robust/src/Analysis/MLP/SESEEffectsSet.java
Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java
Robust/src/IR/Flat/BuildCode.java

index 138fe11e59d25b1f135eab686aa487ca941404ce..ad9df31e825cf4c565eeaff367dfe24884ee0d6f 100644 (file)
@@ -57,12 +57,13 @@ public class ConflictGraph {
        }
 
        private boolean hasSameReadEffects(ConflictNode nodeA, ConflictNode nodeB) {
-               
+
                StallSiteNode stallSiteNode = null;
                LiveInNode liveInNode = null;
-               
-               if(nodeA instanceof StallSiteNode && nodeB instanceof StallSiteNode){
-                       return hasSameReadEffects((StallSiteNode)nodeA,(StallSiteNode)nodeB);
+
+               if (nodeA instanceof StallSiteNode && nodeB instanceof StallSiteNode) {
+                       return hasSameReadEffects((StallSiteNode) nodeA,
+                                       (StallSiteNode) nodeB);
                }
 
                if (nodeA instanceof StallSiteNode) {
@@ -90,51 +91,56 @@ public class ConflictGraph {
                Set<SESEEffectsKey> readSetA = linA.getReadEffectsSet();
                Set<SESEEffectsKey> readSetB = linB.getReadEffectsSet();
 
-               boolean returnValue=true;
+               boolean returnValue = true;
                for (Iterator iterator = readSetA.iterator(); iterator.hasNext();) {
                        SESEEffectsKey seseEffectsKey = (SESEEffectsKey) iterator.next();
 
                        for (Iterator iterator2 = readSetB.iterator(); iterator2.hasNext();) {
                                SESEEffectsKey opr = (SESEEffectsKey) iterator2.next();
-                               if (!(seseEffectsKey.getHRNUniqueId()
-                                               .equals(opr.getHRNUniqueId())
-                                               && seseEffectsKey.getFieldDescriptor().equals(
-                                                               opr.getFieldDescriptor()))) {
-                                       returnValue=false;
+                               if (!(seseEffectsKey.getHRNUniqueId().equals(
+                                               opr.getHRNUniqueId()) && seseEffectsKey
+                                               .getFieldDescriptor().equals(opr.getFieldDescriptor()))) {
+                                       returnValue = false;
                                }
                        }
                }
                return returnValue;
        }
-       
+
        private boolean hasSameReadEffects(StallSiteNode ssnA, StallSiteNode ssnB) {
-               
+
                HashSet<Effect> effectSetA = ssnA.getStallSite().getEffectSet();
                HashSet<HeapRegionNode> nodeSetA = ssnA.getStallSite().getHRNSet();
                HashSet<Effect> effectSetB = ssnB.getStallSite().getEffectSet();
                HashSet<HeapRegionNode> nodeSetB = ssnA.getStallSite().getHRNSet();
-               boolean returnValue=true;
-               
+               boolean returnValue = true;
+
                for (Iterator iteratorA = effectSetA.iterator(); iteratorA.hasNext();) {
                        Effect effectKeyA = (Effect) iteratorA.next();
-                       for (Iterator iterator2A = nodeSetA.iterator(); iterator2A.hasNext();) {
+                       for (Iterator iterator2A = nodeSetA.iterator(); iterator2A
+                                       .hasNext();) {
                                HeapRegionNode hrnA = (HeapRegionNode) iterator2A.next();
-                               
-                               for (Iterator iteratorB = effectSetB.iterator(); iteratorB.hasNext();) {
+
+                               for (Iterator iteratorB = effectSetB.iterator(); iteratorB
+                                               .hasNext();) {
                                        Effect effectKeyB = (Effect) iteratorB.next();
-                                       for (Iterator iterator2B = nodeSetB.iterator(); iterator2B.hasNext();) {
-                                               HeapRegionNode hrnB = (HeapRegionNode) iterator2B.next();
-                                               
-                                               if(!(hrnA.getGloballyUniqueIdentifier().equals(hrnB.getGloballyUniqueIdentifier()) && effectKeyA.getField().equals(effectKeyB.getField()))){
-                                                       returnValue=false;
+                                       for (Iterator iterator2B = nodeSetB.iterator(); iterator2B
+                                                       .hasNext();) {
+                                               HeapRegionNode hrnB = (HeapRegionNode) iterator2B
+                                                               .next();
+
+                                               if (!(hrnA.getGloballyUniqueIdentifier().equals(
+                                                               hrnB.getGloballyUniqueIdentifier()) && effectKeyA
+                                                               .getField().equals(effectKeyB.getField()))) {
+                                                       returnValue = false;
                                                }
                                        }
                                }
-                               
+
                        }
-                       
+
                }
-               
+
                return returnValue;
        }
 
@@ -144,11 +150,11 @@ public class ConflictGraph {
                HashSet<HeapRegionNode> nodeSetA = ssnA.getStallSite().getHRNSet();
 
                Set<SESEEffectsKey> readSetB = linB.getReadEffectsSet();
-               if(readSetB==null){
+               if (readSetB == null) {
                        return false;
                }
-               
-               boolean returnValue=true;
+
+               boolean returnValue = true;
 
                for (Iterator iterator = effectSetA.iterator(); iterator.hasNext();) {
                        Effect effectKey = (Effect) iterator.next();
@@ -161,10 +167,9 @@ public class ConflictGraph {
                                                        .next();
 
                                        if (!(seseEffectsKey.getHRNUniqueId().equals(
-                                                       hrn.getGloballyUniqueIdentifier())
-                                                       && seseEffectsKey.getFieldDescriptor().equals(
-                                                                       effectKey.getField()))) {
-                                               returnValue=false;
+                                                       hrn.getGloballyUniqueIdentifier()) && seseEffectsKey
+                                                       .getFieldDescriptor().equals(effectKey.getField()))) {
+                                               returnValue = false;
                                        }
 
                                }
@@ -388,52 +393,81 @@ public class ConflictGraph {
 
        }
 
+       private boolean hasStrongUpdate(SESEEffectsKey writeEffect,
+                       Set<SESEEffectsKey> strongUpdateSet) {
+               
+               if(strongUpdateSet!=null){
+                       Iterator<SESEEffectsKey> strongUpdateIter = strongUpdateSet.iterator();
+                       while (strongUpdateIter.hasNext()) {
+                               SESEEffectsKey strongEffect = (SESEEffectsKey) strongUpdateIter
+                                               .next();
+
+                               if (strongEffect.getHRNUniqueId().equals(
+                                               writeEffect.getHRNUniqueId())
+                                               && strongEffect.getFieldDescriptor().equals(
+                                                               writeEffect.getFieldDescriptor())) {
+                                       return true;
+                               }
+                       }
+               }
+
+               return false;
+       }
+
        private boolean isWriteConflicts(LiveInNode nodeA, LiveInNode nodeB) {
 
                Set<SESEEffectsKey> readEffectsSetA = nodeA.getReadEffectsSet();
                Set<SESEEffectsKey> writeEffectsSetA = nodeA.getWriteEffectsSet();
+               Set<SESEEffectsKey> strongUpdateSetA = nodeA.getStrongUpdateSet();
+
                Set<SESEEffectsKey> readEffectsSetB = nodeB.getReadEffectsSet();
                Set<SESEEffectsKey> writeEffectsSetB = nodeB.getWriteEffectsSet();
-
+               Set<SESEEffectsKey> strongUpdateSetB = nodeB.getStrongUpdateSet();
+               
                // if node A has write effects on reading/writing regions of node B
                if (writeEffectsSetA != null) {
                        Iterator<SESEEffectsKey> writeIterA = writeEffectsSetA.iterator();
                        while (writeIterA.hasNext()) {
                                SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIterA
                                                .next();
-                               String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
-                               String writeFieldName = seseEffectsKey.getFieldDescriptor();
 
-                               if (readEffectsSetB != null) {
-                                       Iterator<SESEEffectsKey> readIterB = readEffectsSetB
-                                                       .iterator();
-                                       while (readIterB.hasNext()) {
-                                               SESEEffectsKey readingEffect = (SESEEffectsKey) readIterB
-                                                               .next();
+                               if (!hasStrongUpdate(seseEffectsKey, strongUpdateSetA)) {
+
+                                       String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
+                                       String writeFieldName = seseEffectsKey.getFieldDescriptor();
 
-                                               if (readingEffect.getHRNUniqueId().equals(
-                                                               writeHeapRegionID)
-                                                               && readingEffect.getFieldDescriptor().equals(
-                                                                               writeFieldName)) {
-                                                       return true;
+                                       if (readEffectsSetB != null) {
+                                               Iterator<SESEEffectsKey> readIterB = readEffectsSetB
+                                                               .iterator();
+                                               while (readIterB.hasNext()) {
+                                                       SESEEffectsKey readingEffect = (SESEEffectsKey) readIterB
+                                                                       .next();
+
+                                                       if (readingEffect.getHRNUniqueId().equals(
+                                                                       writeHeapRegionID)
+                                                                       && readingEffect.getFieldDescriptor()
+                                                                                       .equals(writeFieldName)) {
+                                                               return true;
+                                                       }
                                                }
                                        }
-                               }
 
-                               if (writeEffectsSetB != null) {
-                                       Iterator<SESEEffectsKey> writeIterB = writeEffectsSetB
-                                                       .iterator();
-                                       while (writeIterB.hasNext()) {
-                                               SESEEffectsKey writingEffect = (SESEEffectsKey) writeIterB
-                                                               .next();
+                                       if (writeEffectsSetB != null) {
+                                               Iterator<SESEEffectsKey> writeIterB = writeEffectsSetB
+                                                               .iterator();
+                                               while (writeIterB.hasNext()) {
+                                                       SESEEffectsKey writingEffect = (SESEEffectsKey) writeIterB
+                                                                       .next();
 
-                                               if (writingEffect.getHRNUniqueId().equals(
-                                                               writeHeapRegionID)
-                                                               && writingEffect.getFieldDescriptor().equals(
-                                                                               writeFieldName)) {
-                                                       return true;
+                                                       if (writingEffect.getHRNUniqueId().equals(
+                                                                       writeHeapRegionID)
+                                                                       && writingEffect.getFieldDescriptor()
+                                                                                       .equals(writeFieldName)) {
+                                                               return true;
+                                                       }
                                                }
                                        }
+
                                }
 
                        }
@@ -445,35 +479,39 @@ public class ConflictGraph {
                        while (writeIterB.hasNext()) {
                                SESEEffectsKey seseEffectsKey = (SESEEffectsKey) writeIterB
                                                .next();
-                               String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
-                               String writeFieldName = seseEffectsKey.getFieldDescriptor();
 
-                               if (readEffectsSetA != null) {
-                                       Iterator<SESEEffectsKey> readIterA = readEffectsSetA
-                                                       .iterator();
-                                       while (readIterA.hasNext()) {
-                                               SESEEffectsKey readingEffect = (SESEEffectsKey) readIterA
-                                                               .next();
-                                               if (readingEffect.getHRNUniqueId().equals(
-                                                               writeHeapRegionID)
-                                                               && readingEffect.getFieldDescriptor().equals(
-                                                                               writeFieldName)) {
-                                                       return true;
+                               if (!hasStrongUpdate(seseEffectsKey, strongUpdateSetB)) {
+
+                                       String writeHeapRegionID = seseEffectsKey.getHRNUniqueId();
+                                       String writeFieldName = seseEffectsKey.getFieldDescriptor();
+
+                                       if (readEffectsSetA != null) {
+                                               Iterator<SESEEffectsKey> readIterA = readEffectsSetA
+                                                               .iterator();
+                                               while (readIterA.hasNext()) {
+                                                       SESEEffectsKey readingEffect = (SESEEffectsKey) readIterA
+                                                                       .next();
+                                                       if (readingEffect.getHRNUniqueId().equals(
+                                                                       writeHeapRegionID)
+                                                                       && readingEffect.getFieldDescriptor()
+                                                                                       .equals(writeFieldName)) {
+                                                               return true;
+                                                       }
                                                }
                                        }
-                               }
 
-                               if (writeEffectsSetA != null) {
-                                       Iterator<SESEEffectsKey> writeIterA = writeEffectsSetA
-                                                       .iterator();
-                                       while (writeIterA.hasNext()) {
-                                               SESEEffectsKey writingEffect = (SESEEffectsKey) writeIterA
-                                                               .next();
-                                               if (writingEffect.getHRNUniqueId().equals(
-                                                               writeHeapRegionID)
-                                                               && writingEffect.getFieldDescriptor().equals(
-                                                                               writeFieldName)) {
-                                                       return true;
+                                       if (writeEffectsSetA != null) {
+                                               Iterator<SESEEffectsKey> writeIterA = writeEffectsSetA
+                                                               .iterator();
+                                               while (writeIterA.hasNext()) {
+                                                       SESEEffectsKey writingEffect = (SESEEffectsKey) writeIterA
+                                                                       .next();
+                                                       if (writingEffect.getHRNUniqueId().equals(
+                                                                       writeHeapRegionID)
+                                                                       && writingEffect.getFieldDescriptor()
+                                                                                       .equals(writeFieldName)) {
+                                                               return true;
+                                                       }
                                                }
                                        }
                                }
@@ -483,6 +521,36 @@ public class ConflictGraph {
                return false;
        }
 
+       private boolean isSelfConflicted(LiveInNode liveInNode) {
+
+               int strongUpdateCount = 0;
+
+               if (liveInNode.getWriteEffectsSet() != null
+                               && liveInNode.getWriteEffectsSet().size() > 0) {
+
+                       Set<SESEEffectsKey> strongUpdateSet = liveInNode
+                                       .getStrongUpdateSet();
+
+                       Iterator<SESEEffectsKey> writeIter = liveInNode
+                                       .getWriteEffectsSet().iterator();
+                       while (writeIter.hasNext()) {
+                               SESEEffectsKey writeEffect = (SESEEffectsKey) writeIter.next();
+                               if (hasStrongUpdate(writeEffect, strongUpdateSet)) {
+                                       strongUpdateCount++;
+                               }
+                       }
+
+                       if (liveInNode.getWriteEffectsSet().size() == strongUpdateCount) {
+                               return false;
+                       }else{
+                               return true;
+                       }
+
+               }
+
+               return false;
+       }
+
        public void analyzePossibleConflicts(Set<String> analyzedIDSet,
                        ConflictNode currentNode) {
 
@@ -491,15 +559,17 @@ public class ConflictGraph {
                // examine the case where self-edge exists
                if (currentNode instanceof LiveInNode) {
                        LiveInNode liveInNode = (LiveInNode) currentNode;
-                       // Set<SESEEffectsSet> writeSet=liveInNode.getWriteEffectsSet();
-
-                       if (liveInNode.getWriteEffectsSet() != null
-                                       && liveInNode.getWriteEffectsSet().size() > 0) {
+//                     if (liveInNode.getWriteEffectsSet() != null
+//                                     && liveInNode.getWriteEffectsSet().size() > 0) {
+//                             addConflictEdge(ConflictEdge.FINE_GRAIN_EDGE, currentNode,
+//                                             currentNode);
+//                     }
+                       if(isSelfConflicted(liveInNode)){                               
                                addConflictEdge(ConflictEdge.FINE_GRAIN_EDGE, currentNode,
                                                currentNode);
                        }
+                       
                }
-               //
 
                Set<Entry<String, ConflictNode>> set = id2cn.entrySet();
                for (Iterator iterator = set.iterator(); iterator.hasNext();) {
@@ -619,13 +689,14 @@ public class ConflictGraph {
 
        public void addLiveInNode(TempDescriptor td, Set<HeapRegionNode> hrnSet,
                        FlatSESEEnterNode fsen, Set<SESEEffectsKey> readEffectsSet,
-                       Set<SESEEffectsKey> writeEffectsSet, Set<Set> reachabilitySet) {
+                       Set<SESEEffectsKey> writeEffectsSet,
+                       Set<SESEEffectsKey> strongUpdateSet, Set<Set> reachabilitySet) {
 
                String liveinNodeID = td + "_" + fsen.getIdentifier();
 
                LiveInNode newNode = new LiveInNode(liveinNodeID, td, hrnSet,
-                               readEffectsSet, writeEffectsSet, reachabilitySet, fsen
-                                               .getIdentifier());
+                               readEffectsSet, writeEffectsSet, strongUpdateSet,
+                               reachabilitySet, fsen.getIdentifier());
                id2cn.put(liveinNodeID, newNode);
 
        }
@@ -653,13 +724,14 @@ public class ConflictGraph {
 
                return resultSet;
        }
-       
-       public Set<WaitingElement> getStallSiteWaitingElementSet(ParentChildConflictsMap conflictsMap, HashSet<SESELock> seseLockSet){
-               
+
+       public Set<WaitingElement> getStallSiteWaitingElementSet(
+                       ParentChildConflictsMap conflictsMap, HashSet<SESELock> seseLockSet) {
+
                HashSet<WaitingElement> waitingElementSet = new HashSet<WaitingElement>();
                Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
                Collection<StallSite> stallSites = conflictsMap.getStallMap().values();
-               
+
                for (Iterator iterator = stallSites.iterator(); iterator.hasNext();) {
 
                        StallSite stallSite = (StallSite) iterator.next();
@@ -677,10 +749,10 @@ public class ConflictGraph {
                                                                .hasNext();) {
                                                        ConflictEdge conflictEdge = (ConflictEdge) iter2
                                                                        .next();
-                                                       
-                                                       int type=-1;
+
+                                                       int type = -1;
                                                        HashSet<Integer> allocSet = new HashSet<Integer>();
-                                                       
+
                                                        if (conflictEdge.getType() == ConflictEdge.COARSE_GRAIN_EDGE) {
                                                                if (isReadOnly(node)) {
                                                                        type = 2; // coarse read
@@ -693,38 +765,43 @@ public class ConflictGraph {
                                                                allocSet.addAll(getAllocSet(conflictEdge
                                                                                .getVertexV()));
 
-                                                       } else if(conflictEdge.getType() == ConflictEdge.FINE_GRAIN_EDGE){// it is fine-grain edge
+                                                       } else if (conflictEdge.getType() == ConflictEdge.FINE_GRAIN_EDGE) {// it
+                                                                                                                                                                                               // is
+                                                                                                                                                                                               // fine-grain
+                                                                                                                                                                                               // edge
                                                                allocSet.addAll(getAllocSet(node));
                                                                if (isReadOnly(node)) {
-                                                                       //fine-grain read
-                                                                       type=0;
+                                                                       // fine-grain read
+                                                                       type = 0;
                                                                } else {
-                                                                       //fine-grain write
-                                                                       type=1;
+                                                                       // fine-grain write
+                                                                       type = 1;
                                                                }
                                                        }
-                                                       
-                                                       if(type>-1){
-                                                                for (Iterator<SESELock> seseLockIter = seseLockSet.iterator(); seseLockIter.hasNext();) {
-                                                                        SESELock seseLock=seseLockIter.next();
-                                                                        if(seseLock.containsConflictNode(stallSiteNode)){
-                                                                                WaitingElement newElement=new WaitingElement();
-                                                                                newElement.setAllocList(allocSet);
-                                                                                newElement.setWaitingID(seseLock.getID());
-                                                                                newElement.setStatus(type);
-                                                                                waitingElementSet.add(newElement);
-                                                                        }
-                                                                }
+
+                                                       if (type > -1) {
+                                                               for (Iterator<SESELock> seseLockIter = seseLockSet
+                                                                               .iterator(); seseLockIter.hasNext();) {
+                                                                       SESELock seseLock = seseLockIter.next();
+                                                                       if (seseLock
+                                                                                       .containsConflictNode(stallSiteNode)) {
+                                                                               WaitingElement newElement = new WaitingElement();
+                                                                               newElement.setAllocList(allocSet);
+                                                                               newElement.setWaitingID(seseLock
+                                                                                               .getID());
+                                                                               newElement.setStatus(type);
+                                                                               waitingElementSet.add(newElement);
+                                                                       }
+                                                               }
                                                        }
 
                                                }
                                        }
                                }
                        }
-                       
+
                }
-               
-               
+
                return waitingElementSet;
        }
 
@@ -853,7 +930,7 @@ public class ConflictGraph {
                        HashSet<SESELock> seseLockSet) {
 
                HashSet<WaitingElement> waitingElementSet = new HashSet<WaitingElement>();
-               
+
                Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
                Iterator<Entry<String, ConflictNode>> i = s.iterator();
 
@@ -864,16 +941,16 @@ public class ConflictGraph {
                        if (node instanceof LiveInNode) {
                                LiveInNode liveInNode = (LiveInNode) node;
                                if (liveInNode.getSESEIdentifier() == seseID) {
-                                       
+
                                        HashSet<ConflictEdge> edgeSet = liveInNode.getEdgeSet();
 
                                        for (Iterator iterator = edgeSet.iterator(); iterator
                                                        .hasNext();) {
                                                ConflictEdge conflictEdge = (ConflictEdge) iterator
                                                                .next();
-                                               int type=-1;
+                                               int type = -1;
                                                HashSet<Integer> allocSet = new HashSet<Integer>();
-                                               
+
                                                if (conflictEdge.getType() == ConflictEdge.COARSE_GRAIN_EDGE) {
                                                        if (isReadOnly(node)) {
                                                                type = 2; // coarse read
@@ -886,29 +963,33 @@ public class ConflictGraph {
                                                        allocSet.addAll(getAllocSet(conflictEdge
                                                                        .getVertexV()));
 
-                                               } else if(conflictEdge.getType() == ConflictEdge.FINE_GRAIN_EDGE){// it is fine-grain edge
+                                               } else if (conflictEdge.getType() == ConflictEdge.FINE_GRAIN_EDGE) {// it
+                                                                                                                                                                                       // is
+                                                                                                                                                                                       // fine-grain
+                                                                                                                                                                                       // edge
                                                        allocSet.addAll(getAllocSet(node));
                                                        if (isReadOnly(node)) {
-                                                               //fine-grain read
-                                                               type=0;
+                                                               // fine-grain read
+                                                               type = 0;
                                                        } else {
-                                                               //fine-grain write
-                                                               type=1;
+                                                               // fine-grain write
+                                                               type = 1;
                                                        }
                                                }
-                                               
-                                               if(type>-1){
-                                                       
-                                                        for (Iterator<SESELock> seseLockIter = seseLockSet.iterator(); seseLockIter.hasNext();) {
-                                                                SESELock seseLock=seseLockIter.next();
-                                                                if(seseLock.containsConflictNode(liveInNode)){
-                                                                        WaitingElement newElement=new WaitingElement();
-                                                                        newElement.setAllocList(allocSet);
-                                                                        newElement.setWaitingID(seseLock.getID());
-                                                                        newElement.setStatus(type);
-                                                                        waitingElementSet.add(newElement);
-                                                                }
-                                                        }
+
+                                               if (type > -1) {
+
+                                                       for (Iterator<SESELock> seseLockIter = seseLockSet
+                                                                       .iterator(); seseLockIter.hasNext();) {
+                                                               SESELock seseLock = seseLockIter.next();
+                                                               if (seseLock.containsConflictNode(liveInNode)) {
+                                                                       WaitingElement newElement = new WaitingElement();
+                                                                       newElement.setAllocList(allocSet);
+                                                                       newElement.setWaitingID(seseLock.getID());
+                                                                       newElement.setStatus(type);
+                                                                       waitingElementSet.add(newElement);
+                                                               }
+                                                       }
                                                }
                                        }
 
@@ -1024,7 +1105,9 @@ public class ConflictGraph {
                        for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
                                HeapRegionNode hrn = (HeapRegionNode) iterator.next();
                                // allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
-                               returnSet.add(new Integer(hrn.getAllocationSite().getID()));
+                               if (hrn.getAllocationSite() != null) {
+                                       returnSet.add(new Integer(hrn.getAllocationSite().getID()));
+                               }
                        }
                } else {
                        LiveInNode liveInNode = (LiveInNode) node;
@@ -1032,7 +1115,9 @@ public class ConflictGraph {
                        for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
                                HeapRegionNode hrn = (HeapRegionNode) iterator.next();
                                // allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
-                               returnSet.add(new Integer(hrn.getAllocationSite().getID()));
+                               if (hrn.getAllocationSite() != null) {
+                                       returnSet.add(new Integer(hrn.getAllocationSite().getID()));
+                               }
                        }
                }
 
index 1923ce651bb886afffff1aada6a9ee4fe1e14cde..fc556c53917138795a1e81c73f0a8f0f8e010638 100644 (file)
@@ -11,17 +11,19 @@ public class LiveInNode extends ConflictNode {
 
        Set<SESEEffectsKey> readEffectsSet;
        Set<SESEEffectsKey> writeEffectsSet;
+       Set<SESEEffectsKey> strongUpdateSet;
        Set<HeapRegionNode> hrnSet;
        int seseID;
 
        public LiveInNode(String id, TempDescriptor td, Set<HeapRegionNode> hrnSet,
                        Set<SESEEffectsKey> readEffectsSet,
-                       Set<SESEEffectsKey> writeEffectsSet, Set<Set> reachabilitySet, int seseID) {
+                       Set<SESEEffectsKey> writeEffectsSet, Set<SESEEffectsKey> strongUpdateSet, Set<Set> reachabilitySet, int seseID) {
                this.hrnSet = hrnSet;
                this.id = id;
                this.td = td;
                this.readEffectsSet = readEffectsSet;
                this.writeEffectsSet = writeEffectsSet;
+               this.strongUpdateSet=strongUpdateSet;
                this.reachabilitySet = reachabilitySet;
                this.seseID=seseID;
        }
@@ -37,6 +39,10 @@ public class LiveInNode extends ConflictNode {
        public Set<SESEEffectsKey> getWriteEffectsSet() {
                return writeEffectsSet;
        }
+       
+       public Set<SESEEffectsKey> getStrongUpdateSet(){
+               return strongUpdateSet;
+       }
 
        public void addReadEffectsSet(Set<SESEEffectsKey> newReadEffectsSet) {
                if (newReadEffectsSet != null) {
index b4ef4021181c0fe8815d092e87ac4e1bd2d63a7d..eb7e1c85febba457c29dc5643f6513df4720ed51 100644 (file)
@@ -1539,9 +1539,16 @@ public class MLPAnalysis {
                                                while (referSetIter.hasNext()) {
                                                        TempDescriptor tempDescriptor = (TempDescriptor) referSetIter
                                                                        .next();
-                                                       currentSESE.writeEffects(tempDescriptor, field
-                                                                       .getSymbol(), dst.getType(), accessHRN,
-                                                                       strongUpdate);
+                                                       SESEEffectsSet effectSet=currentSESE.getSeseEffectsSet();
+                                                       ///// if write effects occurs through variable which was strongly updated, ignore it?
+                                                       if(effectSet.getStrongUpdateSet(tempDescriptor)!=null && effectSet.getStrongUpdateSet(tempDescriptor).size()>0){
+//                                                             System.out.println("not write effect?");
+                                                       }else{
+                                                               currentSESE.writeEffects(tempDescriptor, field
+                                                                               .getSymbol(), dst.getType(), accessHRN,
+                                                                               strongUpdate);
+                                                       }
+                                                       /////
                                                }
                                                // }
                                        }
@@ -2117,32 +2124,35 @@ public class MLPAnalysis {
                // reachability set
                Set<Set> reachabilitySet = new HashSet();
                LabelNode ln = og.td2ln.get(tempDescriptor);
-               Iterator<ReferenceEdge> refEdgeIter = ln.iteratorToReferencees();
-               while (refEdgeIter.hasNext()) {
-                       ReferenceEdge referenceEdge = (ReferenceEdge) refEdgeIter.next();
-
-                       ReachabilitySet set = referenceEdge.getBeta();
-                       Iterator<TokenTupleSet> ttsIter = set.iterator();
-                       while (ttsIter.hasNext()) {
-                               TokenTupleSet tokenTupleSet = (TokenTupleSet) ttsIter.next();
-
-                               HashSet<GloballyUniqueTokenTuple> newTokenTupleSet = new HashSet<GloballyUniqueTokenTuple>();
-                               // reachabilitySet.add(tokenTupleSet);
+               if(ln!=null){
+                       Iterator<ReferenceEdge> refEdgeIter = ln.iteratorToReferencees();
+                       while (refEdgeIter.hasNext()) {
+                               ReferenceEdge referenceEdge = (ReferenceEdge) refEdgeIter.next();
+
+                               ReachabilitySet set = referenceEdge.getBeta();
+                               Iterator<TokenTupleSet> ttsIter = set.iterator();
+                               while (ttsIter.hasNext()) {
+                                       TokenTupleSet tokenTupleSet = (TokenTupleSet) ttsIter.next();
+
+                                       HashSet<GloballyUniqueTokenTuple> newTokenTupleSet = new HashSet<GloballyUniqueTokenTuple>();
+                                       // reachabilitySet.add(tokenTupleSet);
+
+                                       Iterator iter = tokenTupleSet.iterator();
+                                       while (iter.hasNext()) {
+                                               TokenTuple tt = (TokenTuple) iter.next();
+                                               int token = tt.getToken();
+                                               String uniqueID = og.id2hrn.get(new Integer(token))
+                                                               .getGloballyUniqueIdentifier();
+                                               GloballyUniqueTokenTuple gtt = new GloballyUniqueTokenTuple(
+                                                               uniqueID, tt);
+                                               newTokenTupleSet.add(gtt);
+                                       }
 
-                               Iterator iter = tokenTupleSet.iterator();
-                               while (iter.hasNext()) {
-                                       TokenTuple tt = (TokenTuple) iter.next();
-                                       int token = tt.getToken();
-                                       String uniqueID = og.id2hrn.get(new Integer(token))
-                                                       .getGloballyUniqueIdentifier();
-                                       GloballyUniqueTokenTuple gtt = new GloballyUniqueTokenTuple(
-                                                       uniqueID, tt);
-                                       newTokenTupleSet.add(gtt);
+                                       reachabilitySet.add(newTokenTupleSet);
                                }
-
-                               reachabilitySet.add(newTokenTupleSet);
                        }
                }
+
                return reachabilitySet;
        }
        
@@ -2174,13 +2184,18 @@ public class MLPAnalysis {
                                        TempDescriptor tempDescriptor = (TempDescriptor) iterator
                                                        .next();
                                        
+                                       if(tempDescriptor.getType().isImmutable()){
+                                               continue;
+                                       }
+                                       
                                        // effects set
                                        SESEEffectsSet seseEffectsSet = fsen.getSeseEffectsSet();
                                        Set<SESEEffectsKey> readEffectsSet = seseEffectsSet
                                                        .getReadingSet(tempDescriptor);
                                        Set<SESEEffectsKey> writeEffectsSet = seseEffectsSet
                                                        .getWritingSet(tempDescriptor);
-
+                                       Set<SESEEffectsKey> strongUpdateSet = seseEffectsSet.getStrongUpdateSet(tempDescriptor);                
+                                       
                                        Set<Set> reachabilitySet = calculateReachabilitySet(og,
                                                        tempDescriptor);
 
@@ -2201,7 +2216,7 @@ public class MLPAnalysis {
                                        }
                                        
                                        conflictGraph.addLiveInNode(tempDescriptor, hrnSet, fsen,
-                                                       readEffectsSet, writeEffectsSet, reachabilitySet);
+                                                       readEffectsSet, writeEffectsSet, strongUpdateSet, reachabilitySet);
                                }
                                
                                if(conflictGraph.id2cn.size()>0){
index be6500af71c0850eff8a3ccd15d9272d225d4454..c03edfc736c79e45dff0cbab3d8b78350ba97680 100644 (file)
@@ -94,6 +94,10 @@ public class SESEEffectsSet {
        public Set<SESEEffectsKey> getWritingSet(TempDescriptor td) {
                return writeTable.get(td);
        }
+       
+       public Set<SESEEffectsKey> getStrongUpdateSet(TempDescriptor td){
+               return strongUpdateTable.get(td);               
+       }
 
        public String printSet() {
                
index 8c20871b32c566f3e4fb33a2947bbd710f9fd016..05994018868a3e4662cd880b84d1cc64c043d5d4 100644 (file)
@@ -241,6 +241,7 @@ public class HeapRegionNode extends OwnershipNode {
                endpart = endpart.replaceAll("S", "1");
                endpart = endpart.replaceAll("P", "2");
                endpart = endpart.replaceAll("A", "3");
+               endpart = endpart.replace(".", "");
                String modified = fristpart.substring(0, idx) + endpart;
                return Long.parseLong(modified);
        }
index ac52e6b68e8981d56e019395ac6eb39be77a685d..b76043ffcbe2910cd66b70c0d38acaa0d4a22988 100644 (file)
@@ -3416,8 +3416,7 @@ public class BuildCode {
                                output.println("     WaitingElement* newElement=NULL;");
                                output.println("     struct Queue* list=NULL;");
                                output.println("     struct QueueItem* newQItem=NULL;");
-                               output
-                                               .println("     pthread_mutex_lock( &(parentCommon->lock) );");
+                               output.println("     pthread_mutex_lock( &(parentCommon->lock) );");
                                for (Iterator iterator = waitingQueueSet.iterator(); iterator
                                                .hasNext();) {
                                        WaitingElement waitingElement = (WaitingElement) iterator.next();
@@ -3449,8 +3448,8 @@ public class BuildCode {
                        
                        output.println("     /*decide whether it is runnable or not in regarding to memory conflicts*/");
                        output.println("     {");
-                       output.println("      pthread_mutex_lock( &(parentCommon->lock)  );");
                        output.println("      if( !isEmpty(newWaitingItemQueue) ){");
+                       output.println("         pthread_mutex_lock( &(parentCommon->lock)  );");
                        output.println("         int idx;");
                        output.println("         for(idx = 0 ; idx < numRelatedWaitingQueue ; idx++){");
                        output.println("            struct Queue *allocQueue=parentCommon->allocSiteArray[idx].waitingQueue;");
@@ -3462,9 +3461,9 @@ public class BuildCode {
                        output.println("                  }");
                        output.println("                     nextQItem=getNextQueueItem(nextQItem);");
                        output.println("               }");
-                       output.println("         }");
-                       output.println("       }");
-                       output.println("     pthread_mutex_unlock( &(parentCommon->lock)  );");
+                       output.println("          }");
+                       output.println("        }");
+                       output.println("        pthread_mutex_unlock( &(parentCommon->lock)  );");
                        output.println("     }");
                        output.println("     }");
                        output.println();
@@ -3475,7 +3474,10 @@ public class BuildCode {
     //  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) );");
-
+    // eom
+//    output.println("     pthread_mutex_init( &(seseToIssue->common.waitingQueueLock), NULL );");
+    //
+    
     if( fsen != mlpa.getMainSESE() ) {
       // count up outstanding dependencies, static first, then dynamic
       Iterator<SESEandAgePair> staticSrcsItr = fsen.getStaticInVarSrcs().iterator();
@@ -3604,7 +3606,7 @@ public class BuildCode {
     }
 
     output.println("   /* SESE exiting */");
-
+    
     String com = paramsprefix+"->common";
 
     // this SESE cannot be done until all of its children are done
@@ -3663,6 +3665,7 @@ public class BuildCode {
     output.println("     pthread_mutex_unlock( &(consumer->lock) );");
     output.println("   }");
     
+    
     // eom
     // clean up its lock element from waiting queue, and decrement dependency count for next SESE block
     if( fsen != mlpa.getMainSESE() ) {
@@ -3671,6 +3674,7 @@ public class BuildCode {
         output.println("   /* check memory dependency*/");
        output.println("  {");
        output.println("   pthread_mutex_lock( &(___params___->common.parent->lock) );");
+//     output.println("   pthread_mutex_lock( &(___params___->common.parent->waitingQueueLock) );");
        output.println("   int idx;");
        output.println("   int giveCount=0;");
        output.println("   struct Queue* launchQueue=createQueue();");
@@ -3726,6 +3730,7 @@ public class BuildCode {
 //     output.println("  }");
        output.println("  }");
        output.println("  pthread_mutex_unlock( &(___params___->common.parent->lock)  );");
+//     output.println("  pthread_mutex_unlock( &(___params___->common.parent->waitingQueueLock)  );");
        output.println("  if(!isEmpty(launchQueue)){");
        output.println("     struct QueueItem* qItem=getHead(launchQueue);");
        output.println("     while(qItem!=NULL){");