seems to work fine with a very simple test case.
String liveinNodeID = td + "_" + fsen.getIdentifier();
LiveInNode newNode = new LiveInNode(liveinNodeID, td, hrnSet,
- readEffectsSet, writeEffectsSet, reachabilitySet);
+ readEffectsSet, writeEffectsSet, reachabilitySet, fsen
+ .getIdentifier());
id2cn.put(liveinNodeID, newNode);
}
return resultSet;
}
+ /*
+ public Set<Integer> getAllocationSiteIDSetBySESEID(int seseID) {
+
+ HashSet<Integer> allocSiteIDSet = new HashSet<Integer>();
+
+ Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
+ Iterator<Entry<String, ConflictNode>> i = s.iterator();
+
+ while (i.hasNext()) {
+ Entry<String, ConflictNode> entry = i.next();
+ ConflictNode node = entry.getValue();
+
+ if (node instanceof LiveInNode) {
+ LiveInNode liveInNode = (LiveInNode) node;
+ if (liveInNode.getSESEIdentifier() == seseID) {
+ Set<HeapRegionNode> 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()));
+ }
+ }
+ }
+ }
+
+ return allocSiteIDSet;
+
+ }
+*/
+
+ public Set<Integer> getAllocationSiteIDSetBySESEID(int seseID) {
+
+ HashSet<Integer> allocSiteIDSet = new HashSet<Integer>();
+
+ Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
+ Iterator<Entry<String, ConflictNode>> i = s.iterator();
+
+ while (i.hasNext()) {
+ Entry<String, ConflictNode> entry = i.next();
+ ConflictNode node = entry.getValue();
+
+ 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();
+ 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<HeapRegionNode> 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()));
+// }
+
+ }
+ }
+ }
+
+ return allocSiteIDSet;
+
+ }
+
+ public Set<Integer> getAllocationSiteIDSet() {
+
+ HashSet<Integer> allocSiteIDSet = new HashSet<Integer>();
+
+ Set<Entry<String, ConflictNode>> s = id2cn.entrySet();
+ Iterator<Entry<String, ConflictNode>> i = s.iterator();
+
+ while (i.hasNext()) {
+ Entry<String, ConflictNode> entry = i.next();
+ ConflictNode node = entry.getValue();
+
+ HashSet<ConflictEdge> edgeSet = node.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));
+ }
+ }
+
+ }
+
+ return allocSiteIDSet;
+
+ }
+
+ private HashSet<Integer> getHRNIdentifierSet(ConflictNode node) {
+
+ HashSet<Integer> returnSet = new HashSet<Integer>();
+
+ if (node instanceof StallSiteNode) {
+ StallSiteNode stallSiteNode = (StallSiteNode) node;
+ Set<HeapRegionNode> hrnSet = stallSiteNode.getHRNSet();
+ for (Iterator iterator = hrnSet.iterator(); iterator.hasNext();) {
+ HeapRegionNode hrn = (HeapRegionNode) iterator.next();
+ // allocSiteIDSet.add(hrn.getGloballyUniqueIdentifier());
+ returnSet.add(new Integer(hrn
+ .getGloballyUniqueIntegerIdentifier()));
+ }
+ } else {
+ LiveInNode liveInNode = (LiveInNode) node;
+ Set<HeapRegionNode> hrnSet = liveInNode.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 void writeGraph(String graphName, boolean filter)
throws java.io.IOException {
Set<SESEEffectsKey> readEffectsSet;
Set<SESEEffectsKey> writeEffectsSet;
Set<HeapRegionNode> hrnSet;
+ int seseID;
public LiveInNode(String id, TempDescriptor td, Set<HeapRegionNode> hrnSet,
Set<SESEEffectsKey> readEffectsSet,
- Set<SESEEffectsKey> writeEffectsSet, Set<Set> reachabilitySet) {
+ Set<SESEEffectsKey> writeEffectsSet, Set<Set> reachabilitySet, int seseID) {
this.hrnSet = hrnSet;
this.id = id;
this.td = td;
this.readEffectsSet = readEffectsSet;
this.writeEffectsSet = writeEffectsSet;
this.reachabilitySet = reachabilitySet;
+ this.seseID=seseID;
}
public Set<HeapRegionNode> getHRNSet() {
return result;
}
+
+ public int getSESEIdentifier(){
+ return seseID;
+ }
public boolean equals(Object o) {
import java.io.FileWriter;
import java.io.IOException;
import java.io.StringWriter;
+import java.util.Enumeration;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
private Hashtable < FlatNode, ParentChildConflictsMap > conflictsResults;
private Hashtable< FlatMethod, MethodSummary > methodSummaryResults;
private OwnershipAnalysis ownAnalysisForSESEConflicts;
- private Hashtable <FlatMethod, ConflictGraph> conflictGraphResults;
+ private Hashtable <FlatNode, ConflictGraph> conflictGraphResults;
// temporal data structures to track analysis progress.
private MethodSummary currentMethodSummary;
conflictsResults = new Hashtable < FlatNode, ParentChildConflictsMap >();
methodSummaryResults=new Hashtable<FlatMethod, MethodSummary>();
- conflictGraphResults=new Hashtable<FlatMethod, ConflictGraph>();
+ conflictGraphResults=new Hashtable<FlatNode, ConflictGraph>();
seseSummaryMap= new Hashtable<FlatNode, SESESummary>();
isAfterChildSESEIndicatorMap= new Hashtable<FlatNode, Boolean>();
// postSESEConflictsForward(javaCallGraph);
// another pass for making graph
+ makeConflictGraph();
+ /*
methItr = ownAnalysis.descriptorsToAnalyze.iterator();
while (methItr.hasNext()) {
Descriptor d = methItr.next();
FlatMethod fm = state.getMethodFlat(d);
- makeConflictGraph(fm);
- }
+ makeConflictGraph2(fm);
+ }
+
+ Enumeration<FlatNode> keyEnum1=conflictGraphResults.keys();
+ while (keyEnum1.hasMoreElements()) {
+ FlatNode flatNode = (FlatNode) keyEnum1.nextElement();
+ ConflictGraph conflictGraph=conflictGraphResults.get(flatNode);
+ conflictGraph.analyzeConflicts();
+ conflictGraphResults.put(flatNode, conflictGraph);
+ }
+ */
+
+ Enumeration<FlatNode> keyEnum=conflictGraphResults.keys();
+ while (keyEnum.hasMoreElements()) {
+ FlatNode key = (FlatNode) keyEnum.nextElement();
+ ConflictGraph cg=conflictGraphResults.get(key);
+ try {
+ cg.writeGraph("ConflictGraphFor"+key, false);
+ } catch (IOException e) {
+ System.out.println("Error writing");
+ System.exit(0);
+ }
+ }
+
+ /*
methItr = ownAnalysis.descriptorsToAnalyze.iterator();
while(methItr.hasNext()){
Descriptor d = methItr.next();
}
}
}
+ */
////////////////
}
return sorted;
}
- private void makeConflictGraph(FlatMethod fm) {
-
- // create conflict graph for each flat method
- ConflictGraph conflictGraph = new ConflictGraph();
+ private void makeConflictGraph2(FlatMethod fm) {
HashSet<MethodContext> mcSet = ownAnalysisForSESEConflicts
.getAllMethodContextSetByDescriptor(fm.getMethod());
flatNodesToVisit.add(fm);
Set<FlatNode> visited = new HashSet<FlatNode>();
+
+ SESESummary summary = new SESESummary(null, fm);
+ seseSummaryMap.put(fm, summary);
while (!flatNodesToVisit.isEmpty()) {
Iterator<FlatNode> fnItr = flatNodesToVisit.iterator();
flatNodesToVisit.remove(fn);
visited.add(fn);
-
+
// ///////////////////////////////////////////////////////////////////////
// Adding Stall Node of current program statement
ParentChildConflictsMap currentConflictsMap = conflictsResults
.getStallMap();
Set<Entry<TempDescriptor, StallSite>> entrySet = stallMap
.entrySet();
-
-// HashSet<String> newStallNodeSet = new HashSet<String>();
-
+
+
+ SESESummary seseSummary=seseSummaryMap.get(fn);
+
+ ConflictGraph conflictGraph=null;
+ conflictGraph=conflictGraphResults.get(seseSummary.getCurrentSESE());
+
+ if(conflictGraph==null){
+ conflictGraph = new ConflictGraph();
+ }
for (Iterator<Entry<TempDescriptor, StallSite>> iterator2 = entrySet
.iterator(); iterator2.hasNext();) {
Entry<TempDescriptor, StallSite> entry = iterator2.next();
TempDescriptor td = entry.getKey();
StallSite stallSite = entry.getValue();
- String stallNodeID;
// reachability set
OwnershipGraph og = ownAnalysisForSESEConflicts
.getOwnvershipGraphByMethodContext(mc);
Set<Set> reachabilitySet = calculateReachabilitySet(og, td);
-
conflictGraph.addStallNode(td, fm, stallSite,
reachabilitySet);
-
+
+ }
+
+ if(conflictGraph.id2cn.size()>0){
+ conflictGraphResults.put(seseSummary.getCurrentSESE(), conflictGraph);
}
- conflictGraph_nodeAction(mc, fm, fn, conflictGraph,
- currentConflictsMap);
-
+ conflictGraph_nodeAction(mc, fm, fn);
+
for (int i = 0; i < fn.numNext(); i++) {
FlatNode nn = fn.getNext(i);
if (!visited.contains(nn)) {
flatNodesToVisit.add(nn);
}
}
-
} // end of while(flatNodesToVisit)
} // end of while(mcIter)
// decide fine-grain edge or coarse-grain edge among all vertexes by pair-wise comparison
- conflictGraph.analyzeConflicts();
- conflictGraphResults.put(fm, conflictGraph);
+ }
+
+ private void makeConflictGraph() {
+ Iterator<Descriptor> methItr = ownAnalysis.descriptorsToAnalyze
+ .iterator();
+ while (methItr.hasNext()) {
+ Descriptor d = methItr.next();
+ FlatMethod fm = state.getMethodFlat(d);
+
+ HashSet<MethodContext> mcSet = ownAnalysisForSESEConflicts
+ .getAllMethodContextSetByDescriptor(fm.getMethod());
+ Iterator<MethodContext> mcIter = mcSet.iterator();
+
+ while (mcIter.hasNext()) {
+ MethodContext mc = mcIter.next();
+
+ Set<FlatNode> flatNodesToVisit = new HashSet<FlatNode>();
+ flatNodesToVisit.add(fm);
+
+ Set<FlatNode> visited = new HashSet<FlatNode>();
+
+ SESESummary summary = new SESESummary(null, fm);
+ seseSummaryMap.put(fm, summary);
+
+ while (!flatNodesToVisit.isEmpty()) {
+ Iterator<FlatNode> fnItr = flatNodesToVisit.iterator();
+ FlatNode fn = fnItr.next();
+
+ flatNodesToVisit.remove(fn);
+ visited.add(fn);
+
+ // Adding Stall Node of current program statement
+ ParentChildConflictsMap currentConflictsMap = conflictsResults
+ .get(fn);
+
+ Hashtable<TempDescriptor, StallSite> stallMap = currentConflictsMap
+ .getStallMap();
+ Set<Entry<TempDescriptor, StallSite>> entrySet = stallMap
+ .entrySet();
+
+ SESESummary seseSummary = seseSummaryMap.get(fn);
+
+ ConflictGraph conflictGraph = null;
+ conflictGraph = conflictGraphResults.get(seseSummary
+ .getCurrentSESE());
+
+ if (conflictGraph == null) {
+ conflictGraph = new ConflictGraph();
+ }
+ for (Iterator<Entry<TempDescriptor, StallSite>> iterator2 = entrySet
+ .iterator(); iterator2.hasNext();) {
+ Entry<TempDescriptor, StallSite> entry = iterator2
+ .next();
+ TempDescriptor td = entry.getKey();
+ StallSite stallSite = entry.getValue();
+
+ // reachability set
+ OwnershipGraph og = ownAnalysisForSESEConflicts
+ .getOwnvershipGraphByMethodContext(mc);
+ Set<Set> reachabilitySet = calculateReachabilitySet(og,
+ td);
+ conflictGraph.addStallNode(td, fm, stallSite,
+ reachabilitySet);
+
+ }
+
+ if (conflictGraph.id2cn.size() > 0) {
+ conflictGraphResults.put(seseSummary.getCurrentSESE(),
+ conflictGraph);
+ }
+ conflictGraph_nodeAction(mc, fm, fn);
+
+ for (int i = 0; i < fn.numNext(); i++) {
+ FlatNode nn = fn.getNext(i);
+ if (!visited.contains(nn)) {
+ flatNodesToVisit.add(nn);
+ }
+ }
+ } // end of while(flatNodesToVisit)
+
+ } // end of while(mcIter)
+
+ }
+
+ // decide fine-grain edge or coarse-grain edge among all vertexes by pair-wise comparison
+ Enumeration<FlatNode> keyEnum1=conflictGraphResults.keys();
+ while (keyEnum1.hasMoreElements()) {
+ FlatNode flatNode = (FlatNode) keyEnum1.nextElement();
+ ConflictGraph conflictGraph=conflictGraphResults.get(flatNode);
+ conflictGraph.analyzeConflicts();
+ conflictGraphResults.put(flatNode, conflictGraph);
+ }
+
}
private Set<Set> calculateReachabilitySet(OwnershipGraph og,
return reachabilitySet;
}
- private void conflictGraph_nodeAction(MethodContext mc, FlatMethod fm,
+ private void conflictGraph_nodeAction2(MethodContext mc, FlatMethod fm,
FlatNode fn, ConflictGraph graph,
ParentChildConflictsMap currentConflictsMap) {
+
+ switch (fn.kind()) {
+
+ case FKind.FlatSESEEnterNode: {
+
+ }break;
+
+
+
+ }
+
+
+ }
+
+ private void conflictGraph_nodeAction(MethodContext mc, FlatMethod fm,
+ FlatNode fn) {
switch (fn.kind()) {
if (!fsen.getIsCallerSESEplaceholder()) {
Set<TempDescriptor> invar_set = fsen.getInVarSet();
+
+ SESESummary seseSummary=seseSummaryMap.get(fsen);
+ ConflictGraph conflictGraph=null;
+ conflictGraph=conflictGraphResults.get(seseSummary.getCurrentParent());
+
+ if(conflictGraph==null){
+ conflictGraph = new ConflictGraph();
+ }
+
for (Iterator iterator = invar_set.iterator(); iterator
.hasNext();) {
.next();
hrnSet.add(referenceEdge.getDst());
}
- graph.addLiveInNode(tempDescriptor, hrnSet, fsen,
+
+ conflictGraph.addLiveInNode(tempDescriptor, hrnSet, fsen,
readEffectsSet, writeEffectsSet, reachabilitySet);
-
}
-
+
+ if(conflictGraph.id2cn.size()>0){
+ conflictGraphResults.put(seseSummary.getCurrentParent(),conflictGraph);
+ }
+
}
}
isAfterChildSESEIndicatorMap.put(currentSummary
.getCurrentParent(), new Boolean(true));
}
+// currentConflictsMap = new ParentChildConflictsMap();
+ currentConflictsMap.clear();
}
break;
printSESEInfoTree( bw, fsenChild );
}
}
+
+ public Hashtable <FlatNode, ConflictGraph> getConflictGraphResults(){
+ return conflictGraphResults;
+ }
+
+ public Hashtable < FlatNode, ParentChildConflictsMap > getConflictsResults(){
+ return conflictsResults;
+ }
+
}
stallEdgeMap= new Hashtable < ReferenceEdge, HashSet<StallTag> >();
}
+ public void clear(){
+ accessibleMap.clear();
+ stallMap.clear();
+ stallEdgeMap.clear();
+ }
+
public void makeAllInaccessible(){
Set<TempDescriptor> keySet=accessibleMap.keySet();
public String getGloballyUniqueIdentifier(){
return globalIdentifier;
}
+
+ public int getGloballyUniqueIntegerIdentifier() {
+ String fristpart = globalIdentifier;
+ fristpart = fristpart.replaceAll("FN", "1");
+ fristpart = fristpart.replaceAll("FM", "2");
+ int idx = fristpart.indexOf(".");
+ String endpart = fristpart.substring(idx + 1);
+ endpart = endpart.replaceAll("S", "1");
+ endpart = endpart.replaceAll("P", "2");
+ endpart = endpart.replaceAll("A", "3");
+ String modified = fristpart.substring(0, idx) + endpart;
+ return Integer.parseInt(modified);
+ }
}
}
public MethodContext getCalleeMethodContext(MethodContext callerMC, FlatCall fc){
- assert methodEffects;
Hashtable<FlatNode, OwnershipGraph> table=mapMethodContextToFlatNodeOwnershipGraph.get(callerMC);
import Analysis.Loops.WriteBarrier;
import Analysis.Loops.GlobalFieldType;
import Analysis.Locality.TypeAnalysis;
+import Analysis.MLP.ConflictGraph;
import Analysis.MLP.MLPAnalysis;
import Analysis.MLP.VariableSourceToken;
import Analysis.MLP.CodePlan;
}
}
}
+
+ // set up related allocation sites's waiting queues
+ // eom
+ output.println(" /* set up waiting queues */");
+ ConflictGraph graph=null;
+ graph=mlpa.getConflictGraphResults().get(fm);
+ if(graph!=null){
+ Set<Integer> allocSet=graph.getAllocationSiteIDSet();
+
+ if(allocSet.size()>0){
+ output.println(" int 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();
+ output.println(" seseCaller->allocSiteArray["+idx+"].id="+allocID+";");
+ idx++;
+ }
+ output.println();
+ }
+ }
}
output.println(" SESEcommon* parentCommon = seseCaller;");
}
}
-
+
// before doing anything, lock your own record and increment the running children
if( fsen != mlpa.getMainSESE() ) {
output.println(" pthread_mutex_lock( &(parentCommon->lock) );");
generateTemp( fsen.getfmEnclosing(), temp, null )+";");
}
}
+
+ // count up memory conflict dependencies,
+ // eom
+ ConflictGraph graph=null;
+ FlatSESEEnterNode parent=fsen.getParent();
+ if(parent!=null){
+ if(parent.isCallerSESEplaceholder){
+ graph=mlpa.getConflictGraphResults().get(parent.getfmEnclosing());
+ }else{
+ graph=mlpa.getConflictGraphResults().get(fsen);
+ }
+ }
+ if (graph != null) {
+ output.println();
+ output.println(" /*add waiting queue element*/");
+
+ Set<Integer> allocSet = graph.getAllocationSiteIDSetBySESEID(fsen
+ .getIdentifier());
+ if (allocSet.size() > 0) {
+ output.println(" {");
+ output
+ .println(" pthread_mutex_lock( &(parentCommon->lock) );");
+
+ for (Iterator iterator = allocSet.iterator(); iterator
+ .hasNext();) {
+ Integer allocID = (Integer) iterator.next();
+ output
+ .println(" addWaitingQueueElement(parentCommon->allocSiteArray,numRelatedAllocSites,"
+ + allocID
+ + ",seseToIssue);");
+ output
+ .println(" ++(seseToIssue->common.unresolvedDependencies);");
+ }
+ output
+ .println(" pthread_mutex_unlock( &(parentCommon->lock) );");
+ output.println(" }");
+ }
+
+ output.println(" /*decide whether it is runnable or not in regarding to memory conflicts*/");
+ output.println(" {");
+ output.println(" int idx;");
+ 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(" }");
+ output.println(" }");
+ output.println(" }");
+ output.println();
+ }
// before potentially adding this SESE to other forwarding lists,
// create it's lock and take it immediately
}
output.println(" "+p+" = seseToIssue;");
}
+
}
// if there were no outstanding dependencies, issue here
// eventually, for it to mark itself finished
output.println(" pthread_mutex_unlock( &(seseToIssue->common.lock) );");
output.println(" }");
-
+
}
public void generateFlatSESEExitNode( FlatMethod fm,
output.println(" pthread_mutex_unlock( &(consumer->lock) );");
output.println(" }");
+ // eom
+ // clean up its lock element from waiting queue, and decrement dependency count for next SESE block
+ if( fsen != mlpa.getMainSESE() ) {
+ output.println();
+ output.println(" /* check memory dependency*/");
+ output.println(" {");
+ output.println(" int idx;");
+ output.println(" for(idx = 0 ; idx < ___params___->common.parent->numRelatedAllocSites ; idx++){");
+ 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(" 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(" }");
+ output.println(" pthread_mutex_unlock( &(nextItem->lock) );");
+ output.println(" }");
+ output.println(" }");
+ 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) );");
void mlpFreeSESErecord( void* seseRecord ) {
RUNFREE( seseRecord );
}
+
+AllocSite* mlpCreateAllocSiteArray(int numAllocSites){
+ int i;
+ AllocSite* newAllocSite=(AllocSite*)RUNMALLOC( sizeof( AllocSite ) * numAllocSites );
+ for(i=0; i<numAllocSites; i++){
+ newAllocSite[i].waitingQueue=createQueue();
+ }
+ return newAllocSite;
+}
+
+void addWaitingQueueElement(AllocSite* allocSiteArray, int numAllocSites, int allocID, void *seseRec){
+
+ int i;
+ for(i=0;i<numAllocSites;i++){
+ if(allocSiteArray[i].id==allocID){
+ addNewItemBack(allocSiteArray[i].waitingQueue,seseRec);
+ //printf("add new item %d into waiting queue:%d\n",((SESEcommon*)seseRec)->classID,allocID);
+ break;
+ }
+ }
+
+}
#define TRUE 1
#endif
+// each allocation site nees the following
+typedef struct AllocSite_t{
+ int id;
+ struct Queue* waitingQueue;
+} AllocSite;
+
// forward declaration of pointer type
typedef struct SESEcommon_t* SESEcommon_p;
SESEcommon_p parent;
+ AllocSite* allocSiteArray;
+ int numRelatedAllocSites;
+ psemaphore stallSiteSem;
+
} SESEcommon;
void* mlpCreateSESErecord( int size );
void mlpDestroySESErecord( void* seseRecord );
+AllocSite* mlpCreateAllocSiteArray(int numAllocSites);
+
#endif /* __MLP_RUNTIME__ */