Set<SESEEffectsKey> writeEffectsSet = nodeB.getWriteEffectsSet();
Set<SESEEffectsKey> readEffectsSet = nodeB.getReadEffectsSet();
-
+
if (writeEffectsSet != null) {
Iterator<SESEEffectsKey> writeIter = writeEffectsSet.iterator();
while (writeIter.hasNext()) {
}
}
+
+ // add for another case
+ if (readEffectsSet != null) {
+ Iterator<SESEEffectsKey> readIter = readEffectsSet.iterator();
+ while (readIter.hasNext()) {
+ SESEEffectsKey seseEffectsKey = (SESEEffectsKey) readIter
+ .next();
+ String readHeapRegionID = seseEffectsKey.getHRNUniqueId();
+ HashSet<HeapRegionNode> stallSiteHRNSet = nodeA.getHRNSet();
+ for (Iterator iterator = stallSiteHRNSet.iterator(); iterator
+ .hasNext();) {
+ HeapRegionNode stallHRN = (HeapRegionNode) iterator.next();
+ if (stallHRN.getGloballyUniqueIdentifier().equals(
+ readHeapRegionID)) {
+ result = result | true;
+ }
+ }
+ }
+ }
}
if (readEffectsSet != null) {
return resultSet;
}
- public Set<Integer> getAllocationSiteIDSetBySESEID(int seseID) {
+ public Set<Long> getAllocationSiteIDSetBySESEID(int seseID) {
- HashSet<Integer> allocSiteIDSet = new HashSet<Integer>();
+ HashSet<Long> allocSiteIDSet = new HashSet<Long>();
Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
Iterator<Entry<String, ConflictNode>> i = s.iterator();
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();
}
- public Set<Integer> getAllocationSiteIDSetofStallSite() {
+ public Set<Long> getAllocationSiteIDSetofStallSite() {
- HashSet<Integer> allocSiteIDSet = new HashSet<Integer>();
+ HashSet<Long> allocSiteIDSet = new HashSet<Long>();
Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
Iterator<Entry<String, ConflictNode>> i = s.iterator();
}
- public Set<Integer> getAllocationSiteIDSet() {
+ public Set<Long> getAllocationSiteIDSet() {
- HashSet<Integer> allocSiteIDSet = new HashSet<Integer>();
+ HashSet<Long> allocSiteIDSet = new HashSet<Long>();
Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
Iterator<Entry<String, ConflictNode>> i = s.iterator();
}
- private HashSet<Integer> getHRNIdentifierSet(ConflictNode node) {
+ private HashSet<Long> getHRNIdentifierSet(ConflictNode node) {
- HashSet<Integer> returnSet = new HashSet<Integer>();
+ HashSet<Long> returnSet = new HashSet<Long>();
if (node instanceof StallSiteNode) {
StallSiteNode stallSiteNode = (StallSiteNode) node;
for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
HeapRegionNode hrn = (HeapRegionNode) iterator.next();
// allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
- returnSet.add(new Integer(hrn
+ returnSet.add(new Long(hrn
.getGloballyUniqueIntegerIdentifier()));
}
} else {
for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
HeapRegionNode hrn = (HeapRegionNode) iterator.next();
// allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
- returnSet.add(new Integer(hrn
+ returnSet.add(new Long(hrn
.getGloballyUniqueIntegerIdentifier()));
}
}
import IR.TypeUtil;
import IR.Flat.FKind;
import IR.Flat.FlatCall;
+import IR.Flat.FlatCondBranch;
import IR.Flat.FlatEdge;
import IR.Flat.FlatFieldNode;
import IR.Flat.FlatLiteralNode;
Hashtable<TempDescriptor, StallSite> stallMap = currentConflictsMap
.getStallMap();
+
Set<Entry<TempDescriptor, StallSite>> entrySet = stallMap
.entrySet();
.hasNext();) {
TempDescriptor tempDescriptor = (TempDescriptor) iterator
.next();
-
+
// effects set
SESEEffectsSet seseEffectsSet = fsen.getSeseEffectsSet();
Set<SESEEffectsKey> readEffectsSet = seseEffectsSet
while (mcIter.hasNext()) {
MethodContext mc = mcIter.next();
- Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
+ LinkedList<FlatNode> flatNodesToVisit=new LinkedList<FlatNode>();
flatNodesToVisit.add(fm);
SESESummary summary = new SESESummary(null, fm);
while (!flatNodesToVisit.isEmpty()) {
FlatNode fn = (FlatNode) flatNodesToVisit.iterator().next();
flatNodesToVisit.remove(fn);
-
ParentChildConflictsMap prevResult = conflictsResults
.get(fn);
// merge sets from control flow
+ Boolean prevSESE=null;
ParentChildConflictsMap currentConflictsMap = new ParentChildConflictsMap();
for (int i = 0; i < fn.numPrev(); i++) {
FlatNode prevFlatNode = fn.getPrev(i);
if (incoming != null) {
currentConflictsMap.merge(incoming);
}
+
+ if(prevFlatNode instanceof FlatCondBranch){
+ prevSESE=isAfterChildSESEIndicatorMap.get(prevFlatNode);
+ }
}
-
SESESummary currentSummary = seseSummaryMap.get(fn);
- if (currentSummary == null) {
+ //if (currentSummary == null) {
+ if(!(fn instanceof FlatMethod)){
FlatNode current = null;
FlatNode currentParent = null;
// calculate sese summary info from previous flat nodes
currentParent = prevSummary
.getCurrentParent();
}
+
break;
}
}
currentSummary = new SESESummary(currentParent, current);
seseSummaryMap.put(fn, currentSummary);
}
+
+ if(prevSESE!=null){
+ if(fn instanceof FlatSESEEnterNode){
+ isAfterChildSESEIndicatorMap.put(currentSummary.getCurrentSESE(), currentConflictsMap.isAfterSESE());
+ }else{
+ isAfterChildSESEIndicatorMap.put(currentSummary.getCurrentSESE(), prevSESE);
+ }
+ }
+
+ Boolean b=isAfterChildSESEIndicatorMap.get(currentSummary.getCurrentSESE());;
+ if(b==null){
+ currentConflictsMap.setIsAfterSESE(false);
+ }else{
+ currentConflictsMap.setIsAfterSESE(b.booleanValue());
+ }
+
+ FlatNode tempP=currentSummary.getCurrentParent();
+ FlatNode tempS=currentSummary.getCurrentSESE();
conflicts_nodeAction(mc, fn, callGraph, preeffectsSet,
currentConflictsMap, currentSummary);
+
// if we have a new result, schedule forward nodes for
// analysis
if (!currentConflictsMap.equals(prevResult)) {
+ seseSummaryMap.put(fn, currentSummary);
conflictsResults.put(fn, currentConflictsMap);
for (int i = 0; i < fn.numNext(); i++) {
FlatNode nn = fn.getNext(i);
- flatNodesToVisit.add(nn);
+ flatNodesToVisit.addFirst(nn);
}
}
FlatNode parentNode = currentSummary.getCurrentSESE();
currentSummary.setCurrentParent(parentNode);
currentSummary.setCurrentSESE(fsen);
- seseSummaryMap.put(fsen, currentSummary);
+// seseSummaryMap.put(fsen, currentSummary);
}
if (!fsen.getIsCallerSESEplaceholder()) {
}
break;
+
+ case FKind.FlatCondBranch: {
+ boolean isAfterChildSESE = false;
+ FlatNode current = currentSummary.getCurrentSESE();
+ Boolean isAfter = isAfterChildSESEIndicatorMap.get(current);
+ if (isAfter != null && isAfter.booleanValue()) {
+ isAfterChildSESE = true;
+ }
+ isAfterChildSESEIndicatorMap.put(fn, new Boolean(isAfterChildSESE));
+ }
+ break;
+
case FKind.FlatNew: {
FlatNew fnew = (FlatNew) fn;
}
- seseSummaryMap.put(fn, currentSummary);
+// seseSummaryMap.put(fn, currentSummary);
}
private Hashtable<TempDescriptor, Integer> accessibleMap;
private Hashtable<TempDescriptor, StallSite> stallMap;
private Hashtable < ReferenceEdge, HashSet<StallTag> > stallEdgeMap;
+ private boolean isAfterSESE;
public ParentChildConflictsMap() {
accessibleMap = new Hashtable<TempDescriptor, Integer>();
stallMap = new Hashtable<TempDescriptor, StallSite>();
stallEdgeMap= new Hashtable < ReferenceEdge, HashSet<StallTag> >();
+ isAfterSESE=false;
+ }
+
+ public void setIsAfterSESE(boolean after){
+ this.isAfterSESE=after;
+ }
+
+ public boolean isAfterSESE(){
+ return isAfterSESE;
}
public void clear(){
}
- public Set<Integer> getAllocationSiteIDSetofStallSite() {
+ public Set<Long> getAllocationSiteIDSetofStallSite() {
- HashSet<Integer> returnSet=new HashSet<Integer>();
+ HashSet<Long> returnSet=new HashSet<Long>();
Enumeration<StallSite> stallSiteEnum=stallMap.elements();
while (stallSiteEnum.hasMoreElements()) {
for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
HeapRegionNode hrn = (HeapRegionNode) iterator.next();
// allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
- returnSet.add(new Integer(hrn
+ returnSet.add(new Long(hrn
.getGloballyUniqueIntegerIdentifier()));
}
}
ParentChildConflictsMap in = (ParentChildConflictsMap) o;
if ( accessibleMap.equals(in.getAccessibleMap())
- && stallMap.equals(in.getStallMap())) {
+ && stallMap.equals(in.getStallMap()) && isAfterSESE()==in.isAfterSESE()) {
return true;
} else {
return false;
return globalIdentifier;
}
- public int getGloballyUniqueIntegerIdentifier() {
+ public long getGloballyUniqueIntegerIdentifier() {
String fristpart = globalIdentifier;
fristpart = fristpart.replaceAll("FN", "1");
fristpart = fristpart.replaceAll("FM", "2");
endpart = endpart.replaceAll("P", "2");
endpart = endpart.replaceAll("A", "3");
String modified = fristpart.substring(0, idx) + endpart;
- return Integer.parseInt(modified);
+ return Long.parseLong(modified);
}
}
// set up related allocation sites's waiting queues
// eom
output.println(" /* set up waiting queues */");
+ output.println(" int numRelatedAllocSites=0;");
ConflictGraph graph=null;
graph=mlpa.getConflictGraphResults().get(fm);
if(graph!=null){
- Set<Integer> allocSet=graph.getAllocationSiteIDSet();
+ Set<Long> allocSet=graph.getAllocationSiteIDSet();
if(allocSet.size()>0){
- output.println(" int numRelatedAllocSites="+allocSet.size()+";");
+ output.println(" numRelatedAllocSites="+allocSet.size()+";");
output.println(" seseCaller->numRelatedAllocSites=numRelatedAllocSites;");
output.println(" seseCaller->allocSiteArray=mlpCreateAllocSiteArray(numRelatedAllocSites);");
int idx=0;
for (Iterator iterator = allocSet.iterator(); iterator.hasNext();) {
- Integer allocID = (Integer) iterator.next();
+ Long allocID = (Long) iterator.next();
output.println(" seseCaller->allocSiteArray["+idx+"].id="+allocID+";");
idx++;
}
output.println(" "+type+" "+temp+";");
}
}
+
+ // set up related allocation sites's waiting queues
+ // eom
+ output.println(" /* set up waiting queues */");
+ output.println(" int numRelatedAllocSites=0;");
+ ConflictGraph graph=null;
+ graph=mlpa.getConflictGraphResults().get(fsen);
+ if (graph != null) {
+ output.println(" {");
+ output.println(" SESEcommon* parentCommon = &(___params___->common);");
+ Set<Long> allocSet = graph.getAllocationSiteIDSet();
+ if (allocSet.size() > 0) {
+ output.println(" numRelatedAllocSites=" + allocSet.size()
+ + ";");
+ output
+ .println(" parentCommon->numRelatedAllocSites=numRelatedAllocSites;");
+ output
+ .println(" parentCommon->allocSiteArray=mlpCreateAllocSiteArray(numRelatedAllocSites);");
+ int idx = 0;
+ for (Iterator iterator = allocSet.iterator(); iterator
+ .hasNext();) {
+ Long allocID = (Long) iterator.next();
+ output.println(" parentCommon->allocSiteArray[" + idx
+ + "].id=" + allocID + ";");
+ idx++;
+ }
+ output.println();
+ }
+ output.println(" }");
+ }
+
// copy in-set into place, ready vars were already
// copied when the SESE was issued
exitset.add(seseExit);
generateCode(fsen.getNext(0), fm, null, exitset, output, true);
output.println("}\n\n");
+
}
ParentChildConflictsMap conflictsMap=mlpa.getConflictsResults().get(fn);
if (conflictsMap != null) {
- Set<Integer> allocSet = conflictsMap
+ Set<Long> allocSet = conflictsMap
.getAllocationSiteIDSetofStallSite();
if (allocSet.size() > 0) {
output.println(" /* stall on parent's stall sites */");
output.println(" {");
- output
- .println(" pthread_mutex_lock( &(seseCaller->lock) );");
-
+ output.println(" pthread_mutex_lock( &(seseCaller->lock) );");
+ output.println(" psem_init( &(seseCaller->memoryStallSiteSem) );");
+ output.println(" int qIdx;");
+ output.println(" int takeCount=0;");
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(" }");
+ Long allocID = (Long) iterator.next();
+ output.println(" qIdx=getQueueIdx(seseCaller->allocSiteArray,numRelatedAllocSites,"
+ + allocID + ");");
+ output.println(" if(qIdx!=-1 && !isEmpty(seseCaller->allocSiteArray[qIdx].waitingQueue)){");
+ output.println(" addNewItemBack(seseCaller->allocSiteArray[qIdx].waitingQueue,seseCaller);");
+ output.println(" takeCount++;");
+ output.println(" }");
}
- output
- .println(" pthread_mutex_unlock( &(seseCaller->lock) );");
+ output.println(" pthread_mutex_unlock( &(seseCaller->lock) );");
+ output.println(" if( takeCount>0 ){");
+ output.println(" psem_take( &(seseCaller->memoryStallSiteSem) );");
+ output.println(" }");
output.println(" }");
}
-
}
-
}
switch(fn.kind()) {
if(parent.isCallerSESEplaceholder){
graph=mlpa.getConflictGraphResults().get(parent.getfmEnclosing());
}else{
- graph=mlpa.getConflictGraphResults().get(fsen);
+ graph=mlpa.getConflictGraphResults().get(parent);
}
}
if (graph != null) {
output.println();
output.println(" /*add waiting queue element*/");
- Set<Integer> allocSet = graph.getAllocationSiteIDSetBySESEID(fsen
+ Set<Long> allocSet = graph.getAllocationSiteIDSetBySESEID(fsen
.getIdentifier());
if (allocSet.size() > 0) {
output.println(" {");
for (Iterator iterator = allocSet.iterator(); iterator
.hasNext();) {
- Integer allocID = (Integer) iterator.next();
+ Long allocID = (Long) iterator.next();
output
.println(" addWaitingQueueElement(parentCommon->allocSiteArray,numRelatedAllocSites,"
+ allocID
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(" SESEcommon* item=peekItem(seseCaller->allocSiteArray[idx].waitingQueue);");
- output.println(" if(item->classID==seseToIssue->common.classID){");
- output.println(" --(seseToIssue->common.unresolvedDependencies);");
+ 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(" }");
+ output.println(" pthread_mutex_unlock( &(parentCommon->lock) );");
output.println(" }");
output.println();
}
output.println();
output.println(" /* check memory dependency*/");
output.println(" {");
+ output.println(" pthread_mutex_lock( &(___params___->common.parent->lock) );");
output.println(" int idx;");
+ output.println(" int giveCount=0;");
output.println(" for(idx = 0 ; idx < ___params___->common.parent->numRelatedAllocSites ; idx++){");
+ output.println(" if(!isEmpty(___params___->common.parent->allocSiteArray[idx].waitingQueue)){");
output.println(" SESEcommon* item=peekItem(___params___->common.parent->allocSiteArray[idx].waitingQueue);");
output.println(" if( item->classID == ___params___->common.classID ){");
output.println(" struct QueueItem* qItem=findItem(___params___->common.parent->allocSiteArray[idx].waitingQueue,item);");
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(" giveCount++;");
output.println(" }else{");
output.println(" pthread_mutex_lock( &(nextItem->lock) );");
output.println(" --(nextItem->unresolvedDependencies);");
output.println(" }");
output.println(" }");
output.println(" }");
+ output.println(" }");
output.println(" }");
+ output.println(" pthread_mutex_unlock( &(___params___->common.parent->lock) );");
+ output.println(" if(giveCount>0){");
+ output.println(" psem_give(&(___params___->common.parent->memoryStallSiteSem));");
+ output.println(" }");
output.println(" }");
}
-
// if parent is stalling on you, let them know you're done
if( fsexn.getFlatEnter() != mlpa.getMainSESE() ) {
output.println(" psem_give( &("+paramsprefix+"->common.stallSem) );");
return newAllocSite;
}
-void addWaitingQueueElement(AllocSite* allocSiteArray, int numAllocSites, int allocID, void *seseRec){
-
+void addWaitingQueueElement(AllocSite* allocSiteArray, int numAllocSites, long allocID, void *seseRec){
+
int i;
for(i=0;i<numAllocSites;i++){
if(allocSiteArray[i].id==allocID){
break;
}
}
+
+}
+int getQueueIdx(AllocSite* allocSiteArray, int numAllocSites, long allocID){
+
+ int i;
+ for(i=0;i<numAllocSites;i++){
+ if(allocSiteArray[i].id==allocID){
+ return i;
+ }
+ }
+ return -1;
}
// each allocation site nees the following
typedef struct AllocSite_t{
- int id;
+ long id;
struct Queue* waitingQueue;
} AllocSite;
AllocSite* allocSiteArray;
int numRelatedAllocSites;
- psemaphore stallSiteSem;
+ psemaphore memoryStallSiteSem;
} SESEcommon;