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();) {
String entryNodeID = entry.getKey();
ConflictNode entryNode = entry.getValue();
-
+
if ((!currentNode.getID().equals(entryNodeID))
&& !(analyzedIDSet.contains(currentNode.getID()
+ entryNodeID) || analyzedIDSet
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();
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;
}
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);
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());
.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);");
}
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();
}
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){
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;
+
+}
AllocSite* mlpCreateAllocSiteArray(int numAllocSites);
ConflictNode* mlpCreateConflictNode(int id);
+struct QueueItem* addWaitingQueueElement(AllocSite* allocSiteArray, int numAllocSites, long allocID, void *seseRec);
+
#endif /* __MLP_RUNTIME__ */