keep last snapshot for benchmark before moving to new queue impl.
authoryeom <yeom>
Mon, 1 Feb 2010 21:29:49 +0000 (21:29 +0000)
committeryeom <yeom>
Mon, 1 Feb 2010 21:29:49 +0000 (21:29 +0000)
Robust/src/Analysis/MLP/ConflictGraph.java
Robust/src/Analysis/MLP/WaitingElement.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/mlp_runtime.c
Robust/src/Runtime/mlp_runtime.h

index 59b263d2b667d06de242952836e47da6fd60c4d1..04288209183aad3bb025be0886e39a1871a1d5f5 100644 (file)
@@ -1045,6 +1045,8 @@ public class ConflictGraph {
                                                                .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)) {
@@ -1063,12 +1065,22 @@ public class ConflictGraph {
                                                                                                                                                                                        // 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();
                                                        }
                                                }
 
@@ -1082,9 +1094,24 @@ public class ConflictGraph {
                                                                        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());
+                                                                                       }
+                                                                               }
+                                                                       
+
                                                                        }
                                                                        
                                                                        
index 33606cf5a0b4b9d24a0486a7d4c7df25d828b924..7524285af2dc14d89f3127d8ad8738964528ed07 100644 (file)
@@ -8,15 +8,34 @@ public class WaitingElement {
        private int waitingID;
        private int status;
        private HashSet<Integer> allocList;
+       private String dynID;
+       private HashSet<Integer> connectedSet;
 
        public WaitingElement() {
                this.allocList = new HashSet<Integer>();
+               this.connectedSet = new HashSet<Integer>();
        }
-
+       
        public void setWaitingID(int waitingID) {
                this.waitingID = waitingID;
        }
+       
+       public HashSet<Integer> getConnectedSet() {
+               return connectedSet;
+       }
+
+       public void setConnectedSet(HashSet<Integer> connectedSet) {
+               this.connectedSet.addAll(connectedSet);
+       }
 
+       public String getDynID(){
+               return dynID;
+       }
+       
+       public void setDynID(String dynID){
+               this.dynID=dynID;
+       }
+       
        public int getWaitingID() {
                return waitingID;
        }
index b82448eda20fe38067308cc3bee078633dd6a3a2..1724ea38b0ff4d22f4c8811390e31bece1ebb592 100644 (file)
@@ -2110,13 +2110,16 @@ public class BuildCode {
       
       // 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()+";");
 
@@ -2134,11 +2137,14 @@ public class BuildCode {
 
       // 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() ) {
@@ -2734,7 +2740,9 @@ public class BuildCode {
                                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();) {
@@ -2754,13 +2762,13 @@ public class BuildCode {
                                        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("  }");
                        }
 
@@ -3310,9 +3318,7 @@ public class BuildCode {
     
     // 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
@@ -3667,6 +3673,8 @@ public class BuildCode {
        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){");
@@ -3681,9 +3689,10 @@ public class BuildCode {
        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("                       }");
@@ -3691,6 +3700,11 @@ public class BuildCode {
        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("     }");
@@ -3705,7 +3719,8 @@ public class BuildCode {
        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("  }");
        
@@ -3718,11 +3733,12 @@ public class BuildCode {
 
     // 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
@@ -3730,7 +3746,7 @@ public class BuildCode {
     output.println("   seseCaller = (SESEcommon*) 0x1;");    
     
   }
-
   public void generateFlatWriteDynamicVarNode( FlatMethod fm,  
                                               LocalityBinding lb, 
                                               FlatWriteDynamicVarNode fwdvn,
index 1fa12b1d72c8d6983ab20bf994db87891b0d0013..fb52b53405d1efa6f2fc73090c1172a61b68000f 100644 (file)
@@ -81,8 +81,11 @@ int addWaitingQueueElement(AllocSite* allocSiteArray, int numAllocSites, long al
     if(allocSiteArray[i].id==allocID){
       
       if(isRunnableNewElement(allocSiteArray[i].waitingQueue,wElement)){
+       wElement->resolved=1;
+       addNewItemBack(allocSiteArray[i].waitingQueue,wElement);
        return 0;
       }else{
+       wElement->resolved=0;
        addNewItemBack(allocSiteArray[i].waitingQueue,wElement);
        return 1;
       }
index cbf8858cc5960e81bbe25773a40466ef4fdd4ab5..9e58418d3aa227c87043bc803977f4dc8fd7b3ba 100644 (file)
@@ -66,6 +66,8 @@ typedef struct SESEcommon_t {
   int numRelatedWaitingQueue;
   int waitingQueueItemID;
 
+  pthread_cond_t stallDone;
+
 } SESEcommon;
 
 
@@ -73,6 +75,7 @@ typedef struct WaitingElement_t{
   void* seseRec;
   int status;
   int id;
+  int resolved;
   struct Queue* list;
 } WaitingElement;
 
@@ -97,4 +100,5 @@ int addWaitingQueueElement(AllocSite* allocSiteArray, int numAllocSites, long al
 WaitingElement* mlpCreateWaitingElement(int status, void* seseToIssue, struct Queue* queue, int id);
 void* mlpAllocSESErecord( int size );
 
+
 #endif /* __MLP_RUNTIME__ */