From dc23cc27b5d7b9f343419537c9f6c5372399536e Mon Sep 17 00:00:00 2001 From: yeom Date: Sat, 9 Jan 2010 02:45:59 +0000 Subject: [PATCH] changes. --- Robust/src/Analysis/MLP/ConflictGraph.java | 62 +++++++++++++++------- Robust/src/IR/Flat/BuildCode.java | 36 ++++++++----- Robust/src/Runtime/mlp_runtime.c | 25 +++++++-- Robust/src/Runtime/mlp_runtime.h | 2 + 4 files changed, 89 insertions(+), 36 deletions(-) diff --git a/Robust/src/Analysis/MLP/ConflictGraph.java b/Robust/src/Analysis/MLP/ConflictGraph.java index fd5e0d69..49ad68ba 100644 --- a/Robust/src/Analysis/MLP/ConflictGraph.java +++ b/Robust/src/Analysis/MLP/ConflictGraph.java @@ -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 writeSet=liveInNode.getWriteEffectsSet(); + + if(liveInNode.getWriteEffectsSet()!=null && liveInNode.getWriteEffectsSet().size()>0){ + addConflictEdge(ConflictEdge.FINE_GRAIN_EDGE, currentNode, + currentNode); + } + } + // Set> 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 nodeIDSet = new HashSet(); Set> s = id2cn.entrySet(); - Iterator> i = s.iterator(); + Collection stallSites=conflictsMap.getStallMap().values(); for (Iterator iterator = stallSites.iterator(); iterator.hasNext();) { StallSite stallSite = (StallSite) iterator.next(); + Iterator> i = s.iterator(); while (i.hasNext()) { Entry 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 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 getConnectedConflictNode(ConflictEdge conflictEdge, int seseID){ - + private Set getConnectedConflictNode(ConflictEdge conflictEdge, + int seseID) { + HashSet nodeIDSet = new HashSet(); - - 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; } diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 34f1e7bb..2655bb7e 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -2723,7 +2723,7 @@ public class BuildCode { ConflictGraph graph=mlpa.getConflictGraphResults().get(enclosingFlatNode); Set 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 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(); } diff --git a/Robust/src/Runtime/mlp_runtime.c b/Robust/src/Runtime/mlp_runtime.c index b9105ff3..da39c41d 100644 --- a/Robust/src/Runtime/mlp_runtime.c +++ b/Robust/src/Runtime/mlp_runtime.c @@ -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;iclassID,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; + +} diff --git a/Robust/src/Runtime/mlp_runtime.h b/Robust/src/Runtime/mlp_runtime.h index 99c8c426..7ab92c1e 100644 --- a/Robust/src/Runtime/mlp_runtime.h +++ b/Robust/src/Runtime/mlp_runtime.h @@ -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__ */ -- 2.34.1