more implementation on the SESE runtime
authoryeom <yeom>
Mon, 4 Jan 2010 17:50:06 +0000 (17:50 +0000)
committeryeom <yeom>
Mon, 4 Jan 2010 17:50:06 +0000 (17:50 +0000)
Robust/src/Analysis/MLP/ConflictGraph.java
Robust/src/Analysis/MLP/MLPAnalysis.java
Robust/src/Analysis/MLP/ParentChildConflictsMap.java
Robust/src/IR/Flat/BuildCode.java

index bdc4d1fc0dcfdf4399d93710c73cbb5d317f665b..3156706df8de6929cd10c9267ac3a30b700e4e32 100644 (file)
@@ -461,7 +461,6 @@ public class ConflictGraph {
                return resultSet;
        }
 
-       /*
        public Set<Integer> getAllocationSiteIDSetBySESEID(int seseID) {
 
                HashSet<Integer> allocSiteIDSet = new HashSet<Integer>();
@@ -476,17 +475,18 @@ public class ConflictGraph {
                        if (node instanceof LiveInNode) {
                                LiveInNode liveInNode = (LiveInNode) node;
                                if (liveInNode.getSESEIdentifier() == seseID) {
-                                       Set<HeapRegionNode> hrnSet = liveInNode.getHRNSet();
-                                       for (Iterator iterator = hrnSet.iterator(); iterator
-                                                       .hasNext();) {
-                                               HeapRegionNode hrn = (HeapRegionNode) iterator.next();
-                                               // allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
-                                               allocSiteIDSet.add(new    pthread_mutex_lock( &(parentCommon->lock) );
-     addWaitingQueueElement(parentCommon->allocSiteArray,numRelatedAllocSites,196130920,seseToIssue->common.classID);
-     ++(seseToIssue->common.unresolvedDependencies);
-     addWaitingQueueElement(parentCommon->allocSiteArray,numRelatedAllocSites,1289650030,seseToIssue->common.classID); Integer(hrn
-                                                               .getGloballyUniqueIntegerIdentifier()));
+                                       
+                                       HashSet<ConflictEdge> edgeSet = liveInNode.getEdgeSet();
+                                       for (Iterator iterator = edgeSet.iterator(); iterator.hasNext();) {
+                                               ConflictEdge conflictEdge = (ConflictEdge) iterator.next();
+                                               if (conflictEdge.getType() == ConflictEdge.COARSE_GRAIN_EDGE) {
+                                                       allocSiteIDSet.addAll(getHRNIdentifierSet(conflictEdge.getVertexU()));
+                                                       allocSiteIDSet.addAll(getHRNIdentifierSet(conflictEdge.getVertexV()));
+                                               }else{// it is fine-grain edge
+                                                       allocSiteIDSet.addAll(getHRNIdentifierSet(node));
+                                               }
                                        }
+                                       
                                }
                        }
                }
@@ -494,50 +494,27 @@ public class ConflictGraph {
                return allocSiteIDSet;
 
        }
-*/
        
-       public Set<Integer> getAllocationSiteIDSetBySESEID(int seseID) {
-
+       public Set<Integer> getAllocationSiteIDSetofStallSite() {
+               
                HashSet<Integer> allocSiteIDSet = new HashSet<Integer>();
 
                Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
                Iterator<Entry<String, ConflictNode>> i = s.iterator();
-
+               
                while (i.hasNext()) {
+                       
                        Entry<String, ConflictNode> entry = i.next();
                        ConflictNode node = entry.getValue();
-
-                       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();
-                                               if (conflictEdge.getType() == ConflictEdge.COARSE_GRAIN_EDGE) {
-                                                       allocSiteIDSet.addAll(getHRNIdentifierSet(conflictEdge.getVertexU()));
-                                                       allocSiteIDSet.addAll(getHRNIdentifierSet(conflictEdge.getVertexV()));
-                                               }else{// it is fine-grain edge
-                                                       allocSiteIDSet.addAll(getHRNIdentifierSet(node));
-                                               }
-                                       }
-                                       
-                                       
-//                                     Set<HeapRegionNode> hrnSet = liveInNode.getHRNSet();
-//                                     for (Iterator iterator = hrnSet.iterator(); iterator
-//                                                     .hasNext();) {
-//                                             HeapRegionNode hrn = (HeapRegionNode) iterator.next();
-//                                             // allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
-//                                             allocSiteIDSet.add(new Integer(hrn
-//                                                             .getGloballyUniqueIntegerIdentifier()));
-//                                     }
-                                       
-                               }
+                       
+                       if(node instanceof StallSiteNode){
+                               allocSiteIDSet.addAll(getHRNIdentifierSet(node));
                        }
+                       
                }
-
+               
                return allocSiteIDSet;
-
+               
        }
        
        public Set<Integer> getAllocationSiteIDSet() {
index 2cc97ad085959aa36ae811da580f61fb06cbf4f4..9cf473177561eb286dda706b93cc2e20c4134cdc 100644 (file)
@@ -2321,6 +2321,8 @@ public class MLPAnalysis {
                        SESESummary currentSummary) {
 
                OwnershipGraph og = ownAnalysis.getOwnvershipGraphByMethodContext(mc);
+               
+               currentConflictsMap.clearStallMap();
 
                switch (fn.kind()) {
 
index 773b5eaa6f3faf5e1fc9f35c0aa0da803972d603..251355356cf804751dd1626c8ebf1c55abe34eec 100644 (file)
@@ -1,5 +1,6 @@
 package Analysis.MLP;
 
+import java.util.Enumeration;
 import java.util.HashSet;
 import java.util.Hashtable;
 import java.util.Iterator;
@@ -33,6 +34,10 @@ public class ParentChildConflictsMap {
                stallEdgeMap.clear();
        }
        
+       public void clearStallMap(){
+               stallMap.clear();
+       }
+       
        public void makeAllInaccessible(){
                
                Set<TempDescriptor> keySet=accessibleMap.keySet();
@@ -226,6 +231,25 @@ public class ParentChildConflictsMap {
 
        }
        
+       public Set<Integer> getAllocationSiteIDSetofStallSite() {
+               
+               HashSet<Integer> returnSet=new HashSet<Integer>();
+               
+               Enumeration<StallSite> stallSiteEnum=stallMap.elements();
+               while (stallSiteEnum.hasMoreElements()) {
+                       StallSite stallSite = (StallSite) stallSiteEnum.nextElement();
+                       HashSet<HeapRegionNode> hrnSet=stallSite.getHRNSet();                   
+                       for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
+                               HeapRegionNode hrn = (HeapRegionNode) iterator.next();
+                               // allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
+                               returnSet.add(new Integer(hrn
+                                               .getGloballyUniqueIntegerIdentifier()));
+                       }
+               }
+               return returnSet;
+               
+       }
+       
        public boolean equals(Object o) {
 
                if (o == null) {
index 8fbd65995e625054c7fb4788c6c243719fe4daef..b50f7b0a3e5a3521facf14b121d9828d60a64f08 100644 (file)
@@ -29,6 +29,7 @@ import Analysis.Loops.GlobalFieldType;
 import Analysis.Locality.TypeAnalysis;
 import Analysis.MLP.ConflictGraph;
 import Analysis.MLP.MLPAnalysis;
+import Analysis.MLP.ParentChildConflictsMap;
 import Analysis.MLP.VariableSourceToken;
 import Analysis.MLP.CodePlan;
 import Analysis.MLP.SESEandAgePair;
@@ -2668,6 +2669,41 @@ public class BuildCode {
          output.println("   "+dynVar+"_srcSESE = NULL;");
        }
       }     
+      
+      // eom
+      // handling stall site
+      ParentChildConflictsMap conflictsMap=mlpa.getConflictsResults().get(fn);
+               if (conflictsMap != null) {
+       
+                       Set<Integer> allocSet = conflictsMap
+                                       .getAllocationSiteIDSetofStallSite();
+       
+                       if (allocSet.size() > 0) {
+                               output.println("   /*  stall on parent's stall sites */");
+                               output.println("  {");
+                               output
+                                               .println("  pthread_mutex_lock( &(seseCaller->lock) );");
+       
+                               for (Iterator iterator = allocSet.iterator(); iterator
+                                               .hasNext();) {
+                                       Integer allocID = (Integer) iterator.next();
+                                       output
+                                                       .println("  if(addWaitingQueueElement(seseCaller->allocSiteArray,numRelatedAllocSites,"
+                                                                       + allocID + ",seseCaller)!=0){");
+       
+                                       output
+                                                       .println("     psem_init( &(seseCaller->memoryStallSiteSem) );");
+                                       output
+                                       .println("     psem_take( &(seseCaller->memoryStallSiteSem) );");
+                                       output.println("   }");
+                               }
+                               output
+                                               .println("  pthread_mutex_unlock( &(seseCaller->lock) );");
+                               output.println("  }");
+                       }
+       
+               }
+               
     }
 
     switch(fn.kind()) {
@@ -3518,12 +3554,18 @@ public class BuildCode {
        output.println("        removeItem(___params___->common.parent->allocSiteArray[idx].waitingQueue,qItem);");
        output.println("        if( !isEmpty(___params___->common.parent->allocSiteArray[idx].waitingQueue) ){");
        output.println("           SESEcommon* nextItem=peekItem(___params___->common.parent->allocSiteArray[idx].waitingQueue);");
-       output.println("           pthread_mutex_lock( &(nextItem->lock) );");
-       output.println("           --(nextItem->unresolvedDependencies);");
-       output.println("           if( nextItem->unresolvedDependencies == 0){");
-       output.println("              workScheduleSubmit( (void*)nextItem);");
+       output.println("           if(nextItem->classID==___params___->common.parent->classID){");
+       output.println("              struct QueueItem* stallItem=findItem(___params___->common.parent->allocSiteArray[idx].waitingQueue,nextItem);");
+       output.println("              removeItem(___params___->common.parent->allocSiteArray[idx].waitingQueue,stallItem);");
+       output.println("              psem_give(&(nextItem->memoryStallSiteSem));");
+       output.println("           }else{");
+       output.println("              pthread_mutex_lock( &(nextItem->lock) );");
+       output.println("              --(nextItem->unresolvedDependencies);");
+       output.println("              if( nextItem->unresolvedDependencies == 0){");
+       output.println("                 workScheduleSubmit( (void*)nextItem);");
+       output.println("              }");
+       output.println("              pthread_mutex_unlock( &(nextItem->lock) );");
        output.println("           }");
-       output.println("           pthread_mutex_unlock( &(nextItem->lock) );");
        output.println("        }");
        output.println("     }");
        output.println("  }");
@@ -3548,6 +3590,7 @@ public class BuildCode {
     // data has been taken care of--set sese pointer to remember self over method
     // calls to a non-zero, invalid address
     output.println("   seseCaller = (SESEcommon*) 0x1;");    
+    
   }
 
   public void generateFlatWriteDynamicVarNode( FlatMethod fm,