.next();
int type = -1;
HashSet<Integer> allocSet = new HashSet<Integer>();
+ HashSet<Integer> connectedSet=new HashSet<Integer>();
+ String dynID="";
if (conflictEdge.getType() == ConflictEdge.COARSE_GRAIN_EDGE) {
if (isReadOnly(node)) {
// fine-grain
// edge
allocSet.addAll(getAllocSet(node));
+ if(conflictEdge.getVertexU() instanceof LiveInNode ){
+ connectedSet.add(new Integer(((LiveInNode)conflictEdge.getVertexU()).getSESEIdentifier()));
+ }
+ if(conflictEdge.getVertexV() instanceof LiveInNode ){
+ connectedSet.add(new Integer(((LiveInNode)conflictEdge.getVertexV()).getSESEIdentifier()));
+ }
+
+
if (isReadOnly(node)) {
// fine-grain read
type = 0;
+ dynID=node.getTempDescriptor().toString();
} else {
// fine-grain write
type = 1;
+ dynID=node.getTempDescriptor().toString();
}
}
newElement.setAllocList(allocSet);
newElement.setWaitingID(seseLock.getID());
newElement.setStatus(type);
+ newElement.setDynID(dynID);
+ newElement.setConnectedSet(connectedSet);
+// System.out.println(seseID+"connectedSet="+connectedSet);
if(!waitingElementSet.contains(newElement)){
waitingElementSet.add(newElement);
}else{
+ for (Iterator iterator2 = waitingElementSet
+ .iterator(); iterator2
+ .hasNext();) {
+ WaitingElement e = (WaitingElement) iterator2
+ .next();
+ if(e.equals(newElement)){
+ e.getConnectedSet().addAll(connectedSet);
+// System.out.println(seseID+"!!!connectedSet="+e.getConnectedSet());
+ }
+ }
+
+
}
// can't grab something from this source until it is done
output.println(" {");
- output.println(" SESEcommon* com = (SESEcommon*)"+paramsprefix+"->"+srcPair+";" );
- output.println(" pthread_mutex_lock( &(com->lock) );");
- output.println(" while( com->doneExecuting == FALSE ) {");
- output.println(" pthread_cond_wait( &(com->doneCond), &(com->lock) );");
- output.println(" }");
- output.println(" pthread_mutex_unlock( &(com->lock) );");
+ /*
+ If we are running, everything is done. This check is redundant.
+ output.println(" SESEcommon* com = (SESEcommon*)"+paramsprefix+"->"+srcPair+";" );
+ output.println(" pthread_mutex_lock( &(com->lock) );");
+ output.println(" while( com->doneExecuting == FALSE ) {");
+ output.println(" pthread_cond_wait( &(com->doneCond), &(com->lock) );");
+ output.println(" }");
+ output.println(" pthread_mutex_unlock( &(com->lock) );");
+ */
output.println(" "+generateTemp( fsen.getfmBogus(), temp, null )+
" = "+paramsprefix+"->"+srcPair+"->"+vst.getAddrVar()+";");
// gotta wait until the source is done
output.println(" SESEcommon* com = (SESEcommon*)"+paramsprefix+"->"+temp+"_srcSESE;" );
- output.println(" pthread_mutex_lock( &(com->lock) );");
- output.println(" while( com->doneExecuting == FALSE ) {");
- output.println(" pthread_cond_wait( &(com->doneCond), &(com->lock) );");
- output.println(" }");
- output.println(" pthread_mutex_unlock( &(com->lock) );");
+ /*
+ If we are running, everything is done!
+ output.println(" pthread_mutex_lock( &(com->lock) );");
+ output.println(" while( com->doneExecuting == FALSE ) {");
+ output.println(" pthread_cond_wait( &(com->doneCond), &(com->lock) );");
+ output.println(" }");
+ output.println(" pthread_mutex_unlock( &(com->lock) );");
+ */
String typeStr;
if( type.isNull() ) {
output.println(" WaitingElement* newElement=NULL;");
output.println(" struct QueueItem* newQItem=NULL;");
output.println(" waitingQueueItemID++;");
- output.println(" psem_init( &(seseCaller->memoryStallSiteSem) );");
+// output.println(" psem_init( &(seseCaller->memoryStallSiteSem) );");
+ output.println(" pthread_cond_init( &(seseCaller->stallDone), NULL );");
+// output.println(" psem_init( &(seseCaller->memoryStallSiteSem) );");
output.println(" int qIdx;");
output.println(" int takeCount=0;");
for (Iterator iterator = waitingElementSet.iterator(); iterator.hasNext();) {
output.println(" addNewItemBack(seseCaller->allocSiteArray[qIdx].waitingQueue,newElement);");
output.println(" takeCount++;");
output.println(" }");
-
}
-
- output.println(" pthread_mutex_unlock( &(seseCaller->lock) );");
output.println(" if( takeCount>0 ){");
- output.println(" psem_take( &(seseCaller->memoryStallSiteSem) );");
+// output.println(" psem_take( &(seseCaller->memoryStallSiteSem) );");
+ output.println(" pthread_cond_wait( &(seseCaller->stallDone), &(seseCaller->lock) );");
output.println(" }");
+
+ output.println(" pthread_mutex_unlock( &(seseCaller->lock) );");
output.println(" }");
}
// before doing anything, lock your own record and increment the running children
if( fsen != mlpa.getMainSESE() ) {
- output.println(" pthread_mutex_lock( &(parentCommon->lock) );");
- output.println(" ++(parentCommon->numRunningChildren);");
- output.println(" pthread_mutex_unlock( &(parentCommon->lock) );");
+ output.println(" atomic_inc(&parentCommon->numRunningChildren);");
}
// just allocate the space for this record
output.println(" while(nextQItem!=NULL){");
output.println(" WaitingElement* nextItem=nextQItem->objectptr;");
output.println(" SESEcommon* seseNextItem=(SESEcommon*)nextItem->seseRec;");
+ output.println(" if(nextItem->resolved==0){");
+
output.println(" int isResolved=isRunnable(___params___->common.parent->allocSiteArray[idx].waitingQueue,nextQItem);");
output.println(" if(seseNextItem->classID==___params___->common.parent->classID){"); // stall site
output.println(" if(isResolved){");
output.println(" }");
output.println(" }else{");
output.println(" if(isResolved){");
- output.println(" struct QueueItem* currentItem=findItem(___params___->common.parent->allocSiteArray[idx].waitingQueue,nextItem);");
- output.println(" nextQItem=getNextQueueItem(currentItem);");
- output.println(" removeItem(___params___->common.parent->allocSiteArray[idx].waitingQueue,currentItem);");
+ //output.println(" struct QueueItem* currentItem=findItem(___params___->common.parent->allocSiteArray[idx].waitingQueue,nextItem);");
+ //output.println(" nextQItem=getNextQueueItem(currentItem);");
+ //output.println(" removeItem(___params___->common.parent->allocSiteArray[idx].waitingQueue,currentItem);");
+ output.println(" nextItem->resolved=1;");
output.println(" if( atomic_sub_and_test(1, &(seseNextItem->unresolvedDependencies)) ){");
output.println(" addNewItem(launchQueue,(void*)seseNextItem);");
output.println(" }");
output.println(" nextQItem=getNextQueueItem(nextQItem);");
output.println(" }");
output.println(" }");
+
+ output.println(" }else{");
+ output.println(" nextQItem=getNextQueueItem(nextQItem);");
+ output.println(" }");
+
output.println(" } "); // end of while(nextQItem!=NULL)
output.println(" }");
output.println(" }");
output.println(" }");
output.println(" }");
output.println(" if(giveCount>0){");
- output.println(" psem_give(&(___params___->common.parent->memoryStallSiteSem));");
+// output.println(" psem_give(&(___params___->common.parent->memoryStallSiteSem));");
+ output.println(" pthread_cond_signal(&(___params___->common.parent->stallDone));");
output.println(" }");
output.println(" }");
// last of all, decrement your parent's number of running children
output.println(" if( "+paramsprefix+"->common.parent != NULL ) {");
- output.println(" pthread_mutex_lock( &("+paramsprefix+"->common.parent->lock) );");
- output.println(" --("+paramsprefix+"->common.parent->numRunningChildren);");
- output.println(" pthread_cond_signal( &("+paramsprefix+"->common.parent->runningChildrenCond) );");
- output.println(" pthread_mutex_unlock( &("+paramsprefix+"->common.parent->lock) );");
- output.println(" }");
+ output.println(" if (atomic_sub_and_test(1, &"+paramsprefix+"->common.parent->numRunningChildren)) {");
+ output.println(" pthread_mutex_lock( &("+paramsprefix+"->common.parent->lock) );");
+ output.println(" pthread_cond_signal( &("+paramsprefix+"->common.parent->runningChildrenCond) );");
+ output.println(" pthread_mutex_unlock( &("+paramsprefix+"->common.parent->lock) );");
+ output.println(" }");
+ output.println(" }");
// this is a thread-only variable that can be handled when critical sese-to-sese
// data has been taken care of--set sese pointer to remember self over method
output.println(" seseCaller = (SESEcommon*) 0x1;");
}
-
+
public void generateFlatWriteDynamicVarNode( FlatMethod fm,
LocalityBinding lb,
FlatWriteDynamicVarNode fwdvn,