From 7a863802fbbf50568fe0b2420f1b12698c1128e2 Mon Sep 17 00:00:00 2001 From: yeom Date: Mon, 4 Jan 2010 17:50:06 +0000 Subject: [PATCH] more implementation on the SESE runtime --- Robust/src/Analysis/MLP/ConflictGraph.java | 65 ++++++------------- Robust/src/Analysis/MLP/MLPAnalysis.java | 2 + .../Analysis/MLP/ParentChildConflictsMap.java | 24 +++++++ Robust/src/IR/Flat/BuildCode.java | 53 +++++++++++++-- 4 files changed, 95 insertions(+), 49 deletions(-) diff --git a/Robust/src/Analysis/MLP/ConflictGraph.java b/Robust/src/Analysis/MLP/ConflictGraph.java index bdc4d1fc..3156706d 100644 --- a/Robust/src/Analysis/MLP/ConflictGraph.java +++ b/Robust/src/Analysis/MLP/ConflictGraph.java @@ -461,7 +461,6 @@ public class ConflictGraph { return resultSet; } - /* public Set getAllocationSiteIDSetBySESEID(int seseID) { HashSet allocSiteIDSet = new HashSet(); @@ -476,17 +475,18 @@ public class ConflictGraph { if (node instanceof LiveInNode) { LiveInNode liveInNode = (LiveInNode) node; if (liveInNode.getSESEIdentifier() == seseID) { - Set 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 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 getAllocationSiteIDSetBySESEID(int seseID) { - + public Set getAllocationSiteIDSetofStallSite() { + HashSet allocSiteIDSet = new HashSet(); Set> s = id2cn.entrySet(); Iterator> i = s.iterator(); - + while (i.hasNext()) { + Entry entry = i.next(); ConflictNode node = entry.getValue(); - - if (node instanceof LiveInNode) { - LiveInNode liveInNode = (LiveInNode) node; - if (liveInNode.getSESEIdentifier() == seseID) { - - HashSet 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 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 getAllocationSiteIDSet() { diff --git a/Robust/src/Analysis/MLP/MLPAnalysis.java b/Robust/src/Analysis/MLP/MLPAnalysis.java index 2cc97ad0..9cf47317 100644 --- a/Robust/src/Analysis/MLP/MLPAnalysis.java +++ b/Robust/src/Analysis/MLP/MLPAnalysis.java @@ -2321,6 +2321,8 @@ public class MLPAnalysis { SESESummary currentSummary) { OwnershipGraph og = ownAnalysis.getOwnvershipGraphByMethodContext(mc); + + currentConflictsMap.clearStallMap(); switch (fn.kind()) { diff --git a/Robust/src/Analysis/MLP/ParentChildConflictsMap.java b/Robust/src/Analysis/MLP/ParentChildConflictsMap.java index 773b5eaa..25135535 100644 --- a/Robust/src/Analysis/MLP/ParentChildConflictsMap.java +++ b/Robust/src/Analysis/MLP/ParentChildConflictsMap.java @@ -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 keySet=accessibleMap.keySet(); @@ -226,6 +231,25 @@ public class ParentChildConflictsMap { } + public Set getAllocationSiteIDSetofStallSite() { + + HashSet returnSet=new HashSet(); + + Enumeration stallSiteEnum=stallMap.elements(); + while (stallSiteEnum.hasMoreElements()) { + StallSite stallSite = (StallSite) stallSiteEnum.nextElement(); + HashSet 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) { diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 8fbd6599..b50f7b0a 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -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 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, -- 2.34.1