changes.
authoryeom <yeom>
Sat, 9 Jan 2010 02:45:59 +0000 (02:45 +0000)
committeryeom <yeom>
Sat, 9 Jan 2010 02:45:59 +0000 (02:45 +0000)
Robust/src/Analysis/MLP/ConflictGraph.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/mlp_runtime.c
Robust/src/Runtime/mlp_runtime.h

index fd5e0d691981b9c101015a83e5a8cd7f42b6f541..49ad68ba8a09a014719548273accb6b5d2c00707 100644 (file)
@@ -310,6 +310,18 @@ public class ConflictGraph {
                        ConflictNode currentNode) {
 
                // compare with all nodes
+               
+               // 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){
+                               addConflictEdge(ConflictEdge.FINE_GRAIN_EDGE, currentNode,
+                               currentNode);
+                       }                       
+               }
+               //
 
                Set<Entry<String, ConflictNode>> set = id2cn.entrySet();
                for (Iterator iterator = set.iterator(); iterator.hasNext();) {
@@ -318,7 +330,7 @@ public class ConflictGraph {
 
                        String entryNodeID = entry.getKey();
                        ConflictNode entryNode = entry.getValue();
-
+                       
                        if ((!currentNode.getID().equals(entryNodeID))
                                        && !(analyzedIDSet.contains(currentNode.getID()
                                                        + entryNodeID) || analyzedIDSet
@@ -469,18 +481,19 @@ public class ConflictGraph {
                HashSet<Integer> nodeIDSet = new HashSet<Integer>();
                
                Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
-               Iterator<Entry<String, ConflictNode>> i = s.iterator();
+               
                
                Collection<StallSite> stallSites=conflictsMap.getStallMap().values();
                for (Iterator iterator = stallSites.iterator(); iterator.hasNext();) {
                        StallSite stallSite = (StallSite) iterator.next();
+                       Iterator<Entry<String, ConflictNode>> i = s.iterator();
                        while (i.hasNext()) {
                                Entry<String, ConflictNode> entry = i.next();
                                ConflictNode node = entry.getValue();
 
                                if (node instanceof StallSiteNode) {
                                        StallSiteNode stallSiteNode = (StallSiteNode) node;
-                                       if (stallSiteNode.getStallSite() == stallSite) {
+                                       if (stallSiteNode.getStallSite().equals(stallSite)) {
                                                HashSet<ConflictEdge> edgeSet = stallSiteNode.getEdgeSet();
                                                for (Iterator iter2 = edgeSet.iterator(); iter2.hasNext();) {
                                                        ConflictEdge conflictEdge = (ConflictEdge) iter2.next();
@@ -511,29 +524,40 @@ public class ConflictGraph {
                return nodeIDSet;
        }
        
-       private Set<Integer> getConnectedConflictNode(ConflictEdge conflictEdge, int seseID){
-               
+       private Set<Integer> getConnectedConflictNode(ConflictEdge conflictEdge,
+                       int seseID) {
+
                HashSet<Integer> nodeIDSet = new HashSet<Integer>();
-               
-               if(conflictEdge.getVertexU() instanceof LiveInNode){
-                       LiveInNode lin=(LiveInNode)conflictEdge.getVertexU();
-                       if(lin.getSESEIdentifier()!=seseID){
+
+               if (conflictEdge.getVertexU() instanceof LiveInNode) {
+                       LiveInNode lin = (LiveInNode) conflictEdge.getVertexU();
+                       if (lin.getSESEIdentifier() != seseID) {
                                nodeIDSet.add(new Integer(lin.getSESEIdentifier()));
-                       }                                                       
-               }else{
+                       }
+               } else {
                        // it is stall site
                        nodeIDSet.add(new Integer(-1));
-               }       
-               if(conflictEdge.getVertexV() instanceof LiveInNode){
-                       LiveInNode lin=(LiveInNode)conflictEdge.getVertexV();
-                       if(lin.getSESEIdentifier()!=seseID){
+               }
+               if (conflictEdge.getVertexV() instanceof LiveInNode) {
+                       LiveInNode lin = (LiveInNode) conflictEdge.getVertexV();
+                       if (lin.getSESEIdentifier() != seseID) {
                                nodeIDSet.add(new Integer(lin.getSESEIdentifier()));
-                       }                                                       
-               }else{
+                       }
+               } else {
                        // it is stall site
                        nodeIDSet.add(new Integer(-1));
-               }       
-               
+               }
+
+               // self-edge case
+               if (conflictEdge.getVertexU() instanceof LiveInNode
+                               && conflictEdge.getVertexV() instanceof LiveInNode) {
+                       if (((LiveInNode) conflictEdge.getVertexU()).getSESEIdentifier() == seseID
+                                       && ((LiveInNode) conflictEdge.getVertexV())
+                                                       .getSESEIdentifier() == seseID) {
+                               nodeIDSet.add(seseID);
+                       }
+               }
+
                return nodeIDSet;
        }
        
index 34f1e7bb88718608684dbeb83d40fcf98a06a494..2655bb7ec372883ed1e1d15fb64dbe74ee35c136 100644 (file)
@@ -2723,7 +2723,7 @@ public class BuildCode {
                                
                                ConflictGraph graph=mlpa.getConflictGraphResults().get(enclosingFlatNode);
                                Set<Integer> connectedSet=graph.getConnectedConflictNodeSet(conflictsMap);
-               
+
                                if(connectedSet.size()>0){
                                        output.println("   /*  stall on parent's stall sites */");
                                        output.println("   //"+connectedSet);
@@ -3378,6 +3378,8 @@ public class BuildCode {
                if (graph != null) {
                        output.println();
                        output.println("     /*add waiting queue element*/");
+                       output.println("     struct Queue*  newWaitingItemQueue=createQueue();");
+                       output.println("     struct QueueItem* newQItem=NULL;");
 
                        Set<Long> allocSet = graph.getAllocationSiteIDSetBySESEID(fsen
                                        .getIdentifier());
@@ -3406,9 +3408,10 @@ public class BuildCode {
                                                .hasNext();) {
                                        Long allocID = (Long) iterator.next();
                                        output
-                                                       .println("     addWaitingQueueElement(parentCommon->allocSiteArray,numRelatedAllocSites,"
+                                                       .println("     newQItem=addWaitingQueueElement(parentCommon->allocSiteArray,numRelatedAllocSites,"
                                                                        + allocID
                                                                        + ",seseToIssue);");
+                                       output.println("     addNewItem(newWaitingItemQueue,newQItem);");
                                        output
                                                        .println("     ++(seseToIssue->common.unresolvedDependencies);");
                                }
@@ -3419,18 +3422,25 @@ public class BuildCode {
                        
                        output.println("     /*decide whether it is runnable or not in regarding to memory conflicts*/");
                        output.println("     {");
-                       output.println("     int idx;");
-                       output.println("              pthread_mutex_lock( &(parentCommon->lock)  );");
-                       output.println("     for(idx = 0 ; idx < numRelatedAllocSites ; idx++){");
-                       output.println("        struct Queue *allocQueue=parentCommon->allocSiteArray[idx].waitingQueue;");
-                       output.println("        if(allocQueue->head!=NULL){");
-                       output.println("           SESEcommon* item=peekItem(parentCommon->allocSiteArray[idx].waitingQueue);");
-                       output.println("           if(item->classID==seseToIssue->common.classID){");
-                       output.println("              --(seseToIssue->common.unresolvedDependencies);");
-                       output.println("           }");
-                       output.println("        }");
+                       output.println("      pthread_mutex_lock( &(parentCommon->lock)  );");
+                       output.println("      if( !isEmpty(newWaitingItemQueue) ){");
+                       output.println("         int idx;");
+                       output.println("         for(idx = 0 ; idx < numRelatedAllocSites ; idx++){");
+                       output.println("            struct Queue *allocQueue=parentCommon->allocSiteArray[idx].waitingQueue;");
+                       output.println("            if( !isEmpty(allocQueue) ){");
+                       output.println("               struct QueueItem* nextQItem=getHead(allocQueue);");
+                       output.println("               while( nextQItem != NULL ){");
+                       output.println("                  if(contains(newWaitingItemQueue,nextQItem) && resolveWaitingQueue(allocQueue,nextQItem)){");
+                       output.println("                     --(seseToIssue->common.unresolvedDependencies);");
+                       output.println("                     nextQItem=NULL;");
+                       output.println("                  }else{");
+                       output.println("                     nextQItem=getNextQueueItem(nextQItem);");
+                       output.println("                  }");
+                       output.println("               }");
+                       output.println("         }");
+                       output.println("       }");
+                       output.println("     pthread_mutex_unlock( &(parentCommon->lock)  );");
                        output.println("     }");
-                       output.println("              pthread_mutex_unlock( &(parentCommon->lock)  );");
                        output.println("     }");
                        output.println();
                }
index b9105ff3bec498b646a5b1a839c70c7a9c4e1274..da39c41dde79741cf5c3b9819c8d2333ecf50daa 100644 (file)
@@ -45,17 +45,18 @@ ConflictNode* mlpCreateConflictNode(int id){
   return newConflictNode;
 }
 
-void addWaitingQueueElement(AllocSite* allocSiteArray, int numAllocSites, long allocID, void *seseRec){
+struct QueueItem* addWaitingQueueElement(AllocSite* allocSiteArray, int numAllocSites, long allocID, void *seseRec){
 
   int i;
+  struct QueueItem* newItem=NULL;
   for(i=0;i<numAllocSites;i++){
     if(allocSiteArray[i].id==allocID){
-      addNewItemBack(allocSiteArray[i].waitingQueue,seseRec);
+      newItem=addNewItemBack(allocSiteArray[i].waitingQueue,seseRec);
+      return newItem;
       //printf("add new item %d into waiting queue:%d\n",((SESEcommon*)seseRec)->classID,allocID);
-      break;
     }
   }
+  return newItem;
 }
 
 int getQueueIdx(AllocSite* allocSiteArray, int numAllocSites, long  allocID){
@@ -123,3 +124,19 @@ void addNewConflictNode(ConflictNode* node, struct Queue* connectedList){
   addNewItem(connectedList,node);
 
 }
+
+int contains(struct Queue* queue, struct QueueItem* qItem){
+
+  if(!isEmpty(queue)){
+    struct QueueItem* nextQItem=getHead(queue);
+    while(nextQItem!=NULL){
+      if((nextQItem->objectptr)==qItem){
+       return 1;
+      } 
+      nextQItem=getNextQueueItem(nextQItem);
+    }
+  }
+
+  return 0;
+
+}
index 99c8c426e8b1149da442b41a2fba2520e7757f7a..7ab92c1e61f931a66633826a7c8850f7618d4a05 100644 (file)
@@ -83,6 +83,8 @@ void  mlpDestroySESErecord( void* seseRecord );
 
 AllocSite* mlpCreateAllocSiteArray(int numAllocSites);
 ConflictNode* mlpCreateConflictNode(int id);
+struct QueueItem* addWaitingQueueElement(AllocSite* allocSiteArray, int numAllocSites, long allocID, void *seseRec);
+
 
 
 #endif /* __MLP_RUNTIME__ */